flyte 2.0.0b22__py3-none-any.whl → 2.0.0b30__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.
Files changed (197) hide show
  1. flyte/__init__.py +18 -2
  2. flyte/_bin/runtime.py +43 -5
  3. flyte/_cache/cache.py +4 -2
  4. flyte/_cache/local_cache.py +216 -0
  5. flyte/_code_bundle/_ignore.py +1 -1
  6. flyte/_code_bundle/_packaging.py +4 -4
  7. flyte/_code_bundle/_utils.py +14 -8
  8. flyte/_code_bundle/bundle.py +13 -5
  9. flyte/_constants.py +1 -0
  10. flyte/_context.py +4 -1
  11. flyte/_custom_context.py +73 -0
  12. flyte/_debug/constants.py +0 -1
  13. flyte/_debug/vscode.py +6 -1
  14. flyte/_deploy.py +223 -59
  15. flyte/_environment.py +5 -0
  16. flyte/_excepthook.py +1 -1
  17. flyte/_image.py +144 -82
  18. flyte/_initialize.py +95 -12
  19. flyte/_interface.py +2 -0
  20. flyte/_internal/controllers/_local_controller.py +65 -24
  21. flyte/_internal/controllers/_trace.py +1 -1
  22. flyte/_internal/controllers/remote/_action.py +13 -11
  23. flyte/_internal/controllers/remote/_client.py +1 -1
  24. flyte/_internal/controllers/remote/_controller.py +9 -4
  25. flyte/_internal/controllers/remote/_core.py +16 -16
  26. flyte/_internal/controllers/remote/_informer.py +4 -4
  27. flyte/_internal/controllers/remote/_service_protocol.py +7 -7
  28. flyte/_internal/imagebuild/docker_builder.py +139 -84
  29. flyte/_internal/imagebuild/image_builder.py +7 -13
  30. flyte/_internal/imagebuild/remote_builder.py +65 -13
  31. flyte/_internal/imagebuild/utils.py +51 -3
  32. flyte/_internal/resolvers/_task_module.py +5 -38
  33. flyte/_internal/resolvers/default.py +2 -2
  34. flyte/_internal/runtime/convert.py +42 -20
  35. flyte/_internal/runtime/entrypoints.py +24 -1
  36. flyte/_internal/runtime/io.py +21 -8
  37. flyte/_internal/runtime/resources_serde.py +20 -6
  38. flyte/_internal/runtime/reuse.py +1 -1
  39. flyte/_internal/runtime/rusty.py +20 -5
  40. flyte/_internal/runtime/task_serde.py +33 -27
  41. flyte/_internal/runtime/taskrunner.py +10 -1
  42. flyte/_internal/runtime/trigger_serde.py +160 -0
  43. flyte/_internal/runtime/types_serde.py +1 -1
  44. flyte/_keyring/file.py +39 -9
  45. flyte/_logging.py +79 -12
  46. flyte/_map.py +31 -12
  47. flyte/_module.py +70 -0
  48. flyte/_pod.py +2 -2
  49. flyte/_resources.py +213 -31
  50. flyte/_run.py +107 -41
  51. flyte/_task.py +66 -10
  52. flyte/_task_environment.py +96 -24
  53. flyte/_task_plugins.py +4 -2
  54. flyte/_trigger.py +1000 -0
  55. flyte/_utils/__init__.py +2 -1
  56. flyte/_utils/asyn.py +3 -1
  57. flyte/_utils/docker_credentials.py +173 -0
  58. flyte/_utils/module_loader.py +17 -2
  59. flyte/_version.py +3 -3
  60. flyte/cli/_abort.py +3 -3
  61. flyte/cli/_build.py +1 -3
  62. flyte/cli/_common.py +78 -7
  63. flyte/cli/_create.py +178 -3
  64. flyte/cli/_delete.py +23 -1
  65. flyte/cli/_deploy.py +49 -11
  66. flyte/cli/_get.py +79 -34
  67. flyte/cli/_params.py +8 -6
  68. flyte/cli/_plugins.py +209 -0
  69. flyte/cli/_run.py +127 -11
  70. flyte/cli/_serve.py +64 -0
  71. flyte/cli/_update.py +37 -0
  72. flyte/cli/_user.py +17 -0
  73. flyte/cli/main.py +30 -4
  74. flyte/config/_config.py +2 -0
  75. flyte/config/_internal.py +1 -0
  76. flyte/config/_reader.py +3 -3
  77. flyte/connectors/__init__.py +11 -0
  78. flyte/connectors/_connector.py +270 -0
  79. flyte/connectors/_server.py +197 -0
  80. flyte/connectors/utils.py +135 -0
  81. flyte/errors.py +10 -1
  82. flyte/extend.py +8 -1
  83. flyte/extras/_container.py +6 -1
  84. flyte/git/_config.py +11 -9
  85. flyte/io/__init__.py +2 -0
  86. flyte/io/_dataframe/__init__.py +2 -0
  87. flyte/io/_dataframe/basic_dfs.py +1 -1
  88. flyte/io/_dataframe/dataframe.py +12 -8
  89. flyte/io/_dir.py +551 -120
  90. flyte/io/_file.py +538 -141
  91. flyte/models.py +57 -12
  92. flyte/remote/__init__.py +6 -1
  93. flyte/remote/_action.py +18 -16
  94. flyte/remote/_client/_protocols.py +39 -4
  95. flyte/remote/_client/auth/_channel.py +10 -6
  96. flyte/remote/_client/controlplane.py +17 -5
  97. flyte/remote/_console.py +3 -2
  98. flyte/remote/_data.py +4 -3
  99. flyte/remote/_logs.py +3 -3
  100. flyte/remote/_run.py +47 -7
  101. flyte/remote/_secret.py +26 -17
  102. flyte/remote/_task.py +21 -9
  103. flyte/remote/_trigger.py +306 -0
  104. flyte/remote/_user.py +33 -0
  105. flyte/storage/__init__.py +6 -1
  106. flyte/storage/_parallel_reader.py +274 -0
  107. flyte/storage/_storage.py +185 -103
  108. flyte/types/__init__.py +16 -0
  109. flyte/types/_interface.py +2 -2
  110. flyte/types/_pickle.py +17 -4
  111. flyte/types/_string_literals.py +8 -9
  112. flyte/types/_type_engine.py +26 -19
  113. flyte/types/_utils.py +1 -1
  114. {flyte-2.0.0b22.data → flyte-2.0.0b30.data}/scripts/runtime.py +43 -5
  115. {flyte-2.0.0b22.dist-info → flyte-2.0.0b30.dist-info}/METADATA +8 -1
  116. flyte-2.0.0b30.dist-info/RECORD +192 -0
  117. flyte/_protos/__init__.py +0 -0
  118. flyte/_protos/common/authorization_pb2.py +0 -66
  119. flyte/_protos/common/authorization_pb2.pyi +0 -108
  120. flyte/_protos/common/authorization_pb2_grpc.py +0 -4
  121. flyte/_protos/common/identifier_pb2.py +0 -99
  122. flyte/_protos/common/identifier_pb2.pyi +0 -120
  123. flyte/_protos/common/identifier_pb2_grpc.py +0 -4
  124. flyte/_protos/common/identity_pb2.py +0 -48
  125. flyte/_protos/common/identity_pb2.pyi +0 -72
  126. flyte/_protos/common/identity_pb2_grpc.py +0 -4
  127. flyte/_protos/common/list_pb2.py +0 -36
  128. flyte/_protos/common/list_pb2.pyi +0 -71
  129. flyte/_protos/common/list_pb2_grpc.py +0 -4
  130. flyte/_protos/common/policy_pb2.py +0 -37
  131. flyte/_protos/common/policy_pb2.pyi +0 -27
  132. flyte/_protos/common/policy_pb2_grpc.py +0 -4
  133. flyte/_protos/common/role_pb2.py +0 -37
  134. flyte/_protos/common/role_pb2.pyi +0 -53
  135. flyte/_protos/common/role_pb2_grpc.py +0 -4
  136. flyte/_protos/common/runtime_version_pb2.py +0 -28
  137. flyte/_protos/common/runtime_version_pb2.pyi +0 -24
  138. flyte/_protos/common/runtime_version_pb2_grpc.py +0 -4
  139. flyte/_protos/imagebuilder/definition_pb2.py +0 -60
  140. flyte/_protos/imagebuilder/definition_pb2.pyi +0 -153
  141. flyte/_protos/imagebuilder/definition_pb2_grpc.py +0 -4
  142. flyte/_protos/imagebuilder/payload_pb2.py +0 -32
  143. flyte/_protos/imagebuilder/payload_pb2.pyi +0 -21
  144. flyte/_protos/imagebuilder/payload_pb2_grpc.py +0 -4
  145. flyte/_protos/imagebuilder/service_pb2.py +0 -29
  146. flyte/_protos/imagebuilder/service_pb2.pyi +0 -5
  147. flyte/_protos/imagebuilder/service_pb2_grpc.py +0 -66
  148. flyte/_protos/logs/dataplane/payload_pb2.py +0 -100
  149. flyte/_protos/logs/dataplane/payload_pb2.pyi +0 -177
  150. flyte/_protos/logs/dataplane/payload_pb2_grpc.py +0 -4
  151. flyte/_protos/secret/definition_pb2.py +0 -49
  152. flyte/_protos/secret/definition_pb2.pyi +0 -93
  153. flyte/_protos/secret/definition_pb2_grpc.py +0 -4
  154. flyte/_protos/secret/payload_pb2.py +0 -62
  155. flyte/_protos/secret/payload_pb2.pyi +0 -94
  156. flyte/_protos/secret/payload_pb2_grpc.py +0 -4
  157. flyte/_protos/secret/secret_pb2.py +0 -38
  158. flyte/_protos/secret/secret_pb2.pyi +0 -6
  159. flyte/_protos/secret/secret_pb2_grpc.py +0 -198
  160. flyte/_protos/secret/secret_pb2_grpc_grpc.py +0 -198
  161. flyte/_protos/validate/validate/validate_pb2.py +0 -76
  162. flyte/_protos/workflow/common_pb2.py +0 -27
  163. flyte/_protos/workflow/common_pb2.pyi +0 -14
  164. flyte/_protos/workflow/common_pb2_grpc.py +0 -4
  165. flyte/_protos/workflow/environment_pb2.py +0 -29
  166. flyte/_protos/workflow/environment_pb2.pyi +0 -12
  167. flyte/_protos/workflow/environment_pb2_grpc.py +0 -4
  168. flyte/_protos/workflow/node_execution_service_pb2.py +0 -26
  169. flyte/_protos/workflow/node_execution_service_pb2.pyi +0 -4
  170. flyte/_protos/workflow/node_execution_service_pb2_grpc.py +0 -32
  171. flyte/_protos/workflow/queue_service_pb2.py +0 -111
  172. flyte/_protos/workflow/queue_service_pb2.pyi +0 -168
  173. flyte/_protos/workflow/queue_service_pb2_grpc.py +0 -172
  174. flyte/_protos/workflow/run_definition_pb2.py +0 -123
  175. flyte/_protos/workflow/run_definition_pb2.pyi +0 -352
  176. flyte/_protos/workflow/run_definition_pb2_grpc.py +0 -4
  177. flyte/_protos/workflow/run_logs_service_pb2.py +0 -41
  178. flyte/_protos/workflow/run_logs_service_pb2.pyi +0 -28
  179. flyte/_protos/workflow/run_logs_service_pb2_grpc.py +0 -69
  180. flyte/_protos/workflow/run_service_pb2.py +0 -137
  181. flyte/_protos/workflow/run_service_pb2.pyi +0 -185
  182. flyte/_protos/workflow/run_service_pb2_grpc.py +0 -446
  183. flyte/_protos/workflow/state_service_pb2.py +0 -67
  184. flyte/_protos/workflow/state_service_pb2.pyi +0 -76
  185. flyte/_protos/workflow/state_service_pb2_grpc.py +0 -138
  186. flyte/_protos/workflow/task_definition_pb2.py +0 -82
  187. flyte/_protos/workflow/task_definition_pb2.pyi +0 -88
  188. flyte/_protos/workflow/task_definition_pb2_grpc.py +0 -4
  189. flyte/_protos/workflow/task_service_pb2.py +0 -60
  190. flyte/_protos/workflow/task_service_pb2.pyi +0 -59
  191. flyte/_protos/workflow/task_service_pb2_grpc.py +0 -138
  192. flyte-2.0.0b22.dist-info/RECORD +0 -250
  193. {flyte-2.0.0b22.data → flyte-2.0.0b30.data}/scripts/debug.py +0 -0
  194. {flyte-2.0.0b22.dist-info → flyte-2.0.0b30.dist-info}/WHEEL +0 -0
  195. {flyte-2.0.0b22.dist-info → flyte-2.0.0b30.dist-info}/entry_points.txt +0 -0
  196. {flyte-2.0.0b22.dist-info → flyte-2.0.0b30.dist-info}/licenses/LICENSE +0 -0
  197. {flyte-2.0.0b22.dist-info → flyte-2.0.0b30.dist-info}/top_level.txt +0 -0
