Skip to content

Commit

Permalink
Print a more meaningful error message when fork parent does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kgodlewski committed Jan 14, 2025
1 parent 0dd8fa0 commit ac70f06
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/neptune_scale/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
sync,
)
from neptune_scale.storage.operations import DATA_DIR
from neptune_scale.util.styles import ensure_style_detected


@click.group()
Expand All @@ -33,6 +34,8 @@
)
@click.pass_context
def main(ctx: click.Context, path: Optional[str]) -> None:
ensure_style_detected()

ctx.ensure_object(dict)
if path is None:
neptune_dir = Path(".") / DATA_DIR
Expand Down
23 changes: 17 additions & 6 deletions src/neptune_scale/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
list_runs,
)
from neptune_scale.util import get_logger
from neptune_scale.util.styles import STYLES


@dataclass
Expand Down Expand Up @@ -216,13 +217,23 @@ def _verify_fork_parent(local_run: LocalRun, parent_must_exist: bool) -> None:
return
time.sleep(2**i)

msg = f"Parent Run `{local_run.fork_run_id}` does not exist."

if parent_must_exist:
logger.error(msg)
raise NeptuneRunForkParentNotFound()

msg += " Proceeding because --sync-no-parent was passed."
msg = """
{h1}
Parent Run `{fork_run_id}` does not exist.
{end}
This can happen if the parent run was created in offline mode and is not yet
synced to the Neptune backend.
Run {bash}neptune status -v{end} to list all local runs, and manually sync the parent
run first using {bash}neptune sync <filename>{end}.
Alternatively you can run {bash}neptune sync --sync-no-parent{end} to ignore this error,
and proceed with syncing the without the parent run.
"""
raise Exception(msg.format(fork_run_id=local_run.fork_run_id, **STYLES))

msg = f"Parent Run `{local_run.fork_run_id}` does not exist. Proceeding because --sync-no-parent was passed."
logger.warning(msg)


Expand Down

0 comments on commit ac70f06

Please sign in to comment.