env#

Environment object describing the conda environment.yaml file.

Classes#

Dependencies

A dict subclass that parses the raw dependencies into a conda and pip list

EnvironmentYaml

A class representing an environment.yaml file

Functions#

field_type_validation(→ None)

Validates the type of a value

prefix_validation(prefix)

Validate the contents of the prefix field.

name_validation(name)

Validate the contents of the name field.

dependencies_validation(dependencies)

Validate the contents of the dependencies field.

channels_validation(channels)

Validate the contents of the channels field.

variables_validation(variables)

Validate the contents of the variables field.

get_schema_errors(...)

Parses environment.yaml data to build a list of schema errors

validate_keys(data, kwargs)

Check for unknown keys, remove them and print a warning

from_environment(name, prefix[, no_builds, ...])

Build an EnvironmentYaml from an existing environment prefix.

from_yaml(→ EnvironmentYaml)

Load and return a EnvironmentYaml from a given yaml string

_expand_channels(data)

Expands EnvironmentYaml variables for the channels found in the yaml data

load_file(filename)

Load and return an yaml string from a given file

from_file(filename)

Load and return an EnvironmentYaml from a given file

print_result(args, prefix, result)

Print the result of an install operation

Attributes#

REQUIRED_KEYS#
OPTIONAL_KEYS#
VALID_KEYS#
field_type_validation(field_name: str, value: Any, value_type: Any) None#

Validates the type of a value

prefix_validation(prefix: str)#

Validate the contents of the prefix field.

Will ensure:
  • prefix is a string

name_validation(name: str)#

Validate the contents of the name field.

Will ensure:
  • name is a string

dependencies_validation(dependencies: list)#

Validate the contents of the dependencies field.

Will ensure:
  • dependencies are a list

  • all string dependencies are MatchSpec compatible

  • the only other type allowed is a dict

channels_validation(channels: list)#

Validate the contents of the channels field.

Will ensure:
  • channels is a list

  • all entries are strings

variables_validation(variables: dict[str, str])#

Validate the contents of the variables field.

Will ensure:
  • variables is a dict

  • all entries are strings

SCHEMA_VALIDATORS#
get_schema_errors(data: dict) list[conda.exceptions.EnvironmentFileInvalid]#

Parses environment.yaml data to build a list of schema errors

Will produce errors to ensure:
  • all required fields are present

  • all fields contain valid data

Parameters:

data -- The contents of the environment.yaml

Returns:

Validation errors for the environment file schema.

validate_keys(data, kwargs)#

Check for unknown keys, remove them and print a warning

from_environment(name, prefix, no_builds=False, ignore_channels=False, from_history=False)#

Build an EnvironmentYaml from an existing environment prefix.

Parameters:
  • name -- Environment name.

  • prefix -- Path to the environment prefix.

  • no_builds -- Omit build strings from dependency specs.

  • ignore_channels -- Do not add channels from installed packages.

  • from_history -- Base dependencies on explicit specs from install history.

Returns:

Representation of the environment suitable for export to YAML.

from_yaml(yamlstr: str, **kwargs) EnvironmentYaml#

Load and return a EnvironmentYaml from a given yaml string

Parameters:

yamlstr -- The contents of the environment.yaml.

Returns:

A representation of the environment file

_expand_channels(data)#

Expands EnvironmentYaml variables for the channels found in the yaml data

load_file(filename)#

Load and return an yaml string from a given file

from_file(filename)#

Load and return an EnvironmentYaml from a given file

class Dependencies(raw, *args, **kwargs)#

Bases: dict

A dict subclass that parses the raw dependencies into a conda and pip list

Initialize self. See help(type(self)) for accurate signature.

raw#
parse()#

Parse the raw dependencies into a conda and pip list

add(package_name)#

Add a package to the EnvironmentYaml

class EnvironmentYaml(name=None, filename=None, channels=None, dependencies=None, prefix=None, variables=None)#

A class representing an environment.yaml file

name = None#
filename = None#
prefix = None#
dependencies#
variables = None#
channels = None#
add_channels(channels)#

Add channels to the EnvironmentYaml

remove_channels()#

Remove all channels from the EnvironmentYaml

to_dict(stream=None)#

Convert information related to the EnvironmentYaml into a dictionary

to_yaml(stream=None)#

Convert information related to the EnvironmentYaml into a yaml string

save()#

Save the EnvironmentYaml data to a yaml file

to_environment_model() conda.models.environment.Environment#

Convert the Environment into a model.Environment object

print_result(args, prefix, result)#

Print the result of an install operation