Run
Python package: neptune-scale
Representation of experiment tracking run logged with Neptune Scale.
By default, Neptune periodically synchronizes the data with the servers in the background. The connection to Neptune remains open until the run is stopped or the script finishes executing.
Initialization
Initialize with the class constructor:
from neptune_scale import Run
run = Run(...)
Or with a context manager:
from neptune_scale import Run
with Run(...) as run:
...
Parameters
Name | Type | Default | Description |
---|---|---|---|
run_id | str | - | Identifier of the run. Max length: 128 bytes. The custom run ID provided to the |
project | str , optional | None | Name of a project in the form workspace-name/project-name . If None , the value of the NEPTUNE_PROJECT environment variable is used. |
api_token | str , optional | None | Your Neptune API token or a service account's API token. If None , the value of the NEPTUNE_API_TOKEN environment variable is used. To keep your token secure, don't place it in source code. Instead, save it as an environment variable. |
resume | bool , optional | False | If False , creates a new run.To continue an existing run, set to True and pass the ID of an existing run to the run_id argument. To fork a run, use fork_run_id and fork_step instead. |
mode | "async" or "disabled" | "async" | Mode of operation. If set to "disabled" , the run doesn't log any metadata. |
experiment_name | str , optional | None | Name of the experiment to associate the run with. To make the name easy to read in the app, ensure that it's at most 190 characters long. |
creation_time | datetime , optional | datetime.now() | Custom creation time of the run. If not provided, the current time is used. If provided, and timestamp.tzinfo is not set, the time is assumed to be in the local timezone. |
fork_run_id | str , optional | None | The ID of the run to fork from. |
fork_step | int , optional | None | The step number to fork from. |
max_queue_size | int , optional | 1000000 | Maximum number of operations queued for processing. 1 000 000 by default. You should raise this value if you see the on_queue_full_callback function being called. |
on_queue_full_callback | Callable[[BaseException, Optional[float]], None] , optional | None | Callback function triggered when the queue is full. The function must take as an argument the exception that made the queue full and, as an optional argument, a timestamp of when the exception was last raised. |
on_network_error_callback | Callable[[BaseException, Optional[float]], None] , optional | None | Callback function triggered when a network error occurs. |
on_error_callback | Callable[[BaseException, Optional[float]], None] , optional | None | The default callback function triggered when an unrecoverable error occurs. Applies if an error wasn't caught by other callbacks. In this callback you can choose to perform your cleanup operations and close the training script. For how to end the run in this case, use terminate() . |
on_warning_callback | Callable[[BaseException, Optional[float]], None] , optional | None | Callback function triggered when a warning occurs. |
Examples
Create a run:
from neptune_scale import Run
with Run(
run_id="likable-barracuda",
experiment_name="swim-further",
) as run:
...
Create a run and pass Neptune credentials as arguments:
from neptune_scale import Run
with Run(
project="team-alpha/project-x",
api_token="h0dHBzOi8aHR0cHM6...Y2MifQ==",
run_id="likable-barracuda",
experiment_name="swim-further",
) as run:
...
For help, see Create an experiment.
To restart (fork) an experiment, create a forked run:
with Run(
run_id="adventurous-barracuda",
experiment_name="swim-further",
fork_run_id="likable-barracuda",
fork_step=102,
) as run:
...
Resume a run:
with Run(
run_id="likable-barracuda", # a Neptune run with this ID already exists
resume=True,
) as run:
...
Create a non-experiment run:
with Run(run_id="likable-barracuda") as run:
...
Forking and history is only supported for experiment runs.
To take advantage of these and other features that concern analysis of multiple related runs, create experiments rather than stand-alone runs.
Methods
Method | Description |
---|---|
log_configs() | Logs the specified metadata to a Neptune run. |
log_metrics() | Logs the specified metrics to a Neptune run. |
add_tags() | Adds the list of tags to the run. |
remove_tags() | Removes the specified tags from the run. |
wait_for_submission() | Waits until all metadata is submitted to Neptune for processing. |
wait_for_processing() | Waits until all metadata is processed by Neptune. |
close() | Waits for all locally queued data to be processed by Neptune and closes the run. |
terminate() | Terminates the failed run in the error callback. |