GuidesAPI reference
DiscordDashboard
DiscordDashboard

pipeline.objects.environment.Environment

Environment - class

Source on GitHub

pipeline.objects.environment.Environment(
	environment_name: str = None,
  dependencies: List[str] = [],
)

Description

The Environment object for creating and managing pipeline dependencies and virtual environments.

Parameters

  • environment_name (str, optional) - name of the environment.
  • dependencies (List[str], optional) - dependencies for the environment.

Functions

to_requirements(self, output_dir: str = "./") -> None

Description

Creates a requirements.txt file from the dependencies listed in the environment object.

Parameters

  • output_dir, (str, optional) - the directory to write the requirements.txt file.

add_dependency(self, dependency: str) -> None

Description

Add an additional dependency to the environment.

Parameters

  • dependency, (str) - the dependency package string to add to the dependency list.

from_requirements(cls, requirements_path: str, environment_name: str = None) -> Environment

Description

Creates an Environment object from a requirements.txt file.

Parameters

  • requirements_path (str) - the path to the requirements file to extract dependencies from.
  • environment_name (str, optional) - the name for the environment.

from_current(cls, environment_name: str = None) -> Environment

Description

Creates an Environment object with dependencies from the environment currently being used.

Parameters

  • environment_name (str, optional) - name for the environment.

Examples

from pipeline.objects.environment import Environment

# Create a basic env with the minimum transformers dependencies
env = Environment(
    "transformers-env",
    dependencies=[
        "transformers==4.24.0",
        "torch==1.13.0",
    ],
)

# Write dependencies to file
env.to_requirements()