flyte/cli/_run.py CHANGED
@@ -9,14 +9,13 @@ from types import ModuleType
9
9
  from typing import Any, Dict, List, cast
10
10
 
11
11
  import rich_click as click
12
- from rich.console import Console
13
12
  from typing_extensions import get_args
14
13
 
15
14
  from .._code_bundle._utils import CopyFiles
16
15
  from .._task import TaskTemplate
17
16
  from ..remote import Run
18
17
  from . import _common as common
19
- from ._common import CLIConfig
18
+ from ._common import CLIConfig, initialize_config
20
19
  from ._params import to_click_option
21
20
 
22
21
  RUN_REMOTE_CMD = "deployed-task"
@@ -44,7 +43,7 @@ def _list_tasks(
44
43
  ) -> list[str]:
45
44
  import flyte.remote
46
45
 
47
- _initialize_config(ctx, project, domain)
46
+ common.initialize_config(ctx, project, domain)
48
47
  return [task.name for task in flyte.remote.Task.listall(by_task_name=by_task_name, by_task_env=by_task_env)]
49
48
 
50
49
 
@@ -87,6 +86,26 @@ class RunArguments:
87
86
  )
88
87
  },
89
88
  )
89
+ raw_data_path: str | None = field(
90
+ default=None,
91
+ metadata={
92
+ "click.option": click.Option(
93
+ ["--raw-data-path"],
94
+ type=str,
95
+ help="Override the output prefix used to store offloaded data types. e.g. s3://bucket/",
96
+ )
97
+ },
98
+ )
99
+ service_account: str | None = field(
100
+ default=None,
101
+ metadata={
102
+ "click.option": click.Option(
103
+ ["--service-account"],
104
+ type=str,
105
+ help="Kubernetes service account. If not provided, the configured default will be used",
106
+ )
107
+ },
108
+ )
90
109
  name: str | None = field(
91
110
  default=None,
92
111
  metadata={
@@ -109,10 +128,35 @@ class RunArguments:
109
128
  )
110
129
  },
