aiida.orm.utils.builders package#

Submodules#

Manage code objects with lazy loading of the db env

class aiida.orm.utils.builders.code.CodeBuilder(**kwargs)[源代码]#

基类:object

Build a code with validation of attribute combinations

class CodeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类:Enum

ON_COMPUTER = 'on computer'#
STORE_AND_UPLOAD = 'store in the db and upload'#
__module__ = 'aiida.orm.utils.builders.code'#
exception CodeValidationError(msg)[源代码]#

基类:ValueError

A CodeBuilder instance may raise this

  • when asked to instanciate a code with missing or invalid code attributes

  • when asked for a code attibute that has not been set yet

__init__(msg)[源代码]#
__module__ = 'aiida.orm.utils.builders.code'#
__repr__()[源代码]#

Return repr(self).

__str__()[源代码]#

Return str(self).

__weakref__#

list of weak references to the object (if defined)

__dict__ = mappingproxy({'__module__': 'aiida.orm.utils.builders.code', '__doc__': 'Build a code with validation of attribute combinations', '__init__': <function CodeBuilder.__init__>, 'validate': <function CodeBuilder.validate>, 'new': <function CodeBuilder.new>, 'from_code': <staticmethod(<function CodeBuilder.from_code>)>, 'get_code_spec': <staticmethod(<function CodeBuilder.get_code_spec>)>, '__getattr__': <function CodeBuilder.__getattr__>, '_get': <function CodeBuilder._get>, '_get_and_count': <function CodeBuilder._get_and_count>, '__setattr__': <function CodeBuilder.__setattr__>, '_set_code_attr': <function CodeBuilder._set_code_attr>, 'validate_code_type': <function CodeBuilder.validate_code_type>, 'validate_upload': <function CodeBuilder.validate_upload>, 'validate_installed': <function CodeBuilder.validate_installed>, 'CodeValidationError': <class 'aiida.orm.utils.builders.code.CodeBuilder.CodeValidationError'>, 'is_local': <function CodeBuilder.is_local>, 'CodeType': <enum 'CodeType'>, '__dict__': <attribute '__dict__' of 'CodeBuilder' objects>, '__weakref__': <attribute '__weakref__' of 'CodeBuilder' objects>, '__annotations__': {}})#
__getattr__(key)[源代码]#

Access code attributes used to build the code

__init__(**kwargs)[源代码]#

Construct a new instance.

__module__ = 'aiida.orm.utils.builders.code'#
__setattr__(key, value)[源代码]#

Implement setattr(self, name, value).

__weakref__#

list of weak references to the object (if defined)

_get(key)[源代码]#

Return a spec, or None if not defined

参数:

key – name of a code spec

_get_and_count(key, used)[源代码]#

Return a spec, or raise if not defined. Moreover, add the key to the ‘used’ dict.

参数:
  • key – name of a code spec

  • used – should be a set of keys that you want to track. key will be added to this set if the value exists in the spec and can be retrieved.

_set_code_attr(key, value)[源代码]#

Set a code attribute, if it passes validation.

Checks compatibility with other code attributes.

static from_code(code)[源代码]#

Create CodeBuilder from existing code instance.

See also get_code_spec()

static get_code_spec(code)[源代码]#

Get code attributes from existing code instance.

These attributes can be used to create a new CodeBuilder:

spec = CodeBuilder.get_code_spec(old_code)
builder = CodeBuilder(**spec)
new_code = builder.new()
is_local()[源代码]#

Analogous to Code.is_local()

new()[源代码]#

Build and return a new code instance (not stored)

validate(raise_error=True)[源代码]#
validate_code_type()[源代码]#

Make sure the code type is set correctly

validate_installed()[源代码]#

If the code is on-computer, catch invalid store-and-upload attributes

validate_upload()[源代码]#

If the code is stored and uploaded, catch invalid on-computer attributes

Manage computer objects with lazy loading of the db env

class aiida.orm.utils.builders.computer.ComputerBuilder(**kwargs)[源代码]#

基类:object

Build a computer with validation of attribute combinations

exception ComputerValidationError(msg)[源代码]#

基类:Exception

A ComputerBuilder instance may raise this.

  • when asked to instanciate a code with missing or invalid computer attributes

  • when asked for a computer attibute that has not been set yet.

__init__(msg)[源代码]#
__module__ = 'aiida.orm.utils.builders.computer'#
__repr__()[源代码]#

Return repr(self).

__str__()[源代码]#

Return str(self).

__weakref__#

list of weak references to the object (if defined)

__dict__ = mappingproxy({'__module__': 'aiida.orm.utils.builders.computer', '__doc__': 'Build a computer with validation of attribute combinations', 'from_computer': <staticmethod(<function ComputerBuilder.from_computer>)>, 'get_computer_spec': <staticmethod(<function ComputerBuilder.get_computer_spec>)>, '__init__': <function ComputerBuilder.__init__>, 'validate': <function ComputerBuilder.validate>, 'new': <function ComputerBuilder.new>, '__getattr__': <function ComputerBuilder.__getattr__>, '_get': <function ComputerBuilder._get>, '_get_and_count': <function ComputerBuilder._get_and_count>, '__setattr__': <function ComputerBuilder.__setattr__>, '_set_computer_attr': <function ComputerBuilder._set_computer_attr>, 'ComputerValidationError': <class 'aiida.orm.utils.builders.computer.ComputerBuilder.ComputerValidationError'>, '__dict__': <attribute '__dict__' of 'ComputerBuilder' objects>, '__weakref__': <attribute '__weakref__' of 'ComputerBuilder' objects>, '__annotations__': {}})#
__getattr__(key)[源代码]#

Access computer attributes used to build the computer

__init__(**kwargs)[源代码]#

Construct a new instance.

__module__ = 'aiida.orm.utils.builders.computer'#
__setattr__(key, value)[源代码]#

Implement setattr(self, name, value).

__weakref__#

list of weak references to the object (if defined)

_get(key)[源代码]#

Return a spec, or None if not defined

参数:

key – name of a computer spec

_get_and_count(key, used)[源代码]#

Return a spec, or raise if not defined. Moreover, add the key to the ‘used’ dict.

参数:
  • key – name of a computer spec

  • used – should be a set of keys that you want to track. key will be added to this set if the value exists in the spec and can be retrieved.

_set_computer_attr(key, value)[源代码]#

Set a computer attribute if it passes validation.

static from_computer(computer)[源代码]#

Create ComputerBuilder from existing computer instance.

See also get_computer_spec()

static get_computer_spec(computer)[源代码]#

Get computer attributes from existing computer instance.

These attributes can be used to create a new ComputerBuilder:

spec = ComputerBuilder.get_computer_spec(old_computer)
builder = ComputerBuilder(**spec)
new_computer = builder.new()
new()[源代码]#

Build and return a new computer instance (not stored)

validate(raise_error=True)[源代码]#

Validate the computer options.