Skip to content

Environment API#

Handle#

[source]

get_environment_api#

Project.get_environment_api()

Get the Python environment AP

Returns

EnvironmentApi: The Python Environment Api handle


Creation#

[source]

create_environment#

EnvironmentApi.create_environment(
    name, description=None, base_environment_name="python-feature-pipeline", await_creation=True
)

Create Python environment for the project

import hopsworks

project = hopsworks.login()

env_api = project.get_environment_api()

new_env = env_api.create_environment("my_custom_environment", base_environment_name="python-feature-pipeline")
Arguments

  • name str: name of the environment
  • base_environment_name str | None: the name of the environment to clone from
  • await_creation bool | None: bool. If True the method returns only when the creation is finished. Default True

Returns

Environment: The Environment object

Raises

  • RestAPIError: If unable to create the environment

Retrieval#

[source]

get_environment#

EnvironmentApi.get_environment(name)

Get handle for the Python environment for the project

import hopsworks

project = hopsworks.login()

env_api = project.get_environment_api()

env = env_api.get_environment("my_custom_environment")
Arguments

  • name str: name of the environment

Returns

Environment: The Environment object

Raises

  • RestAPIError: If unable to get the environment

Methods#

[source]

delete#

Environment.delete()

Delete the environment

Potentially dangerous operation

This operation deletes the python environment.

Raises

RestAPIError.


[source]

install_requirements#

Environment.install_requirements(path, await_installation=True)

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)

Arguments

  • path str: str. The path on Hopsworks where the requirements.txt file is located
  • await_installation bool | None: bool. If True the method returns only when the installation is finished. Default True

Returns

Library: The library object


[source]

install_wheel#

Environment.install_wheel(path, await_installation=True)

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)

Arguments

  • path str: str. The path on Hopsworks where the wheel file is located
  • await_installation bool | None: bool. If True the method returns only when the installation finishes. Default True

Returns

Library: The library object