API reference: Sacred integration#
The Neptune–Sacred integration provides a Sacred observer that logs experiment metadata to Neptune.
Related
- For an in-depth tutorial, see Integrations ≫ Sacred integration guide.
- neptune-sacred repo on GitHub
NeptuneObserver
#
Logs Sacred experiment data to Neptune.
Parameters
Name | Type | Default | Description |
---|---|---|---|
run |
Run or Handler |
- | An existing run reference, as returned by neptune.init_run() , or a namespace handler. |
base_namespace |
str , optional |
"experiment" |
Namespace under which all metadata logged by the observer will be stored. |
Examples
Start a Neptune run:
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:
export NEPTUNE_API_TOKEN="h0dHBzOi8aHR0cHM6Lkc78ghs74kl0jvYh3Kb8"
export NEPTUNE_PROJECT="ml-team/classification"
You can, however, also pass them as arguments when initializing Neptune:
run = neptune.init_run(
api_token="h0dHBzOi8aHR0cHM6Lkc78ghs74kl0jvYh3Kb8", # your token here
project="ml-team/classification", # your full project name here
)
- 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!):
Create an experiment:
Add a Neptune observer:
from neptune.integrations.sacred import NeptuneObserver
ex.observers.append(NeptuneObserver(run=run))
Define the model and run the experiment: