env#
Environment object describing the conda environment.yaml file.
Classes#
A |
|
A class representing an |
|
A class representing an |
Functions#
|
Validates the type of a value |
|
Validate the contents of the prefix field. |
|
Validate the contents of the name field. |
|
Validate the contents of the dependencies field. |
|
Validate the contents of the channels field. |
|
Validate the contents of the variables field. |
|
Parses environment.yaml data to build a list of schema errors |
|
Check for unknown keys, remove them and print a warning |
|
Get |
|
Load and return a |
|
Expands |
|
Load and return an yaml string from a given file |
|
Load and return an |
|
Expand filename if local path or return the |
|
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
- 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
EnvironmentYamlobject 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
EnvironmentYamlfrom a givenyamlstring- 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
EnvironmentYamlvariables for the channels found in theyamldata
- load_file(filename)#
Load and return an yaml string from a given file
- from_file(filename)#
Load and return an
EnvironmentYamlfrom a given file
- class Dependencies(raw, *args, **kwargs)#
Bases:
dictA
dictsubclass that parses the raw dependencies into a conda and pip listInitialize 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.yamlfile- 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
EnvironmentYamlinto a dictionary
- to_yaml(stream=None)#
Convert information related to the
EnvironmentYamlinto ayamlstring
- save()#
Save the
EnvironmentYamldata to ayamlfile
- to_environment_model() conda.models.environment.Environment#
Convert the
Environmentinto amodel.Environmentobject
- class Environment(name=None, filename=None, channels=None, dependencies=None, prefix=None, variables=None)#
Bases:
EnvironmentYamlA class representing an
environment.yamlfile
- get_filename(filename)#
Expand filename if local path or return the
url
- print_result(args, prefix, result)#
Print the result of an install operation