flyte 2.0.0b22__py3-none-any.whl → 2.0.0b23__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/__init__.py +5 -0
- flyte/_bin/runtime.py +35 -5
- flyte/_cache/cache.py +4 -2
- flyte/_cache/local_cache.py +215 -0
- flyte/_code_bundle/bundle.py +1 -0
- flyte/_debug/constants.py +0 -1
- flyte/_debug/vscode.py +6 -1
- flyte/_deploy.py +193 -52
- flyte/_environment.py +5 -0
- flyte/_excepthook.py +1 -1
- flyte/_image.py +101 -72
- flyte/_initialize.py +23 -0
- flyte/_internal/controllers/_local_controller.py +64 -24
- flyte/_internal/controllers/remote/_action.py +4 -1
- flyte/_internal/controllers/remote/_controller.py +5 -2
- flyte/_internal/controllers/remote/_core.py +6 -3
- flyte/_internal/controllers/remote/_informer.py +1 -1
- flyte/_internal/imagebuild/docker_builder.py +92 -28
- flyte/_internal/imagebuild/image_builder.py +7 -13
- flyte/_internal/imagebuild/remote_builder.py +6 -1
- flyte/_internal/runtime/io.py +13 -1
- flyte/_internal/runtime/rusty.py +17 -2
- flyte/_internal/runtime/task_serde.py +14 -20
- flyte/_internal/runtime/taskrunner.py +1 -1
- flyte/_internal/runtime/trigger_serde.py +153 -0
- flyte/_logging.py +1 -1
- flyte/_protos/common/identifier_pb2.py +19 -1
- flyte/_protos/common/identifier_pb2.pyi +22 -0
- flyte/_protos/workflow/common_pb2.py +14 -3
- flyte/_protos/workflow/common_pb2.pyi +49 -0
- flyte/_protos/workflow/queue_service_pb2.py +41 -35
- flyte/_protos/workflow/queue_service_pb2.pyi +26 -12
- flyte/_protos/workflow/queue_service_pb2_grpc.py +34 -0
- flyte/_protos/workflow/run_definition_pb2.py +38 -38
- flyte/_protos/workflow/run_definition_pb2.pyi +4 -2
- flyte/_protos/workflow/run_service_pb2.py +60 -50
- flyte/_protos/workflow/run_service_pb2.pyi +24 -6
- flyte/_protos/workflow/run_service_pb2_grpc.py +34 -0
- flyte/_protos/workflow/task_definition_pb2.py +15 -11
- flyte/_protos/workflow/task_definition_pb2.pyi +19 -2
- flyte/_protos/workflow/task_service_pb2.py +18 -17
- flyte/_protos/workflow/task_service_pb2.pyi +5 -2
- flyte/_protos/workflow/trigger_definition_pb2.py +66 -0
- flyte/_protos/workflow/trigger_definition_pb2.pyi +117 -0
- flyte/_protos/workflow/trigger_definition_pb2_grpc.py +4 -0
- flyte/_protos/workflow/trigger_service_pb2.py +96 -0
- flyte/_protos/workflow/trigger_service_pb2.pyi +110 -0
- flyte/_protos/workflow/trigger_service_pb2_grpc.py +281 -0
- flyte/_run.py +42 -15
- flyte/_task.py +35 -4
- flyte/_task_environment.py +60 -15
- flyte/_trigger.py +382 -0
- flyte/_version.py +3 -3
- flyte/cli/_abort.py +3 -3
- flyte/cli/_build.py +1 -3
- flyte/cli/_common.py +15 -2
- flyte/cli/_create.py +74 -0
- flyte/cli/_delete.py +23 -1
- flyte/cli/_deploy.py +5 -9
- flyte/cli/_get.py +75 -34
- flyte/cli/_params.py +4 -2
- flyte/cli/_run.py +12 -3
- flyte/cli/_update.py +36 -0
- flyte/cli/_user.py +17 -0
- flyte/cli/main.py +9 -1
- flyte/errors.py +9 -0
- flyte/io/_dir.py +513 -115
- flyte/io/_file.py +495 -135
- flyte/models.py +32 -0
- flyte/remote/__init__.py +6 -1
- flyte/remote/_client/_protocols.py +36 -2
- flyte/remote/_client/controlplane.py +19 -3
- flyte/remote/_run.py +42 -2
- flyte/remote/_task.py +14 -1
- flyte/remote/_trigger.py +308 -0
- flyte/remote/_user.py +33 -0
- flyte/storage/__init__.py +6 -1
- flyte/storage/_storage.py +119 -101
- flyte/types/_pickle.py +16 -3
- {flyte-2.0.0b22.data → flyte-2.0.0b23.data}/scripts/runtime.py +35 -5
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/METADATA +3 -1
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/RECORD +87 -75
- flyte/_protos/secret/secret_pb2_grpc_grpc.py +0 -198
- {flyte-2.0.0b22.data → flyte-2.0.0b23.data}/scripts/debug.py +0 -0
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/WHEEL +0 -0
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/entry_points.txt +0 -0
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/licenses/LICENSE +0 -0
- {flyte-2.0.0b22.dist-info → flyte-2.0.0b23.dist-info}/top_level.txt +0 -0
flyte/_task_environment.py
CHANGED
|
@@ -12,6 +12,7 @@ from typing import (
|
|
|
12
12
|
List,
|
|
13
13
|
Literal,
|
|
14
14
|
Optional,
|
|
15
|
+
Tuple,
|
|
15
16
|
Union,
|
|
16
17
|
cast,
|
|
17
18
|
)
|
|
@@ -22,16 +23,16 @@ from ._cache import Cache, CacheRequest
|
|
|
22
23
|
from ._doc import Documentation
|
|
23
24
|
from ._environment import Environment
|
|
24
25
|
from ._image import Image
|
|
26
|
+
from ._pod import PodTemplate
|
|
25
27
|
from ._resources import Resources
|
|
26
28
|
from ._retry import RetryStrategy
|
|
27
29
|
from ._reusable_environment import ReusePolicy
|
|
28
30
|
from ._secret import SecretRequest
|
|
29
31
|
from ._task import AsyncFunctionTaskTemplate, TaskTemplate
|
|
32
|
+
from ._trigger import Trigger
|
|
30
33
|
from .models import MAX_INLINE_IO_BYTES, NativeInterface
|
|
31
34
|
|
|
32
35
|
if TYPE_CHECKING:
|
|
33
|
-
from kubernetes.client import V1PodTemplate
|
|
34
|
-
|
|
35
36
|
from ._task import FunctionTypes, P, R
|
|
36
37
|
|
|
37
38
|
|
|
@@ -60,13 +61,18 @@ class TaskEnvironment(Environment):
|
|
|
60
61
|
that depend on each other.
|
|
61
62
|
:param cache: Cache policy for the environment.
|
|
62
63
|
:param reusable: Reuse policy for the environment, if set, a python process may be reused for multiple tasks.
|
|
64
|
+
:param plugin_config: Optional plugin configuration for custom task types.
|
|
65
|
+
If set, all tasks in this environment will use the specified plugin configuration.
|
|
66
|
+
:param queue: Optional queue name to use for tasks in this environment.
|
|
67
|
+
If not set, the default queue will be used.
|
|
68
|
+
:param pod_template: Optional pod template to use for tasks in this environment.
|
|
69
|
+
If not set, the default pod template will be used.
|
|
63
70
|
"""
|
|
64
71
|
|
|
65
72
|
cache: CacheRequest = "disable"
|
|
66
73
|
reusable: ReusePolicy | None = None
|
|
67
74
|
plugin_config: Optional[Any] = None
|
|
68
|
-
|
|
69
|
-
# TODO also we could add list of files that are used by this environment
|
|
75
|
+
queue: Optional[str] = None
|
|
70
76
|
|
|
71
77
|
_tasks: Dict[str, TaskTemplate] = field(default_factory=dict, init=False)
|
|
72
78
|
|
|
@@ -87,6 +93,8 @@ class TaskEnvironment(Environment):
|
|
|
87
93
|
env_vars: Optional[Dict[str, str]] = None,
|
|
88
94
|
secrets: Optional[SecretRequest] = None,
|
|
89
95
|
depends_on: Optional[List[Environment]] = None,
|
|
96
|
+
description: Optional[str] = None,
|
|
97
|
+
interruptible: Optional[bool] = None,
|
|
90
98
|
**kwargs: Any,
|
|
91
99
|
) -> TaskEnvironment:
|
|
92
100
|
"""
|
|
@@ -102,6 +110,11 @@ class TaskEnvironment(Environment):
|
|
|
102
110
|
:param depends_on: The environment dependencies to hint, so when you deploy the environment,
|
|
103
111
|
the dependencies are also deployed. This is useful when you have a set of environments
|
|
104
112
|
that depend on each other.
|
|
113
|
+
:param queue: The queue name to use for tasks in this environment.
|
|
114
|
+
:param pod_template: The pod template to use for tasks in this environment.
|
|
115
|
+
:param description: The description of the environment.
|
|
116
|
+
:param interruptible: Whether the environment is interruptible and can be scheduled on spot/preemptible
|
|
117
|
+
instances.
|
|
105
118
|
:param kwargs: Additional parameters to override the environment (e.g., cache, reusable, plugin_config).
|
|
106
119
|
"""
|
|
107
120
|
cache = kwargs.pop("cache", None)
|
|
@@ -131,6 +144,10 @@ class TaskEnvironment(Environment):
|
|
|
131
144
|
kwargs["secrets"] = secrets
|
|
132
145
|
if depends_on is not None:
|
|
133
146
|
kwargs["depends_on"] = depends_on
|
|
147
|
+
if description is not None:
|
|
148
|
+
kwargs["description"] = description
|
|
149
|
+
if interruptible is not None:
|
|
150
|
+
kwargs["interruptible"] = interruptible
|
|
134
151
|
return replace(self, **kwargs)
|
|
135
152
|
|
|
136
153
|
def task(
|
|
@@ -142,10 +159,13 @@ class TaskEnvironment(Environment):
|
|
|
142
159
|
retries: Union[int, RetryStrategy] = 0,
|
|
143
160
|
timeout: Union[timedelta, int] = 0,
|
|
144
161
|
docs: Optional[Documentation] = None,
|
|
145
|
-
pod_template: Optional[Union[str,
|
|
162
|
+
pod_template: Optional[Union[str, PodTemplate]] = None,
|
|
146
163
|
report: bool = False,
|
|
164
|
+
interruptible: bool | None = None,
|
|
147
165
|
max_inline_io_bytes: int = MAX_INLINE_IO_BYTES,
|
|
148
|
-
|
|
166
|
+
queue: Optional[str] = None,
|
|
167
|
+
triggers: Tuple[Trigger, ...] | Trigger = (),
|
|
168
|
+
) -> Union[AsyncFunctionTaskTemplate[P, R], Callable[P, R]]:
|
|
149
169
|
"""
|
|
150
170
|
Decorate a function to be a task.
|
|
151
171
|
|
|
@@ -162,6 +182,12 @@ class TaskEnvironment(Environment):
|
|
|
162
182
|
:param report: Optional Whether to generate the html report for the task, defaults to False.
|
|
163
183
|
:param max_inline_io_bytes: Maximum allowed size (in bytes) for all inputs and outputs passed directly to the
|
|
164
184
|
task (e.g., primitives, strings, dicts). Does not apply to files, directories, or dataframes.
|
|
185
|
+
:param triggers: Optional A tuple of triggers to associate with the task. This allows the task to be run on a
|
|
186
|
+
schedule or in response to events. Triggers can be defined using the `flyte.trigger` module.
|
|
187
|
+
:param interruptible: Optional Whether the task is interruptible, defaults to environment setting.
|
|
188
|
+
:param queue: Optional queue name to use for this task. If not set, the environment's queue will be used.
|
|
189
|
+
|
|
190
|
+
:return: A TaskTemplate that can be used to deploy the task.
|
|
165
191
|
"""
|
|
166
192
|
from ._task import P, R
|
|
167
193
|
|
|
@@ -214,6 +240,9 @@ class TaskEnvironment(Environment):
|
|
|
214
240
|
short_name=short,
|
|
215
241
|
plugin_config=self.plugin_config,
|
|
216
242
|
max_inline_io_bytes=max_inline_io_bytes,
|
|
243
|
+
queue=queue or self.queue,
|
|
244
|
+
interruptible=interruptible if interruptible is not None else self.interruptible,
|
|
245
|
+
triggers=triggers if isinstance(triggers, tuple) else (triggers,),
|
|
217
246
|
)
|
|
218
247
|
self._tasks[task_name] = tmpl
|
|
219
248
|
return tmpl
|
|
@@ -229,16 +258,32 @@ class TaskEnvironment(Environment):
|
|
|
229
258
|
"""
|
|
230
259
|
return self._tasks
|
|
231
260
|
|
|
232
|
-
|
|
261
|
+
@classmethod
|
|
262
|
+
def from_task(cls, name: str, *tasks: TaskTemplate) -> TaskEnvironment:
|
|
233
263
|
"""
|
|
234
|
-
|
|
264
|
+
Create a TaskEnvironment from a list of tasks. All tasks should have the same image or no Image defined.
|
|
265
|
+
Similarity of Image is determined by the python reference, not by value.
|
|
266
|
+
|
|
267
|
+
If images are different, an error is raised. If no image is defined, the image is set to "auto".
|
|
235
268
|
|
|
236
|
-
|
|
269
|
+
For any other tasks that need to be use these tasks, the returned environment can be used in the `depends_on`
|
|
270
|
+
attribute of the other TaskEnvironment.
|
|
271
|
+
|
|
272
|
+
:param name: The name of the environment.
|
|
273
|
+
:param tasks: The list of tasks to create the environment from.
|
|
237
274
|
|
|
238
|
-
:
|
|
275
|
+
:raises ValueError: If tasks are assigned to multiple environments or have different images.
|
|
276
|
+
:return: The created TaskEnvironment.
|
|
239
277
|
"""
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
278
|
+
envs = [t.parent_env() for t in tasks if t.parent_env and t.parent_env() is not None]
|
|
279
|
+
if envs:
|
|
280
|
+
raise ValueError("Tasks cannot assigned to multiple environments.")
|
|
281
|
+
images = {t.image for t in tasks}
|
|
282
|
+
if len(images) > 1:
|
|
283
|
+
raise ValueError("Tasks must have the same image to be in the same environment.")
|
|
284
|
+
image: Union[str, Image] = images.pop() if images else "auto"
|
|
285
|
+
env = cls(name, image=image)
|
|
286
|
+
for t in tasks:
|
|
287
|
+
env._tasks[t.name] = t
|
|
288
|
+
t.parent_env = weakref.ref(env)
|
|
289
|
+
return env
|
flyte/_trigger.py
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import Any, Dict, Mapping, Union
|
|
6
|
+
|
|
7
|
+
import rich.repr
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _trigger_time:
|
|
11
|
+
"""
|
|
12
|
+
This class represents the actual time of Trigger, which can be bound to any task input.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
TriggerTime = _trigger_time()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@rich.repr.auto
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class Cron:
|
|
22
|
+
"""
|
|
23
|
+
This class defines a Cron automation that can be associated with a Trigger in Flyte.
|
|
24
|
+
Example usage:
|
|
25
|
+
```python
|
|
26
|
+
from flyte.trigger import Trigger, Cron
|
|
27
|
+
my_trigger = Trigger(
|
|
28
|
+
name="my_cron_trigger",
|
|
29
|
+
automation=Cron("0 * * * *"), # Runs every hour
|
|
30
|
+
description="A trigger that runs every hour",
|
|
31
|
+
)
|
|
32
|
+
```
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
expression: str
|
|
36
|
+
|
|
37
|
+
def __str__(self):
|
|
38
|
+
return f"Cron Trigger: {self.expression}"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@rich.repr.auto
|
|
42
|
+
@dataclass(frozen=True)
|
|
43
|
+
class FixedRate:
|
|
44
|
+
"""
|
|
45
|
+
This class defines a FixedRate automation that can be associated with a Trigger in Flyte.
|
|
46
|
+
Example usage:
|
|
47
|
+
```python
|
|
48
|
+
from flyte.trigger import Trigger, FixedRate
|
|
49
|
+
my_trigger = Trigger(
|
|
50
|
+
name="my_fixed_rate_trigger",
|
|
51
|
+
automation=FixedRate(60), # Runs every hour
|
|
52
|
+
description="A trigger that runs every hour",
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
interval_minutes: int
|
|
58
|
+
start_time: datetime | None = None
|
|
59
|
+
|
|
60
|
+
def __str__(self):
|
|
61
|
+
return f"FixedRate Trigger: every {self.interval_minutes} minutes"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@rich.repr.auto
|
|
65
|
+
@dataclass(frozen=True)
|
|
66
|
+
class Trigger:
|
|
67
|
+
"""
|
|
68
|
+
This class defines specification of a Trigger, that can be associated with any Flyte V2 task.
|
|
69
|
+
The trigger then is deployed to the Flyte Platform.
|
|
70
|
+
|
|
71
|
+
Triggers can be used to run tasks on a schedule, in response to events, or based on other conditions.
|
|
72
|
+
The `Trigger` class encapsulates the metadata and configuration needed to define a trigger.
|
|
73
|
+
|
|
74
|
+
You can associate the same Trigger object with multiple tasks.
|
|
75
|
+
|
|
76
|
+
Example usage:
|
|
77
|
+
```python
|
|
78
|
+
from flyte.trigger import Trigger
|
|
79
|
+
my_trigger = Trigger(
|
|
80
|
+
name="my_trigger",
|
|
81
|
+
description="A trigger that runs every hour",
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
:param name: (str) The name of the trigger.
|
|
86
|
+
:param automation: (AutomationType) The automation type, currently only supports Cron.
|
|
87
|
+
:param description: (str) A description of the trigger, default is an empty string.
|
|
88
|
+
:param auto_activate: (bool) Whether the trigger should be automatically activated, default is True.
|
|
89
|
+
:param inputs: (Dict[str, Any]) Optional inputs for the trigger, default is None. If provided, will replace the
|
|
90
|
+
values for inputs to these defaults.
|
|
91
|
+
:param env_vars: (Dict[str, str]) Optional environment variables for the trigger, default is None. If provided, will
|
|
92
|
+
replace the environment variables set in the config of the task.
|
|
93
|
+
:param interruptible: (bool) Whether the trigger is interruptible, default is None. If provided,
|
|
94
|
+
it overrides whatever is set in the config of the task.
|
|
95
|
+
:param overwrite_cache: (bool) Whether to overwrite the cache, default is False.
|
|
96
|
+
:param queue: (str) Optional queue to run the trigger in, default is None.
|
|
97
|
+
:param labels: (Mapping[str, str]) Optional labels to attach to the trigger, default is None.
|
|
98
|
+
:param annotations: (Mapping[str, str]) Optional annotations to attach to the trigger, default is None.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
name: str
|
|
102
|
+
automation: Union[Cron, FixedRate]
|
|
103
|
+
description: str = ""
|
|
104
|
+
auto_activate: bool = True
|
|
105
|
+
inputs: Dict[str, Any] | None = None
|
|
106
|
+
env_vars: Dict[str, str] | None = None
|
|
107
|
+
interruptible: bool | None = None
|
|
108
|
+
overwrite_cache: bool = False
|
|
109
|
+
queue: str | None = None
|
|
110
|
+
labels: Mapping[str, str] | None = None
|
|
111
|
+
annotations: Mapping[str, str] | None = None
|
|
112
|
+
|
|
113
|
+
def __post_init__(self):
|
|
114
|
+
if not self.name:
|
|
115
|
+
raise ValueError("Trigger name cannot be empty")
|
|
116
|
+
if self.automation is None:
|
|
117
|
+
raise ValueError("Automation cannot be None")
|
|
118
|
+
|
|
119
|
+
@classmethod
|
|
120
|
+
def daily(
|
|
121
|
+
cls,
|
|
122
|
+
trigger_time_input_key: str = "trigger_time",
|
|
123
|
+
*,
|
|
124
|
+
name: str = "daily",
|
|
125
|
+
description: str = "A trigger that runs daily at midnight",
|
|
126
|
+
auto_activate: bool = True,
|
|
127
|
+
inputs: Dict[str, Any] | None = None,
|
|
128
|
+
env_vars: Dict[str, str] | None = None,
|
|
129
|
+
interruptible: bool | None = None,
|
|
130
|
+
overwrite_cache: bool = False,
|
|
131
|
+
queue: str | None = None,
|
|
132
|
+
labels: Mapping[str, str] | None = None,
|
|
133
|
+
annotations: Mapping[str, str] | None = None,
|
|
134
|
+
) -> Trigger:
|
|
135
|
+
"""
|
|
136
|
+
Creates a Cron trigger that runs daily at midnight.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
trigger_time_input_key (str): The input key for the trigger time, default is "trigger_time".
|
|
140
|
+
name (str): The name of the trigger, default is "daily".
|
|
141
|
+
description (str): A description of the trigger.
|
|
142
|
+
auto_activate (bool): Whether the trigger should be automatically activated.
|
|
143
|
+
inputs (Dict[str, Any] | None): Optional inputs for the trigger.
|
|
144
|
+
env_vars (Dict[str, str] | None): Optional environment variables.
|
|
145
|
+
interruptible (bool | None): Whether the trigger is interruptible.
|
|
146
|
+
overwrite_cache (bool): Whether to overwrite the cache.
|
|
147
|
+
queue (str | None): Optional queue to run the trigger in.
|
|
148
|
+
labels (Mapping[str, str] | None): Optional labels to attach to the trigger.
|
|
149
|
+
annotations (Mapping[str, str] | None): Optional annotations to attach to the trigger.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
Trigger: A trigger that runs daily at midnight.
|
|
153
|
+
"""
|
|
154
|
+
final_inputs = {trigger_time_input_key: TriggerTime}
|
|
155
|
+
if inputs:
|
|
156
|
+
final_inputs.update(inputs)
|
|
157
|
+
|
|
158
|
+
return cls(
|
|
159
|
+
name=name,
|
|
160
|
+
automation=Cron("0 0 * * *"), # Cron expression for daily at midnight
|
|
161
|
+
description=description,
|
|
162
|
+
auto_activate=auto_activate,
|
|
163
|
+
inputs=final_inputs,
|
|
164
|
+
env_vars=env_vars,
|
|
165
|
+
interruptible=interruptible,
|
|
166
|
+
overwrite_cache=overwrite_cache,
|
|
167
|
+
queue=queue,
|
|
168
|
+
labels=labels,
|
|
169
|
+
annotations=annotations,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
@classmethod
|
|
173
|
+
def hourly(
|
|
174
|
+
cls,
|
|
175
|
+
trigger_time_input_key: str = "trigger_time",
|
|
176
|
+
*,
|
|
177
|
+
name: str = "hourly",
|
|
178
|
+
description: str = "A trigger that runs every hour",
|
|
179
|
+
auto_activate: bool = True,
|
|
180
|
+
inputs: Dict[str, Any] | None = None,
|
|
181
|
+
env_vars: Dict[str, str] | None = None,
|
|
182
|
+
interruptible: bool | None = None,
|
|
183
|
+
overwrite_cache: bool = False,
|
|
184
|
+
queue: str | None = None,
|
|
185
|
+
labels: Mapping[str, str] | None = None,
|
|
186
|
+
annotations: Mapping[str, str] | None = None,
|
|
187
|
+
) -> Trigger:
|
|
188
|
+
"""
|
|
189
|
+
Creates a Cron trigger that runs every hour.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
trigger_time_input_key (str): The input parameter for the trigger time, default is "trigger_time".
|
|
193
|
+
name (str): The name of the trigger, default is "hourly".
|
|
194
|
+
description (str): A description of the trigger.
|
|
195
|
+
auto_activate (bool): Whether the trigger should be automatically activated.
|
|
196
|
+
inputs (Dict[str, Any] | None): Optional inputs for the trigger.
|
|
197
|
+
env_vars (Dict[str, str] | None): Optional environment variables.
|
|
198
|
+
interruptible (bool | None): Whether the trigger is interruptible.
|
|
199
|
+
overwrite_cache (bool): Whether to overwrite the cache.
|
|
200
|
+
queue (str | None): Optional queue to run the trigger in.
|
|
201
|
+
labels (Mapping[str, str] | None): Optional labels to attach to the trigger.
|
|
202
|
+
annotations (Mapping[str, str] | None): Optional annotations to attach to the trigger.
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
Trigger: A trigger that runs every hour, on the hour.
|
|
206
|
+
"""
|
|
207
|
+
final_inputs = {trigger_time_input_key: TriggerTime}
|
|
208
|
+
if inputs:
|
|
209
|
+
final_inputs.update(inputs)
|
|
210
|
+
|
|
211
|
+
return cls(
|
|
212
|
+
name=name,
|
|
213
|
+
automation=Cron("0 * * * *"), # Cron expression for every hour
|
|
214
|
+
description=description,
|
|
215
|
+
auto_activate=auto_activate,
|
|
216
|
+
inputs=final_inputs,
|
|
217
|
+
env_vars=env_vars,
|
|
218
|
+
interruptible=interruptible,
|
|
219
|
+
overwrite_cache=overwrite_cache,
|
|
220
|
+
queue=queue,
|
|
221
|
+
labels=labels,
|
|
222
|
+
annotations=annotations,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
def minutely(
|
|
227
|
+
cls,
|
|
228
|
+
trigger_time_input_key: str = "trigger_time",
|
|
229
|
+
*,
|
|
230
|
+
name: str = "minutely",
|
|
231
|
+
description: str = "A trigger that runs every minute",
|
|
232
|
+
auto_activate: bool = True,
|
|
233
|
+
inputs: Dict[str, Any] | None = None,
|
|
234
|
+
env_vars: Dict[str, str] | None = None,
|
|
235
|
+
interruptible: bool | None = None,
|
|
236
|
+
overwrite_cache: bool = False,
|
|
237
|
+
queue: str | None = None,
|
|
238
|
+
labels: Mapping[str, str] | None = None,
|
|
239
|
+
annotations: Mapping[str, str] | None = None,
|
|
240
|
+
) -> Trigger:
|
|
241
|
+
"""
|
|
242
|
+
Creates a Cron trigger that runs every minute.
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
trigger_time_input_key (str): The input parameter for the trigger time, default is "trigger_time".
|
|
246
|
+
name (str): The name of the trigger, default is "every_minute".
|
|
247
|
+
description (str): A description of the trigger.
|
|
248
|
+
auto_activate (bool): Whether the trigger should be automatically activated.
|
|
249
|
+
inputs (Dict[str, Any] | None): Optional inputs for the trigger.
|
|
250
|
+
env_vars (Dict[str, str] | None): Optional environment variables.
|
|
251
|
+
interruptible (bool | None): Whether the trigger is interruptible.
|
|
252
|
+
overwrite_cache (bool): Whether to overwrite the cache.
|
|
253
|
+
queue (str | None): Optional queue to run the trigger in.
|
|
254
|
+
labels (Mapping[str, str] | None): Optional labels to attach to the trigger.
|
|
255
|
+
annotations (Mapping[str, str] | None): Optional annotations to attach to the trigger.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
Trigger: A trigger that runs every minute.
|
|
259
|
+
"""
|
|
260
|
+
final_inputs = {trigger_time_input_key: TriggerTime}
|
|
261
|
+
if inputs:
|
|
262
|
+
final_inputs.update(inputs)
|
|
263
|
+
|
|
264
|
+
return cls(
|
|
265
|
+
name=name,
|
|
266
|
+
automation=Cron("* * * * *"), # Cron expression for every minute
|
|
267
|
+
description=description,
|
|
268
|
+
auto_activate=auto_activate,
|
|
269
|
+
inputs=final_inputs,
|
|
270
|
+
env_vars=env_vars,
|
|
271
|
+
interruptible=interruptible,
|
|
272
|
+
overwrite_cache=overwrite_cache,
|
|
273
|
+
queue=queue,
|
|
274
|
+
labels=labels,
|
|
275
|
+
annotations=annotations,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
@classmethod
|
|
279
|
+
def weekly(
|
|
280
|
+
cls,
|
|
281
|
+
trigger_time_input_key: str = "trigger_time",
|
|
282
|
+
*,
|
|
283
|
+
name: str = "weekly",
|
|
284
|
+
description: str = "A trigger that runs weekly on Sundays at midnight",
|
|
285
|
+
auto_activate: bool = True,
|
|
286
|
+
inputs: Dict[str, Any] | None = None,
|
|
287
|
+
env_vars: Dict[str, str] | None = None,
|
|
288
|
+
interruptible: bool | None = None,
|
|
289
|
+
overwrite_cache: bool = False,
|
|
290
|
+
queue: str | None = None,
|
|
291
|
+
labels: Mapping[str, str] | None = None,
|
|
292
|
+
annotations: Mapping[str, str] | None = None,
|
|
293
|
+
) -> Trigger:
|
|
294
|
+
"""
|
|
295
|
+
Creates a Cron trigger that runs weekly on Sundays at midnight.
|
|
296
|
+
|
|
297
|
+
Args:
|
|
298
|
+
trigger_time_input_key (str): The input parameter for the trigger time, default is "trigger_time".
|
|
299
|
+
name (str): The name of the trigger, default is "weekly".
|
|
300
|
+
description (str): A description of the trigger.
|
|
301
|
+
auto_activate (bool): Whether the trigger should be automatically activated.
|
|
302
|
+
inputs (Dict[str, Any] | None): Optional inputs for the trigger.
|
|
303
|
+
env_vars (Dict[str, str] | None): Optional environment variables.
|
|
304
|
+
interruptible (bool | None): Whether the trigger is interruptible.
|
|
305
|
+
overwrite_cache (bool): Whether to overwrite the cache.
|
|
306
|
+
queue (str | None): Optional queue to run the trigger in.
|
|
307
|
+
labels (Mapping[str, str] | None): Optional labels to attach to the trigger.
|
|
308
|
+
annotations (Mapping[str, str] | None): Optional annotations to attach to the trigger.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
Trigger: A trigger that runs weekly on Sundays at midnight.
|
|
312
|
+
"""
|
|
313
|
+
final_inputs = {trigger_time_input_key: TriggerTime}
|
|
314
|
+
if inputs:
|
|
315
|
+
final_inputs.update(inputs)
|
|
316
|
+
|
|
317
|
+
return cls(
|
|
318
|
+
name=name,
|
|
319
|
+
automation=Cron("0 0 * * 0"), # Cron expression for every Sunday at midnight
|
|
320
|
+
description=description,
|
|
321
|
+
auto_activate=auto_activate,
|
|
322
|
+
inputs=final_inputs,
|
|
323
|
+
env_vars=env_vars,
|
|
324
|
+
interruptible=interruptible,
|
|
325
|
+
overwrite_cache=overwrite_cache,
|
|
326
|
+
queue=queue,
|
|
327
|
+
labels=labels,
|
|
328
|
+
annotations=annotations,
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
@classmethod
|
|
332
|
+
def monthly(
|
|
333
|
+
cls,
|
|
334
|
+
trigger_time_input_key: str = "trigger_time",
|
|
335
|
+
*,
|
|
336
|
+
name: str = "monthly",
|
|
337
|
+
description: str = "A trigger that runs monthly on the 1st at midnight",
|
|
338
|
+
auto_activate: bool = True,
|
|
339
|
+
inputs: Dict[str, Any] | None = None,
|
|
340
|
+
env_vars: Dict[str, str] | None = None,
|
|
341
|
+
interruptible: bool | None = None,
|
|
342
|
+
overwrite_cache: bool = False,
|
|
343
|
+
queue: str | None = None,
|
|
344
|
+
labels: Mapping[str, str] | None = None,
|
|
345
|
+
annotations: Mapping[str, str] | None = None,
|
|
346
|
+
) -> Trigger:
|
|
347
|
+
"""
|
|
348
|
+
Creates a Cron trigger that runs monthly on the 1st at midnight.
|
|
349
|
+
|
|
350
|
+
Args:
|
|
351
|
+
trigger_time_input_key (str): The input parameter for the trigger time, default is "trigger_time".
|
|
352
|
+
name (str): The name of the trigger, default is "monthly".
|
|
353
|
+
description (str): A description of the trigger.
|
|
354
|
+
auto_activate (bool): Whether the trigger should be automatically activated.
|
|
355
|
+
inputs (Dict[str, Any] | None): Optional inputs for the trigger.
|
|
356
|
+
env_vars (Dict[str, str] | None): Optional environment variables.
|
|
357
|
+
interruptible (bool | None): Whether the trigger is interruptible.
|
|
358
|
+
overwrite_cache (bool): Whether to overwrite the cache.
|
|
359
|
+
queue (str | None): Optional queue to run the trigger in.
|
|
360
|
+
labels (Mapping[str, str] | None): Optional labels to attach to the trigger.
|
|
361
|
+
annotations (Mapping[str, str] | None): Optional annotations to attach to the trigger.
|
|
362
|
+
|
|
363
|
+
Returns:
|
|
364
|
+
Trigger: A trigger that runs monthly on the 1st at midnight.
|
|
365
|
+
"""
|
|
366
|
+
final_inputs = {trigger_time_input_key: TriggerTime}
|
|
367
|
+
if inputs:
|
|
368
|
+
final_inputs.update(inputs)
|
|
369
|
+
|
|
370
|
+
return cls(
|
|
371
|
+
name=name,
|
|
372
|
+
automation=Cron("0 0 1 * *"), # Cron expression for monthly on the 1st at midnight
|
|
373
|
+
description=description,
|
|
374
|
+
auto_activate=auto_activate,
|
|
375
|
+
inputs=final_inputs,
|
|
376
|
+
env_vars=env_vars,
|
|
377
|
+
interruptible=interruptible,
|
|
378
|
+
overwrite_cache=overwrite_cache,
|
|
379
|
+
queue=queue,
|
|
380
|
+
labels=labels,
|
|
381
|
+
annotations=annotations,
|
|
382
|
+
)
|
flyte/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '2.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (2, 0, 0, '
|
|
31
|
+
__version__ = version = '2.0.0b23'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 0, 0, 'b23')
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g52dc01de2'
|
flyte/cli/_abort.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import rich_click as click
|
|
2
|
-
from rich.console import Console
|
|
3
2
|
|
|
4
3
|
from flyte.cli import _common as common
|
|
5
4
|
|
|
@@ -23,6 +22,7 @@ def run(cfg: common.CLIConfig, run_name: str, project: str | None = None, domain
|
|
|
23
22
|
cfg.init(project=project, domain=domain)
|
|
24
23
|
r = Run.get(name=run_name)
|
|
25
24
|
if r:
|
|
26
|
-
console =
|
|
27
|
-
|
|
25
|
+
console = common.get_console()
|
|
26
|
+
with console.status(f"Aborting run '{run_name}'...", spinner="dots"):
|
|
27
|
+
r.abort()
|
|
28
28
|
console.print(f"Run '{run_name}' has been aborted.")
|
flyte/cli/_build.py
CHANGED
|
@@ -44,9 +44,7 @@ class BuildEnvCommand(click.Command):
|
|
|
44
44
|
super().__init__(*args, **kwargs)
|
|
45
45
|
|
|
46
46
|
def invoke(self, ctx: click.Context):
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
console = Console()
|
|
47
|
+
console = common.get_console()
|
|
50
48
|
console.print(f"Building Environment: {self.obj_name}")
|
|
51
49
|
obj: CLIConfig = ctx.obj
|
|
52
50
|
obj.init()
|
flyte/cli/_common.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import importlib.util
|
|
4
|
+
import json
|
|
4
5
|
import logging
|
|
5
6
|
import os
|
|
6
7
|
import sys
|
|
@@ -22,7 +23,7 @@ from rich.traceback import Traceback
|
|
|
22
23
|
import flyte.errors
|
|
23
24
|
from flyte.config import Config
|
|
24
25
|
|
|
25
|
-
OutputFormat = Literal["table", "json", "table-simple"]
|
|
26
|
+
OutputFormat = Literal["table", "json", "table-simple", "json-raw"]
|
|
26
27
|
|
|
27
28
|
PREFERRED_BORDER_COLOR = "dim cyan"
|
|
28
29
|
PREFERRED_ACCENT_COLOR = "bold #FFD700"
|
|
@@ -177,7 +178,7 @@ class InvokeBaseMixin:
|
|
|
177
178
|
except Exception as e:
|
|
178
179
|
if ctx.obj and ctx.obj.log_level and ctx.obj.log_level <= logging.DEBUG:
|
|
179
180
|
# If the user has requested verbose output, print the full traceback
|
|
180
|
-
console =
|
|
181
|
+
console = get_console()
|
|
181
182
|
console.print(Traceback.from_exception(type(e), e, e.__traceback__))
|
|
182
183
|
exit(1)
|
|
183
184
|
else:
|
|
@@ -381,6 +382,11 @@ def format(title: str, vals: Iterable[Any], of: OutputFormat = "table") -> Table
|
|
|
381
382
|
if not vals:
|
|
382
383
|
return pretty_repr([])
|
|
383
384
|
return pretty_repr([v.to_dict() for v in vals])
|
|
385
|
+
case "json-raw":
|
|
386
|
+
if not vals:
|
|
387
|
+
return []
|
|
388
|
+
return json.dumps([v.to_dict() for v in vals])
|
|
389
|
+
|
|
384
390
|
raise click.ClickException("Unknown output format. Supported formats are: table, table-simple, json.")
|
|
385
391
|
|
|
386
392
|
|
|
@@ -395,3 +401,10 @@ def get_panel(title: str, renderable: Any, of: OutputFormat = "table") -> Panel:
|
|
|
395
401
|
title=f"[{PREFERRED_ACCENT_COLOR}]{title}[/{PREFERRED_ACCENT_COLOR}]",
|
|
396
402
|
border_style=PREFERRED_BORDER_COLOR,
|
|
397
403
|
)
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def get_console() -> Console:
|
|
407
|
+
"""
|
|
408
|
+
Get a console that is configured to use colors if the terminal supports it.
|
|
409
|
+
"""
|
|
410
|
+
return Console(color_system="auto", force_terminal=True, width=120)
|