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(await_creation=True)

Create Python environment for the project

import hopsworks

project = hopsworks.login()

env_api = project.get_environment_api()

env = env_api.create_environment()
Arguments

  • await_creation: 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()

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()
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()
env.install_requirements(requirements_path)

Arguments

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

[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()
env.install_wheel(whl_path)

Arguments

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