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

Environment

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, ...])

Get EnvironmentYaml object from 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

get_filename(filename)

Expand filename if local path or return the url

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 (dict) -- The contents of the environment.yaml

Returns errors:

A list of EnvironmentFileInvalid exceptions that occurred during validation

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)#

Get EnvironmentYaml object from prefix

Parameters:
  • name -- The name of environment

  • prefix -- The path of prefix

  • no_builds -- Whether has build requirement

  • ignore_channels -- whether ignore_channels

  • from_history -- Whether environment file should be based on explicit specs in history

Returns: EnvironmentYaml object

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

Load and return a EnvironmentYaml from a given yaml string

Parameters:
  • yamlstr -- The contents of the environment.yaml

  • raise_validation_errors -- Indicates if an error should be raised if the yamlstr is found to be invalid

Returns EnvironmentYaml:

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.

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

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

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

Bases: EnvironmentYaml

A class representing an environment.yaml file

get_filename(filename)#

Expand filename if local path or return the url

print_result(args, prefix, result)#

Print the result of an install operation