From 9c133d8c0d8adba89274b95f413d66cb9e69ac28 Mon Sep 17 00:00:00 2001 From: Vanshika Chowdhary Date: Fri, 9 Sep 2022 12:23:51 -0700 Subject: [PATCH] More flag propagation Signed-off-by: Vanshika Chowdhary --- flytekit/clis/sdk_in_container/package.py | 12 ++++++++++-- flytekit/tools/repo.py | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/flytekit/clis/sdk_in_container/package.py b/flytekit/clis/sdk_in_container/package.py index 2a884e29da..1a849d0681 100644 --- a/flytekit/clis/sdk_in_container/package.py +++ b/flytekit/clis/sdk_in_container/package.py @@ -77,8 +77,16 @@ default="/root", help="Filesystem path to where the code is copied into within the Dockerfile. look for `COPY . /root` like command.", ) +@click.option( + "--deref-symlinks", + default=False, + is_flag=True, + help="Enables symlink dereferencing when packaging files in fast registration", +) @click.pass_context -def package(ctx, image_config, source, output, force, fast, in_container_source_path, python_interpreter): +def package( + ctx, image_config, source, output, force, fast, in_container_source_path, python_interpreter, deref_symlinks +): """ This command produces a Flyte backend registrable package of all entities in Flyte. For tasks, one pb file is produced for each task, representing one TaskTemplate object. @@ -103,6 +111,6 @@ def package(ctx, image_config, source, output, force, fast, in_container_source_ display_help_with_error(ctx, "No packages to scan for flyte entities. Aborting!") try: - serialize_and_package(pkgs, serialization_settings, source, output, fast) + serialize_and_package(pkgs, serialization_settings, source, output, fast, deref_symlinks) except NoSerializableEntitiesError: click.secho(f"No flyte objects found in packages {pkgs}", fg="yellow") diff --git a/flytekit/tools/repo.py b/flytekit/tools/repo.py index 167c772184..ceaee36435 100644 --- a/flytekit/tools/repo.py +++ b/flytekit/tools/repo.py @@ -75,6 +75,7 @@ def package( source: str = ".", output: str = "./flyte-package.tgz", fast: bool = False, + deref_symlinks: bool = False, ): """ Package the given entities and the source code (if fast is enabled) into a package with the given name in output @@ -82,6 +83,7 @@ def package( :param source: source folder :param output: output package name with suffix :param fast: fast enabled implies source code is bundled + :param deref_symlinks: if enabled then symlinks are dereferenced during packaging """ if not registrable_entities: raise NoSerializableEntitiesError("Nothing to package") @@ -95,7 +97,7 @@ def package( if os.path.abspath(output).startswith(os.path.abspath(source)) and os.path.exists(output): click.secho(f"{output} already exists within {source}, deleting and re-creating it", fg="yellow") os.remove(output) - archive_fname = fast_registration.fast_package(source, output_tmpdir) + archive_fname = fast_registration.fast_package(source, output_tmpdir, deref_symlinks) click.secho(f"Fast mode enabled: compressed archive {archive_fname}", dim=True) with tarfile.open(output, "w:gz") as tar: @@ -110,13 +112,14 @@ def serialize_and_package( source: str = ".", output: str = "./flyte-package.tgz", fast: bool = False, + deref_symlinks: bool = False, options: typing.Optional[Options] = None, ): """ Fist serialize and then package all entities """ registrable_entities = serialize(pkgs, settings, source, options=options) - package(registrable_entities, source, output, fast) + package(registrable_entities, source, output, fast, deref_symlinks) def register(