Login API#
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 toNone
. - port
int
: The port on which the Hopsworks instance can be reached, defaults to443
. - 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'] | Literal['spark-no-metastore'] | Literal['spark-delta']
: Specifies the engine to use. Possible options are "spark", "python", "training", "spark-no-metastore", or "spark-delta". The default value is None, which automatically selects the engine based on the environment: "spark": Used if Spark is available, such as in Hopsworks or Databricks environments. "python": Used in local Python environments or AWS SageMaker when Spark is not available. "training": Used when only feature store metadata is needed, such as for obtaining training dataset locations and label information during Hopsworks training experiments. "spark-no-metastore": Functions like "spark" but does not rely on the Hive metastore. "spark-delta": Minimizes dependencies further by avoiding both Hive metastore and HopsFS.
Returns
Project
: The Project object to perform operations on
Raises
RestAPIError
: If unable to connect to HopsworksHopsworksSSLClientError
: If SSLError is raised from underlying requests library
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#
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#
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#
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