How to use Neptune with argparse#
You can use Neptune to log parameters defined with argparse .
Before you start#
- Sign up at neptune.ai/register.
- Create a project for storing your metadata.
Have argparse and Neptune installed:
neptune-client already installed
Important: To smoothly upgrade to the
1.0 version of the Neptune client library, first uninstall the
neptune-client library and then install
Logging parameters with argparse#
Import Neptune and start a run:
If you haven't set up your credentials, you can log anonymously:
Specify and parse the arguments.
Log the parsed arguments to a namespace in the run:
Inside the namespace, Neptune creates a field for each argument.
To stop the connection to Neptune and sync all data, call the
Run your script as you normally would.
The general format is
https://app.neptune.ai/<workspace>/<project> followed by the Neptune ID of the initialized object.
If Neptune can't find your project name or API token
As a best practice, you should save your Neptune API token and project name as environment variables:
You can, however, also pass them as arguments when initializing Neptune:
- API token: In the bottom-left corner, expand the user menu and select Get my API token.
- Project name: in the top-right menu: → Edit project details.
If you haven't registered, you can also log anonymously to a public project (make sure not to publish sensitive data through your code!):
Follow the run link and explore the logged parameters in the All metadata dashboard.
You can also use
Namespace() to define the args: