flyte 0.0.1b3__py3-none-any.whl → 0.2.0a0__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.

Files changed (319) hide show
  1. flyte/__init__.py +20 -4
  2. flyte/_bin/runtime.py +33 -7
  3. flyte/_build.py +3 -2
  4. flyte/_cache/cache.py +1 -2
  5. flyte/_code_bundle/_packaging.py +1 -1
  6. flyte/_code_bundle/_utils.py +0 -16
  7. flyte/_code_bundle/bundle.py +43 -12
  8. flyte/_context.py +8 -2
  9. flyte/_deploy.py +56 -15
  10. flyte/_environment.py +45 -4
  11. flyte/_excepthook.py +37 -0
  12. flyte/_group.py +2 -1
  13. flyte/_image.py +8 -4
  14. flyte/_initialize.py +112 -254
  15. flyte/_interface.py +3 -3
  16. flyte/_internal/controllers/__init__.py +19 -6
  17. flyte/_internal/controllers/_local_controller.py +83 -8
  18. flyte/_internal/controllers/_trace.py +2 -1
  19. flyte/_internal/controllers/remote/__init__.py +27 -7
  20. flyte/_internal/controllers/remote/_action.py +7 -2
  21. flyte/_internal/controllers/remote/_client.py +5 -1
  22. flyte/_internal/controllers/remote/_controller.py +159 -26
  23. flyte/_internal/controllers/remote/_core.py +13 -5
  24. flyte/_internal/controllers/remote/_informer.py +4 -4
  25. flyte/_internal/controllers/remote/_service_protocol.py +6 -6
  26. flyte/_internal/imagebuild/docker_builder.py +12 -1
  27. flyte/_internal/imagebuild/image_builder.py +16 -11
  28. flyte/_internal/runtime/convert.py +164 -21
  29. flyte/_internal/runtime/entrypoints.py +1 -1
  30. flyte/_internal/runtime/io.py +3 -3
  31. flyte/_internal/runtime/task_serde.py +140 -20
  32. flyte/_internal/runtime/taskrunner.py +4 -3
  33. flyte/_internal/runtime/types_serde.py +1 -1
  34. flyte/_logging.py +12 -1
  35. flyte/_map.py +215 -0
  36. flyte/_pod.py +19 -0
  37. flyte/_protos/common/list_pb2.py +3 -3
  38. flyte/_protos/common/list_pb2.pyi +2 -0
  39. flyte/_protos/logs/dataplane/payload_pb2.py +28 -24
  40. flyte/_protos/logs/dataplane/payload_pb2.pyi +11 -2
  41. flyte/_protos/workflow/common_pb2.py +27 -0
  42. flyte/_protos/workflow/common_pb2.pyi +14 -0
  43. flyte/_protos/workflow/environment_pb2.py +29 -0
  44. flyte/_protos/workflow/environment_pb2.pyi +12 -0
  45. flyte/_protos/workflow/queue_service_pb2.py +40 -41
  46. flyte/_protos/workflow/queue_service_pb2.pyi +35 -30
  47. flyte/_protos/workflow/queue_service_pb2_grpc.py +15 -15
  48. flyte/_protos/workflow/run_definition_pb2.py +61 -61
  49. flyte/_protos/workflow/run_definition_pb2.pyi +8 -4
  50. flyte/_protos/workflow/run_service_pb2.py +20 -24
  51. flyte/_protos/workflow/run_service_pb2.pyi +2 -6
  52. flyte/_protos/workflow/state_service_pb2.py +36 -28
  53. flyte/_protos/workflow/state_service_pb2.pyi +19 -15
  54. flyte/_protos/workflow/state_service_pb2_grpc.py +28 -28
  55. flyte/_protos/workflow/task_definition_pb2.py +29 -22
  56. flyte/_protos/workflow/task_definition_pb2.pyi +21 -5
  57. flyte/_protos/workflow/task_service_pb2.py +27 -11
  58. flyte/_protos/workflow/task_service_pb2.pyi +29 -1
  59. flyte/_protos/workflow/task_service_pb2_grpc.py +34 -0
  60. flyte/_run.py +166 -95
  61. flyte/_task.py +110 -28
  62. flyte/_task_environment.py +55 -72
  63. flyte/_trace.py +6 -14
  64. flyte/_utils/__init__.py +6 -0
  65. flyte/_utils/async_cache.py +139 -0
  66. flyte/_utils/coro_management.py +0 -2
  67. flyte/_utils/helpers.py +45 -19
  68. flyte/_utils/org_discovery.py +57 -0
  69. flyte/_version.py +2 -2
  70. flyte/cli/__init__.py +3 -0
  71. flyte/cli/_abort.py +28 -0
  72. flyte/{_cli → cli}/_common.py +73 -23
  73. flyte/cli/_create.py +145 -0
  74. flyte/{_cli → cli}/_delete.py +4 -4
  75. flyte/{_cli → cli}/_deploy.py +26 -14
  76. flyte/cli/_gen.py +163 -0
  77. flyte/{_cli → cli}/_get.py +98 -23
  78. {union/_cli → flyte/cli}/_params.py +106 -147
  79. flyte/{_cli → cli}/_run.py +99 -20
  80. flyte/cli/main.py +166 -0
  81. flyte/config/__init__.py +3 -0
  82. flyte/config/_config.py +216 -0
  83. flyte/config/_internal.py +64 -0
  84. flyte/config/_reader.py +207 -0
  85. flyte/errors.py +29 -0
  86. flyte/extras/_container.py +33 -43
  87. flyte/io/__init__.py +17 -1
  88. flyte/io/_dir.py +2 -2
  89. flyte/io/_file.py +3 -4
  90. flyte/io/{structured_dataset → _structured_dataset}/basic_dfs.py +1 -1
  91. flyte/io/{structured_dataset → _structured_dataset}/structured_dataset.py +1 -1
  92. flyte/{_datastructures.py → models.py} +56 -7
  93. flyte/remote/__init__.py +2 -1
  94. flyte/remote/_client/_protocols.py +2 -0
  95. flyte/remote/_client/auth/_auth_utils.py +14 -0
  96. flyte/remote/_client/auth/_channel.py +34 -3
  97. flyte/remote/_client/auth/_token_client.py +3 -3
  98. flyte/remote/_client/controlplane.py +13 -13
  99. flyte/remote/_console.py +1 -1
  100. flyte/remote/_data.py +10 -6
  101. flyte/remote/_logs.py +89 -29
  102. flyte/remote/_project.py +8 -9
  103. flyte/remote/_run.py +228 -131
  104. flyte/remote/_secret.py +12 -12
  105. flyte/remote/_task.py +179 -15
  106. flyte/report/_report.py +4 -4
  107. flyte/storage/__init__.py +5 -0
  108. flyte/storage/_config.py +233 -0
  109. flyte/storage/_storage.py +23 -3
  110. flyte/syncify/__init__.py +56 -0
  111. flyte/syncify/_api.py +371 -0
  112. flyte/types/__init__.py +23 -0
  113. flyte/types/_interface.py +22 -7
  114. flyte/{io/pickle/transformer.py → types/_pickle.py} +2 -1
  115. flyte/types/_type_engine.py +95 -18
  116. flyte-0.2.0a0.dist-info/METADATA +249 -0
  117. flyte-0.2.0a0.dist-info/RECORD +218 -0
  118. {flyte-0.0.1b3.dist-info → flyte-0.2.0a0.dist-info}/entry_points.txt +1 -1
  119. flyte/_api_commons.py +0 -3
  120. flyte/_cli/__init__.py +0 -0
  121. flyte/_cli/_create.py +0 -42
  122. flyte/_cli/main.py +0 -72
  123. flyte/_internal/controllers/pbhash.py +0 -39
  124. flyte/io/_dataframe.py +0 -0
  125. flyte/io/pickle/__init__.py +0 -0
  126. flyte-0.0.1b3.dist-info/METADATA +0 -179
  127. flyte-0.0.1b3.dist-info/RECORD +0 -390
  128. union/__init__.py +0 -54
  129. union/_api_commons.py +0 -3
  130. union/_bin/__init__.py +0 -0
  131. union/_bin/runtime.py +0 -113
  132. union/_build.py +0 -25
  133. union/_cache/__init__.py +0 -12
  134. union/_cache/cache.py +0 -141
  135. union/_cache/defaults.py +0 -9
  136. union/_cache/policy_function_body.py +0 -42
  137. union/_cli/__init__.py +0 -0
  138. union/_cli/_common.py +0 -263
  139. union/_cli/_create.py +0 -40
  140. union/_cli/_delete.py +0 -23
  141. union/_cli/_deploy.py +0 -120
  142. union/_cli/_get.py +0 -162
  143. union/_cli/_run.py +0 -150
  144. union/_cli/main.py +0 -72
  145. union/_code_bundle/__init__.py +0 -8
  146. union/_code_bundle/_ignore.py +0 -113
  147. union/_code_bundle/_packaging.py +0 -187
  148. union/_code_bundle/_utils.py +0 -342
  149. union/_code_bundle/bundle.py +0 -176
  150. union/_context.py +0 -146
  151. union/_datastructures.py +0 -295
  152. union/_deploy.py +0 -185
  153. union/_doc.py +0 -29
  154. union/_docstring.py +0 -26
  155. union/_environment.py +0 -43
  156. union/_group.py +0 -31
  157. union/_hash.py +0 -23
  158. union/_image.py +0 -760
  159. union/_initialize.py +0 -585
  160. union/_interface.py +0 -84
  161. union/_internal/__init__.py +0 -3
  162. union/_internal/controllers/__init__.py +0 -77
  163. union/_internal/controllers/_local_controller.py +0 -77
  164. union/_internal/controllers/pbhash.py +0 -39
  165. union/_internal/controllers/remote/__init__.py +0 -40
  166. union/_internal/controllers/remote/_action.py +0 -131
  167. union/_internal/controllers/remote/_client.py +0 -43
  168. union/_internal/controllers/remote/_controller.py +0 -169
  169. union/_internal/controllers/remote/_core.py +0 -341
  170. union/_internal/controllers/remote/_informer.py +0 -260
  171. union/_internal/controllers/remote/_service_protocol.py +0 -44
  172. union/_internal/imagebuild/__init__.py +0 -11
  173. union/_internal/imagebuild/docker_builder.py +0 -416
  174. union/_internal/imagebuild/image_builder.py +0 -243
  175. union/_internal/imagebuild/remote_builder.py +0 -0
  176. union/_internal/resolvers/__init__.py +0 -0
  177. union/_internal/resolvers/_task_module.py +0 -31
  178. union/_internal/resolvers/common.py +0 -24
  179. union/_internal/resolvers/default.py +0 -27
  180. union/_internal/runtime/__init__.py +0 -0
  181. union/_internal/runtime/convert.py +0 -163
  182. union/_internal/runtime/entrypoints.py +0 -121
  183. union/_internal/runtime/io.py +0 -136
  184. union/_internal/runtime/resources_serde.py +0 -134
  185. union/_internal/runtime/task_serde.py +0 -202
  186. union/_internal/runtime/taskrunner.py +0 -179
  187. union/_internal/runtime/types_serde.py +0 -53
  188. union/_logging.py +0 -124
  189. union/_protos/__init__.py +0 -0
  190. union/_protos/common/authorization_pb2.py +0 -66
  191. union/_protos/common/authorization_pb2.pyi +0 -106
  192. union/_protos/common/identifier_pb2.py +0 -71
  193. union/_protos/common/identifier_pb2.pyi +0 -82
  194. union/_protos/common/identity_pb2.py +0 -48
  195. union/_protos/common/identity_pb2.pyi +0 -72
  196. union/_protos/common/identity_pb2_grpc.py +0 -4
  197. union/_protos/common/list_pb2.py +0 -36
  198. union/_protos/common/list_pb2.pyi +0 -69
  199. union/_protos/common/list_pb2_grpc.py +0 -4
  200. union/_protos/common/policy_pb2.py +0 -37
  201. union/_protos/common/policy_pb2.pyi +0 -27
  202. union/_protos/common/policy_pb2_grpc.py +0 -4
  203. union/_protos/common/role_pb2.py +0 -37
  204. union/_protos/common/role_pb2.pyi +0 -51
  205. union/_protos/common/role_pb2_grpc.py +0 -4
  206. union/_protos/common/runtime_version_pb2.py +0 -28
  207. union/_protos/common/runtime_version_pb2.pyi +0 -24
  208. union/_protos/common/runtime_version_pb2_grpc.py +0 -4
  209. union/_protos/logs/dataplane/payload_pb2.py +0 -96
  210. union/_protos/logs/dataplane/payload_pb2.pyi +0 -168
  211. union/_protos/logs/dataplane/payload_pb2_grpc.py +0 -4
  212. union/_protos/secret/definition_pb2.py +0 -49
  213. union/_protos/secret/definition_pb2.pyi +0 -93
  214. union/_protos/secret/definition_pb2_grpc.py +0 -4
  215. union/_protos/secret/payload_pb2.py +0 -62
  216. union/_protos/secret/payload_pb2.pyi +0 -94
  217. union/_protos/secret/payload_pb2_grpc.py +0 -4
  218. union/_protos/secret/secret_pb2.py +0 -38
  219. union/_protos/secret/secret_pb2.pyi +0 -6
  220. union/_protos/secret/secret_pb2_grpc.py +0 -198
  221. union/_protos/validate/validate/validate_pb2.py +0 -76
  222. union/_protos/workflow/node_execution_service_pb2.py +0 -26
  223. union/_protos/workflow/node_execution_service_pb2.pyi +0 -4
  224. union/_protos/workflow/node_execution_service_pb2_grpc.py +0 -32
  225. union/_protos/workflow/queue_service_pb2.py +0 -75
  226. union/_protos/workflow/queue_service_pb2.pyi +0 -103
  227. union/_protos/workflow/queue_service_pb2_grpc.py +0 -172
  228. union/_protos/workflow/run_definition_pb2.py +0 -100
  229. union/_protos/workflow/run_definition_pb2.pyi +0 -256
  230. union/_protos/workflow/run_definition_pb2_grpc.py +0 -4
  231. union/_protos/workflow/run_logs_service_pb2.py +0 -41
  232. union/_protos/workflow/run_logs_service_pb2.pyi +0 -28
  233. union/_protos/workflow/run_logs_service_pb2_grpc.py +0 -69
  234. union/_protos/workflow/run_service_pb2.py +0 -133
  235. union/_protos/workflow/run_service_pb2.pyi +0 -173
  236. union/_protos/workflow/run_service_pb2_grpc.py +0 -412
  237. union/_protos/workflow/state_service_pb2.py +0 -58
  238. union/_protos/workflow/state_service_pb2.pyi +0 -69
  239. union/_protos/workflow/state_service_pb2_grpc.py +0 -138
  240. union/_protos/workflow/task_definition_pb2.py +0 -72
  241. union/_protos/workflow/task_definition_pb2.pyi +0 -65
  242. union/_protos/workflow/task_definition_pb2_grpc.py +0 -4
  243. union/_protos/workflow/task_service_pb2.py +0 -44
  244. union/_protos/workflow/task_service_pb2.pyi +0 -31
  245. union/_protos/workflow/task_service_pb2_grpc.py +0 -104
  246. union/_resources.py +0 -226
  247. union/_retry.py +0 -32
  248. union/_reusable_environment.py +0 -25
  249. union/_run.py +0 -374
  250. union/_secret.py +0 -61
  251. union/_task.py +0 -354
  252. union/_task_environment.py +0 -186
  253. union/_timeout.py +0 -47
  254. union/_tools.py +0 -27
  255. union/_utils/__init__.py +0 -11
  256. union/_utils/asyn.py +0 -119
  257. union/_utils/file_handling.py +0 -71
  258. union/_utils/helpers.py +0 -46
  259. union/_utils/lazy_module.py +0 -54
  260. union/_utils/uv_script_parser.py +0 -49
  261. union/_version.py +0 -21
  262. union/connectors/__init__.py +0 -0
  263. union/errors.py +0 -128
  264. union/extras/__init__.py +0 -5
  265. union/extras/_container.py +0 -263
  266. union/io/__init__.py +0 -11
  267. union/io/_dataframe.py +0 -0
  268. union/io/_dir.py +0 -425
  269. union/io/_file.py +0 -418
  270. union/io/pickle/__init__.py +0 -0
  271. union/io/pickle/transformer.py +0 -117
  272. union/io/structured_dataset/__init__.py +0 -122
  273. union/io/structured_dataset/basic_dfs.py +0 -219
  274. union/io/structured_dataset/structured_dataset.py +0 -1057
  275. union/py.typed +0 -0
  276. union/remote/__init__.py +0 -23
  277. union/remote/_client/__init__.py +0 -0
  278. union/remote/_client/_protocols.py +0 -129
  279. union/remote/_client/auth/__init__.py +0 -12
  280. union/remote/_client/auth/_authenticators/__init__.py +0 -0
  281. union/remote/_client/auth/_authenticators/base.py +0 -391
  282. union/remote/_client/auth/_authenticators/client_credentials.py +0 -73
  283. union/remote/_client/auth/_authenticators/device_code.py +0 -120
  284. union/remote/_client/auth/_authenticators/external_command.py +0 -77
  285. union/remote/_client/auth/_authenticators/factory.py +0 -200
  286. union/remote/_client/auth/_authenticators/pkce.py +0 -515
  287. union/remote/_client/auth/_channel.py +0 -184
  288. union/remote/_client/auth/_client_config.py +0 -83
  289. union/remote/_client/auth/_default_html.py +0 -32
  290. union/remote/_client/auth/_grpc_utils/__init__.py +0 -0
  291. union/remote/_client/auth/_grpc_utils/auth_interceptor.py +0 -204
  292. union/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +0 -144
  293. union/remote/_client/auth/_keyring.py +0 -154
  294. union/remote/_client/auth/_token_client.py +0 -258
  295. union/remote/_client/auth/errors.py +0 -16
  296. union/remote/_client/controlplane.py +0 -86
  297. union/remote/_data.py +0 -149
  298. union/remote/_logs.py +0 -74
  299. union/remote/_project.py +0 -86
  300. union/remote/_run.py +0 -820
  301. union/remote/_secret.py +0 -132
  302. union/remote/_task.py +0 -193
  303. union/report/__init__.py +0 -3
  304. union/report/_report.py +0 -178
  305. union/report/_template.html +0 -124
  306. union/storage/__init__.py +0 -24
  307. union/storage/_remote_fs.py +0 -34
  308. union/storage/_storage.py +0 -247
  309. union/storage/_utils.py +0 -5
  310. union/types/__init__.py +0 -11
  311. union/types/_renderer.py +0 -162
  312. union/types/_string_literals.py +0 -120
  313. union/types/_type_engine.py +0 -2131
  314. union/types/_utils.py +0 -80
  315. /union/_protos/common/authorization_pb2_grpc.py → /flyte/_protos/workflow/common_pb2_grpc.py +0 -0
  316. /union/_protos/common/identifier_pb2_grpc.py → /flyte/_protos/workflow/environment_pb2_grpc.py +0 -0
  317. /flyte/io/{structured_dataset → _structured_dataset}/__init__.py +0 -0
  318. {flyte-0.0.1b3.dist-info → flyte-0.2.0a0.dist-info}/WHEEL +0 -0
  319. {flyte-0.0.1b3.dist-info → flyte-0.2.0a0.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,11 @@
1
+ from flyte._protos.common import identifier_pb2 as _identifier_pb2
2
+ from flyte._protos.common import list_pb2 as _list_pb2
1
3
  from flyte._protos.validate.validate import validate_pb2 as _validate_pb2
2
4
  from flyte._protos.workflow import task_definition_pb2 as _task_definition_pb2
5
+ from google.protobuf.internal import containers as _containers
3
6
  from google.protobuf import descriptor as _descriptor
4
7
  from google.protobuf import message as _message
5
- from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union
8
+ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
6
9
 
7
10
  DESCRIPTOR: _descriptor.FileDescriptor
8
11
 
@@ -29,3 +32,28 @@ class GetTaskDetailsResponse(_message.Message):
29
32
  DETAILS_FIELD_NUMBER: _ClassVar[int]
30
33
  details: _task_definition_pb2.TaskDetails
31
34
  def __init__(self, details: _Optional[_Union[_task_definition_pb2.TaskDetails, _Mapping]] = ...) -> None: ...
35
+
36
+ class ListTasksRequest(_message.Message):
37
+ __slots__ = ["request", "org", "project_id", "known_filters"]
38
+ class KnownFilter(_message.Message):
39
+ __slots__ = ["deployed_by"]
40
+ DEPLOYED_BY_FIELD_NUMBER: _ClassVar[int]
41
+ deployed_by: str
42
+ def __init__(self, deployed_by: _Optional[str] = ...) -> None: ...
43
+ REQUEST_FIELD_NUMBER: _ClassVar[int]
44
+ ORG_FIELD_NUMBER: _ClassVar[int]
45
+ PROJECT_ID_FIELD_NUMBER: _ClassVar[int]
46
+ KNOWN_FILTERS_FIELD_NUMBER: _ClassVar[int]
47
+ request: _list_pb2.ListRequest
48
+ org: str
49
+ project_id: _identifier_pb2.ProjectIdentifier
50
+ known_filters: _containers.RepeatedCompositeFieldContainer[ListTasksRequest.KnownFilter]
51
+ def __init__(self, request: _Optional[_Union[_list_pb2.ListRequest, _Mapping]] = ..., org: _Optional[str] = ..., project_id: _Optional[_Union[_identifier_pb2.ProjectIdentifier, _Mapping]] = ..., known_filters: _Optional[_Iterable[_Union[ListTasksRequest.KnownFilter, _Mapping]]] = ...) -> None: ...
52
+
53
+ class ListTasksResponse(_message.Message):
54
+ __slots__ = ["tasks", "token"]
55
+ TASKS_FIELD_NUMBER: _ClassVar[int]
56
+ TOKEN_FIELD_NUMBER: _ClassVar[int]
57
+ tasks: _containers.RepeatedCompositeFieldContainer[_task_definition_pb2.Task]
58
+ token: str
59
+ def __init__(self, tasks: _Optional[_Iterable[_Union[_task_definition_pb2.Task, _Mapping]]] = ..., token: _Optional[str] = ...) -> None: ...
@@ -25,6 +25,11 @@ class TaskServiceStub(object):
25
25
  request_serializer=workflow_dot_task__service__pb2.GetTaskDetailsRequest.SerializeToString,
26
26
  response_deserializer=workflow_dot_task__service__pb2.GetTaskDetailsResponse.FromString,
27
27
  )
