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,162 @@
1
+ from typing import TYPE_CHECKING, Any
2
+
3
+ from markdown_it import MarkdownIt
4
+ from typing_extensions import Protocol, runtime_checkable
5
+
6
+ from flyte._utils import lazy_module
7
+
8
+ if TYPE_CHECKING:
9
+ # Always import these modules in type-checking mode or when running pytest
10
+ import pandas
11
+ import pyarrow
12
+ else:
13
+ pandas = lazy_module("pandas")
14
+ pyarrow = lazy_module("pyarrow")
15
+
16
+
17
+ @runtime_checkable
18
+ class Renderable(Protocol):
19
+ def to_html(self, python_value: Any) -> str:
20
+ """Convert an object(markdown, pandas.dataframe) to HTML and return HTML as a unicode string.
21
+ Returns: An HTML document as a string.
22
+ """
23
+ raise NotImplementedError
24
+
25
+
26
+ DEFAULT_MAX_ROWS = 10
27
+ DEFAULT_MAX_COLS = 100
28
+
29
+
30
+ class TopFrameRenderer:
31
+ """
32
+ Render a DataFrame as an HTML table.
33
+ """
34
+
35
+ def __init__(self, max_rows: int = DEFAULT_MAX_ROWS, max_cols: int = DEFAULT_MAX_COLS):
36
+ self._max_rows = max_rows
37
+ self._max_cols = max_cols
38
+
39
+ def to_html(self, df: "pandas.DataFrame") -> str:
40
+ assert isinstance(df, pandas.DataFrame)
41
+ return df.to_html(max_rows=self._max_rows, max_cols=self._max_cols)
42
+
43
+
44
+ class ArrowRenderer:
45
+ """
46
+ Render an Arrow dataframe as an HTML table.
47
+ """
48
+
49
+ def to_html(self, df: "pyarrow.Table") -> str:
50
+ assert isinstance(df, pyarrow.Table)
51
+ return df.to_string()
52
+
53
+
54
+ class MarkdownRenderer:
55
+ """Convert a markdown string to HTML and return HTML as a unicode string."""
56
+
57
+ def to_html(self, text: str) -> str:
58
+ return MarkdownIt().render(text)
59
+
60
+
61
+ class SourceCodeRenderer:
62
+ """
63
+ Convert Python source code to HTML, and return HTML as a unicode string.
64
+ """
65
+
66
+ def __init__(self, title: str = "Source Code"):
67
+ self._title = title
68
+
69
+ def to_html(self, source_code: str) -> str:
70
+ """
71
+ Convert the provided Python source code into HTML format using Pygments library.
72
+
73
+ This method applies a colorful style and replaces the color "#fff0f0" with "#ffffff" in CSS.
74
+
75
+ Args:
76
+ source_code (str): The Python source code to be converted.
77
+
78
+ Returns:
79
+ str: The resulting HTML as a string, including CSS and highlighted source code.
80
+ """
81
+ from pygments import highlight
82
+ from pygments.formatters.html import HtmlFormatter
83
+ from pygments.lexers.python import PythonLexer
84
+
85
+ formatter = HtmlFormatter(style="colorful")
86
+ css = formatter.get_style_defs(".highlight").replace("#fff0f0", "#ffffff")
87
+ html = highlight(source_code, PythonLexer(), formatter)
88
+ return f"<style>{css}</style>{html}"
89
+
90
+
91
+ class PythonDependencyRenderer:
92
+ """
93
+ PythonDependencyDeck is a deck that contains information about packages installed via pip.
94
+ """
95
+
96
+ def __init__(self, title: str = "Dependencies"):
97
+ self._title = title
98
+
99
+ def to_html(self) -> str:
100
+ import json
101
+ import subprocess
102
+ import sys
103
+
104
+ from flytekit.loggers import logger
105
+
106
+ try:
107
+ installed_packages = json.loads(
108
+ subprocess.check_output([sys.executable, "-m", "pip", "list", "--format", "json"])
109
+ )
110
+ requirements_txt = (
111
+ subprocess.check_output([sys.executable, "-m", "pip", "freeze"])
112
+ .decode("utf-8")
113
+ .replace("\\n", "\n")
114
+ .rstrip()
115
+ )
116
+ except Exception as e:
117
+ logger.error(f"Error occurred while fetching installed packages: {e}")
118
+ return "Error occurred while fetching installed packages."
119
+
120
+ table = (
121
+ "<table>\n<tr>\n<th style='text-align:left;'>Name</th>\n<th style='text-align:left;'>Version</th>\n</tr>\n"
122
+ )
123
+
124
+ for entry in installed_packages:
125
+ table += f"<tr>\n<td>{entry['name']}</td>\n<td>{entry['version']}</td>\n</tr>\n"
126
+
127
+ table += "</table>"
128
+
129
+ html = f"""
130
+ <!DOCTYPE html>
131
+ <html lang="en">
132
+ <head>
133
+ <meta charset="UTF-8">
134
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
135
+ <title>Flyte Dependencies</title>
136
+ <script>
137
+ async function copyTable() {{
138
+ var requirements_txt = document.getElementById('requirements_txt');
139
+
140
+ try {{
141
+ await navigator.clipboard.writeText(requirements_txt.innerText);
142
+ }} catch (err) {{
143
+ console.log('Error accessing the clipboard: ' + err);
144
+ }}
145
+ }}
146
+ </script>
147
+ </head>
148
+ <body>
149
+
150
+ <button onclick="copyTable()">
151
+ <span>Copy table as requirements.txt</span>
152
+ </button>
153
+ <h3>Python Dependencies</h3>
154
+
155
+ {table}
156
+
157
+ <div id="requirements_txt" style="display:none">{requirements_txt}</div>
158
+
159
+ </body>
160
+ </html>
161
+ """
162
+ return html
@@ -0,0 +1,119 @@
1
+ import base64
2
+ import json
3
+ from typing import Any, Dict, Union
4
+
5
+ import msgpack
6
+ from flyteidl2.core import literals_pb2
7
+ from flyteidl2.task import common_pb2
8
+ from google.protobuf.json_format import MessageToDict
9
+
10
+
11
+ def _primitive_to_string(primitive: literals_pb2.Primitive) -> Any:
12
+ """
13
+ This method is used to convert a primitive to a string representation.
14
+ """
15
+ match primitive.WhichOneof("value"):
16
+ case "integer":
17
+ return primitive.integer
18
+ case "float_value":
19
+ return primitive.float_value
20
+ case "boolean":
21
+ return primitive.boolean
22
+ case "string_value":
23
+ return primitive.string_value
24
+ case "datetime":
25
+ return primitive.datetime.ToDatetime().isoformat()
26
+ case "duration":
27
+ return primitive.duration.ToSeconds()
28
+ case _:
29
+ raise ValueError(f"Unknown primitive type {primitive}")
30
+
31
+
32
+ def _scalar_to_string(scalar: literals_pb2.Scalar) -> Any:
33
+ """
34
+ This method is used to convert a scalar to a string representation.
35
+ """
36
+ match scalar.WhichOneof("value"):
37
+ case "primitive":
38
+ return _primitive_to_string(scalar.primitive)
39
+ case "none_type":
40
+ return None
41
+ case "error":
42
+ return scalar.error.message
43
+ case "structured_dataset":
44
+ return scalar.structured_dataset.uri
45
+ case "schema":
46
+ return scalar.schema.uri
47
+ case "blob":
48
+ return scalar.blob.uri
49
+ case "binary":
50
+ if scalar.binary.tag == "msgpack":
51
+ return json.dumps(msgpack.unpackb(scalar.binary.value))
52
+ return base64.b64encode(scalar.binary.value)
53
+ case "generic":
54
+ return MessageToDict(scalar.generic)
55
+ case "union":
56
+ return _literal_string_repr(scalar.union.value)
57
+ case _:
58
+ raise ValueError(f"Unknown scalar type {scalar}")
59
+
60
+
61
+ def _literal_string_repr(lit: literals_pb2.Literal) -> Any:
62
+ """
63
+ This method is used to convert a literal to a string representation. This is useful in places, where we need to
64
+ use a shortened string representation of a literal, especially a FlyteFile, FlyteDirectory, or StructuredDataset.
65
+ """
66
+ match lit.WhichOneof("value"):
67
+ case "scalar":
68
+ return _scalar_to_string(lit.scalar)
69
+ case "collection":
70
+ return [literal_string_repr(i) for i in lit.collection.literals]
71
+ case "map":
72
+ return {k: literal_string_repr(v) for k, v in lit.map.literals.items()}
73
+ case "offloaded_metadata":
74
+ # TODO: load literal from offloaded literal?
75
+ return f"Offloaded literal metadata: {lit.offloaded_metadata}"
76
+ case _:
77
+ raise ValueError(f"Unknown literal type {lit}")
78
+
79
+
80
+ def _dict_literal_repr(lmd: Dict[str, literals_pb2.Literal]) -> Dict[str, Any]:
81
+ """
82
+ This method is used to convert a literal map to a string representation.
83
+ """
84
+ return {k: _literal_string_repr(v) for k, v in lmd.items()}
85
+
86
+
87
+ def literal_string_repr(
88
+ lm: Union[
89
+ literals_pb2.Literal,
90
+ common_pb2.NamedLiteral,
91
+ common_pb2.Inputs,
92
+ common_pb2.Outputs,
93
+ literals_pb2.LiteralMap,
94
+ Dict[str, literals_pb2.Literal],
95
+ ],
96
+ ) -> Dict[str, Any]:
97
+ """
98
+ This method is used to convert a literal map to a string representation.
99
+ """
100
+ if lm is None:
101
+ return {}
102
+ match lm:
103
+ case literals_pb2.Literal():
104
+ return _literal_string_repr(lm)
105
+ case literals_pb2.LiteralMap():
106
+ return _dict_literal_repr(lm.literals)
107
+ case common_pb2.NamedLiteral():
108
+ lmd = {lm.name: lm.value}
109
+ return _dict_literal_repr(lmd)
110
+ case common_pb2.Inputs():
111
+ lmd = {n.name: n.value for n in lm.literals}
112
+ return _dict_literal_repr(lmd)
113
+ case common_pb2.Outputs():
114
+ lmd = {n.name: n.value for n in lm.literals}
115
+ return _dict_literal_repr(lmd)
116
+ case dict():
117
+ return _dict_literal_repr(lm)
118
+ case _:
119
+ raise ValueError(f"Unknown literal type {lm}, type{type(lm)}")