You're viewing docs for the deprecated Fetcher API.
We recommend upgrading to the new Query API.
Set context for Fetcher API
To work with multiple projects simultaneously, use contexts. This way, you can set the scope for individual fetching calls or globally for your session.
-
To set a new project or API token globally, use
set_project()
orset_api_token()
:import neptune_fetcher.alpha as npt
npt.set_project("some-workspace/another-project") -
To create a context object that you can pass to the
context
argument of a fetching method, useget_context()
to copy the global context and set a different project or API token:another_project_context = npt.get_context().with_project("some-workspace/another-project")
npt.list_experiments(r"exp_.*", context=another_project_context)
Example flow
-
NEPTUNE_PROJECT
environment variable is read on module initialization:import neptune_fetcher.alpha as npt
-
Work on the default project inferred from the environment variables:
npt.list_experiments(r"exp_.*")
Output['exp_dhxxz', 'exp_saazg', 'exp_sxlrq', 'exp_vlqfe', 'exp_fpogj']
-
Work on another project without changing the global context:
another_project_ctx = npt.get_context().with_project("some-workspace/another-project")
npt.list_experiments(r"exp_.*", context=another_project_ctx)Output['exp_oecez', 'exp_ytbda', 'exp_khfym']
-
Change the project globally:
npt.set_project("some-workspace/another-project")
-
Do some more work on another project:
npt.list_experiments(r"exp_.*")
Output['exp_oecez', 'exp_ytbda', 'exp_khfym']