Skip to content

Commit

Permalink
Print more info in neptune sync and neptune status
Browse files Browse the repository at this point in the history
  • Loading branch information
kgodlewski committed Jan 8, 2025
1 parent ab3dbab commit b35269d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
14 changes: 5 additions & 9 deletions src/neptune_scale/cli/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import click

from neptune_scale.cli.util import is_neptune_dir
from neptune_scale.cli.util import (
format_local_run,
is_neptune_dir,
)
from neptune_scale.storage.operations import list_runs


Expand All @@ -14,12 +17,5 @@ def status(ctx: click.Context, verbose: bool) -> None:
sys.exit(1)

for run in list_runs(ctx.obj["neptune_dir"]):
pct = round(run.last_synced_operation / run.operation_count * 100, 2)
line = (
f"Project: {run.project}, Run ID: {run.run_id}, "
f"{run.last_synced_operation}/{run.operation_count} ({pct}%) synced"
)
if verbose:
line = f"{run.path}: {line}"

line = format_local_run(run, verbose)
print(line)
11 changes: 7 additions & 4 deletions src/neptune_scale/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from neptune_scale import Run
from neptune_scale.cli.util import (
format_duration,
format_local_run,
is_neptune_dir,
)
from neptune_scale.exceptions import (
Expand Down Expand Up @@ -194,13 +195,16 @@ def _do_sync(reader: OperationReader, state: SyncState) -> None:


def sync_file(path: Path, allow_non_increasing_step: bool) -> None:
logger.info(f"Processing file {path}")
reader = OperationReader(path)
local_run = reader.run

logger.info(format_local_run(local_run))

if reader.pending_operations_count == 0:
logger.info("No operations to sync")
return

local_run = reader.run

resume = local_run.last_synced_operation > 0
if resume:
logger.info("Resuming sync")
Expand All @@ -224,7 +228,7 @@ def sync_file(path: Path, allow_non_increasing_step: bool) -> None:
)
state.run = run

updater = Thread(target=_db_updater_thread, args=(local_run.project, local_run.run_id, path, state))
updater = Thread(target=_db_updater_thread, args=(local_run.project, local_run.run_id, local_run.path, state))
updater.start()

try:
Expand Down Expand Up @@ -272,7 +276,6 @@ def sync(ctx: click.Context, filename: Optional[str], keep: bool, allow_non_incr
error = False

for path in files:
logger.info(f"Processing file {path}")
try:
sync_file(path, allow_non_increasing_step=allow_non_increasing_step)
if not keep:
Expand Down
17 changes: 17 additions & 0 deletions src/neptune_scale/cli/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path

from neptune_scale.storage.operations import LocalRun
from neptune_scale.util import get_logger

logger = get_logger()
Expand Down Expand Up @@ -32,3 +33,19 @@ def format_duration(seconds: int) -> str:
parts.append(f"{seconds}s")

return " ".join(parts)


def format_local_run(run: LocalRun, verbose: bool = False) -> str:
pct = round(run.last_synced_operation / run.operation_count * 100, 2)
parts = [f"Run ID: {run.run_id}, {run.last_synced_operation}/{run.operation_count} ({pct}%) synced"]

if run.experiment_name:
parts.append(f"Experiment: {run.experiment_name}")
if run.fork_run_id:
parts.append(f"Forked from `{run.fork_run_id}` at step {run.fork_step}")

line = ", ".join(parts)
if verbose:
line = f"{run.path}: Project: {run.project}, Created At: {run.creation_time}, {line}"

return line

0 comments on commit b35269d

Please sign in to comment.