Neptune

neptune

neptune is a global object that you can use to start new tracked runs or re-connect to already existing ones. It also provides some convenience functionalities like obtaining the last created run.

.init()

Convenience alias for .init_run().

.init_model()

Initializes a Model object with an existing or new model.
You can use this method to create a new model from code or to perform actions on existing models.
Parameters
model
(str, optional, default is None) - An identifier of an existing model, for example "SUN-PRED". If not None, the model object will be initialized with the existing model instead of creating a new one. The identifier is stored in the object's sys/id field.
name
(str, optional, default is "Untitled") - A name for the new model.
key
(str, optional, default is None) - A key for the new model. Must be uppercase and unique within the workspace; that is, two models in the same workspace cannot have the same key. Required when creating a new model.
project
(str, optional, default is None) – Name of a project in a form of MY_WORKSPACE/MY_PROJECT. If None, the value of NEPTUNE_PROJECT environment variable will be taken.
api_token
(str, optional, default is None) – User’s API token. If None, the value of NEPTUNE_API_TOKEN environment variable will be taken.
Note: It is strongly recommended to use NEPTUNE_API_TOKEN environment variable rather than placing your API token in plain text in your source code.
mode
(str, optional, default is "async") – Connection mode in which the tracking will work. Possible values "async", "sync", "read-only", and "debug". See the Connection modes guide.
flush_period
(float, optional, default is 5) - In an asynchronous (default) connection mode, how often an asynchronous thread should synchronize data with Neptune servers. Value in seconds.
proxies
(dict, optional, default is None) - Argument passed to HTTP calls made via the Requests library. For more information, see the Proxies section.

Returns

Model object that is used to manage the model and log metadata to it.

Examples

1
import neptune.new as neptune
2
3
# Create a new model
4
model = neptune.init_model(key="PRED")
5
6
# You can provide the project parameter as an environment variable
7
# or directly in the init_model function.
8
model = neptune.init_model(key="PRED", project="MY_WORKSPACE/MY_PROJECT")
9
10
# When creating a model you can specify its name as well
11
model = neptune.init_model(key="PRED", name="Sales prediction")
12
13
# Initialize model object with an existing model with identifier "SUN-PRED"
14
model = neptune.init_model(model="SUN-PRED")
15
16
# When you are connecting to an existing model in order to fetch data only,
17
# you can connect to it in a read-only mode that prevents any modifications.
18
model = neptune.init_model(model="SUN-PRED", mode="read-only")
Copied!

.init_model_version()

Initializes a Model version object with an existing or new model version.
You can use this method to create a new version of a model. You can also use it to resume work on an existing model version, fetch or update metadata, request a stage change transition, or change the stage directly.
Parameters
version
(str, optional, default is None) - An identifier of an existing model version e.g. "SUN-PRED-11". If not None, the model version object will be initialized with the existing model version instead of creating a new one.
name
(str, optional, default is "Untitled") - A name of the new model.
model
(str, optional, default is None) - An identifier of the model for which the new version should be created. Required when creating a new model version. The identifier is stored in the object's sys/id field.
project
(str, optional, default is None) – Name of the project in the form of WORKSPACE_NAME/PROJECT_NAME. If None, the value of NEPTUNE_PROJECT environment variable will be taken.
api_token
(str, optional, default is None) – User’s API token. If None, the value of NEPTUNE_API_TOKEN environment variable will be taken.
Note: It is strongly recommended to use NEPTUNE_API_TOKEN environment variable rather than placing your API token in plain text in your source code.
mode
(str, optional, default is "async") – Connection mode in which the tracking will work. Possible values "async", "sync", "read-only", and "debug". See the Connection modes guide.
flush_period
(float, optional, default is 5) - In an asynchronous (default) connection mode how often asynchronous thread should synchronize data with Neptune servers. Value in seconds.
proxies
(dict, optional, default is None) - Argument passed to HTTP calls made via the Requests library. For more information, see the Proxies section.

Returns

Model version object that is used to manage the model version and log metadata to it.

Examples

1
import neptune.new as neptune
2
3
# Create a new model version for a model with identifier "PROJ-PRED".
4
model_version = neptune.init_model_version(model="SUN-PRED")
5
6
# You can provide the project parameter as an environment variable
7
# or directly in the init_model_version function.
8
model_version = neptune.init_model_version(
9
model="SUN-PRED",
10
project="MY_WORKSPACE/MY_PROJECT",
11
)
12
13
# Initialize model version object with an existing model version
14
# with identifier "SUN-PRED-12"
15
model_version = neptune.init_model(version="SUN-PRED-12")
16
17
# When you are connecting to an existing model version in order to fetch data,
18
# you can connect to it in a read-only mode that prevents any modifications.
19
model_version = neptune.init_model(version="SUN-PRED-12", mode="read-only")
Copied!

