neptune.sessions
¶
Module Contents¶
Classes¶
|
A class for running communication with Neptune. |
-
neptune.sessions.
_logger
¶
-
class
neptune.sessions.
Session
(api_token=None, proxies=None, backend=None)[source]¶ Bases:
object
A class for running communication with Neptune.
In order to query Neptune experiments you need to instantiate this object first.
- Parameters
backend (
Backend
, optional, default isNone
) –By default, Neptune client library sends logs, metrics, images, etc to Neptune servers: either publicly available SaaS, or an on-premises installation.
You can pass the default backend instance explicitly to specify its parameters:
from neptune import Session, HostedNeptuneBackend session = Session(backend=HostedNeptuneBackend(...))
Passing an instance of
OfflineBackend
makes your code run without communicating with Neptune servers.from neptune import Session, OfflineBackend session = Session(backend=OfflineBackend())
api_token (
str
, optional, default isNone
) –User’s API token. If
None
, the value ofNEPTUNE_API_TOKEN
environment variable will be taken. Parameter is ignored ifbackend
is passed.Deprecated since version 0.4.4.
Instead, use:
from neptune import Session session = Session.with_default_backend(api_token='...')
proxies (
str
, optional, default isNone
) –Argument passed to HTTP calls made via the Requests library. For more information see their proxies section. Parameter is ignored if
backend
is passed.Deprecated since version 0.4.4.
Instead, use:
from neptune import Session, HostedNeptuneBackend session = Session(backend=HostedNeptuneBackend(proxies=...))
Examples
Create session, assuming you have created an environment variable
NEPTUNE_API_TOKEN
from neptune import Session session = Session.with_default_backend()
Create session and pass
api_token
from neptune import Session session = Session.with_default_backend(api_token='...')
Create an offline session
from neptune import Session, OfflineBackend session = Session(backend=OfflineBackend())
-
classmethod
with_default_backend
(cls, api_token=None)[source]¶ The simplest way to instantiate a
Session
.- Parameters
api_token (
str
) – User’s API token. IfNone
, the value ofNEPTUNE_API_TOKEN
environment variable will be taken.
Examples
from neptune import Session session = Session.with_default_backend()
-
get_project
(self, project_qualified_name)[source]¶ Get a project with given
project_qualified_name
.In order to access experiments data one needs to get a
Project
object first. This method gives you the ability to do that.- Parameters
project_qualified_name (
str
) – Qualified name of a project in a form ofnamespace/project_name
.- Returns
Project
object.
- Raise:
ProjectNotFound
: When a project with given name does not exist.
Examples
# Create a Session instance from neptune.sessions import Session session = Session() # Get a project by it's ``project_qualified_name``: my_project = session.get_project('namespace/project_name')
-
get_projects
(self, namespace)[source]¶ Get all projects that you have permissions to see in given workspace.
This method gets you all available projects names and their correspondingProject
objects.Both private and public projects may be returned for the workspace. If you have role in private project, it is included.You can retrieve all the public projects that belong to any user or workspace, as long as you know their username or workspace name.- Parameters
namespace (
str
) – It can either be name of the workspace or username.- Returns
OrderedDict
- keys are
project_qualified_name
that is: ‘workspace/project_name’values are correspondingProject
objects.
- Raises
NamespaceNotFound – When the given namespace does not exist.
Examples
# create Session from neptune.sessions import Session session = Session() # Now, you can list all the projects available for a selected namespace. # You can use `YOUR_NAMESPACE` which is your workspace or user name. # You can also list public projects created in other workspaces. # For example you can use the `neptune-ai` namespace. session.get_projects('neptune-ai') # Example output: # OrderedDict([('neptune-ai/credit-default-prediction', # Project(neptune-ai/credit-default-prediction)), # ('neptune-ai/GStore-Customer-Revenue-Prediction', # Project(neptune-ai/GStore-Customer-Revenue-Prediction)), # ('neptune-ai/human-protein-atlas', # Project(neptune-ai/human-protein-atlas)), # ('neptune-ai/Ships', # Project(neptune-ai/Ships)), # ('neptune-ai/Mapping-Challenge', # Project(neptune-ai/Mapping-Challenge)) # ])