Skip to content

hopsworks.environment #

Environment #

description property #

Description of the environment.

name property #

Name of the environment.

python_version property #

Python version of the environment.

delete #

delete()

Delete the environment.

Potentially dangerous operation

This operation deletes the python environment.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

install_requirements #

install_requirements(
    path: str,
    await_installation: bool | None = True,
    timeout: float | None = None,
)

Install libraries specified in a requirements.txt file.

import hopsworks

project = hopsworks.login()

# Upload to Hopsworks
ds_api = project.get_dataset_api()
requirements_path = ds_api.upload("requirements.txt", "Resources")

# Install
env_api = project.get_environment_api()
env = env_api.get_environment("my_custom_environment")

env.install_requirements(requirements_path)
PARAMETER DESCRIPTION
path

The path in Hopsworks where the requirements.txt file is located.

TYPE: str

await_installation

If True the method returns only when the installation is finished.

TYPE: bool | None DEFAULT: True

timeout

Seconds to wait for the installation to finish before raising. Falls back to the engine's default when unset. It also bounds the wait for any environment command already in flight, which happens before the install is submitted and therefore applies even when await_installation is False.

TYPE: float | None DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

install_wheel #

install_wheel(
    path: str,
    await_installation: bool | None = True,
    timeout: float | None = None,
)

Install a python library packaged in a wheel file.

import hopsworks

project = hopsworks.login()

# Upload to Hopsworks
ds_api = project.get_dataset_api()
whl_path = ds_api.upload("matplotlib-3.1.3-cp38-cp38-manylinux1_x86_64.whl", "Resources")

# Install
env_api = project.get_environment_api()
env = env_api.get_environment("my_custom_environment")

env.install_wheel(whl_path)
PARAMETER DESCRIPTION
path

The path in Hopsworks where the wheel file is located.

TYPE: str

await_installation

If True the method returns only when the installation finishes.

TYPE: bool | None DEFAULT: True

timeout

Seconds to wait for the installation to finish before raising. Falls back to the engine's default when unset. It also bounds the wait for any environment command already in flight, which happens before the install is submitted and therefore applies even when await_installation is False.

TYPE: float | None DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

uninstall #

uninstall(
    library_name: str,
    await_uninstallation: bool | None = True,
    timeout: float | None = None,
) -> None

Uninstall a library from the environment.

import hopsworks

project = hopsworks.login()

env_api = project.get_environment_api()
env = env_api.get_environment("my_custom_environment")

env.uninstall("matplotlib")
PARAMETER DESCRIPTION
library_name

Name of the installed library to remove.

TYPE: str

await_uninstallation

If True the method returns only when the uninstallation finishes.

TYPE: bool | None DEFAULT: True

timeout

Seconds to wait for the uninstallation to finish before raising. Falls back to the engine's default when unset. It also bounds the wait for any environment command already in flight, which happens before the removal is submitted and therefore applies even when await_uninstallation is False.

TYPE: float | None DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.