.init_run()

Starts a new tracked run, and append it to the top of the Runs table view. All parameters are optional, hence minimal invocation: run = neptune.init().
Parameters
project
(str, optional, default is None) – Name of a project in a form of MY_WORKSPACE/MY_PROJECT. If None, the value of NEPTUNE_PROJECT environment variable will be taken.
api_token
(str, optional, default is None) – User’s API token. If None, the value of NEPTUNE_API_TOKEN environment variable will be taken.
Note: It is strongly recommended to use NEPTUNE_API_TOKEN environment variable rather than placing your API token in plain text in your source code.
run
(str, optional, default is None) – An existing run's identifier like"SAN-1" in case of resuming a tracked run. A run with such identifier must exist. The identifier is stored in the object's sys/id field. If None is passed, starts a new tracked run. See Resume run guide.
custom_run_id
(str, optional, default is None) – A unique identifier that can be used to log metadata to a single run from multiple files or processes. The maximum length of the identifier is 32 characters. Make sure you are using the same identifier everywhere. See Pipelines guide.
If None and the NEPTUNE_CUSTOM_RUN_ID environment variable is set Neptune will use its value as custom_run_id.
mode
(str, optional, default is "async") – Connection mode in which the tracking will work. Possible values "async", "sync", "offline", "read-only", and "debug". See the Connection modes guide.
name
(str, optional, default is "Untitled") – Editable name of the run. Name is displayed in the run's Details and in Runs table as a column.
description
(str, optional, default is "") – Editable description of the run. Description is displayed in the run's Details and can be displayed in the runs view as a column.
tags
(list, optional, default is []) – Must be a list of str. Tags of the run. They are editable after run is created. Tags are displayed in the run's Details and can be viewed in Runs table view as a column.
source_files
(list or str, optional, default is None) – List of source files to be uploaded. Must be list of str or single str. Uploaded sources are displayed in the run’s Source code tab.
If None is passed, the Python file from which the run was created will be uploaded. In case of resuming the run no file will be uploaded by default.
Pass empty list ([]) to upload no files.
Unix style pathname pattern expansion is supported. For example, you can pass ".py" to upload all python source files from the current directory. For Python 3.5 or later, paths of uploaded files on server are resolved as relative to the calculated common root of all uploaded source files. For older Python versions, paths on server are resolved always as relative to the current directory. For recursion lookup use '**/.py' (for Python 3.5 and later). For more information see glob library.
capture_stdout
(Boolean, optional, default is True) – Whether to send run's stdout. Tracked metadata will be stored inside monitoring_namespace.
capture_stderr
(Boolean, optional, default is True) – Whether to send run’s stderr. Tracked metadata will be stored inside monitoring_namespace.
capture_hardware_metrics
(Boolean, optional, default is True) – Whether to send hardware monitoring logs (CPU, GPU, Memory utilization). Tracked metadata will be stored inside monitoring_namespace.
capture_traceback
(Boolean, optional, default is True) – Whether to send run’s traceback in case of an exception.
monitoring_namespace
(str, optional, default is 'monitoring') - Namespace inside which all monitoring logs be stored.
fail_on_exception
(Boolean, optional, default is True) – Whether to set run's Failed state as True, if an uncaught exception happens.
flush_period
(float, optional, default is 5) - In an asynchronous (default) connection mode how often asynchronous thread should synchronize data with Neptune servers. Value in seconds.
proxies
(dict, optional, default is None) - Argument passed to HTTP calls made via the Requests library. For more information see their proxies section.

Returns

Run object that is used to manage the tracked run and log metadata to it.

Examples

