flyte 2.0.0b5__py3-none-any.whl → 2.0.0b6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flyte might be problematic. Click here for more details.

flyte/_image.py CHANGED
@@ -5,10 +5,10 @@ import hashlib
5
5
  import sys
6
6
  import typing
7
7
  from abc import abstractmethod
8
- from dataclasses import asdict, dataclass, field
8
+ from dataclasses import asdict, dataclass, field, fields
9
9
  from functools import cached_property
10
10
  from pathlib import Path
11
- from typing import TYPE_CHECKING, Callable, ClassVar, Dict, List, Literal, Optional, Tuple, TypeVar, Union
11
+ from typing import TYPE_CHECKING, ClassVar, Dict, List, Literal, Optional, Tuple, TypeVar, Union
12
12
 
13
13
  import rich.repr
14
14
  from packaging.version import Version
@@ -49,8 +49,6 @@ class Layer:
49
49
  layered images programmatically.
50
50
  """
51
51
 
52
- _compute_identifier: Callable[[Layer], str] = field(default=lambda x: x.__str__(), init=True)
53
-
54
52
  @abstractmethod
55
53
  def update_hash(self, hasher: hashlib._Hash):
56
54
  """
@@ -66,6 +64,27 @@ class Layer:
66
64
  :return:
67
65
  """
68
66
 
67
+ def identifier(self) -> str:
68
+ """
69
+ This method computes a unique identifier for the layer based on its properties.
70
+ It is used to identify the layer in the image cache.
71
+
72
+ It is also used to compute a unique identifier for the image itself, which is a combination of all the layers.
73
+ This identifier is used to look up previously built images in the image cache. So having a consistent
74
+ identifier is important for the image cache to work correctly.
75
+
76
+ :return: A unique identifier for the layer.
77
+ """
78
+ ignore_fields: list[str] = []
79
+ for f in fields(self):
80
+ if f.metadata.get("identifier", True) is False:
81
+ ignore_fields.append(f.name)
82
+ d = asdict(self)
83
+ for v in ignore_fields:
84
+ d.pop(v)
85
+
86
+ return str(d)
87
+
69
88
 
70
89
  @rich.repr.auto
71
90
  @dataclass(kw_only=True, frozen=True, repr=True)
@@ -133,7 +152,11 @@ class PipPackages(PipOption, Layer):
133
152
  @rich.repr.auto
134
153
  @dataclass(kw_only=True, frozen=True, repr=True)
135
154
  class PythonWheels(PipOption, Layer):
136
- wheel_dir: Path
155
+ wheel_dir: Path = field(metadata={"identifier": False})
156
+ wheel_dir_name: str = field(init=False)
157
+
158
+ def __post_init__(self):
159
+ object.__setattr__(self, "wheel_dir_name", self.wheel_dir.name)
137
160
 
138
161
  def update_hash(self, hasher: hashlib._Hash):
139
162
  super().update_hash(hasher)
@@ -184,7 +207,11 @@ class UVProject(PipOption, Layer):
184
207
  @rich.repr.auto
185
208
  @dataclass(frozen=True, repr=True)
186
209
  class UVScript(PipOption, Layer):
187
- script: Path
210
+ script: Path = field(metadata={"identifier": False})
211
+ script_name: str = field(init=False)
212
+
213
+ def __post_init__(self):
214
+ object.__setattr__(self, "script_name", self.script.name)
188
215
 
189
216
  def validate(self):
190
217
  if not self.script.exists():
@@ -196,10 +223,13 @@ class UVScript(PipOption, Layer):
196
223
  super().validate()
197
224
 
198
225
  def update_hash(self, hasher: hashlib._Hash):
199
- from ._utils import filehash_update
226
+ from ._utils import parse_uv_script_file
200
227
 
228
+ header = parse_uv_script_file(self.script)
229
+ h_tuple = _ensure_tuple(header)
230
+ if h_tuple:
231
+ hasher.update(h_tuple.__str__().encode("utf-8"))
201
232
  super().update_hash(hasher)
202
- filehash_update(self.script, hasher)
203
233
 
204
234
 
205
235
  @rich.repr.auto
@@ -247,9 +277,15 @@ class DockerIgnore(Layer):
247
277
  @rich.repr.auto
248
278
  @dataclass(frozen=True, repr=True)
249
279
  class CopyConfig(Layer):
250
- path_type: CopyConfigType
251
- src: Path
252
- dst: str = "."
280
+ path_type: CopyConfigType = field(metadata={"identifier": True})
281
+ src: Path = field(metadata={"identifier": True})
282
+ dst: str
283
+ src_name: str = field(init=False)
284
+
285
+ def __post_init__(self):
286
+ if self.path_type not in (0, 1):
287
+ raise ValueError(f"Invalid path_type {self.path_type}, must be 0 (file) or 1 (directory)")
288
+ object.__setattr__(self, "src_name", self.src.name)
253
289
 
254
290
  def validate(self):
255
291
  if not self.src.exists():
@@ -393,7 +429,7 @@ class Image:
393
429
  # across different SDK versions.
394
430
  # Layers can specify a _compute_identifier optionally, but the default will just stringify
395
431
  image_dict = asdict(self, dict_factory=lambda x: {k: v for (k, v) in x if v is not None and k != "_layers"})
396
- layers_str_repr = "".join([layer._compute_identifier(layer) for layer in self._layers])
432
+ layers_str_repr = "".join([layer.identifier() for layer in self._layers])
397
433
  image_dict["layers"] = layers_str_repr
398
434
  spec_bytes = image_dict.__str__().encode("utf-8")
399
435
  return base64.urlsafe_b64encode(hashlib.md5(spec_bytes).digest()).decode("ascii").rstrip("=")
@@ -430,6 +466,7 @@ class Image:
430
466
  base_image=f"python:{python_version[0]}.{python_version[1]}-slim-bookworm",
431
467
  registry=_BASE_REGISTRY,
432
468
  name=_DEFAULT_IMAGE_NAME,
469
+ python_version=python_version,
433
470
  platform=("linux/amd64", "linux/arm64") if platform is None else platform,
434
471
  )
435
472
  labels_and_user = _DockerLines(
@@ -572,8 +609,12 @@ class Image:
572
609
  :param extra_index_urls: extra index urls to use for pip install, default is None
573
610
  :param pre: whether to allow pre-release versions, default is False
574
611
  :param extra_args: extra arguments to pass to pip install, default is None
612
+ :param secret_mounts: Secret mounts to use for the image, default is None.
575
613
 
576
614
  :return: Image
615
+
616
+ Args:
617
+ secret_mounts:
577
618
  """
