Skip to content

Commit

Permalink
More flag propagation
Browse files Browse the repository at this point in the history
Signed-off-by: Vanshika Chowdhary <[email protected]>
  • Loading branch information
Vanshika Chowdhary committed Sep 9, 2022
1 parent 957d18a commit 9c133d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 10 additions & 2 deletions flytekit/clis/sdk_in_container/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
7 changes: 5 additions & 2 deletions flytekit/tools/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ 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
:param registrable_entities: Entities that can be serialized
: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")
Expand All @@ -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:
Expand All @@ -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(
Expand Down

0 comments on commit 9c133d8

Please sign in to comment.