Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
Signed-off-by: amitani <amitani.tky@gmail.com>
  • Loading branch information
amitani committed Feb 7, 2025
1 parent 62bae95 commit c64dd6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 5 additions & 4 deletions flytekit/image_spec/default_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ def prepare_python_install(image_spec: ImageSpec, tmp_dir: Path) -> str:
pip_install_args.extend(extra_urls)

pip_secret_mount = ""
pip_secret_mount = " ".join(
f"--mount=type=secret,id={_secret_id(i)},target={dst}"
for i, (_, dst) in enumerate(image_spec.pip_secret_mounts or [])
)
if image_spec.pip_secret_mounts:
pip_secret_mount = " ".join(
f"--mount=type=secret,id={_secret_id(i)},target={dst}"
for i, (_, dst) in enumerate(image_spec.pip_secret_mounts)
)

if image_spec.pip_extra_args:
pip_install_args.append(image_spec.pip_extra_args)
Expand Down
14 changes: 6 additions & 8 deletions flytekit/image_spec/image_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ def __post_init__(self):
error_msg = f"{parameter} must be a list of strings or None"
raise ValueError(error_msg)

parameters_two_str_tuple_list = ["pip_secret_mounts"]
for parameter in parameters_two_str_tuple_list:
attr = getattr(self, parameter)
parameter_is_none = attr is None
parameter_is_list_tuple = isinstance(attr, list) and all(
isinstance(v, tuple) and len(v) == 2 and all(isinstance(vv, str) for vv in v) for v in attr
if self.pip_secret_mounts is not None:
pip_secret_mounts_is_list_tuple = isinstance(self.pip_secret_mounts, list) and all(
isinstance(v, tuple) and len(v) == 2 and all(isinstance(vv, str) for vv in v)
for v in self.pip_secret_mounts
)
if not (parameter_is_none or parameter_is_list_tuple):
error_msg = f"{parameter} must be a list of tuples of two strings or None"
if not pip_secret_mounts_is_list_tuple:
error_msg = "pip_secret_mounts must be a list of tuples of two strings or None"
raise ValueError(error_msg)

@cached_property
Expand Down

0 comments on commit c64dd6a

Please sign in to comment.