flyte 2.0.0b5__py3-none-any.whl → 2.0.0b7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flyte might be problematic. Click here for more details.
- flyte/_bin/runtime.py +4 -17
- flyte/_cache/cache.py +1 -1
- flyte/_deploy.py +2 -1
- flyte/_image.py +56 -15
- flyte/_internal/controllers/remote/_controller.py +15 -0
- flyte/_internal/controllers/remote/_core.py +3 -3
- flyte/_internal/runtime/rusty.py +41 -18
- flyte/_run.py +1 -1
- flyte/_task_environment.py +2 -2
- flyte/_version.py +16 -3
- flyte/cli/_build.py +1 -1
- flyte/cli/_common.py +34 -18
- flyte/cli/_create.py +24 -2
- flyte/cli/_deploy.py +6 -10
- flyte/cli/_gen.py +4 -0
- flyte/cli/_get.py +17 -10
- flyte/cli/_option.py +33 -0
- flyte/cli/_run.py +1 -1
- flyte/cli/main.py +10 -6
- flyte/errors.py +22 -0
- flyte/remote/_action.py +5 -4
- flyte/remote/_common.py +30 -0
- flyte/remote/_project.py +9 -7
- flyte/remote/_run.py +10 -3
- flyte/remote/_secret.py +2 -1
- flyte/remote/_task.py +18 -6
- flyte/syncify/_api.py +4 -0
- {flyte-2.0.0b5.data → flyte-2.0.0b7.data}/scripts/runtime.py +4 -17
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/METADATA +1 -1
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/RECORD +34 -32
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/WHEEL +0 -0
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/entry_points.txt +0 -0
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/licenses/LICENSE +0 -0
- {flyte-2.0.0b5.dist-info → flyte-2.0.0b7.dist-info}/top_level.txt +0 -0
flyte/cli/_get.py
CHANGED
|
@@ -48,13 +48,20 @@ def project(cfg: common.CLIConfig, name: str | None = None):
|
|
|
48
48
|
if name:
|
|
49
49
|
console.print(pretty_repr(Project.get(name)))
|
|
50
50
|
else:
|
|
51
|
-
console.print(common.
|
|
51
|
+
console.print(common.format("Projects", Project.listall(), cfg.output_format))
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
@get.command(cls=common.CommandBase)
|
|
55
55
|
@click.argument("name", type=str, required=False)
|
|
56
|
+
@click.option("--limit", type=int, default=100, help="Limit the number of runs to fetch when listing.")
|
|
56
57
|
@click.pass_obj
|
|
57
|
-
def run(
|
|
58
|
+
def run(
|
|
59
|
+
cfg: common.CLIConfig,
|
|
60
|
+
name: str | None = None,
|
|
61
|
+
project: str | None = None,
|
|
62
|
+
domain: str | None = None,
|
|
63
|
+
limit: int = 100,
|
|
64
|
+
):
|
|
58
65
|
"""
|
|
59
66
|
Get a list of all runs, or details of a specific run by name.
|
|
60
67
|
|
|
@@ -71,13 +78,13 @@ def run(cfg: common.CLIConfig, name: str | None = None, project: str | None = No
|
|
|
71
78
|
details = RunDetails.get(name=name)
|
|
72
79
|
console.print(pretty_repr(details))
|
|
73
80
|
else:
|
|
74
|
-
console.print(common.
|
|
81
|
+
console.print(common.format("Runs", Run.listall(limit=limit), cfg.output_format))
|
|
75
82
|
|
|
76
83
|
|
|
77
84
|
@get.command(cls=common.CommandBase)
|
|
78
85
|
@click.argument("name", type=str, required=False)
|
|
79
86
|
@click.argument("version", type=str, required=False)
|
|
80
|
-
@click.option("--limit", type=int, default=100, help="Limit the number of tasks to
|
|
87
|
+
@click.option("--limit", type=int, default=100, help="Limit the number of tasks to fetch.")
|
|
81
88
|
@click.pass_obj
|
|
82
89
|
def task(
|
|
83
90
|
cfg: common.CLIConfig,
|
|
@@ -105,9 +112,9 @@ def task(
|
|
|
105
112
|
t = v.fetch()
|
|
106
113
|
console.print(pretty_repr(t))
|
|
107
114
|
else:
|
|
108
|
-
console.print(common.
|
|
115
|
+
console.print(common.format("Tasks", Task.listall(by_task_name=name, limit=limit), cfg.output_format))
|
|
109
116
|
else:
|
|
110
|
-
console.print(common.
|
|
117
|
+
console.print(common.format("Tasks", Task.listall(limit=limit), cfg.output_format))
|
|
111
118
|
|
|
112
119
|
|
|
113
120
|
@get.command(cls=common.CommandBase)
|
|
@@ -133,8 +140,8 @@ def action(
|
|
|
133
140
|
else:
|
|
134
141
|
# List all actions for the run
|
|
135
142
|
console.print(
|
|
136
|
-
common.
|
|
137
|
-
f"Actions for {run_name}", flyte.remote._action.Action.listall(for_run_name=run_name),
|
|
143
|
+
common.format(
|
|
144
|
+
f"Actions for {run_name}", flyte.remote._action.Action.listall(for_run_name=run_name), cfg.output_format
|
|
138
145
|
)
|
|
139
146
|
)
|
|
140
147
|
|
|
@@ -230,7 +237,7 @@ def secret(
|
|
|
230
237
|
if name:
|
|
231
238
|
console.print(pretty_repr(remote.Secret.get(name)))
|
|
232
239
|
else:
|
|
233
|
-
console.print(common.
|
|
240
|
+
console.print(common.format("Secrets", remote.Secret.listall(), cfg.output_format))
|
|
234
241
|
|
|
235
242
|
|
|
236
243
|
@get.command(cls=common.CommandBase)
|
|
@@ -299,7 +306,7 @@ def io(
|
|
|
299
306
|
common.get_panel(
|
|
300
307
|
"Inputs & Outputs",
|
|
301
308
|
f"[green bold]Inputs[/green bold]\n{inputs}\n\n[blue bold]Outputs[/blue bold]\n{outputs}",
|
|
302
|
-
|
|
309
|
+
cfg.output_format,
|
|
303
310
|
)
|
|
304
311
|
)
|
|
305
312
|
|
flyte/cli/_option.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from click import Option, UsageError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MutuallyExclusiveMixin:
|
|
5
|
+
def __init__(self, *args, **kwargs):
|
|
6
|
+
self.mutually_exclusive = set(kwargs.pop("mutually_exclusive", []))
|
|
7
|
+
self.error_format = kwargs.pop(
|
|
8
|
+
"error_msg", "Illegal usage: options '{name}' and '{invalid}' are mutually exclusive"
|
|
9
|
+
)
|
|
10
|
+
super().__init__(*args, **kwargs)
|
|
11
|
+
|
|
12
|
+
def handle_parse_result(self, ctx, opts, args):
|
|
13
|
+
self_present = self.name in opts and opts[self.name] is not None
|
|
14
|
+
others_intersect = self.mutually_exclusive.intersection(opts)
|
|
15
|
+
others_present = others_intersect and any(opts[value] is not None for value in others_intersect)
|
|
16
|
+
|
|
17
|
+
if others_present:
|
|
18
|
+
if self_present:
|
|
19
|
+
raise UsageError(self.error_format.format(name=self.name, invalid=", ".join(self.mutually_exclusive)))
|
|
20
|
+
else:
|
|
21
|
+
self.prompt = None
|
|
22
|
+
|
|
23
|
+
return super().handle_parse_result(ctx, opts, args)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# See https://stackoverflow.com/a/37491504/499285 and https://stackoverflow.com/a/44349292/499285
|
|
27
|
+
class MutuallyExclusiveOption(MutuallyExclusiveMixin, Option):
|
|
28
|
+
def __init__(self, *args, **kwargs):
|
|
29
|
+
mutually_exclusive = kwargs.get("mutually_exclusive", [])
|
|
30
|
+
help = kwargs.get("help", "")
|
|
31
|
+
if mutually_exclusive:
|
|
32
|
+
kwargs["help"] = help + f" Mutually exclusive with {', '.join(mutually_exclusive)}."
|
|
33
|
+
super().__init__(*args, **kwargs)
|
flyte/cli/_run.py
CHANGED
|
@@ -117,7 +117,7 @@ class RunTaskCommand(click.Command):
|
|
|
117
117
|
f"[green bold]Created Run: {r.name} [/green bold] "
|
|
118
118
|
f"(Project: {r.action.action_id.run.project}, Domain: {r.action.action_id.run.domain})\n"
|
|
119
119
|
f"➡️ [blue bold]{r.url}[/blue bold]",
|
|
120
|
-
|
|
120
|
+
obj.output_format,
|
|
121
121
|
)
|
|
122
122
|
)
|
|
123
123
|
if self.run_args.follow:
|
flyte/cli/main.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import rich_click as click
|
|
2
|
+
from typing_extensions import get_args
|
|
2
3
|
|
|
3
4
|
from flyte._logging import initialize_logger, logger
|
|
4
5
|
|
|
@@ -107,10 +108,13 @@ def _verbosity_to_loglevel(verbosity: int) -> int | None:
|
|
|
107
108
|
help="Path to the configuration file to use. If not specified, the default configuration file is used.",
|
|
108
109
|
)
|
|
109
110
|
@click.option(
|
|
110
|
-
"--
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
"--output-format",
|
|
112
|
+
"-of",
|
|
113
|
+
type=click.Choice(get_args(common.OutputFormat), case_sensitive=False),
|
|
114
|
+
default="table",
|
|
115
|
+
help="Output format for commands that support it. Defaults to 'table'.",
|
|
116
|
+
show_default=True,
|
|
117
|
+
required=False,
|
|
114
118
|
)
|
|
115
119
|
@click.rich_config(help_config=help_config)
|
|
116
120
|
@click.pass_context
|
|
@@ -121,8 +125,8 @@ def main(
|
|
|
121
125
|
verbose: int,
|
|
122
126
|
org: str | None,
|
|
123
127
|
config_file: str | None,
|
|
124
|
-
simple: bool = False,
|
|
125
128
|
auth_type: str | None = None,
|
|
129
|
+
output_format: common.OutputFormat = "table",
|
|
126
130
|
):
|
|
127
131
|
"""
|
|
128
132
|
The Flyte CLI is the command line interface for working with the Flyte SDK and backend.
|
|
@@ -176,8 +180,8 @@ def main(
|
|
|
176
180
|
org=org,
|
|
177
181
|
config=cfg,
|
|
178
182
|
ctx=ctx,
|
|
179
|
-
simple=simple,
|
|
180
183
|
auth_type=auth_type,
|
|
184
|
+
output_format=output_format,
|
|
181
185
|
)
|
|
182
186
|
|
|
183
187
|
|
flyte/errors.py
CHANGED
|
@@ -10,6 +10,16 @@ from typing import Literal
|
|
|
10
10
|
ErrorKind = Literal["system", "unknown", "user"]
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
def silence_grpc_polling_error(loop, context):
|
|
14
|
+
"""
|
|
15
|
+
Suppress specific gRPC polling errors in the event loop.
|
|
16
|
+
"""
|
|
17
|
+
exc = context.get("exception")
|
|
18
|
+
if isinstance(exc, BlockingIOError):
|
|
19
|
+
return # suppress
|
|
20
|
+
loop.default_exception_handler(context)
|
|
21
|
+
|
|
22
|
+
|
|
13
23
|
class BaseRuntimeError(RuntimeError):
|
|
14
24
|
"""
|
|
15
25
|
Base class for all Union runtime errors. These errors are raised when the underlying task execution fails, either
|
|
@@ -86,6 +96,9 @@ class TaskTimeoutError(RuntimeUserError):
|
|
|
86
96
|
This error is raised when the underlying task execution runs for longer than the specified timeout.
|
|
87
97
|
"""
|
|
88
98
|
|
|
99
|
+
def __init__(self, message: str):
|
|
100
|
+
super().__init__("TaskTimeoutError", message, "user")
|
|
101
|
+
|
|
89
102
|
|
|
90
103
|
class RetriesExhaustedError(RuntimeUserError):
|
|
91
104
|
"""
|
|
@@ -199,3 +212,12 @@ class InlineIOMaxBytesBreached(RuntimeUserError):
|
|
|
199
212
|
|
|
200
213
|
def __init__(self, message: str):
|
|
201
214
|
super().__init__("InlineIOMaxBytesBreached", message, "user")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class RunAbortedError(RuntimeUserError):
|
|
218
|
+
"""
|
|
219
|
+
This error is raised when the run is aborted by the user.
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
def __init__(self, message: str):
|
|
223
|
+
super().__init__("RunAbortedError", message, "user")
|
flyte/remote/_action.py
CHANGED
|
@@ -28,6 +28,7 @@ from flyte._initialize import ensure_client, get_client, get_common_config
|
|
|
28
28
|
from flyte._protos.common import identifier_pb2, list_pb2
|
|
29
29
|
from flyte._protos.workflow import run_definition_pb2, run_service_pb2
|
|
30
30
|
from flyte._protos.workflow.run_service_pb2 import WatchActionDetailsResponse
|
|
31
|
+
from flyte.remote._common import ToJSONMixin
|
|
31
32
|
from flyte.remote._logs import Logs
|
|
32
33
|
from flyte.syncify import syncify
|
|
33
34
|
|
|
@@ -120,7 +121,7 @@ def _action_done_check(phase: run_definition_pb2.Phase) -> bool:
|
|
|
120
121
|
|
|
121
122
|
|
|
122
123
|
@dataclass
|
|
123
|
-
class Action:
|
|
124
|
+
class Action(ToJSONMixin):
|
|
124
125
|
"""
|
|
125
126
|
A class representing an action. It is used to manage the run of a task and its state on the remote Union API.
|
|
126
127
|
"""
|
|
@@ -411,7 +412,7 @@ class Action:
|
|
|
411
412
|
|
|
412
413
|
|
|
413
414
|
@dataclass
|
|
414
|
-
class ActionDetails:
|
|
415
|
+
class ActionDetails(ToJSONMixin):
|
|
415
416
|
"""
|
|
416
417
|
A class representing an action. It is used to manage the run of a task and its state on the remote Union API.
|
|
417
418
|
"""
|
|
@@ -692,7 +693,7 @@ class ActionDetails:
|
|
|
692
693
|
|
|
693
694
|
|
|
694
695
|
@dataclass
|
|
695
|
-
class ActionInputs(UserDict):
|
|
696
|
+
class ActionInputs(UserDict, ToJSONMixin):
|
|
696
697
|
"""
|
|
697
698
|
A class representing the inputs of an action. It is used to manage the inputs of a task and its state on the
|
|
698
699
|
remote Union API.
|
|
@@ -709,7 +710,7 @@ class ActionInputs(UserDict):
|
|
|
709
710
|
return rich.pretty.pretty_repr(types.literal_string_repr(self.pb2))
|
|
710
711
|
|
|
711
712
|
|
|
712
|
-
class ActionOutputs(tuple):
|
|
713
|
+
class ActionOutputs(tuple, ToJSONMixin):
|
|
713
714
|
"""
|
|
714
715
|
A class representing the outputs of an action. It is used to manage the outputs of a task and its state on the
|
|
715
716
|
remote Union API.
|
flyte/remote/_common.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from google.protobuf.json_format import MessageToDict, MessageToJson
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ToJSONMixin:
|
|
7
|
+
"""
|
|
8
|
+
A mixin class that provides a method to convert an object to a JSON-serializable dictionary.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def to_dict(self) -> dict:
|
|
12
|
+
"""
|
|
13
|
+
Convert the object to a JSON-serializable dictionary.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
dict: A dictionary representation of the object.
|
|
17
|
+
"""
|
|
18
|
+
if hasattr(self, "pb2"):
|
|
19
|
+
return MessageToDict(self.pb2)
|
|
20
|
+
else:
|
|
21
|
+
return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
|
|
22
|
+
|
|
23
|
+
def to_json(self) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Convert the object to a JSON string.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
str: A JSON string representation of the object.
|
|
29
|
+
"""
|
|
30
|
+
return MessageToJson(self.pb2) if hasattr(self, "pb2") else json.dumps(self.to_dict())
|
flyte/remote/_project.py
CHANGED
|
@@ -9,15 +9,17 @@ from flyteidl.admin import common_pb2, project_pb2
|
|
|
9
9
|
from flyte._initialize import ensure_client, get_client
|
|
10
10
|
from flyte.syncify import syncify
|
|
11
11
|
|
|
12
|
+
from ._common import ToJSONMixin
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
# TODO Add support for orgs again
|
|
14
16
|
@dataclass
|
|
15
|
-
class Project:
|
|
17
|
+
class Project(ToJSONMixin):
|
|
16
18
|
"""
|
|
17
19
|
A class representing a project in the Union API.
|
|
18
20
|
"""
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
pb2: project_pb2.Project
|
|
21
23
|
|
|
22
24
|
@syncify
|
|
23
25
|
@classmethod
|
|
@@ -76,11 +78,11 @@ class Project:
|
|
|
76
78
|
break
|
|
77
79
|
|
|
78
80
|
def __rich_repr__(self) -> rich.repr.Result:
|
|
79
|
-
yield "name", self.
|
|
80
|
-
yield "id", self.
|
|
81
|
-
yield "description", self.
|
|
82
|
-
yield "state", project_pb2.Project.ProjectState.Name(self.
|
|
81
|
+
yield "name", self.pb2.name
|
|
82
|
+
yield "id", self.pb2.id
|
|
83
|
+
yield "description", self.pb2.description
|
|
84
|
+
yield "state", project_pb2.Project.ProjectState.Name(self.pb2.state)
|
|
83
85
|
yield (
|
|
84
86
|
"labels",
|
|
85
|
-
", ".join([f"{k}: {v}" for k, v in self.
|
|
87
|
+
", ".join([f"{k}: {v}" for k, v in self.pb2.labels.values.items()]) if self.pb2.labels else None,
|
|
86
88
|
)
|
flyte/remote/_run.py
CHANGED
|
@@ -13,11 +13,12 @@ from flyte.syncify import syncify
|
|
|
13
13
|
|
|
14
14
|
from . import Action, ActionDetails, ActionInputs, ActionOutputs
|
|
15
15
|
from ._action import _action_details_rich_repr, _action_rich_repr
|
|
16
|
+
from ._common import ToJSONMixin
|
|
16
17
|
from ._console import get_run_url
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
@dataclass
|
|
20
|
-
class Run:
|
|
21
|
+
class Run(ToJSONMixin):
|
|
21
22
|
"""
|
|
22
23
|
A class representing a run of a task. It is used to manage the run of a task and its state on the remote
|
|
23
24
|
Union API.
|
|
@@ -41,12 +42,14 @@ class Run:
|
|
|
41
42
|
cls,
|
|
42
43
|
filters: str | None = None,
|
|
43
44
|
sort_by: Tuple[str, Literal["asc", "desc"]] | None = None,
|
|
45
|
+
limit: int = 100,
|
|
44
46
|
) -> AsyncIterator[Run]:
|
|
45
47
|
"""
|
|
46
48
|
Get all runs for the current project and domain.
|
|
47
49
|
|
|
48
50
|
:param filters: The filters to apply to the project list.
|
|
49
51
|
:param sort_by: The sorting criteria for the project list, in the format (field, order).
|
|
52
|
+
:param limit: The maximum number of runs to return.
|
|
50
53
|
:return: An iterator of runs.
|
|
51
54
|
"""
|
|
52
55
|
ensure_client()
|
|
@@ -57,9 +60,10 @@ class Run:
|
|
|
57
60
|
direction=(list_pb2.Sort.ASCENDING if sort_by[1] == "asc" else list_pb2.Sort.DESCENDING),
|
|
58
61
|
)
|
|
59
62
|
cfg = get_common_config()
|
|
63
|
+
i = 0
|
|
60
64
|
while True:
|
|
61
65
|
req = list_pb2.ListRequest(
|
|
62
|
-
limit=100,
|
|
66
|
+
limit=min(100, limit),
|
|
63
67
|
token=token,
|
|
64
68
|
sort_by=sort_pb2,
|
|
65
69
|
)
|
|
@@ -76,6 +80,9 @@ class Run:
|
|
|
76
80
|
)
|
|
77
81
|
token = resp.token
|
|
78
82
|
for r in resp.runs:
|
|
83
|
+
i += 1
|
|
84
|
+
if i > limit:
|
|
85
|
+
return
|
|
79
86
|
yield cls(r)
|
|
80
87
|
if not token:
|
|
81
88
|
break
|
|
@@ -213,7 +220,7 @@ class Run:
|
|
|
213
220
|
|
|
214
221
|
|
|
215
222
|
@dataclass
|
|
216
|
-
class RunDetails:
|
|
223
|
+
class RunDetails(ToJSONMixin):
|
|
217
224
|
"""
|
|
218
225
|
A class representing a run of a task. It is used to manage the run of a task and its state on the remote
|
|
219
226
|
Union API.
|
flyte/remote/_secret.py
CHANGED
|
@@ -7,13 +7,14 @@ import rich.repr
|
|
|
7
7
|
|
|
8
8
|
from flyte._initialize import ensure_client, get_client, get_common_config
|
|
9
9
|
from flyte._protos.secret import definition_pb2, payload_pb2
|
|
10
|
+
from flyte.remote._common import ToJSONMixin
|
|
10
11
|
from flyte.syncify import syncify
|
|
11
12
|
|
|
12
13
|
SecretTypes = Literal["regular", "image_pull"]
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
@dataclass
|
|
16
|
-
class Secret:
|
|
17
|
+
class Secret(ToJSONMixin):
|
|
17
18
|
pb2: definition_pb2.Secret
|
|
18
19
|
|
|
19
20
|
@syncify
|
flyte/remote/_task.py
CHANGED
|
@@ -10,6 +10,7 @@ from google.protobuf import timestamp
|
|
|
10
10
|
|
|
11
11
|
import flyte
|
|
12
12
|
import flyte.errors
|
|
13
|
+
from flyte._cache.cache import CacheBehavior
|
|
13
14
|
from flyte._context import internal_ctx
|
|
14
15
|
from flyte._initialize import ensure_client, get_client, get_common_config
|
|
15
16
|
from flyte._logging import logger
|
|
@@ -18,6 +19,8 @@ from flyte._protos.workflow import task_definition_pb2, task_service_pb2
|
|
|
18
19
|
from flyte.models import NativeInterface
|
|
19
20
|
from flyte.syncify import syncify
|
|
20
21
|
|
|
22
|
+
from ._common import ToJSONMixin
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
def _repr_task_metadata(metadata: task_definition_pb2.TaskMetadata) -> rich.repr.Result:
|
|
23
26
|
"""
|
|
@@ -79,7 +82,7 @@ AutoVersioning = Literal["latest", "current"]
|
|
|
79
82
|
|
|
80
83
|
|
|
81
84
|
@dataclass
|
|
82
|
-
class TaskDetails:
|
|
85
|
+
class TaskDetails(ToJSONMixin):
|
|
83
86
|
pb2: task_definition_pb2.TaskDetails
|
|
84
87
|
max_inline_io_bytes: int = 10 * 1024 * 1024 # 10 MB
|
|
85
88
|
|
|
@@ -201,11 +204,20 @@ class TaskDetails:
|
|
|
201
204
|
"""
|
|
202
205
|
The cache policy of the task.
|
|
203
206
|
"""
|
|
207
|
+
metadata = self.pb2.spec.task_template.metadata
|
|
208
|
+
behavior: CacheBehavior
|
|
209
|
+
if not metadata.discoverable:
|
|
210
|
+
behavior = "disable"
|
|
211
|
+
elif metadata.discovery_version:
|
|
212
|
+
behavior = "override"
|
|
213
|
+
else:
|
|
214
|
+
behavior = "auto"
|
|
215
|
+
|
|
204
216
|
return flyte.Cache(
|
|
205
|
-
behavior=
|
|
206
|
-
version_override=
|
|
207
|
-
serialize=
|
|
208
|
-
ignored_inputs=tuple(
|
|
217
|
+
behavior=behavior,
|
|
218
|
+
version_override=metadata.discovery_version if metadata.discovery_version else None,
|
|
219
|
+
serialize=metadata.cache_serializable,
|
|
220
|
+
ignored_inputs=tuple(metadata.cache_ignore_input_vars),
|
|
209
221
|
)
|
|
210
222
|
|
|
211
223
|
@property
|
|
@@ -294,7 +306,7 @@ class TaskDetails:
|
|
|
294
306
|
|
|
295
307
|
|
|
296
308
|
@dataclass
|
|
297
|
-
class Task:
|
|
309
|
+
class Task(ToJSONMixin):
|
|
298
310
|
pb2: task_definition_pb2.Task
|
|
299
311
|
|
|
300
312
|
def __init__(self, pb2: task_definition_pb2.Task):
|
flyte/syncify/_api.py
CHANGED
|
@@ -64,6 +64,10 @@ class _BackgroundLoop:
|
|
|
64
64
|
atexit.register(self.stop)
|
|
65
65
|
|
|
66
66
|
def _run(self):
|
|
67
|
+
import flyte.errors
|
|
68
|
+
|
|
69
|
+
# Set the exception handler to silence specific gRPC polling errors
|
|
70
|
+
self.loop.set_exception_handler(flyte.errors.silence_grpc_polling_error)
|
|
67
71
|
asyncio.set_event_loop(self.loop)
|
|
68
72
|
self.loop.run_forever()
|
|
69
73
|
|
|
@@ -26,7 +26,6 @@ DOMAIN_NAME = "FLYTE_INTERNAL_TASK_DOMAIN"
|
|
|
26
26
|
ORG_NAME = "_U_ORG_NAME"
|
|
27
27
|
ENDPOINT_OVERRIDE = "_U_EP_OVERRIDE"
|
|
28
28
|
RUN_OUTPUT_BASE_DIR = "_U_RUN_BASE"
|
|
29
|
-
ENABLE_REF_TASKS = "_REF_TASKS" # This is a temporary flag to enable reference tasks in the runtime.
|
|
30
29
|
|
|
31
30
|
# TODO: Remove this after proper auth is implemented
|
|
32
31
|
_UNION_EAGER_API_KEY_ENV_VAR = "_UNION_EAGER_API_KEY"
|
|
@@ -87,6 +86,7 @@ def main(
|
|
|
87
86
|
|
|
88
87
|
import flyte
|
|
89
88
|
import flyte._utils as utils
|
|
89
|
+
import flyte.errors
|
|
90
90
|
from flyte._initialize import init
|
|
91
91
|
from flyte._internal.controllers import create_controller
|
|
92
92
|
from flyte._internal.imagebuild.image_builder import ImageCache
|
|
@@ -123,22 +123,7 @@ def main(
|
|
|
123
123
|
logger.debug(f"Using controller endpoint: {ep} with kwargs: {controller_kwargs}")
|
|
124
124
|
|
|
125
125
|
bundle = CodeBundle(tgz=tgz, pkl=pkl, destination=dest, computed_version=version)
|
|
126
|
-
|
|
127
|
-
# We init regular client here so that reference tasks can work
|
|
128
|
-
# Current reference tasks will not work with remote controller, because we create 2 different
|
|
129
|
-
# channels on different threads and this is not supported by grpcio or the auth system. It ends up leading
|
|
130
|
-
# File "src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi", line 147,
|
|
131
|
-
# in grpc._cython.cygrpc.PollerCompletionQueue._handle_events
|
|
132
|
-
# BlockingIOError: [Errno 11] Resource temporarily unavailable
|
|
133
|
-
# TODO solution is to use a single channel for both controller and reference tasks, but this requires a refactor
|
|
134
|
-
if enable_ref_tasks:
|
|
135
|
-
logger.warning(
|
|
136
|
-
"Reference tasks are enabled. This will initialize client and you will see a BlockIOError. "
|
|
137
|
-
"This is harmless, but a nuisance. We are working on a fix."
|
|
138
|
-
)
|
|
139
|
-
init(org=org, project=project, domain=domain, **controller_kwargs)
|
|
140
|
-
else:
|
|
141
|
-
init()
|
|
126
|
+
init(org=org, project=project, domain=domain, **controller_kwargs)
|
|
142
127
|
# Controller is created with the same kwargs as init, so that it can be used to run tasks
|
|
143
128
|
controller = create_controller(ct="remote", **controller_kwargs)
|
|
144
129
|
|
|
@@ -164,6 +149,8 @@ def main(
|
|
|
164
149
|
|
|
165
150
|
# Run both coroutines concurrently and wait for first to finish and cancel the other
|
|
166
151
|
async def _run_and_stop():
|
|
152
|
+
loop = asyncio.get_event_loop()
|
|
153
|
+
loop.set_exception_handler(flyte.errors.silence_grpc_polling_error)
|
|
167
154
|
await utils.run_coros(controller_failure, task_coroutine)
|
|
168
155
|
await controller.stop()
|
|
169
156
|
|