openclean.engine.library module

The object library is a repository for storing objects of different types. These objects include user-defined functions, lookup tables (mappings), and controlled vocabularies.

Objects within each of the supported types are maintained under a unique name and namespace.

The library is merely a wrapper around an object stores that are responsible for maintaining (and potentially persisting) the objects. The library class provides dedicated methods to access the object stores for different types.

class openclean.engine.library.ObjectLibrary(functions: Optional[openclean.engine.store.base.ObjectStore] = None, lookups: Optional[openclean.engine.store.base.ObjectStore] = None, vocabularies: Optional[openclean.engine.store.base.ObjectStore] = None)

Bases: object

The object library provides access to different types of objects that a user can define and register with the library (e.g., user-defined functions, lookup tables, etc.).

The registered objects for each different object type are managed by separate object stores. For now, the library only provides (hard-coded) access to the object stores for different types of objects. All the functionality for creating, retrieving and deleting objects is with the object stores.

In the future we may want to make this class easier to extend for new object types (e.g., create access methods for object stores of known object types automatically).

eval(name: Optional[str] = None, namespace: Optional[str] = None, label: Optional[str] = None, description: Optional[str] = None, columns: Optional[int] = None, collabels: Optional[Union[str, List[str]]] = None, outputs: Optional[int] = None, parameters: Optional[List[flowserv.model.parameter.base.Parameter]] = None) Callable

Decorator that adds a new function to the registered set of data frame transformers.

Parameters
  • name (string, default=None) – Name of the registered function.

  • namespace (string, default=None) – Name of the namespace that this function belongs to. By default all functions will be placed in a global namespace.

  • label (string, default=None) – Optional human-readable name for display purposes.

  • description (str, default=None) – Descriptive text for the function. This text can for example be displayed as tooltips in a front-end.

  • columns (int, default=None) – Specifies the number of input columns that the registered function operates on. The function will receive exactly one argument for each column plus arguments for any additional parameter. The column values will be the first arguments that are passed to the registered function.

  • collabels (string or list of string, default=None) – Display labels for the nput columns. If given the number of values has to match the columns value.

  • outputs (int, default=None) – Defines the number of scalar output values that the registered function returns. By default it is assumed that the function will return a single scalar value.

  • parameters (list of openclean.engine.object.function.Parameter,) – default=None List of declarations for additional input parameters to the registered function.

Return type

openclean.engine.object.function.FunctionHandle

functions() openclean.engine.store.base.ObjectStore

Get object store that manages user-defined functions.

Return type

openclean.engine.store.base.ObjectStore

lookup(mapping: openclean.data.mapping.Mapping, name: str, namespace: Optional[str] = None, label: Optional[str] = None, description: Optional[str] = None) openclean.engine.object.mapping.MappingHandle

Create a new lookup table object for the given mapping. Returns the handle for the created object.

Parameters
  • mapping (openclean.data.mapping.Mapping) – Mapping (lookup table) of matched terms.

  • name (string) – Name for the mapping.

  • namespace (string, default=None) – Name of the namespace that this mapping belongs to. By default all mappings will be placed in a global namespace (None).

  • label (string, default=None) – Optional human-readable name for display purposes.

  • description (str, default=None) – Descriptive text for the mapping. This text can for example be displayed as a tooltip in a user interface.

Return type

openclean.engine.object.mapping.MappingHandle

lookups() openclean.engine.store.base.ObjectStore

Get object store that manages lookup tables.

Return type

openclean.engine.store.base.ObjectStore

vocabularies() openclean.engine.store.base.ObjectStore

Get object store that manages controlled vocabularies.

Return type

openclean.engine.store.base.ObjectStore

vocabulary(values: Iterable, name: str, namespace: Optional[str] = None, label: Optional[str] = None, description: Optional[str] = None) openclean.engine.object.vocabulary.VocabularyHandle

Register a controlled vocabulary with the library. Returns the handle for the created object.

Parameters
  • values (set) – Terms in the controlled vocabulary.

  • name (string) – Name for the vocabulary.

  • namespace (string, default=None) – Name of the namespace that this vocabulary belongs to. By default all vocabularies will be placed in a global namespace (None).

  • label (string, default=None) – Optional human-readable name for display purposes.

  • description (str, default=None) – Descriptive text for the vocabulary. This text can for example be displayed as a tooltip in a user interface.

Return type

openclean.engine.object.vocabulary.VocabularyHandle

openclean.engine.library.default_store(factory: openclean.engine.object.base.ObjectFactory) openclean.engine.store.default.DefaultObjectStore

Create an instance of the default object store for the object type that is supported by the given factory.

Parameters

factory (openclean.engine.object.base.ObjectFactory) – Factory for object handles.

Return type

openclean.engine.store.default.DefaultObjectStore