1
import neptune.new as neptune
2
3
# minimal invoke
4
run = neptune.init()
5
6
# create a tracked run with a name
7
run = neptune.init(name='first-pytorch-ever')
8
9
# create a tracked run with a name and a description, and no sources files uploaded
10
run = neptune.init(name='neural-net-mnist',
11
description='neural net trained on MNIST',
12
source_files=[])
13
14
# Send all py files in cwd (excluding hidden files with names beginning with a dot)
15
run = neptune.init(source_files='*.py')
16
17
# Send all py files from all subdirectories (excluding hidden files with names beginning with a dot)
18
# Supported on Python 3.5 and later.
19
run = neptune.init(source_files='**/*.py')
20
21
# Send all files and directories in cwd (excluding hidden files with names beginning with a dot)
22
run = neptune.init(source_files='*')
23
24
# Send all files and directories in cwd including hidden files
25
run = neptune.init(source_files=['*', '.*'])
26
27
# Send files with names being a single character followed by '.py' extension.
28
run = neptune.init(source_files='?.py')
29
30
# larger example
31
run = neptune.init(name='first-pytorch-ever',
32
description='write longer description here',
33
tags=['list-of', 'tags', 'goes-here', 'as-list-of-strings'],
34
source_files=['training_with_pytorch.py', 'net.py'])
Copied!

.get_last_run()

Returns last created Run object.

Returns

Run object last created by neptune global object.

Examples

1
import neptune.new as neptune
2
3
# Crate a new tracked run
4
neptune.init(name='A new approach', source_files='**/*.py')
5
# Oops! We didn't capture the reference to the Run object
6
7
# Not a problem! We've got you covered.
8
run = neptune.get_last_run()
Copied!

.init_project()

Starts a connection to an existing Neptune project. You can use it to retrieve information about Runs, Models, and its Model versions within the project. You can also log (and retrieve) metadata on a project level such as information about datasets, links to documentations, key project metrics etc.
Parameters
name
(str, optional, default is None) – Name of a project in a form of "MY_WORKSPACE/MY_PROJECT". If None, the value of NEPTUNE_PROJECT environment variable will be taken.
api_token
(str, optional, default is None) – User’s API token. If None, the value of NEPTUNE_API_TOKEN environment variable will be taken.
Note: It is strongly recommended to use NEPTUNE_API_TOKEN environment variable rather than placing your API token in plain text in your source code.
mode
(str, optional, default is 'async') – Connection mode in which the tracking will work. Possible values "async", "sync", "debug", and "read-only". See Connection modes guide.
flush_period
(float, optional, default is 5) - In an asynchronous (default) connection mode how often asynchronous thread should synchronize data with Neptune servers. Value in seconds.
proxies
(dict, optional, default is None) - Argument passed to HTTP calls made via the Requests library. For more information see their proxies section.

Returns

Project object that can be used to interact with the project as a whole like fetching its metadata or fetching data from Runs table.

Examples

1
import neptune.new as neptune
2
3
# Connect to a project "MY_PROJECT" in workspace "MY_WORKSPACE"
4
project = neptune.init_project(name="MY_WORKSPACE/MY_PROJECT")
5
6
7
# Connect to a project in read-only mode
8
project = neptune.init_project(name="MY_WORKSPACE/MY_PROJECT", mode="read-only")
Copied!

.get_project()

Initialize a connection to a project in read-only mode with given. Equivalent to neptune.init_project(mode="read-only").
Parameters
name
(str, optional, default is None) – Name of a project in a form of "MY_WORKSPACE/MY_PROJECT". If None, the value of NEPTUNE_PROJECT environment variable will be taken.
api_token
(str, optional, default is None) – User’s API token. If None, the value of NEPTUNE_API_TOKEN environment variable will be taken.
Note: It is strongly recommended to use NEPTUNE_API_TOKEN environment variable rather than placing your API token in plain text in your source code.
proxies
(dict, optional, default is None) - Argument passed to HTTP calls made via the Requests library. For more information see their proxies section.

Returns

Project object that can be used to interact with the project as a whole, like fetching its metadata or fetching data from the runs table.

Examples

1
import neptune.new as neptune
2
3
# Fetch project 'jack/sandbox'
4
project = neptune.get_project(name='jack/sandbox')
5
6
# Fetch all Runs metadata as Pandas DataFrame
7
runs_table_df = project.fetch_runs_table().to_pandas()
Copied!

.ANONYMOUS

Anonymous user API token. See ANONYMOUS_API_TOKEN.

.ANONYMOUS_API_TOKEN

Anonymous user API token. You can use this value for the api_token parameter of the .init() method, either by passing it as an argument or by saving it as an environment variable.
1
# Start a run as an anonymous user
2
run = neptune.init(
3
api_token="ANONYMOUS_API_TOKEN",
4
project="common/quickstarts",
5
)
Copied!