flyte 2.0.0b32__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 (204) hide show
  1. flyte/__init__.py +108 -0
  2. flyte/_bin/__init__.py +0 -0
  3. flyte/_bin/debug.py +38 -0
  4. flyte/_bin/runtime.py +195 -0
  5. flyte/_bin/serve.py +178 -0
  6. flyte/_build.py +26 -0
  7. flyte/_cache/__init__.py +12 -0
  8. flyte/_cache/cache.py +147 -0
  9. flyte/_cache/defaults.py +9 -0
  10. flyte/_cache/local_cache.py +216 -0
  11. flyte/_cache/policy_function_body.py +42 -0
  12. flyte/_code_bundle/__init__.py +8 -0
  13. flyte/_code_bundle/_ignore.py +121 -0
  14. flyte/_code_bundle/_packaging.py +218 -0
  15. flyte/_code_bundle/_utils.py +347 -0
  16. flyte/_code_bundle/bundle.py +266 -0
  17. flyte/_constants.py +1 -0
  18. flyte/_context.py +155 -0
  19. flyte/_custom_context.py +73 -0
  20. flyte/_debug/__init__.py +0 -0
  21. flyte/_debug/constants.py +38 -0
  22. flyte/_debug/utils.py +17 -0
  23. flyte/_debug/vscode.py +307 -0
  24. flyte/_deploy.py +408 -0
  25. flyte/_deployer.py +109 -0
  26. flyte/_doc.py +29 -0
  27. flyte/_docstring.py +32 -0
  28. flyte/_environment.py +122 -0
  29. flyte/_excepthook.py +37 -0
  30. flyte/_group.py +32 -0
  31. flyte/_hash.py +8 -0
  32. flyte/_image.py +1055 -0
  33. flyte/_initialize.py +628 -0
  34. flyte/_interface.py +119 -0
  35. flyte/_internal/__init__.py +3 -0
  36. flyte/_internal/controllers/__init__.py +129 -0
  37. flyte/_internal/controllers/_local_controller.py +239 -0
  38. flyte/_internal/controllers/_trace.py +48 -0
  39. flyte/_internal/controllers/remote/__init__.py +58 -0
  40. flyte/_internal/controllers/remote/_action.py +211 -0
  41. flyte/_internal/controllers/remote/_client.py +47 -0
  42. flyte/_internal/controllers/remote/_controller.py +583 -0
  43. flyte/_internal/controllers/remote/_core.py +465 -0
  44. flyte/_internal/controllers/remote/_informer.py +381 -0
  45. flyte/_internal/controllers/remote/_service_protocol.py +50 -0
  46. flyte/_internal/imagebuild/__init__.py +3 -0
  47. flyte/_internal/imagebuild/docker_builder.py +706 -0
  48. flyte/_internal/imagebuild/image_builder.py +277 -0
  49. flyte/_internal/imagebuild/remote_builder.py +386 -0
  50. flyte/_internal/imagebuild/utils.py +78 -0
  51. flyte/_internal/resolvers/__init__.py +0 -0
  52. flyte/_internal/resolvers/_task_module.py +21 -0
  53. flyte/_internal/resolvers/common.py +31 -0
  54. flyte/_internal/resolvers/default.py +28 -0
  55. flyte/_internal/runtime/__init__.py +0 -0
  56. flyte/_internal/runtime/convert.py +486 -0
  57. flyte/_internal/runtime/entrypoints.py +204 -0
  58. flyte/_internal/runtime/io.py +188 -0
  59. flyte/_internal/runtime/resources_serde.py +152 -0
  60. flyte/_internal/runtime/reuse.py +125 -0
  61. flyte/_internal/runtime/rusty.py +193 -0
  62. flyte/_internal/runtime/task_serde.py +362 -0
  63. flyte/_internal/runtime/taskrunner.py +209 -0
  64. flyte/_internal/runtime/trigger_serde.py +160 -0
  65. flyte/_internal/runtime/types_serde.py +54 -0
  66. flyte/_keyring/__init__.py +0 -0
  67. flyte/_keyring/file.py +115 -0
  68. flyte/_logging.py +300 -0
  69. flyte/_map.py +312 -0
  70. flyte/_module.py +72 -0
  71. flyte/_pod.py +30 -0
  72. flyte/_resources.py +473 -0
  73. flyte/_retry.py +32 -0
  74. flyte/_reusable_environment.py +102 -0
  75. flyte/_run.py +724 -0
  76. flyte/_secret.py +96 -0
  77. flyte/_task.py +550 -0
  78. flyte/_task_environment.py +316 -0
  79. flyte/_task_plugins.py +47 -0
  80. flyte/_timeout.py +47 -0
  81. flyte/_tools.py +27 -0
  82. flyte/_trace.py +119 -0
  83. flyte/_trigger.py +1000 -0
  84. flyte/_utils/__init__.py +30 -0
  85. flyte/_utils/asyn.py +121 -0
  86. flyte/_utils/async_cache.py +139 -0
  87. flyte/_utils/coro_management.py +27 -0
  88. flyte/_utils/docker_credentials.py +173 -0
  89. flyte/_utils/file_handling.py +72 -0
  90. flyte/_utils/helpers.py +134 -0
  91. flyte/_utils/lazy_module.py +54 -0
  92. flyte/_utils/module_loader.py +104 -0
  93. flyte/_utils/org_discovery.py +57 -0
  94. flyte/_utils/uv_script_parser.py +49 -0
  95. flyte/_version.py +34 -0
  96. flyte/app/__init__.py +22 -0
  97. flyte/app/_app_environment.py +157 -0
  98. flyte/app/_deploy.py +125 -0
  99. flyte/app/_input.py +160 -0
  100. flyte/app/_runtime/__init__.py +3 -0
  101. flyte/app/_runtime/app_serde.py +347 -0
  102. flyte/app/_types.py +101 -0
  103. flyte/app/extras/__init__.py +3 -0
  104. flyte/app/extras/_fastapi.py +151 -0
  105. flyte/cli/__init__.py +12 -0
  106. flyte/cli/_abort.py +28 -0
  107. flyte/cli/_build.py +114 -0
  108. flyte/cli/_common.py +468 -0
  109. flyte/cli/_create.py +371 -0
  110. flyte/cli/_delete.py +45 -0
  111. flyte/cli/_deploy.py +293 -0
  112. flyte/cli/_gen.py +176 -0
  113. flyte/cli/_get.py +370 -0
  114. flyte/cli/_option.py +33 -0
  115. flyte/cli/_params.py +554 -0
  116. flyte/cli/_plugins.py +209 -0
  117. flyte/cli/_run.py +597 -0
  118. flyte/cli/_serve.py +64 -0
  119. flyte/cli/_update.py +37 -0
  120. flyte/cli/_user.py +17 -0
  121. flyte/cli/main.py +221 -0
  122. flyte/config/__init__.py +3 -0
  123. flyte/config/_config.py +248 -0
  124. flyte/config/_internal.py +73 -0
  125. flyte/config/_reader.py +225 -0
  126. flyte/connectors/__init__.py +11 -0
  127. flyte/connectors/_connector.py +270 -0
  128. flyte/connectors/_server.py +197 -0
  129. flyte/connectors/utils.py +135 -0
  130. flyte/errors.py +243 -0
  131. flyte/extend.py +19 -0
  132. flyte/extras/__init__.py +5 -0
  133. flyte/extras/_container.py +286 -0
  134. flyte/git/__init__.py +3 -0
  135. flyte/git/_config.py +21 -0
  136. flyte/io/__init__.py +29 -0
  137. flyte/io/_dataframe/__init__.py +131 -0
  138. flyte/io/_dataframe/basic_dfs.py +223 -0
  139. flyte/io/_dataframe/dataframe.py +1026 -0
  140. flyte/io/_dir.py +910 -0
  141. flyte/io/_file.py +914 -0
  142. flyte/io/_hashing_io.py +342 -0
  143. flyte/models.py +479 -0
  144. flyte/py.typed +0 -0
  145. flyte/remote/__init__.py +35 -0
  146. flyte/remote/_action.py +738 -0
  147. flyte/remote/_app.py +57 -0
  148. flyte/remote/_client/__init__.py +0 -0
  149. flyte/remote/_client/_protocols.py +189 -0
  150. flyte/remote/_client/auth/__init__.py +12 -0
  151. flyte/remote/_client/auth/_auth_utils.py +14 -0
  152. flyte/remote/_client/auth/_authenticators/__init__.py +0 -0
  153. flyte/remote/_client/auth/_authenticators/base.py +403 -0
  154. flyte/remote/_client/auth/_authenticators/client_credentials.py +73 -0
  155. flyte/remote/_client/auth/_authenticators/device_code.py +117 -0
  156. flyte/remote/_client/auth/_authenticators/external_command.py +79 -0
  157. flyte/remote/_client/auth/_authenticators/factory.py +200 -0
  158. flyte/remote/_client/auth/_authenticators/pkce.py +516 -0
  159. flyte/remote/_client/auth/_channel.py +213 -0
  160. flyte/remote/_client/auth/_client_config.py +85 -0
  161. flyte/remote/_client/auth/_default_html.py +32 -0
  162. flyte/remote/_client/auth/_grpc_utils/__init__.py +0 -0
  163. flyte/remote/_client/auth/_grpc_utils/auth_interceptor.py +288 -0
  164. flyte/remote/_client/auth/_grpc_utils/default_metadata_interceptor.py +151 -0
  165. flyte/remote/_client/auth/_keyring.py +152 -0
  166. flyte/remote/_client/auth/_token_client.py +260 -0
  167. flyte/remote/_client/auth/errors.py +16 -0
  168. flyte/remote/_client/controlplane.py +128 -0
  169. flyte/remote/_common.py +30 -0
  170. flyte/remote/_console.py +19 -0
  171. flyte/remote/_data.py +161 -0
  172. flyte/remote/_logs.py +185 -0
  173. flyte/remote/_project.py +88 -0
  174. flyte/remote/_run.py +386 -0
  175. flyte/remote/_secret.py +142 -0
  176. flyte/remote/_task.py +527 -0
  177. flyte/remote/_trigger.py +306 -0
  178. flyte/remote/_user.py +33 -0
  179. flyte/report/__init__.py +3 -0
  180. flyte/report/_report.py +182 -0
  181. flyte/report/_template.html +124 -0
  182. flyte/storage/__init__.py +36 -0
  183. flyte/storage/_config.py +237 -0
  184. flyte/storage/_parallel_reader.py +274 -0
  185. flyte/storage/_remote_fs.py +34 -0
  186. flyte/storage/_storage.py +456 -0
  187. flyte/storage/_utils.py +5 -0
  188. flyte/syncify/__init__.py +56 -0
  189. flyte/syncify/_api.py +375 -0
  190. flyte/types/__init__.py +52 -0
  191. flyte/types/_interface.py +40 -0
  192. flyte/types/_pickle.py +145 -0
  193. flyte/types/_renderer.py +162 -0
  194. flyte/types/_string_literals.py +119 -0
  195. flyte/types/_type_engine.py +2254 -0
  196. flyte/types/_utils.py +80 -0
  197. flyte-2.0.0b32.data/scripts/debug.py +38 -0
  198. flyte-2.0.0b32.data/scripts/runtime.py +195 -0
  199. flyte-2.0.0b32.dist-info/METADATA +351 -0
  200. flyte-2.0.0b32.dist-info/RECORD +204 -0
  201. flyte-2.0.0b32.dist-info/WHEEL +5 -0
  202. flyte-2.0.0b32.dist-info/entry_points.txt +7 -0
  203. flyte-2.0.0b32.dist-info/licenses/LICENSE +201 -0
  204. flyte-2.0.0b32.dist-info/top_level.txt +1 -0