28
+ self.ListTasks = channel.unary_unary(
29
+ '/cloudidl.workflow.TaskService/ListTasks',
30
+ request_serializer=workflow_dot_task__service__pb2.ListTasksRequest.SerializeToString,
31
+ response_deserializer=workflow_dot_task__service__pb2.ListTasksResponse.FromString,
32
+ )
28
33
 
29
34
 
30
35
  class TaskServiceServicer(object):
@@ -45,6 +50,13 @@ class TaskServiceServicer(object):
45
50
  context.set_details('Method not implemented!')
46
51
  raise NotImplementedError('Method not implemented!')
47
52
 
53
+ def ListTasks(self, request, context):
54
+ """Lists tasks, one per task name, returning the latest version and who it was deployed by.
55
+ """
56
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
57
+ context.set_details('Method not implemented!')
58
+ raise NotImplementedError('Method not implemented!')
59
+
48
60
 
49
61
  def add_TaskServiceServicer_to_server(servicer, server):
50
62
  rpc_method_handlers = {
@@ -58,6 +70,11 @@ def add_TaskServiceServicer_to_server(servicer, server):
58
70
  request_deserializer=workflow_dot_task__service__pb2.GetTaskDetailsRequest.FromString,
59
71
  response_serializer=workflow_dot_task__service__pb2.GetTaskDetailsResponse.SerializeToString,
60
72
  ),
