Skip to content

Login API#

[source]

login#

hopsworks.login(host=None, port=443, project=None, api_key_value=None, api_key_file=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 and HOPSWORKS_API_KEY.

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

Returns

Project: The Project object to perform operations on

Raises

  • RestAPIError: If unable to connect to Hopsworks

[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, engine=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.
  • engine str | None: Which engine to use, "spark", "python" or "training". Defaults to "python" when connected to Serverless Hopsworks. See hsfs.Connection.connection documentation for more information.

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