111
130
  )
131
+ image: List[str] = field(
132
+ default_factory=list,
133
+ metadata={
134
+ "click.option": click.Option(
135
+ ["--image"],
136
+ type=str,
137
+ multiple=True,
138
+ help="Image to be used in the run. Format: imagename=imageuri. Can be specified multiple times.",
139
+ )
140
+ },
141
+ )
142
+ no_sync_local_sys_paths: bool = field(
143
+ default=True,
144
+ metadata={
145
+ "click.option": click.Option(
146
+ ["--no-sync-local-sys-paths"],
147
+ is_flag=True,
148
+ flag_value=True,
149
+ default=False,
150
+ help="Disable synchronization of local sys.path entries under the root directory "
151
+ "to the remote container.",
152
+ )
153
+ },
154
+ )
112
155
 
113
156
  @classmethod
114
157
  def from_dict(cls, d: Dict[str, Any]) -> RunArguments:
115
- return cls(**d)
158
+ modified = {k: v for k, v in d.items() if k in {f.name for f in fields(cls)}}
159
+ return cls(**modified)
116
160
 
117
161
  @classmethod
118
162
  def options(cls) -> List[click.Option]:
@@ -131,18 +175,38 @@ class RunTaskCommand(click.RichCommand):
131
175
  super().__init__(obj_name, *args, **kwargs)
