Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Samhita Alla <[email protected]>
  • Loading branch information
samhita-alla committed Jul 6, 2022
2 parents 6ce6e19 + 03a9487 commit a48472a
Show file tree
Hide file tree
Showing 33 changed files with 1,040 additions and 502 deletions.
16 changes: 12 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# via
# -c requirements.txt
# pytest-flyte
appnope==0.1.3
# via ipython
arrow==1.2.2
# via
# -c requirements.txt
Expand Down Expand Up @@ -73,11 +71,12 @@ croniter==1.3.5
# via
# -c requirements.txt
# flytekit
cryptography==37.0.2
cryptography==37.0.4
# via
# -c requirements.txt
# paramiko
# pyopenssl
# secretstorage
dataclasses-json==0.5.7
# via
# -c requirements.txt
Expand Down Expand Up @@ -122,7 +121,7 @@ docstring-parser==0.14.1
# flytekit
filelock==3.7.1
# via virtualenv
flyteidl==1.1.7
flyteidl==1.1.8
# via
# -c requirements.txt
# flytekit
Expand Down Expand Up @@ -188,6 +187,11 @@ ipython==7.34.0
# via -r dev-requirements.in
jedi==0.18.1
# via ipython
jeepney==0.8.0
# via
# -c requirements.txt
# keyring
# secretstorage
jinja2==3.1.2
# via
# -c requirements.txt
Expand Down Expand Up @@ -400,6 +404,10 @@ retry==0.9.2
# flytekit
rsa==4.8
# via google-auth
secretstorage==3.3.2
# via
# -c requirements.txt
# keyring
singledispatchmethod==1.0
# via
# -c requirements.txt
Expand Down
23 changes: 13 additions & 10 deletions doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ altair==4.2.0
# via great-expectations
ansiwrap==0.8.4
# via papermill
appnope==0.1.3
# via
# ipykernel
# ipython
argon2-cffi==21.3.0
# via notebook
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -46,7 +42,7 @@ binaryornot==0.4.4
# via cookiecutter
bleach==5.0.1
# via nbconvert
botocore==1.27.21
botocore==1.27.22
# via -r doc-requirements.in
cachetools==5.2.0
# via google-auth
Expand Down Expand Up @@ -76,11 +72,12 @@ cookiecutter==2.1.1
# via flytekit
croniter==1.3.5
# via flytekit
cryptography==37.0.2
cryptography==37.0.4
# via
# -r doc-requirements.in
# great-expectations
# pyopenssl
# secretstorage
css-html-js-minify==2.5.5
# via sphinx-material
cycler==0.11.0
Expand Down Expand Up @@ -123,7 +120,7 @@ entrypoints==0.4
# papermill
fastjsonschema==2.15.3
# via nbformat
flyteidl==1.1.7
flyteidl==1.1.8
# via flytekit
fonttools==4.33.3
# via matplotlib
Expand Down Expand Up @@ -217,6 +214,10 @@ ipywidgets==7.7.1
# via jupyter
jedi==0.18.1
# via ipython
jeepney==0.8.0
# via
# keyring
# secretstorage
jinja2==3.1.2
# via
# altair
Expand Down Expand Up @@ -275,7 +276,7 @@ kubernetes==24.2.0
# via -r doc-requirements.in
lazy-object-proxy==1.7.1
# via astroid
lxml==4.9.0
lxml==4.9.1
# via sphinx-material
markdown==3.3.7
# via -r doc-requirements.in
Expand Down Expand Up @@ -407,7 +408,7 @@ phik==0.12.2
# via pandas-profiling
pickleshare==0.7.5
# via ipython
pillow==9.1.1
pillow==9.2.0
# via
# imagehash
# matplotlib
Expand Down Expand Up @@ -572,6 +573,8 @@ seaborn==0.11.2
# via
# missingno
# pandas-profiling
secretstorage==3.3.2
# via keyring
send2trash==1.8.0
# via notebook
singledispatchmethod==1.0
Expand Down Expand Up @@ -663,7 +666,7 @@ toolz==0.11.2
# via altair
torch==1.11.0
# via -r doc-requirements.in
tornado==6.1
tornado==6.2
# via
# ipykernel
# jupyter-client
Expand Down
8 changes: 8 additions & 0 deletions flytekit/clis/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
from typing import Tuple, Union

import click
from flyteidl.admin.launch_plan_pb2 import LaunchPlan
from flyteidl.admin.task_pb2 import TaskSpec
from flyteidl.admin.workflow_pb2 import WorkflowSpec
Expand Down Expand Up @@ -125,3 +127,9 @@ def hydrate_registration_parameters(
del entity.sub_workflows[:]
entity.sub_workflows.extend(refreshed_sub_workflows)
return identifier, entity


def display_help_with_error(ctx: click.Context, message: str):
click.echo(f"{ctx.get_help()}\n")
click.secho(message, fg="red")
sys.exit(1)
5 changes: 2 additions & 3 deletions flytekit/clis/sdk_in_container/package.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import sys

import click

from flytekit.clis.helpers import display_help_with_error
from flytekit.clis.sdk_in_container import constants
from flytekit.configuration import (
DEFAULT_RUNTIME_PYTHON_INTERPRETER,
Expand Down Expand Up @@ -100,8 +100,7 @@ def package(ctx, image_config, source, output, force, fast, in_container_source_

pkgs = ctx.obj[constants.CTX_PACKAGES]
if not pkgs:
click.secho("No packages to scan for flyte entities. Aborting!", fg="red")
sys.exit(-1)
display_help_with_error(ctx, "No packages to scan for flyte entities. Aborting!")

try:
serialize_and_package(pkgs, serialization_settings, source, output, fast)
Expand Down
13 changes: 9 additions & 4 deletions flytekit/clis/sdk_in_container/register.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import pathlib
import sys
import typing

import click

from flytekit.clis.helpers import display_help_with_error
from flytekit.clis.sdk_in_container import constants
from flytekit.clis.sdk_in_container.helpers import get_and_save_remote_with_click_context
from flytekit.configuration import FastSerializationSettings, ImageConfig, SerializationSettings
Expand Down Expand Up @@ -67,7 +67,7 @@
"--output",
required=False,
type=click.Path(dir_okay=True, file_okay=False, writable=True, resolve_path=True),
default=".",
default=None,
help="Directory to write the output zip file containing the protobuf definitions",
)
@click.option(
Expand Down Expand Up @@ -122,6 +122,12 @@ def register(
if pkgs:
raise ValueError("Unimplemented, just specify pkgs like folder/files as args at the end of the command")

if len(package_or_module) == 0:
display_help_with_error(
ctx,
"Missing argument 'PACKAGE_OR_MODULE...', at least one PACKAGE_OR_MODULE is required but multiple can be passed",
)

cli_logger.debug(
f"Running pyflyte register from {os.getcwd()} "
f"with images {image_config} "
Expand Down Expand Up @@ -162,8 +168,7 @@ def register(
serialization_settings, detected_root, list(package_or_module), options
)
if len(registerable_entities) == 0:
click.secho("No Flyte entities were detected. Aborting!", fg="red")
sys.exit(1)
display_help_with_error(ctx, "No Flyte entities were detected. Aborting!")
cli_logger.info(f"Found and serialized {len(registerable_entities)} entities")

if not version:
Expand Down
6 changes: 1 addition & 5 deletions flytekit/extras/pytorch/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@

import torch
from dataclasses_json import dataclass_json
from typing_extensions import Protocol

from flytekit.core.context_manager import FlyteContext
from flytekit.core.type_engine import TypeEngine, TypeTransformer, TypeTransformerFailedError
from flytekit.models.core import types as _core_types
from flytekit.models.literals import Blob, BlobMetadata, Literal, Scalar
from flytekit.models.types import LiteralType

try:
from typing import Protocol
except ImportError:
from typing_extensions import Protocol


class IsDataclass(Protocol):
__dataclass_fields__: Dict
Expand Down
9 changes: 7 additions & 2 deletions flytekit/tools/fast_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import tempfile
from typing import Optional

import click

from flytekit.core.context_manager import FlyteContextManager
from flytekit.tools.ignore import DockerIgnore, GitIgnore, IgnoreGroup, StandardIgnore
from flytekit.tools.script_mode import tar_strip_file_attributes
Expand All @@ -31,8 +33,11 @@ def fast_package(source: os.PathLike, output_dir: os.PathLike) -> os.PathLike:
digest = compute_digest(source, ignore.is_ignored)
archive_fname = f"{FAST_PREFIX}{digest}{FAST_FILEENDING}"

if output_dir:
archive_fname = os.path.join(output_dir, archive_fname)
if output_dir is None:
output_dir = tempfile.mkdtemp()
click.secho(f"Output given as {None}, using a temporary directory at {output_dir} instead", fg="yellow")

archive_fname = os.path.join(output_dir, archive_fname)

with tempfile.TemporaryDirectory() as tmp_dir:
tar_path = os.path.join(tmp_dir, "tmp.tar")
Expand Down
4 changes: 4 additions & 0 deletions flytekit/tools/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def package(

# If Fast serialization is enabled, then an archive is also created and packaged
if fast:
# If output exists and is a path within source, delete it so as to not re-bundle it again.
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)
click.secho(f"Fast mode enabled: compressed archive {archive_fname}", dim=True)

Expand Down
Loading

0 comments on commit a48472a

Please sign in to comment.