578
619
  ll = UVScript(
579
620
  script=Path(script),
@@ -801,7 +842,7 @@ class Image:
801
842
  :param dst: destination folder in the image
802
843
  :return: Image
803
844
  """
804
- new_image = self.clone(addl_layer=CopyConfig(path_type=1, src=src, dst=dst, _compute_identifier=lambda x: dst))
845
+ new_image = self.clone(addl_layer=CopyConfig(path_type=1, src=src, dst=dst))
805
846
  return new_image
806
847
 
807
848
  def with_source_file(self, src: Path, dst: str = ".") -> Image:
@@ -813,7 +854,7 @@ class Image:
813
854
  :param dst: destination folder in the image
814
855
  :return: Image
815
856
  """
816
- new_image = self.clone(addl_layer=CopyConfig(path_type=0, src=src, dst=dst, _compute_identifier=lambda x: dst))
857
+ new_image = self.clone(addl_layer=CopyConfig(path_type=0, src=src, dst=dst))
817
858
  return new_image
818
859
 
819
860
  def with_dockerignore(self, path: Path) -> Image:
@@ -899,7 +940,7 @@ class Image:
899
940
  dist_folder = Path(__file__).parent.parent.parent / "dist"
900
941
  # Manually declare the PythonWheel so we can set the hashing
901
942
  # used to compute the identifier. Can remove if we ever decide to expose the lambda in with_ commands
902
- with_dist = self.clone(addl_layer=PythonWheels(wheel_dir=dist_folder, _compute_identifier=lambda x: "/dist"))
943
+ with_dist = self.clone(addl_layer=PythonWheels(wheel_dir=dist_folder))
903
944
 
904
945
  return with_dist
905
946
 
flyte/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.0.0b5'
21
- __version_tuple__ = version_tuple = (2, 0, 0, 'b5')
20
+ __version__ = version = '2.0.0b6'
21
+ __version_tuple__ = version_tuple = (2, 0, 0, 'b6')
flyte/cli/_gen.py CHANGED
@@ -38,6 +38,10 @@ def walk_commands(ctx: click.Context) -> Generator[Tuple[str, click.Command], No
38
38
 
39
39
  if not isinstance(command, click.Group):
40
40
  yield ctx.command_path, command
41
+ elif isinstance(command, common.FileGroup):
42
+ # If the command is a FileGroup, yield its file path and the command itself
43
+ # No need to recurse further into FileGroup as it doesn't have subcommands, they are dynamically generated
44
+ yield ctx.command_path, command
41
45
  else:
42
46
  for name in command.list_commands(ctx):
43
47
  subcommand = command.get_command(ctx, name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyte
3
- Version: 2.0.0b5
3
+ Version: 2.0.0b6
4
4
  Summary: Add your description here
5
5
  Author-email: Ketan Umare <kumare3@users.noreply.github.com>
6
6
  Requires-Python: >=3.10
@@ -8,7 +8,7 @@ flyte/_environment.py,sha256=6ks0lkvGt4oSqM5EFPFlhWC3eoUghxUvCn0wstcAD2E,3713
8
8
  flyte/_excepthook.py,sha256=nXts84rzEg6-7RtFarbKzOsRZTQR4plnbWVIFMAEprs,1310
9
9
  flyte/_group.py,sha256=7o1j16sZyUmYB50mOiq1ui4TBAKhRpDqLakV8Ya1kw4,803
10
10
  flyte/_hash.py,sha256=Of_Zl_DzzzF2jp4ZsLm-3o-xJFCCJ8_GubmLI1htx78,504
11
- flyte/_image.py,sha256=lPkMW1cqFvFeuIG91CxD9Oif3-EymraSu-2XaLIn2Ng,35691
11
+ flyte/_image.py,sha256=dSChbZeXBSz77wN-AjcXyWLkVUR0kqOtjUuNsflayJM,37310
12
12
  flyte/_initialize.py,sha256=xKl_LYMluRt21wWqa6RTKuLo0_DCbSaTfUk27_brtNk,18232
13
13
  flyte/_interface.py,sha256=1B9zIwFDjiVp_3l_mk8EpA4g3Re-6DUBEBi9z9vDvPs,3504
14
14
  flyte/_logging.py,sha256=QrT4Z30C2tsZ-yIojisQODTuq6Y6zSJYuTrLgF58UYc,3664
@@ -25,7 +25,7 @@ flyte/_task_plugins.py,sha256=9MH3nFPOH_e8_92BT4sFk4oyAnj6GJFvaPYWaraX7yE,1037
25
25
  flyte/_timeout.py,sha256=zx5sFcbYmjJAJbZWSGzzX-BpC9HC7Jfs35T7vVhKwkk,1571
26
26
  flyte/_tools.py,sha256=tWb0sx3t3mm4jbaQVjCTc9y39oR_Ibo3z_KHToP3Lto,966
27
27
  flyte/_trace.py,sha256=SSE1nzUgmVTS2xFNtchEOjEjlRavMOIInasXzY8i9lU,4911
28
- flyte/_version.py,sha256=KY7k4TTnCC_HdhG4ZUyzH7UsSbByUSTtQDckcSpcmmQ,519
28
+ flyte/_version.py,sha256=c1--_MDUEVzy0HOAoU4GvWafX-tUEg8fSks16cbT7nQ,519
29
29
  flyte/errors.py,sha256=DKKw0LVywBNuiWR9WMkODxd_dwWRn-NtyN1TMs6HHd0,5800
30
30
  flyte/extend.py,sha256=GB4ZedGzKa30vYWRVPOdxEeK62xnUVFY4z2tD6H9eEw,376
31
31
  flyte/models.py,sha256=2TgfrkPPgcnnk1P_MO5SEmOYAUbsMKl3gxIDwhW2yEU,15674
@@ -162,7 +162,7 @@ flyte/cli/_common.py,sha256=SLY3M7ganzLCf2MaybJFRkk677IoZrkZKjIR5Qoc0cE,12542
162
162
  flyte/cli/_create.py,sha256=Rv_Ox_OA9TqdSI6zaTzLp9vwiqOanOk-Oasnbgx1Q3M,5081
163
163
  flyte/cli/_delete.py,sha256=VTmXv09PBjkdtyl23mbSjIQQlN7Y1AI_bO0GkHP-f9E,546
164
164
  flyte/cli/_deploy.py,sha256=h-laMIbqNskxPzqtBNxIhgamjt2MxGoNongi9_nTQbo,8939
165
- flyte/cli/_gen.py,sha256=vlE5l8UR1zz4RSdaRyUfYFvGR0TLxGcTYcP4dhA3Pvg,5458
165
+ flyte/cli/_gen.py,sha256=ni3E65_wSBc9x5NNbq1REuxfZCJz-ioLMVQnZIgwyYg,5745
166
166
  flyte/cli/_get.py,sha256=fvoJaBmZuD4sDs33dMo94dvBJVk3MaWPJe24e3cG0Ps,10200
167
167
  flyte/cli/_params.py,sha256=8Gj8UYGHwu-SUXGWCTRX5QsVf19NiajhaUMMae6FF9o,19466
168
168
  flyte/cli/_run.py,sha256=x1BRMK4M0kUboZVOKNuufi8B0cFjsOE7b36zbHT40Cc,7764
@@ -227,10 +227,10 @@ flyte/types/_renderer.py,sha256=ygcCo5l60lHufyQISFddZfWwLlQ8kJAKxUT_XnR_6dY,4818
227
227
  flyte/types/_string_literals.py,sha256=NlG1xV8RSA-sZ-n-IFQCAsdB6jXJOAKkHWtnopxVVDk,4231
228
228
  flyte/types/_type_engine.py,sha256=Tas_OXYddOi0nDuORjqan2SkJ96wKD8937I2l1bo8vk,97916
229
229
  flyte/types/_utils.py,sha256=pbts9E1_2LTdLygAY0UYTLYJ8AsN3BZyviSXvrtcutc,2626
230
- flyte-2.0.0b5.data/scripts/runtime.py,sha256=2jTy3ccvrJ__Xrfdo2t0Fxhsojc5o2zIxDHt98RE_eU,6475
231
- flyte-2.0.0b5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
232
- flyte-2.0.0b5.dist-info/METADATA,sha256=qrlVB1zQRgqKWHit2lwbo3gO0sAEGSXdeoUMJKHIc9E,10004
233
- flyte-2.0.0b5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
234
- flyte-2.0.0b5.dist-info/entry_points.txt,sha256=MIq2z5dBurdCJfpXfMKzgBv7sJOakKRYxr8G0cMiTrg,75
235
- flyte-2.0.0b5.dist-info/top_level.txt,sha256=7dkyFbikvA12LEZEqawx8oDG1CMod6hTliPj7iWzgYo,6
236
- flyte-2.0.0b5.dist-info/RECORD,,
230
+ flyte-2.0.0b6.data/scripts/runtime.py,sha256=2jTy3ccvrJ__Xrfdo2t0Fxhsojc5o2zIxDHt98RE_eU,6475
231
+ flyte-2.0.0b6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
232
+ flyte-2.0.0b6.dist-info/METADATA,sha256=AfK1udiYYhGWg2MmKRBZGsVOe7Ff3QrPdMozeqv3feY,10004
233
+ flyte-2.0.0b6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
234
+ flyte-2.0.0b6.dist-info/entry_points.txt,sha256=MIq2z5dBurdCJfpXfMKzgBv7sJOakKRYxr8G0cMiTrg,75
235
+ flyte-2.0.0b6.dist-info/top_level.txt,sha256=7dkyFbikvA12LEZEqawx8oDG1CMod6hTliPj7iWzgYo,6
236
+ flyte-2.0.0b6.dist-info/RECORD,,