132
176
 
133
177
  def invoke(self, ctx: click.Context):
134
- obj: CLIConfig = _initialize_config(ctx, self.run_args.project, self.run_args.domain, self.run_args.root_dir)
178
+ obj: CLIConfig = initialize_config(
179
+ ctx,
180
+ self.run_args.project,
181
+ self.run_args.domain,
182
+ self.run_args.root_dir,
183
+ tuple(self.run_args.image) or None,
184
+ not self.run_args.no_sync_local_sys_paths,
185
+ )
135
186
 
136
187
  async def _run():
137
188
  import flyte
138
189
 
190
+ console = common.get_console()
139
191
  r = await flyte.with_runcontext(
140
192
  copy_style=self.run_args.copy_style,
141
193
  mode="local" if self.run_args.local else "remote",
142
194
  name=self.run_args.name,
195
+ raw_data_path=self.run_args.raw_data_path,
196
+ service_account=self.run_args.service_account,
197
+ log_format=obj.log_format,
143
198
  ).run.aio(self.obj, **ctx.params)
199
+ if self.run_args.local:
200
+ console.print(
201
+ common.get_panel(
202
+ "Local Run",
203
+ f"[green]Completed Local Run, data stored in path: {r.url} [/green] \n"
204
+ f"➡️ Outputs: {r.outputs()}",
205
+ obj.output_format,
206
+ )
207
+ )
208
+ return
144
209
  if isinstance(r, Run) and r.action is not None:
145
- console = Console()
146
210
  console.print(
147
211
  common.get_panel(
148
212
  "Run",
@@ -196,6 +260,26 @@ class TaskPerFileGroup(common.ObjectsPerFileGroup):
196
260
  def _filter_objects(self, module: ModuleType) -> Dict[str, Any]:
197
261
  return {k: v for k, v in module.__dict__.items() if isinstance(v, TaskTemplate)}
198
262
 
263
+ def list_commands(self, ctx):
264
+ common.initialize_config(
265
+ ctx,
266
+ self.run_args.project,
267
+ self.run_args.domain,
268
+ self.run_args.root_dir,
269
+ sync_local_sys_paths=not self.run_args.no_sync_local_sys_paths,
270
+ )
271
+ return super().list_commands(ctx)
272
+
273
+ def get_command(self, ctx, obj_name):
274
+ common.initialize_config(
275
+ ctx,
276
+ self.run_args.project,
277
+ self.run_args.domain,
278
+ self.run_args.root_dir,
279
+ sync_local_sys_paths=not self.run_args.no_sync_local_sys_paths,
280
+ )
281
+ return super().get_command(ctx, obj_name)
282
+
199
283
  def _get_command_for_obj(self, ctx: click.Context, obj_name: str, obj: Any) -> click.Command:
200
284
  obj = cast(TaskTemplate, obj)
201
285
  return RunTaskCommand(
@@ -215,13 +299,20 @@ class RunReferenceTaskCommand(click.RichCommand):
215
299
  super().__init__(*args, **kwargs)
216
300
 
217
301
  def invoke(self, ctx: click.Context):
218
- obj: CLIConfig = _initialize_config(ctx, self.run_args.project, self.run_args.domain)
302
+ obj: CLIConfig = common.initialize_config(
303
+ ctx,
304
+ self.run_args.project,
305
+ self.run_args.domain,
306
+ self.run_args.root_dir,
307
+ tuple(self.run_args.image) or None,
308
+ not self.run_args.no_sync_local_sys_paths,
309
+ )
219
310
 
220
311
  async def _run():
221
- import flyte
222
312
  import flyte.remote
223
313
 
224
314
  task = flyte.remote.Task.get(self.task_name, version=self.version, auto_version="latest")
315
+ console = common.get_console()
225
316
 
226
317
  r = await flyte.with_runcontext(
227
318
  copy_style=self.run_args.copy_style,
@@ -229,7 +320,6 @@ class RunReferenceTaskCommand(click.RichCommand):
229
320
  name=self.run_args.name,
230
321
  ).run.aio(task, **ctx.params)
231
322
  if isinstance(r, Run) and r.action is not None:
232
- console = Console()
233
323
  console.print(
234
324
  common.get_panel(
235
325
  "Run",
@@ -253,7 +343,12 @@ class RunReferenceTaskCommand(click.RichCommand):
253
343
  import flyte.remote
254
344
  from flyte._internal.runtime.types_serde import transform_native_to_typed_interface
255
345
 
256
- _initialize_config(ctx, self.run_args.project, self.run_args.domain)
346
+ common.initialize_config(
347
+ ctx,
348
+ self.run_args.project,
349
+ self.run_args.domain,
350
+ sync_local_sys_paths=not self.run_args.no_sync_local_sys_paths,
351
+ )
257
352
 
258
353
  task = flyte.remote.Task.get(self.task_name, auto_version="latest")
259
354
  task_details = task.fetch()
@@ -399,7 +494,6 @@ class TaskFiles(common.FileGroup):
399
494
 
400
495
  def get_command(self, ctx, cmd_name):
401
496
  run_args = RunArguments.from_dict(ctx.params)
402
-
403
497
  if cmd_name == RUN_REMOTE_CMD:
404
498
  return ReferenceTaskGroup(
405
499
  name=cmd_name,
@@ -446,6 +540,28 @@ Flyte environment:
446
540
  flyte run --local hello.py my_task --arg1 value1 --arg2 value2
447
541
  ```
448
542
 
543
+ You can provide image mappings with `--image` flag. This allows you to specify
544
+ the image URI for the task environment during CLI execution without changing
545
+ the code. Any images defined with `Image.from_ref_name("name")` will resolve to the
546
+ corresponding URIs you specify here.
547
+
548
+ ```bash
549
+ flyte run hello.py my_task --image my_image=ghcr.io/myorg/my-image:v1.0
550
+ ```
551
+
552
+ If the image name is not provided, it is regarded as a default image and will
553
+ be used when no image is specified in TaskEnvironment:
554
+
555
+ ```bash
556
+ flyte run hello.py my_task --image ghcr.io/myorg/default-image:latest
557
+ ```
558
+
559
+ You can specify multiple image arguments:
560
+
561
+ ```bash
562
+ flyte run hello.py my_task --image ghcr.io/org/default:latest --image gpu=ghcr.io/org/gpu:v2.0
563
+ ```
564
+
449
565
  To run tasks that you've already deployed to Flyte, use the {RUN_REMOTE_CMD} command:
450
566
 
451
567
  ```bash
flyte/cli/_serve.py ADDED
@@ -0,0 +1,64 @@
1
+ from typing import List
2
+
3
+ import click
4
+
5
+
6
+ @click.group("serve")
7
+ @click.pass_context
8
+ def serve(_: click.Context):
9
+ """
10
+ Start the specific service. For example:
11
+
12
+ ```bash
13
+ flyte serve connector
14
+ ```
15
+ """
16
+
17
+
18
+ @serve.command()
19
+ @click.option(
20
+ "--port",
21
+ default="8000",
22
+ is_flag=False,
23
+ type=int,
24
+ help="Grpc port for the connector service",
25
+ )
26
+ @click.option(
27
+ "--prometheus_port",
28
+ default="9090",
29
+ is_flag=False,
30
+ type=int,
31
+ help="Prometheus port for the connector service",
32
+ )
33
+ @click.option(
34
+ "--worker",
35
+ default="10",
36
+ is_flag=False,
37
+ type=int,
38
+ help="Number of workers for the grpc server",
39
+ )
40
+ @click.option(
41
+ "--timeout",
42
+ default=None,
43
+ is_flag=False,
44
+ type=int,
45
+ help="It will wait for the specified number of seconds before shutting down grpc server. It should only be used "
46
+ "for testing.",
47
+ )
48
+ @click.option(
49
+ "--modules",
50
+ required=False,
51
+ multiple=True,
52
+ type=str,
53
+ help="List of additional files or module that defines the connector",
54
+ )
55
+ @click.pass_context
56
+ def connector(
57
+ _: click.Context, port: int, prometheus_port: int, worker: int, timeout: int | None, modules: List[str] | None
58
+ ):
59
+ """
60
+ Start a grpc server for the connector service.
61
+ """
62
+ from flyte.connectors import ConnectorService
63
+
64
+ ConnectorService.run(port, prometheus_port, worker, timeout, modules)
flyte/cli/_update.py ADDED
@@ -0,0 +1,37 @@
1
+ import rich_click as click
2
+
3
+ import flyte.remote as remote
4
+
5
+ from . import _common as common
6
+
7
+
8
+ @click.group(name="update")
9
+ def update():
10
+ """
11
+ Update various flyte entities.
12
+ """
13
+
14
+
15
+ @update.command("trigger", cls=common.CommandBase)
16
+ @click.argument("name", type=str)
17
+ @click.argument("task_name", type=str)
18
+ @click.option("--activate/--deactivate", required=True, help="Activate or deactivate the trigger.")
19
+ @click.pass_obj
20
+ def trigger(cfg: common.CLIConfig, name: str, task_name: str, activate: bool, project: str | None, domain: str | None):
21
+ """
22
+ Update a trigger.
23
+
24
+ \b
25
+ Example usage:
26
+
27
+ ```bash
28
+ flyte update trigger <trigger_name> <task_name> --activate | --deactivate
29
+ [--project <project_name> --domain <domain_name>]
30
+ ```
31
+ """
32
+ cfg.init(project, domain)
33
+ console = common.get_console()
34
+ to_state = "active" if activate else "deactivate"
35
+ with console.status(f"Updating trigger {name} for task {task_name} to {to_state}..."):
36
+ remote.Trigger.update(name, task_name, activate)
37
+ console.print(f"Trigger updated and is set to [fuchsia]{to_state}[/fuchsia]")
flyte/cli/_user.py ADDED
@@ -0,0 +1,17 @@
1
+ import rich_click as click
2
+
3
+ import flyte.remote as remote
4
+
5
+ from . import _common as common
6
+
7
+
8
+ @click.command()
9
+ @click.pass_obj
10
+ def whoami(
11
+ cfg: common.CLIConfig,
12
+ ):
13
+ """Display the current user information."""
14
+ cfg.init()
15
+ console = common.get_console()
16
+ user_info = remote.User.get()
17
+ console.print(user_info.to_json())
flyte/cli/main.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import rich_click as click
2
2
  from typing_extensions import get_args
3
3
 
4
- from flyte._logging import initialize_logger, logger
4
+ from flyte._logging import LogFormat, initialize_logger, logger
5
5
 
6
6
  from . import _common as common
7
7
  from ._abort import abort
@@ -12,7 +12,11 @@ from ._delete import delete
12
12
  from ._deploy import deploy
13
13
  from ._gen import gen
14
14
  from ._get import get
15
+ from ._plugins import discover_and_register_plugins
15
16
  from ._run import run
17
+ from ._serve import serve
18
+ from ._update import update
19
+ from ._user import whoami
16
20
 
17
21
  help_config = click.RichHelpConfiguration(
18
22
  use_markdown=True,
@@ -25,7 +29,7 @@ help_config = click.RichHelpConfiguration(
25
29
  },
26
30
  {
27
31
  "name": "Management of various objects.",
28
- "commands": ["create", "get", "delete"],
32
+ "commands": ["create", "get", "delete", "update"],
29
33
  },
30
34
  {
31
35
  "name": "Build and deploy environments, tasks and images.",
@@ -35,6 +39,10 @@ help_config = click.RichHelpConfiguration(
35
39
  "name": "Documentation generation",
36
40
  "commands": ["gen"],
37
41
  },
42
+ {
43
+ "name": "User information",
44
+ "commands": ["whoami"],
45
+ },
38
46
  ]
39
47
  },
40
48
  )
@@ -116,6 +124,16 @@ def _verbosity_to_loglevel(verbosity: int) -> int | None:
116
124
  show_default=True,
117
125
  required=False,
118
126
  )
127
+ @click.option(
128
+ "--log-format",
129
+ type=click.Choice(get_args(LogFormat), case_sensitive=False),
130
+ envvar="LOG_FORMAT",
131
+ default="console",
132
+ help="Formatting for logs, defaults to 'console' which is meant to be human readable."
133
+ " 'json' is meant for machine parsing.",
134
+ show_default=True,
135
+ required=False,
136
+ )
119
137
  @click.rich_config(help_config=help_config)
120
138
  @click.pass_context
121
139
  def main(
@@ -123,6 +141,7 @@ def main(
123
141
  endpoint: str | None,
124
142
  insecure: bool,
125
143
  verbose: int,
144
+ log_format: LogFormat,
126
145
  org: str | None,
127
146
  config_file: str | None,
128
147
  auth_type: str | None = None,
@@ -166,8 +185,8 @@ def main(
166
185
  import flyte.config as config
167
186
 
168
187
  log_level = _verbosity_to_loglevel(verbose)
169
- if log_level is not None:
170
- initialize_logger(log_level)
188
+ if log_level is not None or log_format != "console":
189
+ initialize_logger(log_level=log_level, log_format=log_format)
171
190
 
172
191
  cfg = config.auto(config_file=config_file)
173
192
  if cfg.source:
@@ -175,6 +194,7 @@ def main(
175
194
 
176
195
  ctx.obj = CLIConfig(
177
196
  log_level=log_level,
197
+ log_format=log_format,
178
198
  endpoint=endpoint,
179
199
  insecure=insecure,
180
200
  org=org,
@@ -193,3 +213,9 @@ main.add_command(abort) # type: ignore
193
213
  main.add_command(gen) # type: ignore
194
214
  main.add_command(delete) # type: ignore
195
215
  main.add_command(build)
216
+ main.add_command(whoami) # type: ignore
217
+ main.add_command(update) # type: ignore
218
+ main.add_command(serve) # type: ignore
219
+
220
+ # Discover and register CLI plugins from installed packages
221
+ discover_and_register_plugins(main)
flyte/config/_config.py CHANGED
@@ -148,6 +148,7 @@ class ImageConfig(object):
148
148
  """
149
149
 
150
150
  builder: str | None = None
151
+ image_refs: typing.Dict[str, str] = field(default_factory=dict)
151
152
 
152
153
  @classmethod
153
154
  def auto(cls, config_file: typing.Optional[typing.Union[str, ConfigFile]] = None) -> "ImageConfig":
@@ -159,6 +160,7 @@ class ImageConfig(object):
159
160
  config_file = get_config_file(config_file)
160
161
  kwargs: typing.Dict[str, typing.Any] = {}
161
162
  kwargs = set_if_exists(kwargs, "builder", _internal.Image.BUILDER.read(config_file))
163
+ kwargs = set_if_exists(kwargs, "image_refs", _internal.Image.IMAGE_REFS.read(config_file))
162
164
  return ImageConfig(**kwargs)
163
165
 
164
166
 
flyte/config/_internal.py CHANGED
@@ -70,3 +70,4 @@ class Image(object):
70
70
  """
71
71
 
72
72
  BUILDER = ConfigEntry(YamlConfigEntry("image.builder"))
73
+ IMAGE_REFS = ConfigEntry(YamlConfigEntry("image.image_refs"))
flyte/config/_reader.py CHANGED
@@ -138,10 +138,10 @@ class ConfigFile(object):
138
138
  def _config_path_from_git_root() -> pathlib.Path | None:
139
139
  from flyte.git import config_from_root
140
140
 
141
- try:
142
- return config_from_root().source
143
- except RuntimeError:
141
+ config = config_from_root()
142
+ if config is None:
144
143
  return None
144
+ return config.source
145
145
 
146
146
 
147
147
  def resolve_config_path() -> pathlib.Path | None:
@@ -0,0 +1,11 @@
1
+ from ._connector import AsyncConnector, AsyncConnectorExecutorMixin, ConnectorRegistry, Resource, ResourceMeta
2
+ from ._server import ConnectorService
3
+
4
+ __all__ = [
5
+ "AsyncConnector",
6
+ "AsyncConnectorExecutorMixin",
7
+ "ConnectorRegistry",
8
+ "ConnectorService",
9
+ "Resource",
10
+ "ResourceMeta",
11
+ ]