From ac70f065676ecf3079a6dd7b88ff61e4222bc29d Mon Sep 17 00:00:00 2001 From: Krzysztof Godlewski Date: Tue, 14 Jan 2025 14:34:10 +0100 Subject: [PATCH] Print a more meaningful error message when fork parent does not exist --- src/neptune_scale/cli/main.py | 3 +++ src/neptune_scale/cli/sync.py | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/neptune_scale/cli/main.py b/src/neptune_scale/cli/main.py index d3927b1..8e4921d 100644 --- a/src/neptune_scale/cli/main.py +++ b/src/neptune_scale/cli/main.py @@ -23,6 +23,7 @@ sync, ) from neptune_scale.storage.operations import DATA_DIR +from neptune_scale.util.styles import ensure_style_detected @click.group() @@ -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 diff --git a/src/neptune_scale/cli/sync.py b/src/neptune_scale/cli/sync.py index 8e4b0e8..b9be1d2 100644 --- a/src/neptune_scale/cli/sync.py +++ b/src/neptune_scale/cli/sync.py @@ -53,6 +53,7 @@ list_runs, ) from neptune_scale.util import get_logger +from neptune_scale.util.styles import STYLES @dataclass @@ -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 {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)