Skip to content

Login API#

[source]

login#

hopsworks.login(
    host=None,
    port=443,
    project=None,
    api_key_value=None,
    api_key_file=None,
    hostname_verification=False,
    trust_store_path=None,
    engine=None,
)

Connect to Serverless Hopsworks by calling the hopsworks.login() function with no arguments.

Connect to Serverless

import hopsworks

project = hopsworks.login()

Alternatively, connect to your own Hopsworks installation by specifying the host, port and api key.

Connect to your Hopsworks cluster

import hopsworks

project = hopsworks.login(host="my.hopsworks.server",
                          port=8181,
                          api_key_value="DKN8DndwaAjdf98FFNSxwdVKx")

In addition to setting function arguments directly, hopsworks.login() also reads the environment variables: HOPSWORKS_HOST, HOPSWORKS_PORT, HOPSWORKS_PROJECT, HOPSWORKS_API_KEY, HOPSWORKS_HOSTNAME_VERIFICATION and HOPSWORKS_TRUST_STORE_PATH.

The function arguments do however take precedence over the environment variables in case both are set.

Arguments

  • host str | None: The hostname of the Hopsworks instance, defaults to None.
  • port int: The port on which the Hopsworks instance can be reached, defaults to 443.
  • project str | None: Name of the project to access. If used inside a Hopsworks environment it always gets the current project. If not provided you will be prompted to enter it.
  • api_key_value str | None: Value of the Api Key
  • api_key_file str | None: Path to file wih Api Key
  • hostname_verification bool: Whether to verify Hopsworks' certificate
  • trust_store_path str | None: Path on the file system containing the Hopsworks certificates
  • engine None | Literal['spark'] | Literal['python'] | Literal['training']: Which engine to use, "spark", "python" or "training". Defaults to None, which initializes the engine to Spark if the environment provides Spark, for example on Hopsworks and Databricks, or falls back to Python if Spark is not available, e.g. on local Python environments or AWS SageMaker. This option allows you to override this behaviour. "training" engine is useful when only feature store metadata is needed, for example training dataset location and label information when Hopsworks training experiment is conducted.

Returns

Project: The Project object to perform operations on

Raises

  • RestAPIError: If unable to connect to Hopsworks
  • HopsworksSSLClientError: If SSLError is raised from underlying requests library

[source]

get_current_project#

hopsworks.get_current_project()

Get a reference to the current logged in project.

Example for getting the project reference

import hopsworks

hopsworks.login()

project = hopsworks.get_current_project()

Returns

Project. The Project object to perform operations on


Feature Store API#

[source]

get_feature_store#

Project.get_feature_store(name=None)

Connect to Project's Feature Store.

Defaulting to the project name of default feature store. To get a shared feature store, the project name of the feature store is required.

Example for getting the Feature Store API of a project

import hopsworks

project = hopsworks.login()

fs = project.get_feature_store()

Arguments

  • name str | None: Project name of the feature store.

Returns

hsfs.feature_store.FeatureStore: The Feature Store API

Raises

  • RestAPIError: If unable to connect

Model Registry API#

[source]

get_model_registry#

Project.get_model_registry()

Connect to Project's Model Registry API.

Example for getting the Model Registry API of a project

import hopsworks

project = hopsworks.login()

mr = project.get_model_registry()

Returns

hsml.model_registry.ModelRegistry: The Model Registry API

Raises

  • RestAPIError: If unable to connect

Model Serving API#

[source]

get_model_serving#

Project.get_model_serving()

Connect to Project's Model Serving API.

Example for getting the Model Serving API of a project

import hopsworks

project = hopsworks.login()

ms = project.get_model_serving()

Returns

hsml.model_serving.ModelServing: The Model Serving API

Raises

  • RestAPIError: If unable to connect