You can track data to Neptune using one of the four connection modes:
You can select mode by providing
mode parameter to the
import neptune.new as neptune# A default connection mode is the asynchronous mode# Other possible values are "async", "sync", "offline", "debug"CONNECTION_MODE = "async"run = neptune.init(name="My new run", mode=CONNECTION_MODE)
All tracking calls (like
save()) are non-blocking. The tracked data is temporarily stored on the local disk and synchronized with the Neptune server in the background (by a separate synchronization thread).
We recommend using Neptune with persistent disks to be able to restore tracked data in case your machine got restarted (e.g. spot instances) or in case there were some connectivity issues with Neptune servers.
Neptune triggers disk flushing:
Every 5 seconds (this period is configurable, see
When you invoke
At the end of the run (destruction of the
Tracking calls in asynchronous mode do not throw exceptions related to connectivity or metadata consistency issues (more in the distributed computing section). Issues related to connectivity or metadata consistency issues will be printed to
When you use asynchronous (default) connection mode and there is a problem with the connection to Neptune servers (e.g. caused by Internet connectivity issues), the Neptune Client Library will try to re-establish the connection in the background.
When your run is finished and the connection has not been reestablished in the last 5 minutes, Neptune will make sure that all the unsuccessful tracking calls are stored on the local disk and will kill the synchronization thread. As in offline mode, the tracked data from the local disk can be uploaded later via
Tracking calls return only after the Neptune server responds that the data was stored.
import neptune.new as neptunerun = neptune.init(name="My new run", mode="sync")
In this mode, no connection to Neptune servers is established. Instead, all the tracked metadata is stored on the local disk and can be uploaded to Neptune servers manually via
neptune sync command.
import neptune.new as neptunerun = neptune.init(name="My new run", mode="offline")
Whether you experience connectivity issues or you are working in offline mode your data is stored safely locally. You can use Neptune CLI (Command Line Interface) to check the synchronization status and synchronize data with Neptune servers.
You can list unsynchronized runs by using
# List unsynchronized runs in the current directoryneptune status# List unsynchronized runs in the given pathneptune status --path PATH_TO_DIRECTORY# Access status command help and examplesneptune status --help
Synchronize local data with Neptune servers with
# Synchronize all runs in the current directoryneptune sync# Synchronize all runs in the given pathneptune sync --path PATH_TO_DIRECTORY# Synchronize only runs NPT-42 and NPT-43neptune sync -run workspace/project/NPT-42 -run workspace/project/NPT-43# Synchronise all runs in the current directory# sending offline runs to project "workspace/project"neptune sync -p workspace/project# Synchronize the offline run a1561719-b425-4000-a65a-b5efb044d6bb# to project "workspace/project"neptune sync -p workspace/project -run offline/a1561719-b425-4000-a65a-b5efb044d6bb# Access sync command help and examplespython -m neptune.new.cli sync --help
Debug mode can come in handy when you are debugging your code and would like to not pollute your project. In this mode, no calls are made to Neptune servers, regardless of what happens in the code. In contrast to Offline mode, all data are stored only in memory.
import neptune.new as neptunerun = neptune.init(name="My new run", mode="debug")