Skip to content

Commit 4a58a67

Browse files
authored
Fix Monodocs build (#2235)
* Fix Monodocs build Signed-off-by: Kevin Su <pingsutw@gmail.com> * SETUPTOOLS_SCM_PRETEND_VERSION=2.0.0 Signed-off-by: Kevin Su <pingsutw@gmail.com> * nit Signed-off-by: Kevin Su <pingsutw@gmail.com> * test Signed-off-by: Kevin Su <pingsutw@gmail.com> * test Signed-off-by: Kevin Su <pingsutw@gmail.com> * test Signed-off-by: Kevin Su <pingsutw@gmail.com> * test Signed-off-by: Kevin Su <pingsutw@gmail.com> --------- Signed-off-by: Kevin Su <pingsutw@gmail.com>
1 parent f1b5eba commit 4a58a67

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

.github/workflows/monodocs_build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ jobs:
3838
working-directory: ${{ github.workspace }}/flyte
3939
run: |
4040
conda activate monodocs-env
41+
export SETUPTOOLS_SCM_PRETEND_VERSION="2.0.0"
4142
pip install -e ./flyteidl
43+
- shell: bash -el {0}
44+
working-directory: ${{ github.workspace }}/flytekit
45+
run: |
46+
conda activate monodocs-env
47+
pip install -e .
4248
conda info
4349
conda list
4450
conda config --show-sources

flytekit/extend/backend/base_agent.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ class Resource:
9090
outputs: Optional[Union[LiteralMap, typing.Dict[str, Any]]] = None
9191

9292

93-
T = typing.TypeVar("T", bound=ResourceMeta)
94-
95-
9693
class AgentBase(ABC):
9794
name = "Base Agent"
9895

@@ -127,7 +124,7 @@ def do(self, task_template: TaskTemplate, inputs: Optional[LiteralMap], **kwargs
127124
raise NotImplementedError
128125

129126

130-
class AsyncAgentBase(AgentBase, typing.Generic[T]):
127+
class AsyncAgentBase(AgentBase):
131128
"""
132129
This is the base class for all async agents. It defines the interface that all agents must implement.
133130
The agent service is responsible for invoking agents. The propeller will communicate with the agent service
@@ -139,7 +136,7 @@ class AsyncAgentBase(AgentBase, typing.Generic[T]):
139136

140137
name = "Base Async Agent"
141138

142-
def __init__(self, metadata_type: typing.Type[T], **kwargs):
139+
def __init__(self, metadata_type: ResourceMeta, **kwargs):
143140
super().__init__(**kwargs)
144141
self._metadata_type = metadata_type
145142

@@ -148,14 +145,14 @@ def metadata_type(self) -> ResourceMeta:
148145
return self._metadata_type
149146

150147
@abstractmethod
151-
def create(self, task_template: TaskTemplate, inputs: Optional[LiteralMap], **kwargs) -> T:
148+
def create(self, task_template: TaskTemplate, inputs: Optional[LiteralMap], **kwargs) -> ResourceMeta:
152149
"""
153150
Return a resource meta that can be used to get the status of the task.
154151
"""
155152
raise NotImplementedError
156153

157154
@abstractmethod
158-
def get(self, resource_meta: T, **kwargs) -> Resource:
155+
def get(self, resource_meta: ResourceMeta, **kwargs) -> Resource:
159156
"""
160157
Return the status of the task, and return the outputs in some cases. For example, bigquery job
161158
can't write the structured dataset to the output location, so it returns the output literals to the propeller,
@@ -164,7 +161,7 @@ def get(self, resource_meta: T, **kwargs) -> Resource:
164161
raise NotImplementedError
165162

166163
@abstractmethod
167-
def delete(self, resource_meta: T, **kwargs):
164+
def delete(self, resource_meta: ResourceMeta, **kwargs):
168165
"""
169166
Delete the task. This call should be idempotent. It should raise an error if fails to delete the task.
170167
"""
@@ -231,9 +228,7 @@ class SyncAgentExecutorMixin:
231228
Sending a prompt to ChatGPT and getting a response, or retrieving some metadata from a backend system.
232229
"""
233230

234-
T = typing.TypeVar("T", "SyncAgentExecutorMixin", PythonTask)
235-
236-
def execute(self: T, **kwargs) -> LiteralMap:
231+
def execute(self: PythonTask, **kwargs) -> LiteralMap:
237232
from flytekit.tools.translator import get_serializable
238233

239234
ctx = FlyteContext.current_context()
@@ -250,7 +245,9 @@ def execute(self: T, **kwargs) -> LiteralMap:
250245
return TypeEngine.dict_to_literal_map(ctx, resource.outputs)
251246
return resource.outputs
252247

253-
async def _do(self: T, agent: SyncAgentBase, template: TaskTemplate, inputs: Dict[str, Any] = None) -> Resource:
248+
async def _do(
249+
self: PythonTask, agent: SyncAgentBase, template: TaskTemplate, inputs: Dict[str, Any] = None
250+
) -> Resource:
254251
try:
255252
ctx = FlyteContext.current_context()
256253
literal_map = TypeEngine.dict_to_literal_map(ctx, inputs or {}, self.get_input_types())
@@ -267,12 +264,10 @@ class AsyncAgentExecutorMixin:
267264
Asynchronous tasks are tasks that take a long time to complete, such as running a query.
268265
"""
269266

270-
T = typing.TypeVar("T", "AsyncAgentExecutorMixin", PythonTask)
271-
272267
_clean_up_task: coroutine = None
273268
_agent: AsyncAgentBase = None
274269

275-
def execute(self: T, **kwargs) -> LiteralMap:
270+
def execute(self: PythonTask, **kwargs) -> LiteralMap:
276271
ctx = FlyteContext.current_context()
277272
ss = ctx.serialization_settings or SerializationSettings(ImageConfig())
278273
output_prefix = ctx.file_access.get_random_remote_directory()
@@ -301,7 +296,7 @@ def execute(self: T, **kwargs) -> LiteralMap:
301296
return resource.outputs
302297

303298
async def _create(
304-
self: T, task_template: TaskTemplate, output_prefix: str, inputs: Dict[str, Any] = None
299+
self: PythonTask, task_template: TaskTemplate, output_prefix: str, inputs: Dict[str, Any] = None
305300
) -> ResourceMeta:
306301
ctx = FlyteContext.current_context()
307302

@@ -322,7 +317,7 @@ async def _create(
322317
signal.signal(signal.SIGINT, partial(self.signal_handler, resource_meta)) # type: ignore
323318
return resource_meta
324319

325-
async def _get(self: T, resource_meta: ResourceMeta) -> Resource:
320+
async def _get(self: PythonTask, resource_meta: ResourceMeta) -> Resource:
326321
phase = TaskExecution.RUNNING
327322

328323
progress = Progress(transient=True)

plugins/flytekit-bigquery/flytekitplugins/bigquery/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BigQueryMetadata(ResourceMeta):
3131
location: str
3232

3333

34-
class BigQueryAgent(AsyncAgentBase[BigQueryMetadata]):
34+
class BigQueryAgent(AsyncAgentBase):
3535
name = "Bigquery Agent"
3636

3737
def __init__(self):

0 commit comments

Comments
 (0)