API reference

Decorators

Instruction

asr.instruction(module=None, version=0, argument_hooks=[<function set_calculator_hook>], package_dependencies=('asr', 'ase', 'gpaw'))[source]

Make instruction object.

Parameters
  • module (str) – Name of recipe that instruction belongs to.

  • version (int) – Instruction version number.

  • argument_hooks (list[callable]) – Functions for preprocessing arguments. Gets a parameter object and should return parameter object.

  • package_dependencies (typing.Tuple[str]) – Python packages for which versions should be logged.

CLI constructors

asr.option(*aliases, matcher=<function EQUAL>, **kwargs)[source]

Make argument descriptor for a CLI option.

Parameters
  • aliases (list[str]) –

  • matcher (callable) – Matching function that wraps value when matching parameter with cache. Default is to use “equal”, eg. EQUAL(“value”).

  • kwargs (dict) – Arguments forwarded to click.option.

asr.argument(name, matcher=<function EQUAL>, **kwargs)[source]

Make argument descriptor for a CLI argument.

Parameters
  • name (str) – Name of argument.

  • matcher (callable) – Matching function that wraps value when matching parameter with cache. Default is to use “equal”, eg. EQ(“value”).

  • kwargs (dict) – Arguments forwarded to click.argument.

Migration

asr.migration(function=None, *, selector=None, uid=None, eagerness=0, description=None)[source]

Migration decorator.

Parameters
  • selector – Callable that returns a boolean used to select records to be migrated. Will be applied to all records in the cache.

  • uid – (optional) uuid.uuid4() uid which can be used to identify migration.

  • eagerness – Integer representing how eager the migration is to be applied. Migrations with higher eagerness will take priority over other migrations with lower values. Default is 0.

  • description – (optional) Description of the migration. Default is to use the docstring of the decorated function.

Dataclasses

Record

class asr.Record(result=None, run_specification=None, resources=None, dependencies=None, history=None, tags=None, metadata=None)[source]

Class that represent a record object.

The Record object is used to store contextual data about the execution of an instruction.

Parameters
Return type

None

result

The result of the instruction.

Type

Optional[Any]

run_specification

The description of the run particular run.

Type

asr.RunSpecification

resources

The resources consumed during the run.

Type

asr.Resources

dependencies

The record dependencies.

Type

asr.Dependencies

history

The revision history.

Type

asr.RevisionHistory

tags

Custom tags of the record.

Type

Optional[List[str]]

metadata

The record metadata.

Type

asr.Metadata

Run Specification

class asr.RunSpecification(name, parameters, version, codes, uid)[source]

Class that represents a run specification.

A run specification is constructed when an instruction is run and represents all information available prior to the instruction has been executed.

Parameters
  • name (str) –

  • parameters (asr.core.parameters.Parameters) –

  • version (int) –

  • codes (asr.core.codes.Codes) –

  • uid (str) –

Return type

None

name

Name of the instruction.

Type

str

parameters

Parameters passed to the instruction during execution.

Type

asr.Parameters

codes

Code versions.

Type

asr.Codes

version

Instruction version.

Type

int

uid

Record UID.

Type

str

Resources

class asr.Resources(execution_start: Union[float, NoneType] = None, execution_end: Union[float, NoneType] = None, execution_duration: Union[float, NoneType] = None, ncores: Union[int, NoneType] = None)[source]
Parameters
  • execution_start (Optional[float]) –

  • execution_end (Optional[float]) –

  • execution_duration (Optional[float]) –

  • ncores (Optional[int]) –

Return type

None

Dependencies

class asr.Dependencies(deps: List[asr.core.dependencies.Dependency] = <factory>)[source]
Parameters

deps (List[asr.core.dependencies.Dependency]) –

Return type

None

History

class asr.RevisionHistory(history=<factory>)[source]

A class that represents the revision history.

Parameters

history (List[asr.core.migrate.Revision]) –

Return type

None

history

A chronological list of the revisions that led to the latest (current) revision. The latest revision is the last element of this list.

Type

List[asr.core.migrate.Revision]

add(revision)[source]

Add revision to history.

Parameters

revision (asr.core.migrate.Revision) –

property latest_revision: Union[None, str]

Get the latest revision, ‘None’ if no revisions.

Metadata

class asr.Metadata(created=None, modified=None, directory=None)[source]

Class representing record metadata.

Parameters
Return type

None

created
Type

Record creation date.

modified
Type

Record modification date.

directory
Type

Record directory.