73
+ 'ListTasks': grpc.unary_unary_rpc_method_handler(
74
+ servicer.ListTasks,
75
+ request_deserializer=workflow_dot_task__service__pb2.ListTasksRequest.FromString,
76
+ response_serializer=workflow_dot_task__service__pb2.ListTasksResponse.SerializeToString,
77
+ ),
61
78
  }
62
79
  generic_handler = grpc.method_handlers_generic_handler(
63
80
  'cloudidl.workflow.TaskService', rpc_method_handlers)
@@ -102,3 +119,20 @@ class TaskService(object):
102
119
  workflow_dot_task__service__pb2.GetTaskDetailsResponse.FromString,
103
120
  options, channel_credentials,
104
121
  insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
122
+
123
+ @staticmethod
124
+ def ListTasks(request,
125
+ target,
126
+ options=(),
127
+ channel_credentials=None,
128
+ call_credentials=None,
129
+ insecure=False,
130
+ compression=None,
131
+ wait_for_ready=None,
132
+ timeout=None,
133
+ metadata=None):
134
+ return grpc.experimental.unary_unary(request, target, '/cloudidl.workflow.TaskService/ListTasks',
135
+ workflow_dot_task__service__pb2.ListTasksRequest.SerializeToString,
136
+ workflow_dot_task__service__pb2.ListTasksResponse.FromString,
137
+ options, channel_credentials,
138
+ insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
flyte/_run.py CHANGED
@@ -1,20 +1,18 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import asyncio
3
4
  import pathlib
4
5
  import uuid
5
6
  from typing import TYPE_CHECKING, Any, Literal, Optional, Tuple, Union, cast
6
7
 
7
- import flyte
8
- import flyte.report
9
- from flyte import S3
8
+ import flyte.errors
9
+ from flyte.errors import InitializationError
10
+ from flyte.models import ActionID, Checkpoints, CodeBundle, RawDataPath, SerializationContext, TaskContext
11
+ from flyte.syncify import syncify
10
12
 
11
- from ._api_commons import syncer
12
13
  from ._context import contextual_run, internal_ctx
13
- from ._datastructures import ActionID, Checkpoints, RawDataPath, SerializationContext, TaskContext
14
14
  from ._environment import Environment
15
15
  from ._initialize import (
16
- ABFS,
17
- GCS,
18
16
  _get_init_config,
19
17
  get_client,
20
18
  get_common_config,
@@ -22,24 +20,35 @@ from ._initialize import (
22
20
  requires_initialization,
23
21
  requires_storage,
24
22
  )
25
- from ._internal import create_controller
26
- from ._internal.runtime.io import _CHECKPOINT_FILE_NAME
27
- from ._internal.runtime.taskrunner import run_task
28
23
  from ._logging import logger
29
- from ._protos.common import identifier_pb2
30
24
  from ._task import P, R, TaskTemplate
31
25
  from ._tools import ipython_check
32
- from .errors import InitializationError
33
26
 
34
27
  if TYPE_CHECKING:
35
28
  from flyte.remote import Run
29
+ from flyte.remote._task import LazyEntity
36
30
 
37
31
  from ._code_bundle import CopyFiles
38
32
 
39
33
  Mode = Literal["local", "remote", "hybrid"]
40
34
 
41
35
 
42
- @syncer.wrap
36
+ async def _get_code_bundle_for_run(name: str) -> CodeBundle | None:
37
+ """
38
+ Get the code bundle for the run with the given name.
39
+ This is used to get the code bundle for the run when running in hybrid mode.
40
+ """
41
+ from flyte._internal.runtime.task_serde import extract_code_bundle
42
+ from flyte.remote import Run
43
+
44
+ run = await Run.get.aio(name=name)
45
+ if run:
46
+ run_details = await run.details()
47
+ spec = run_details.action_details.pb2.resolved_task_spec
48
+ return extract_code_bundle(spec)
49
+ return None
50
+
51
+
43
52
  class _Runner:
44
53
  def __init__(
45
54
  self,
@@ -54,13 +63,14 @@ class _Runner:
54
63
  raw_data_path: str | None = None,
55
64
  metadata_path: str | None = None,
56
65
  run_base_dir: str | None = None,
66
+ overwrite_cache: bool = False,
57
67
  ):
58
68
  init_config = _get_init_config()
59
69
  client = init_config.client if init_config else None
60
70
  if not force_mode and client is not None:
61
71
  force_mode = "remote"
62
72
  force_mode = force_mode or "local"
63
- logger.debug(f"Effective run mode: {force_mode}, client configured: {client is not None}")
73
+ logger.debug(f"Effective run mode: `{force_mode}`, client configured: `{client is not None}`")
64
74
  self._mode = force_mode
65
75
  self._name = name
66
76
  self._service_account = service_account
@@ -72,50 +82,65 @@ class _Runner:
72
82
  self._raw_data_path = raw_data_path
73
83
  self._metadata_path = metadata_path or "/tmp"
74
84
  self._run_base_dir = run_base_dir or "/tmp/base"
85
+ self._overwrite_cache = overwrite_cache
75
86
 
76
87
  @requires_initialization
77
- async def _run_remote(self, obj: TaskTemplate[P, R], *args: P.args, **kwargs: P.kwargs) -> Run:
88
+ async def _run_remote(self, obj: TaskTemplate[P, R] | LazyEntity, *args: P.args, **kwargs: P.kwargs) -> Run:
89
+ import grpc
90
+
78
91
  from flyte.remote import Run
92
+ from flyte.remote._task import LazyEntity
79
93
 
80
94
  from ._code_bundle import build_code_bundle, build_pkl_bundle
81
95
  from ._deploy import build_images, plan_deploy
82
96
  from ._internal.runtime.convert import convert_from_native_to_inputs
83
97
  from ._internal.runtime.task_serde import translate_task_to_wire
98
+ from ._protos.common import identifier_pb2
84
99
  from ._protos.workflow import run_definition_pb2, run_service_pb2
85
100
 
86
101
  cfg = get_common_config()
87
102
 
88
- if obj.parent_env is None:
89
- raise ValueError("Task is not attached to an environment. Please attach the task to an environment.")
103
+ if isinstance(obj, LazyEntity):
104
+ task = await obj.fetch.aio()
105
+ task_spec = task.pb2.spec
106
+ inputs = await convert_from_native_to_inputs(task.interface, *args, **kwargs)
107
+ version = task.pb2.task_id.version
108
+ code_bundle = None
109
+ else:
110
+ if obj.parent_env is None:
111
+ raise ValueError("Task is not attached to an environment. Please attach the task to an environment")
90
112
 
91
- deploy_plan = plan_deploy(cast(Environment, obj.parent_env()))
92
- image_cache = await build_images(deploy_plan)
113
+ deploy_plan = plan_deploy(cast(Environment, obj.parent_env()))
114
+ image_cache = await build_images(deploy_plan)
93
115
 
94
- if self._interactive_mode:
95
- code_bundle = await build_pkl_bundle(
96
- obj, upload_to_controlplane=not self._dry_run, copy_bundle_to=self._copy_bundle_to
97
- )
98
- else:
99
- if self._copy_files != "none":
100
- code_bundle = await build_code_bundle(
101
- from_dir=cfg.root_dir, dryrun=self._dry_run, copy_bundle_to=self._copy_bundle_to
116
+ if self._interactive_mode:
117
+ code_bundle = await build_pkl_bundle(
118
+ obj, upload_to_controlplane=not self._dry_run, copy_bundle_to=self._copy_bundle_to
102
119
  )
103
120
  else:
104
- code_bundle = None
121
+ if self._copy_files != "none":
122
+ code_bundle = await build_code_bundle(
123
+ from_dir=cfg.root_dir,
124
+ dryrun=self._dry_run,
125
+ copy_bundle_to=self._copy_bundle_to,
126
+ copy_style=self._copy_files,
127
+ )
128
+ else:
129
+ code_bundle = None
105
130
 
106
- version = self._version or (
107
- code_bundle.computed_version if code_bundle and code_bundle.computed_version else None
108
- )
109
- if not version:
110
- raise ValueError("Version is required when running a task")
111
- s_ctx = SerializationContext(
112
- code_bundle=code_bundle,
113
- version=version,
114
- image_cache=image_cache,
115
- root_dir=cfg.root_dir,
116
- )
117
- task_spec = translate_task_to_wire(obj, s_ctx)
118
- inputs = await convert_from_native_to_inputs(obj.native_interface, *args, **kwargs)
131
+ version = self._version or (
132
+ code_bundle.computed_version if code_bundle and code_bundle.computed_version else None
133
+ )
134
+ if not version:
135
+ raise ValueError("Version is required when running a task")
136
+ s_ctx = SerializationContext(
137
+ code_bundle=code_bundle,
138
+ version=version,
139
+ image_cache=image_cache,
140
+ root_dir=cfg.root_dir,
141
+ )
142
+ task_spec = translate_task_to_wire(obj, s_ctx)
143
+ inputs = await convert_from_native_to_inputs(obj.native_interface, *args, **kwargs)
119
144
 
120
145
  if not self._dry_run:
121
146
  if get_client() is None:
@@ -152,15 +177,38 @@ class _Runner:
152
177
  if task_spec.task_template.id.version == "":
153
178
  task_spec.task_template.id.version = version
154
179
 
155
- resp = await get_client().run_service.CreateRun(
156
- run_service_pb2.CreateRunRequest(
157
- run_id=run_id,
158
- project_id=project_id,
159
- task_spec=task_spec,
160
- inputs=inputs.proto_inputs,
161
- ),
162
- )
163
- return Run(pb2=resp.run)
180
+ try:
181
+ resp = await get_client().run_service.CreateRun(
182
+ run_service_pb2.CreateRunRequest(
183
+ run_id=run_id,
184
+ project_id=project_id,
185
+ task_spec=task_spec,
186
+ inputs=inputs.proto_inputs,
187
+ run_spec=run_definition_pb2.RunSpec(
188
+ overwrite_cache=self._overwrite_cache,
189
+ ),
190
+ ),
191
+ )
192
+ return Run(pb2=resp.run)
193
+ except grpc.aio.AioRpcError as e:
194
+ if e.code() == grpc.StatusCode.UNAVAILABLE:
195
+ raise flyte.errors.RuntimeSystemError(
196
+ "SystemUnavailableError",
197
+ "Flyte system is currently unavailable. check your configuration, or the service status.",
198
+ ) from e
199
+ elif e.code() == grpc.StatusCode.INVALID_ARGUMENT:
200
+ raise flyte.errors.RuntimeUserError("InvalidArgumentError", e.details())
201
+ elif e.code() == grpc.StatusCode.ALREADY_EXISTS:
202
+ # TODO maybe this should be a pass and return existing run?
203
+ raise flyte.errors.RuntimeUserError(
204
+ "RunAlreadyExistsError",
205
+ f"A run with the name '{self._name}' already exists. Please choose a different name.",
206
+ )
207
+ else:
208
+ raise flyte.errors.RuntimeSystemError(
209
+ "RunCreationError",
210
+ f"Failed to create run: {e.details()}",
211
+ ) from e
164
212
 
165
213
  class DryRun(Run):
166
214
  def __init__(self, _task_spec, _inputs, _code_bundle):
@@ -187,9 +235,14 @@ class _Runner:
187
235
  run in the cluster remotely. This is currently only used for testing,
188
236
  over the longer term we will productize this.
189
237
  """
238
+ import flyte.report
190
239
  from flyte._code_bundle import build_code_bundle, build_pkl_bundle
191
- from flyte._datastructures import RawDataPath
192
240
  from flyte._deploy import build_images, plan_deploy
241
+ from flyte.models import RawDataPath
242
+ from flyte.storage import ABFS, GCS, S3
243
+
244
+ from ._internal import create_controller
245
+ from ._internal.runtime.taskrunner import run_task
193
246
 
194
247
  cfg = get_common_config()
195
248
 
@@ -199,17 +252,26 @@ class _Runner:
199
252
  deploy_plan = plan_deploy(cast(Environment, obj.parent_env()))
200
253
  image_cache = await build_images(deploy_plan)
201
254
 
202
- if self._interactive_mode:
203
- code_bundle = await build_pkl_bundle(
204
- obj, upload_to_controlplane=not self._dry_run, copy_bundle_to=self._copy_bundle_to
205
- )
206
- else:
207
- if self._copy_files != "none":
208
- code_bundle = await build_code_bundle(
209
- from_dir=cfg.root_dir, dryrun=self._dry_run, copy_bundle_to=self._copy_bundle_to
255
+ code_bundle = None
256
+ if self._name is not None:
257
+ # Check if remote run service has this run name already and if exists, then extract the code bundle from it.
258
+ code_bundle = await _get_code_bundle_for_run(name=self._name)
259
+
260
+ if not code_bundle:
261
+ if self._interactive_mode:
262
+ code_bundle = await build_pkl_bundle(
263
+ obj, upload_to_controlplane=not self._dry_run, copy_bundle_to=self._copy_bundle_to
210
264
  )
211
265
  else:
212
- code_bundle = None
266
+ if self._copy_files != "none":
267
+ code_bundle = await build_code_bundle(
268
+ from_dir=cfg.root_dir,
269
+ dryrun=self._dry_run,
270
+ copy_bundle_to=self._copy_bundle_to,
271
+ copy_style=self._copy_files,
272
+ )
273
+ else:
274
+ code_bundle = None
213
275
 
214
276
  version = self._version or (
215
277
  code_bundle.computed_version if code_bundle and code_bundle.computed_version else None
@@ -217,14 +279,14 @@ class _Runner:
217
279
  if not version:
218
280
  raise ValueError("Version is required when running a task")
219
281
 
220
- project = cfg.project or "testproject"
221
- domain = cfg.domain or "development"
222
- org = cfg.org or "testorg"
282
+ project = cfg.project
283
+ domain = cfg.domain
284
+ org = cfg.org
223
285
  action_name = "a0"
224
286
  run_name = self._name
225
287
  random_id = str(uuid.uuid4())[:6]
226
288
 
227
- controller = create_controller(ct="remote", endpoint="localhost:8090", insecure=True)
289
+ controller = create_controller("remote", endpoint="localhost:8090", insecure=True)
228
290
  action = ActionID(name=action_name, run_name=run_name, project=project, domain=domain, org=org)
229
291
 
230
292
  inputs = obj.native_interface.convert_to_kwargs(*args, **kwargs)
@@ -242,7 +304,7 @@ class _Runner:
242
304
  output_path = self._run_base_dir
243
305
  raw_data_path = f"{output_path}/rd/{random_id}"
244
306
  raw_data_path_obj = RawDataPath(path=raw_data_path)
245
- checkpoint_path = f"{raw_data_path}/{_CHECKPOINT_FILE_NAME}"
307
+ checkpoint_path = f"{raw_data_path}/checkpoint"
246
308
  prev_checkpoint = f"{raw_data_path}/prev_checkpoint"
247
309
  checkpoints = Checkpoints(checkpoint_path, prev_checkpoint)
248
310
 
@@ -253,7 +315,7 @@ class _Runner:
253
315
  checkpoints=checkpoints,
254
316
  code_bundle=code_bundle,
255
317
  output_path=output_path,
256
- version=version,
318
+ version=version if version else "na",
257
319
  raw_data_path=raw_data_path_obj,
258
320
  compiled_image_cache=image_cache,
259
321
  run_base_dir=self._run_base_dir,
@@ -269,43 +331,44 @@ class _Runner:
269
331
 
270
332
  async def _run_local(self, obj: TaskTemplate[P, R], *args: P.args, **kwargs: P.kwargs) -> R:
271
333
  from flyte._internal.controllers import create_controller
272
- from flyte._internal.runtime.convert import (
273
- convert_error_to_native,
274
- convert_from_native_to_inputs,
275
- convert_outputs_to_native,
276
- )
277
- from flyte._internal.runtime.entrypoints import direct_dispatch
334
+ from flyte._internal.controllers._local_controller import LocalController
335
+ from flyte.report import Report
278
336
 
279
- controller = create_controller(ct="local")
337
+ controller = cast(LocalController, create_controller("local"))
280
338
 
281
- inputs = await convert_from_native_to_inputs(obj.native_interface, *args, **kwargs)
282
339
  if self._name is None:
283
340
  action = ActionID.create_random()
284
341
  else:
285
342
  action = ActionID(name=self._name)
286
- out, err = await direct_dispatch(
287
- obj,
343
+
344
+ ctx = internal_ctx()
345
+ tctx = TaskContext(
288
346
  action=action,
289
- raw_data_path=internal_ctx().raw_data,
290
- version="na",
291
- controller=controller,
292
- inputs=inputs,
293
- output_path=self._metadata_path,
294
- run_base_dir=self._metadata_path,
295
347
  checkpoints=Checkpoints(
296
348
  prev_checkpoint_path=internal_ctx().raw_data.path, checkpoint_path=internal_ctx().raw_data.path
297
349
  ),
298
- ) # type: ignore
299
- if err:
300
- native_err = convert_error_to_native(err)
301
- if native_err:
302
- raise native_err
303
- if obj.native_interface.outputs and len(obj.native_interface.outputs) > 0:
304
- if out is not None:
305
- return cast(R, await convert_outputs_to_native(obj.native_interface, out))
306
- return cast(R, None)
307
-
308
- async def run(self, task: TaskTemplate[P, Union[R, Run]], *args: P.args, **kwargs: P.kwargs) -> Union[R, Run]:
350
+ code_bundle=None,
351
+ output_path=self._metadata_path,
352
+ run_base_dir=self._metadata_path,
353
+ version="na",
354
+ raw_data_path=internal_ctx().raw_data,
355
+ compiled_image_cache=None,
356
+ report=Report(name=action.name),
357
+ mode="local",
358
+ )
359
+ with ctx.replace_task_context(tctx):
360
+ # make the local version always runs on a different thread, returns a wrapped future.
361
+ if obj._call_as_synchronous:
362
+ fut = controller.submit_sync(obj, *args, **kwargs)
363
+ awaitable = asyncio.wrap_future(fut)
364
+ return await awaitable
365
+ else:
366
+ return await controller.submit(obj, *args, **kwargs)
367
+
368
+ @syncify
369
+ async def run(
370
+ self, task: TaskTemplate[P, Union[R, Run]] | LazyEntity, *args: P.args, **kwargs: P.kwargs
371
+ ) -> Union[R, Run]:
309
372
  """
310
373
  Run an async `@env.task` or `TaskTemplate` instance. The existing async context will be used.
311
374
 
@@ -327,13 +390,18 @@ class _Runner:
327
390
  :param kwargs: Keyword arguments to pass to the Task
328
391
  :return: Run instance or the result of the task
329
392
  """
393
+ from flyte.remote._task import LazyEntity
394
+
395
+ if isinstance(task, LazyEntity) and self._mode != "remote":
396
+ raise ValueError("Remote task can only be run in remote mode.")
330
397
  if self._mode == "remote":
331
398
  return await self._run_remote(task, *args, **kwargs)
399
+ task = cast(TaskTemplate, task)
332
400
  if self._mode == "hybrid":
333
401
  return await self._run_hybrid(task, *args, **kwargs)
334
402
 
335
403
  # TODO We could use this for remote as well and users could simply pass flyte:// or s3:// or file://
336
- async with internal_ctx().new_raw_data_path(
404
+ with internal_ctx().new_raw_data_path(
337
405
  raw_data_path=RawDataPath.from_local_folder(local_folder=self._raw_data_path)
338
406
  ):
339
407
  return await self._run_local(task, *args, **kwargs)
@@ -351,6 +419,7 @@ def with_runcontext(
351
419
  interactive_mode: bool | None = None,
352
420
  raw_data_path: str | None = None,
353
421
  run_base_dir: str | None = None,
422
+ overwrite_cache: bool = False,
354
423
  ) -> _Runner:
355
424
  """
356
425
  Launch a new run with the given parameters as the context.
@@ -380,6 +449,8 @@ def with_runcontext(
380
449
  interactive mode, while scripts are not. This is used to determine how the code bundle is created.
381
450
  :param raw_data_path: Use this path to store the raw data for the run. Currently only supported for local runs,
382
451
  and can be used to store raw data in specific locations. TODO coming soon for remote runs as well.
452
+ :param run_base_dir: Optional The base directory to use for the run. This is used to store the metadata for the run,
453
+ that is passed between tasks.
383
454
  :return: runner
384
455
  """
385
456
  if mode == "hybrid" and not name and not run_base_dir:
@@ -398,7 +469,7 @@ def with_runcontext(
398
469
  )
399
470
 
400
471
 
401
- @syncer.wrap
472
+ @syncify
402
473
  async def run(task: TaskTemplate[P, R], *args: P.args, **kwargs: P.kwargs) -> Union[R, Run]:
403
474
  """
404
475
  Run a task with the given parameters