@@ -0,0 +1,211 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Literal, Optional
5
+
6
+ from flyteidl2.common import identifier_pb2
7
+ from flyteidl2.core import execution_pb2, interface_pb2
8
+ from flyteidl2.task import common_pb2, task_definition_pb2
9
+ from flyteidl2.workflow import (
10
+ run_definition_pb2,
11
+ state_service_pb2,
12
+ )
13
+ from google.protobuf import timestamp_pb2
14
+
15
+ from flyte.models import GroupData
16
+
17
+ ActionType = Literal["task", "trace"]
18
+
19
+
20
+ @dataclass
21
+ class Action:
22
+ """
23
+ Coroutine safe, as we never do await operations in any method.
24
+ Holds the inmemory state of a task. It is combined representation of local and remote states.
25
+ """
26
+
27
+ action_id: identifier_pb2.ActionIdentifier
28
+ parent_action_name: str
29
+ type: ActionType = "task" # type of action, task or trace
30
+ friendly_name: str | None = None
31
+ group: GroupData | None = None
32
+ task: task_definition_pb2.TaskSpec | None = None
33
+ trace: run_definition_pb2.TraceAction | None = None
34
+ inputs_uri: str | None = None
35
+ run_output_base: str | None = None
36
+ realized_outputs_uri: str | None = None
37
+ err: execution_pb2.ExecutionError | None = None
38
+ phase: run_definition_pb2.Phase | None = None
39
+ started: bool = False
40
+ retries: int = 0
41
+ queue: Optional[str] = None # The queue to which this action was submitted.
42
+ client_err: Exception | None = None # This error is set when something goes wrong in the controller.
43
+ cache_key: str | None = None # None means no caching, otherwise it is the version of the cache.
44
+
45
+ @property
46
+ def name(self) -> str:
47
+ return self.action_id.name
48
+
49
+ @property
50
+ def run_name(self) -> str:
51
+ return self.action_id.run.name
52
+
53
+ def is_terminal(self) -> bool:
54
+ """Check if resource has reached terminal state"""
55
+ if self.phase is None:
56
+ return False
57
+ return self.phase in [
58
+ run_definition_pb2.Phase.PHASE_FAILED,
59
+ run_definition_pb2.Phase.PHASE_SUCCEEDED,
60
+ run_definition_pb2.Phase.PHASE_ABORTED,
61
+ run_definition_pb2.Phase.PHASE_TIMED_OUT,
62
+ ]
63
+
64
+ def increment_retries(self):
65
+ self.retries += 1
66
+
67
+ def is_started(self) -> bool:
68
+ """Check if resource has been started."""
69
+ return self.started
70
+
71
+ def mark_started(self):
72
+ self.started = True
73
+ self.task = None
74
+
75
+ def mark_cancelled(self):
76
+ self.mark_started()
77
+ self.phase = run_definition_pb2.Phase.PHASE_ABORTED
78
+
79
+ def merge_state(self, obj: state_service_pb2.ActionUpdate):
80
+ """
81
+ This method is invoked when the watch API sends an update about the state of the action. We need to merge
82
+ the state of the action with the current state of the action. It is possible that we have no phase information
83
+ prior to this.
84
+ :param obj:
85
+ :return:
86
+ """
87
+ if self.phase != obj.phase:
88
+ self.phase = obj.phase
89
+ self.err = obj.error if obj.HasField("error") else None
90
+ self.realized_outputs_uri = obj.output_uri
91
+ self.started = True
92
+
93
+ def merge_in_action_from_submit(self, action: Action):
94
+ """
95
+ This method is invoked when parent_action submits an action that was observed previously observed from the
96
+ watch. We need to merge in the contents of the action, while preserving the observed phase.
97
+
98
+ :param action: The submitted action
99
+ """
100
+ self.run_output_base = action.run_output_base
101
+ self.inputs_uri = action.inputs_uri
102
+ self.group = action.group
103
+ self.friendly_name = action.friendly_name
104
+ if not self.started:
105
+ self.task = action.task
106
+
107
+ self.cache_key = action.cache_key
108
+
109
+ def set_client_error(self, exc: Exception):
110
+ self.client_err = exc
111
+
112
+ def has_error(self) -> bool:
113
+ return self.client_err is not None or self.err is not None
114
+
115
+ @classmethod
116
+ def from_task(
117
+ cls,
118
+ parent_action_name: str,
119
+ sub_action_id: identifier_pb2.ActionIdentifier,
120
+ group_data: GroupData | None,
121
+ task_spec: task_definition_pb2.TaskSpec,
122
+ inputs_uri: str,
123
+ run_output_base: str,
124
+ cache_key: str | None = None,
125
+ queue: Optional[str] = None,
126
+ ) -> Action:
127
+ return cls(
128
+ action_id=sub_action_id,
129
+ parent_action_name=parent_action_name,
130
+ friendly_name=task_spec.task_template.id.name,
131
+ group=group_data,
132
+ task=task_spec,
133
+ inputs_uri=inputs_uri,
134
+ run_output_base=run_output_base,
135
+ cache_key=cache_key,
136
+ queue=queue,
137
+ )
138
+
139
+ @classmethod
140
+ def from_state(cls, parent_action_name: str, obj: state_service_pb2.ActionUpdate) -> Action:
141
+ """
142
+ This creates a new action, from the watch api. This is possible in the case of a recovery, where the
143
+ state service knows about future actions and sends this information to the informer. We may not have
144
+ encountered the "task" itself yet, but we know about the action id and the state of the action.
145
+
146
+ :param parent_action_name:
147
+ :param obj:
148
+ :return:
149
+ """
150
+ from flyte._logging import logger
151
+
152
+ logger.debug(f"In Action from_state {obj.action_id} {obj.phase} {obj.output_uri}")
153
+ return cls(
154
+ action_id=obj.action_id,
155
+ parent_action_name=parent_action_name,
156
+ phase=obj.phase,
157
+ started=True,
158
+ err=obj.error if obj.HasField("error") else None,
159
+ realized_outputs_uri=obj.output_uri,
160
+ )
161
+
162
+ @classmethod
163
+ def from_trace(
164
+ cls,
165
+ parent_action_name: str,
166
+ action_id: identifier_pb2.ActionIdentifier,
167
+ friendly_name: str,
168
+ group_data: GroupData | None,
169
+ inputs_uri: str,
170
+ outputs_uri: str,
171
+ start_time: float, # Unix timestamp in seconds with fractional seconds
172
+ end_time: float, # Unix timestamp in seconds with fractional seconds
173
+ run_output_base: str,
174
+ report_uri: str | None = None,
175
+ typed_interface: interface_pb2.TypedInterface | None = None,
176
+ ) -> Action:
177
+ """
178
+ This creates a new action for tracing purposes. It is used to track the execution of a trace.
179
+ """
180
+ st = timestamp_pb2.Timestamp()
181
+ st.FromSeconds(int(start_time))
182
+ st.nanos = int((start_time % 1) * 1e9)
183
+
184
+ et = timestamp_pb2.Timestamp()
185
+ et.FromSeconds(int(end_time))
186
+ et.nanos = int((end_time % 1) * 1e9)
187
+
188
+ spec = task_definition_pb2.TraceSpec(interface=typed_interface) if typed_interface else None
189
+
190
+ return cls(
191
+ action_id=action_id,
192
+ parent_action_name=parent_action_name,
193
+ type="trace",
194
+ friendly_name=friendly_name,
195
+ group=group_data,
196
+ inputs_uri=inputs_uri,
197
+ realized_outputs_uri=outputs_uri,
198
+ phase=run_definition_pb2.Phase.PHASE_SUCCEEDED,
199
+ run_output_base=run_output_base,
200
+ trace=run_definition_pb2.TraceAction(
201
+ name=friendly_name,
202
+ phase=run_definition_pb2.Phase.PHASE_SUCCEEDED,
203
+ start_time=st,
204
+ end_time=et,
205
+ outputs=common_pb2.OutputReferences(
206
+ output_uri=outputs_uri,
207
+ report_uri=report_uri,
208
+ ),
209
+ spec=spec,
210
+ ),
211
+ )
@@ -0,0 +1,47 @@
1
+ from __future__ import annotations
2
+
3
+ import grpc.aio
4
+ from flyteidl2.workflow import queue_service_pb2_grpc, state_service_pb2_grpc
5
+
6
+ from flyte.remote import create_channel
7
+
8
+ from ._service_protocol import QueueService, StateService
9
+
10
+
11
+ class ControllerClient:
12
+ """
13
+ A client for the Controller API.
14
+ """
15
+
16
+ def __init__(self, channel: grpc.aio.Channel):
17
+ self._channel = channel
18
+ self._state_service = state_service_pb2_grpc.StateServiceStub(channel=channel)
19
+ self._queue_service = queue_service_pb2_grpc.QueueServiceStub(channel=channel)
20
+
21
+ @classmethod
22
+ async def for_endpoint(cls, endpoint: str, insecure: bool = False, **kwargs) -> ControllerClient:
23
+ return cls(await create_channel(endpoint, None, insecure=insecure, **kwargs))
24
+
25
+ @classmethod
26
+ async def for_api_key(cls, api_key: str, insecure: bool = False, **kwargs) -> ControllerClient:
27
+ return cls(await create_channel(None, api_key, insecure=insecure, **kwargs))
28
+
29
+ @property
30
+ def state_service(self) -> StateService:
31
+ """
32
+ The state service.
33
+ """
34
+ return self._state_service
35
+
36
+ @property
37
+ def queue_service(self) -> QueueService:
38
+ """
39
+ The queue service.
40
+ """
41
+ return self._queue_service
42
+
43
+ def close(self, grace: float | None = None):
44
+ """
45
+ Close the channel.
46
+ """
47
+ return self._channel.close(grace=grace)