plumpy.loaders module#

class plumpy.loaders.DefaultObjectLoader[source]#

Bases: ObjectLoader

A default implementation for an object loader. Can load module level classes, functions and constants.

_abc_impl = <_abc._abc_data object>#
identify_object(obj: Any) str[source]#

Get an identifier for an object.

Throws a ValueError if the object cannot be identified.

Parameters:

obj – The object to identify

Returns:

An identifier for the object

load_object(identifier: str) Any[source]#

Given an identifier load an object.

Throws a ValueError if the object cannot be loaded.

Parameters:

identifier – The identifier

Returns:

The loaded object

class plumpy.loaders.ObjectLoader[source]#

Bases: object

An abstract object loaders. Concrete implementations can be used to identify an object and load it with that identifier.

_abc_impl = <_abc._abc_data object>#
abstract identify_object(obj: Any) str[source]#

Get an identifier for an object.

Throws a ValueError if the object cannot be identified.

Parameters:

obj – The object to identify

Returns:

An identifier for the object

abstract load_object(identifier: str) Any[source]#

Given an identifier load an object.

Throws a ValueError if the object cannot be loaded.

Parameters:

identifier – The identifier

Returns:

The loaded object

plumpy.loaders.get_object_loader() ObjectLoader[source]#

Get the plumpy global class loader

Returns:

A class loader

Return type:

ObjectLoader

plumpy.loaders.set_object_loader(loader: ObjectLoader | None) None[source]#

Set the plumpy global object loader

Parameters:

loader (ObjectLoader) – An object loader

Returns: