Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip errors when running pyflyte register #2111

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions flytekit/clis/sdk_in_container/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@
callback=key_value_callback,
help="Environment variables to set in the container, of the format `ENV_NAME=ENV_VALUE`",
)
@click.option(
"--skip-errors",
"--skip-error",
default=False,
is_flag=True,
help="Skip errors during registration. This is useful when registering multiple packages and you want to skip "
"errors for some packages.",
)
@click.argument("package-or-module", type=click.Path(exists=True, readable=True, resolve_path=True), nargs=-1)
@click.pass_context
def register(
Expand All @@ -135,6 +143,7 @@ def register(
dry_run: bool,
activate_launchplans: bool,
env: typing.Optional[typing.Dict[str, str]],
skip_errors: bool,
):
"""
see help
Expand Down Expand Up @@ -187,6 +196,7 @@ def register(
env=env,
dry_run=dry_run,
activate_launchplans=activate_launchplans,
skip_errors=skip_errors,
)
except Exception as e:
raise e
22 changes: 14 additions & 8 deletions flytekit/tools/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
env: typing.Optional[typing.Dict[str, str]],
dry_run: bool = False,
activate_launchplans: bool = False,
skip_errors: bool = False,
):
detected_root = find_common_root(package_or_module)
click.secho(f"Detected Root {detected_root}, using this to create deployable package...", fg="yellow")
Expand Down Expand Up @@ -276,14 +277,19 @@
secho(og_id, "")
try:
if not dry_run:
i = remote.raw_register(
cp_entity, serialization_settings, version=version, create_default_launchplan=False
)
secho(i)
if is_lp and activate_launchplans:
secho(og_id, "", op="Activation")
remote.activate_launchplan(i)
secho(i, reason="activated", op="Activation")
try:
i = remote.raw_register(
cp_entity, serialization_settings, version=version, create_default_launchplan=False
)
secho(i, state="success")
if is_lp and activate_launchplans:
secho(og_id, "", op="Activation")
remote.activate_launchplan(i)
secho(i, reason="activated", op="Activation")
except Exception as e:

Check warning on line 289 in flytekit/tools/repo.py

View check run for this annotation

Codecov / codecov/patch

flytekit/tools/repo.py#L286-L289

Added lines #L286 - L289 were not covered by tests
if not skip_errors:
raise e
secho(og_id, state="failed")

Check warning on line 292 in flytekit/tools/repo.py

View check run for this annotation

Codecov / codecov/patch

flytekit/tools/repo.py#L291-L292

Added lines #L291 - L292 were not covered by tests
else:
secho(og_id, reason="Dry run Mode!")
except RegistrationSkipped:
Expand Down