Environment API#
To create an object of this class, use get_environment_api. You can then use the following methods of EnvironmentApi to create or get an Environment.
create_environment #
create_environment(
name: str,
description: str | None = None,
base_environment_name: str
| None = "python-feature-pipeline",
await_creation: bool | None = True,
) -> environment.Environment
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")
| PARAMETER | DESCRIPTION |
|---|---|
name | Name of the environment. TYPE: |
base_environment_name | The name of the environment to clone from. TYPE: |
await_creation | Whether the method returns only when the creation is finished. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
environment.Environment | The Environment object. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
get_environment #
get_environment(
name: str,
) -> environment.Environment | None
Get handle for a Python environment in the project.
import hopsworks
project = hopsworks.login()
env_api = project.get_environment_api()
env = env_api.get_environment("my_custom_environment")
| PARAMETER | DESCRIPTION |
|---|---|
name | Name of the environment. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
environment.Environment | None | The Environment object or |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
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 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 TYPE: |
await_installation | If TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Library | The library object. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |
install_wheel #
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: |
await_installation | If TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Library | The library object. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the backend encounters an error when handling the request. |