pumpwood_communication.type

Module for custom types at pumpwood systems.

 1"""Module for custom types at pumpwood systems."""
 2from .action import (
 3    ActionReturnFile, ActionInfomation, ActionParameterType,
 4    ActionReturnType)
 5from .abc import PumpwoodSentinel, PumpwoodDataclassMixin
 6from .sentinel import (
 7    PumpwoodMissingType, PumpwoodAutoincrementType, PumpwoodAutoNowType,
 8    PumpwoodAutoTodayType, PumpwoodPKType, PumpwoodLoggedUserType,
 9    PumpwoodAutoFillType, MISSING, AUTOINCREMENT, NOW, TODAY, PUMPWOOD_PK,
10    LOGGED_USER, AUTO_FILL)
11from .info import (
12    ForeignKeyColumnExtraInfo, RelatedColumnExtraInfo,
13    FileColumnExtraInfo, OptionsColumnExtraInfo,
14    ColumnInfo, ColumnExtraInfo, PrimaryKeyExtraInfo)
15from .views import (
16    BulkSaveMicroserviceAutoFillField, BulkSaveLocalAutoFillField,
17    BulkSaveDefaultField, MixinBulkSaveField)
18from .etl import (
19    ETLDimensions, ETLDataInputObject, ETLFact, ETLAuxResults,
20    ETLResultObjectSave, ETLResultObjectDelete,
21    ETLResultActionRun, ETLResultAuxInfo)
22
23
24__all__ = [
25    PumpwoodSentinel, PumpwoodMissingType, PumpwoodAutoincrementType,
26    PumpwoodAutoNowType, PumpwoodAutoTodayType, MISSING, AUTOINCREMENT, NOW,
27    TODAY, PumpwoodDataclassMixin, PumpwoodPKType, PUMPWOOD_PK,
28    ActionReturnFile, ForeignKeyColumnExtraInfo, RelatedColumnExtraInfo,
29    FileColumnExtraInfo, OptionsColumnExtraInfo,
30    ColumnInfo, ColumnExtraInfo, PrimaryKeyExtraInfo,
31    PumpwoodLoggedUserType, LOGGED_USER, PumpwoodAutoFillType, AUTO_FILL,
32    BulkSaveMicroserviceAutoFillField, BulkSaveLocalAutoFillField,
33    BulkSaveDefaultField, MixinBulkSaveField, ActionInfomation,
34    ActionParameterType, ActionReturnType,
35    ETLDimensions, ETLDataInputObject, ETLFact, ETLAuxResults,
36    ETLResultObjectSave, ETLResultObjectDelete,
37    ETLResultActionRun, ETLResultAuxInfo]
class PumpwoodSentinel(abc.ABC):
 8class PumpwoodSentinel(ABC):
 9    """Pumpwood Sentinel class for missing values."""
10
11    _RETURN_VALUE: str = ""
12    """Value that will be returned on dataclass to dict."""
13
14    _HELP_TEXT: str = ""
15    """Value that will be returned on dataclass to dict."""
16
17    @classmethod
18    def value(cls):
19        """Return defult value."""
20        return cls._RETURN_VALUE
21
22    @classmethod
23    def help_text(cls):
24        """Return defult value."""
25        return cls._HELP_TEXT

Pumpwood Sentinel class for missing values.

@classmethod
def value(cls):
17    @classmethod
18    def value(cls):
19        """Return defult value."""
20        return cls._RETURN_VALUE

Return defult value.

@classmethod
def help_text(cls):
22    @classmethod
23    def help_text(cls):
24        """Return defult value."""
25        return cls._HELP_TEXT

Return defult value.

class PumpwoodMissingType(pumpwood_communication.type.PumpwoodSentinel):
 7class PumpwoodMissingType(PumpwoodSentinel):
 8    """Pumpwood Sentinel class for missing values."""
 9
10    _RETURN_VALUE: str = "**missing**"
11    _HELP_TEXT: str = "Missing value"

Pumpwood Sentinel class for missing values.

class PumpwoodAutoincrementType(pumpwood_communication.type.PumpwoodSentinel):
14class PumpwoodAutoincrementType(PumpwoodSentinel):
15    """Pumpwood Sentinel class for missing values."""
16
17    _RETURN_VALUE: str = "**autoincrement**"
18    _HELP_TEXT: str = "Auto-increment value, usually an integer"

Pumpwood Sentinel class for missing values.

class PumpwoodAutoNowType(pumpwood_communication.type.PumpwoodSentinel):
21class PumpwoodAutoNowType(PumpwoodSentinel):
22    """Pumpwood Sentinel class for auto now default."""
23
24    _RETURN_VALUE: str = "**now**"
25    _HELP_TEXT: str = "Return the now time at the server"

Pumpwood Sentinel class for auto now default.

class PumpwoodAutoTodayType(pumpwood_communication.type.PumpwoodSentinel):
28class PumpwoodAutoTodayType(PumpwoodSentinel):
29    """Pumpwood Sentinel class for auto now default."""
30
31    _RETURN_VALUE: str = "**today**"
32    _HELP_TEXT: str = "Return the todat date at the server"

Pumpwood Sentinel class for auto now default.

PumpwoodMissingType object at 0x70237205b530>
PumpwoodAutoincrementType object at 0x70237205bd10>
PumpwoodAutoNowType object at 0x70237205bda0>
PumpwoodAutoTodayType object at 0x70237205bdd0>
class PumpwoodDataclassMixin(abc.ABC):
28class PumpwoodDataclassMixin(ABC):
29    """Pumpwood Dataclasses with some pre-implemented methods.
30
31    Is implemented so it can be used as an object, but data can also be
32    retrived as dictionary using obj['key'] notation.
33    """
34
35    _RENAME_FIELDS: ClassVar[dict[str, str]] = {}
36    """Rename field on the dataclass and the response, this migth be
37       particullary usefull when dealling with fields like 'in', which is
38       not avaiable."""
39
40    def to_dict(self):
41        """Converts the dataclass instance into a dictionary recursively."""
42        clean_data = {}
43        # Iterate over the fields of the current dataclass
44        for field in dataclasses.fields(self):
45            key = field.name
46            value = getattr(self, key)
47
48            # Rename the keys
49            new_key = self._RENAME_FIELDS.get(key, key)
50            clean_data[new_key] = self._process_value(value)
51        return clean_data
52
53    def _process_value(self, value):
54        """Helper to handle recursion and sentinel replacement."""
55        # Handle Sentinels
56        if isinstance(value, PumpwoodSentinel):
57            return value.value()
58
59        # Handle Nested Pumpwood Dataclasses (Recursion)
60        if isinstance(value, PumpwoodDataclassMixin):
61            return value.to_dict()
62
63        # Handle Lists (check each element)
64        if isinstance(value, list):
65            return [
66                self._process_value(item)
67                for item in value]
68
69        # Handle Dicts (check each value)
70        if isinstance(value, dict):
71            return {
72                k: self._process_value(v)
73                for k, v in value.items()}
74        return value
75
76    def __iter__(self):
77        """This allows: for key, val in my_dataclass."""
78        for key, value in self.to_dict().items():
79            yield key, value
80
81    def __getitem__(self, key):
82        """Allows obj["name"]."""
83        return getattr(self, key)
84
85    def keys(self):
86        """Allows dict(obj) and spreading **obj."""
87        return [f.name for f in dataclasses.fields(self)]

Pumpwood Dataclasses with some pre-implemented methods.

Is implemented so it can be used as an object, but data can also be retrived as dictionary using obj['key'] notation.

def to_dict(self):
40    def to_dict(self):
41        """Converts the dataclass instance into a dictionary recursively."""
42        clean_data = {}
43        # Iterate over the fields of the current dataclass
44        for field in dataclasses.fields(self):
45            key = field.name
46            value = getattr(self, key)
47
48            # Rename the keys
49            new_key = self._RENAME_FIELDS.get(key, key)
50            clean_data[new_key] = self._process_value(value)
51        return clean_data

Converts the dataclass instance into a dictionary recursively.

def keys(self):
85    def keys(self):
86        """Allows dict(obj) and spreading **obj."""
87        return [f.name for f in dataclasses.fields(self)]

Allows dict(obj) and spreading **obj.

class PumpwoodPKType(pumpwood_communication.type.PumpwoodSentinel):
35class PumpwoodPKType(PumpwoodSentinel):
36    """Pumpwood Sentinel class for auto now default."""
37
38    _RETURN_VALUE: str = "**pumpwood_pk**"
39    _HELP_TEXT: str = (
40        "Primary key associated with model. It is an integer if not composite "
41        "and a base64 dictionary if it is composite (more than one field)")

Pumpwood Sentinel class for auto now default.

PumpwoodPKType object at 0x70237205ba70>
@dataclass
class ActionReturnFile(pumpwood_communication.type.PumpwoodDataclassMixin):
 8@dataclass
 9class ActionReturnFile(PumpwoodDataclassMixin):
10    """Type for returning files at Pumpwood Actions."""
11
12    content: bytes
13    """Content of the file that will be returned at the action."""
14    filename: str
15    """Name off the file that will be returned at the action."""
16    content_type: str = 'application/octet-stream'
17    """Type content the the file that will be returned at the action."""

Type for returning files at Pumpwood Actions.

ActionReturnFile( content: bytes, filename: str, content_type: str = 'application/octet-stream')
content: bytes

Content of the file that will be returned at the action.

filename: str

Name off the file that will be returned at the action.

content_type: str = 'application/octet-stream'

Type content the the file that will be returned at the action.

@dataclass
class ForeignKeyColumnExtraInfo(pumpwood_communication.type.ColumnExtraInfo):
23@dataclass
24class ForeignKeyColumnExtraInfo(ColumnExtraInfo):
25    """Foreign Key Extra Info for fill column information."""
26    model_class: str
27    """Model class associated with the Foreign Key."""
28    display_field: str
29    """Field that will be used to display the object, it will be serialized
30       as `__display_field__`."""
31    object_field: str
32    """Field that will receive information from the object."""
33    source_keys: list[str]
34    """Fields that will used at current object to fetch data at
35       the foreign key object."""
36    many: bool = False
37    """Foreign keys are always many=False."""
38    fields: list[str] | None = None
39    """Fields that will be returned at object call."""

Foreign Key Extra Info for fill column information.

ForeignKeyColumnExtraInfo( model_class: str, display_field: str, object_field: str, source_keys: list[str], many: bool = False, fields: list[str] | None = None)
model_class: str

Model class associated with the Foreign Key.

display_field: str

Field that will be used to display the object, it will be serialized as __display_field__.

object_field: str

Field that will receive information from the object.

source_keys: list[str]

Fields that will used at current object to fetch data at the foreign key object.

many: bool = False

Foreign keys are always many=False.

fields: list[str] | None = None

Fields that will be returned at object call.

@dataclass
class RelatedColumnExtraInfo(pumpwood_communication.type.ColumnExtraInfo):
42@dataclass
43class RelatedColumnExtraInfo(ColumnExtraInfo):
44    """Related Key Extra Info for fill column information."""
45    model_class: str
46    """Model class associated with Foreign Key."""
47    pk_field: str
48    """Field of the origin model class that will be used to filter
49       related models at foreign_key."""
50    foreign_key: str
51    """Field of the origin model class that will be used to filter
52       related models at foreign_key."""
53    complementary_foreign_key: dict[str, str]
54    """Complementary primary key fields that will be used on query
55       to reduce query time."""
56    fields: list[str]
57    """Set the fileds that will be returned at the foreign key
58       object."""
59    many: bool = True
60    """Related will always return many=True."""

Related Key Extra Info for fill column information.

RelatedColumnExtraInfo( model_class: str, pk_field: str, foreign_key: str, complementary_foreign_key: dict[str, str], fields: list[str], many: bool = True)
model_class: str

Model class associated with Foreign Key.

pk_field: str

Field of the origin model class that will be used to filter related models at foreign_key.

foreign_key: str

Field of the origin model class that will be used to filter related models at foreign_key.

complementary_foreign_key: dict[str, str]

Complementary primary key fields that will be used on query to reduce query time.

fields: list[str]

Set the fileds that will be returned at the foreign key object.

many: bool = True

Related will always return many=True.

@dataclass
class FileColumnExtraInfo(pumpwood_communication.type.ColumnExtraInfo):
72@dataclass
73class FileColumnExtraInfo(ColumnExtraInfo):
74    """File field extra info for column information."""
75
76    permited_file_types: list[str]
77    """Files allowed to be uploaded."""

File field extra info for column information.

FileColumnExtraInfo(permited_file_types: list[str])
permited_file_types: list[str]

Files allowed to be uploaded.

@dataclass
class OptionsColumnExtraInfo(pumpwood_communication.type.ColumnExtraInfo):
80@dataclass
81class OptionsColumnExtraInfo(ColumnExtraInfo):
82    """Options field extra info for column information."""
83    _RENAME_FIELDS: ClassVar[dict[str, str]] = {
84        'in_': 'in'
85    }
86    """Rename keys at the result dictionary."""
87
88    in_: list[dict] | PumpwoodSentinel = MISSING
89    """Options avaiable for the field."""

Options field extra info for column information.

OptionsColumnExtraInfo( in_: list[dict] | PumpwoodSentinel = <PumpwoodMissingType object>)
in_: list[dict] | PumpwoodSentinel = <PumpwoodMissingType object>

Options avaiable for the field.

@dataclass
class ColumnInfo(pumpwood_communication.type.PumpwoodDataclassMixin):
 92@dataclass
 93class ColumnInfo(PumpwoodDataclassMixin):
 94    """Type for returning files at Pumpwood Actions."""
 95    _RENAME_FIELDS: ClassVar[dict[str, str]] = {
 96        'in_': 'in',
 97        'type_': 'type'}
 98    """Rename keys at the result dictionary."""
 99
100    primary_key: bool
101    """If column should be considered a primary_key."""
102    column: str
103    """Name of the column."""
104    column__verbose: str
105    """User friendly name for the column."""
106    help_text: str
107    """Help text associated with the column."""
108    help_text__verbose: str
109    """User friendly help text associated with the column."""
110    type_: str
111    """Type of the column."""
112    nullable: bool
113    """If column can be nullable."""
114    read_only: bool
115    """If column column is considered read only."""
116    unique: bool
117    """Is column is to be considered unique."""
118    indexed: bool
119    """If column is indexed."""
120    extra_info: ColumnExtraInfo
121    """Extra info associated with custom field types like Foreign Key and
122       related."""
123    in_: list[dict] | PumpwoodSentinel = MISSING
124    """Return a list with options associated with field possible values."""
125    default: Any | PumpwoodSentinel = MISSING
126    """If column column is considered read only."""
127
128    def to_dict(self):
129        """Remove in from dict return when it is missing."""
130        data = super().to_dict()
131
132        # Remove the in data if it is missing
133        if data.get("in") == "**missing**":
134            data.pop("in")
135        return data

Type for returning files at Pumpwood Actions.

ColumnInfo( primary_key: bool, column: str, column__verbose: str, help_text: str, help_text__verbose: str, type_: str, nullable: bool, read_only: bool, unique: bool, indexed: bool, extra_info: ColumnExtraInfo, in_: list[dict] | PumpwoodSentinel = <PumpwoodMissingType object>, default: typing.Any | PumpwoodSentinel = <PumpwoodMissingType object>)
primary_key: bool

If column should be considered a primary_key.

column: str

Name of the column.

column__verbose: str

User friendly name for the column.

help_text: str

Help text associated with the column.

help_text__verbose: str

User friendly help text associated with the column.

type_: str

Type of the column.

nullable: bool

If column can be nullable.

read_only: bool

If column column is considered read only.

unique: bool

Is column is to be considered unique.

indexed: bool

If column is indexed.

extra_info: ColumnExtraInfo

Extra info associated with custom field types like Foreign Key and related.

in_: list[dict] | PumpwoodSentinel = <PumpwoodMissingType object>

Return a list with options associated with field possible values.

default: typing.Any | PumpwoodSentinel = <PumpwoodMissingType object>

If column column is considered read only.

def to_dict(self):
128    def to_dict(self):
129        """Remove in from dict return when it is missing."""
130        data = super().to_dict()
131
132        # Remove the in data if it is missing
133        if data.get("in") == "**missing**":
134            data.pop("in")
135        return data

Remove in from dict return when it is missing.

@dataclass
class ColumnExtraInfo(pumpwood_communication.type.PumpwoodDataclassMixin):
 9@dataclass
10class ColumnExtraInfo(PumpwoodDataclassMixin):
11    """Foreign Key Extra Info for fill column information."""

Foreign Key Extra Info for fill column information.

@dataclass
class PrimaryKeyExtraInfo(pumpwood_communication.type.ColumnExtraInfo):
63@dataclass
64class PrimaryKeyExtraInfo(ColumnExtraInfo):
65    """Extra-info associated with primary key information."""
66    columns: list[str]
67    """Columns that together form the primary key."""
68    partition: list[str]
69    """Partition logic of the table."""

Extra-info associated with primary key information.

PrimaryKeyExtraInfo(columns: list[str], partition: list[str])
columns: list[str]

Columns that together form the primary key.

partition: list[str]

Partition logic of the table.

class PumpwoodLoggedUserType(pumpwood_communication.type.PumpwoodSentinel):
44class PumpwoodLoggedUserType(PumpwoodSentinel):
45    """Pumpwood Sentinel class for logged user default."""
46
47    _RETURN_VALUE: str = "**logged_user**"
48    _HELP_TEXT: str = (
49        "Use autentication header to fill field with id of the logged "
50        "user.")

Pumpwood Sentinel class for logged user default.

PumpwoodLoggedUserType object at 0x70237205bd70>
class PumpwoodAutoFillType(pumpwood_communication.type.PumpwoodSentinel):
53class PumpwoodAutoFillType(PumpwoodSentinel):
54    """Pumpwood Sentinel class auto fill fields on serializer."""
55
56    _RETURN_VALUE: str = "**autofill**"
57    _HELP_TEXT: str = (
58        "Use autentication header to fill field with id of the logged "
59        "user.")

Pumpwood Sentinel class auto fill fields on serializer.

PumpwoodAutoFillType object at 0x70237205baa0>
@dataclass
class BulkSaveMicroserviceAutoFillField(pumpwood_communication.type.MixinBulkSaveField):
15@dataclass
16class BulkSaveMicroserviceAutoFillField(MixinBulkSaveField):
17    """Define a field to be auto filled by microservice at bulk save."""
18
19    field: str
20    """Name of the field that will be filled on bulk save."""
21    fill_model_class: str
22    """String associated with model class to fetch information from."""
23    fill_col: str
24    """Column of the foreign object that will be used to fill the data."""
25    object_fk_column: str | None
26    """Column that contains the field with pk for the object used to fill
27       the data."""
28    use_cache: bool = True
29    """If it is allowed to use local cache to fill column value."""

Define a field to be auto filled by microservice at bulk save.

BulkSaveMicroserviceAutoFillField( field: str, fill_model_class: str, fill_col: str, object_fk_column: str | None, use_cache: bool = True)
field: str

Name of the field that will be filled on bulk save.

fill_model_class: str

String associated with model class to fetch information from.

fill_col: str

Column of the foreign object that will be used to fill the data.

object_fk_column: str | None

Column that contains the field with pk for the object used to fill the data.

use_cache: bool = True

If it is allowed to use local cache to fill column value.

@dataclass
class BulkSaveLocalAutoFillField(pumpwood_communication.type.MixinBulkSaveField):
32@dataclass
33class BulkSaveLocalAutoFillField(MixinBulkSaveField):
34    """Define a field to be auto filled by local at bulk save."""
35
36    field: str
37    """Name of the field that will be filled on bulk save."""
38    fill_model_class: str
39    """String or SQLAlchemy class associated with model class to fetch
40       information from."""
41    fill_col: str
42    """Column of the foreign object that will be used to fill the data."""
43    object_fk_column: str | None
44    """Column that contains the field with pk for the object used to fill
45       the data."""
46    use_cache: bool = True
47    """If it is allowed to use local cache to fill column value."""
48
49    @cached_property
50    def cls_fill_model_class(self):
51        """Class used to fetch local data information."""
52        if isinstance(self.fill_model_class, str):
53            return import_function_by_string(self.fill_model_class)
54        return self.fill_model_class

Define a field to be auto filled by local at bulk save.

BulkSaveLocalAutoFillField( field: str, fill_model_class: str, fill_col: str, object_fk_column: str | None, use_cache: bool = True)
field: str

Name of the field that will be filled on bulk save.

fill_model_class: str

String or SQLAlchemy class associated with model class to fetch information from.

fill_col: str

Column of the foreign object that will be used to fill the data.

object_fk_column: str | None

Column that contains the field with pk for the object used to fill the data.

use_cache: bool = True

If it is allowed to use local cache to fill column value.

cls_fill_model_class
49    @cached_property
50    def cls_fill_model_class(self):
51        """Class used to fetch local data information."""
52        if isinstance(self.fill_model_class, str):
53            return import_function_by_string(self.fill_model_class)
54        return self.fill_model_class

Class used to fetch local data information.

@dataclass
class BulkSaveDefaultField(pumpwood_communication.type.MixinBulkSaveField):
57@dataclass
58class BulkSaveDefaultField(MixinBulkSaveField):
59    """Define a field to be auto filled by default at bulk save."""
60
61    field: str
62    """Name of the field that will be filled on bulk save by default."""
63    default: Any
64    """Default value to be used if the field is not filled."""

Define a field to be auto filled by default at bulk save.

BulkSaveDefaultField(field: str, default: Any)
field: str

Name of the field that will be filled on bulk save by default.

default: Any

Default value to be used if the field is not filled.

@dataclass
class MixinBulkSaveField(pumpwood_communication.type.PumpwoodDataclassMixin):
10@dataclass
11class MixinBulkSaveField(PumpwoodDataclassMixin):
12    """Mixin to define a field to be used on bulk save."""

Mixin to define a field to be used on bulk save.

@dataclass
class ActionInfomation(pumpwood_communication.type.PumpwoodDataclassMixin):
20@dataclass
21class ActionInfomation(PumpwoodDataclassMixin):
22    """Type to standardize action information exchange."""
23
24    action_name: str
25    """Name of the action."""
26    is_static_function: bool
27    """If action should be considered a static function and should run without
28       an associated object (pk should not be passed on function call)."""
29    info: str
30    """Description of the action."""
31    return_: dict
32    """Information about the variable that be returned by the action."""
33    parameters: dict
34    """Description of the parameters used by the action."""
35    doc_string: str
36    """Doc string avaiable at action definition."""
37    required_role: str = 'default'
38    """Required role to run the action, if default is set the permission will
39       be managed by end-point permission at pumpwood auth."""
40
41    _RENAME_FIELDS = {"return_": "return"}
42    """Rename 'return_' to 'return' since it is a retricted expression on
43       python."""

Type to standardize action information exchange.

ActionInfomation( action_name: str, is_static_function: bool, info: str, return_: dict, parameters: dict, doc_string: str, required_role: str = 'default')
action_name: str

Name of the action.

is_static_function: bool

If action should be considered a static function and should run without an associated object (pk should not be passed on function call).

info: str

Description of the action.

return_: dict

Information about the variable that be returned by the action.

parameters: dict

Description of the parameters used by the action.

doc_string: str

Doc string avaiable at action definition.

required_role: str = 'default'

Required role to run the action, if default is set the permission will be managed by end-point permission at pumpwood auth.

@dataclass
class ActionParameterType(pumpwood_communication.type.PumpwoodDataclassMixin):
46@dataclass
47class ActionParameterType(PumpwoodDataclassMixin):
48    """Type to standardize action parameter type exchange."""
49
50    many: bool
51    """Define if the parameter is a list of the type."""
52    type_: str
53    """Type of the parameter."""
54    required: bool
55    """Define if the parameter is required or not."""
56    default_value: Any
57    """Default value associated with the parameter."""
58    in_: list[str] | None = None
59    """If the parameter if an options, it will return the possible options
60       associated with the parameter."""
61
62    _RENAME_FIELDS = {"type_": "type", "in_": "in"}
63    """Rename 'return_' to 'return' since it is a retricted expression on
64       python."""

Type to standardize action parameter type exchange.

ActionParameterType( many: bool, type_: str, required: bool, default_value: Any, in_: list[str] | None = None)
many: bool

Define if the parameter is a list of the type.

type_: str

Type of the parameter.

required: bool

Define if the parameter is required or not.

default_value: Any

Default value associated with the parameter.

in_: list[str] | None = None

If the parameter if an options, it will return the possible options associated with the parameter.

@dataclass
class ActionReturnType(pumpwood_communication.type.PumpwoodDataclassMixin):
67@dataclass
68class ActionReturnType(PumpwoodDataclassMixin):
69    """Type to standardize action return type exchange."""
70
71    many: bool
72    """Define if the parameter is a list of the type."""
73    type_: str
74    """Type of the parameter."""
75    in_: list[str] | None = None
76    """If the parameter if an options, it will return the possible options
77       associated with the parameter."""
78
79    _RENAME_FIELDS = {"type_": "type", "in_": "in"}
80    """Rename 'return_' to 'return' since it is a retricted expression on
81       python."""

Type to standardize action return type exchange.

ActionReturnType(many: bool, type_: str, in_: list[str] | None = None)
many: bool

Define if the parameter is a list of the type.

type_: str

Type of the parameter.

in_: list[str] | None = None

If the parameter if an options, it will return the possible options associated with the parameter.

@dataclass
class ETLDimensions(pumpwood_communication.type.PumpwoodDataclassMixin):
11@dataclass
12class ETLDimensions(PumpwoodDataclassMixin):
13    """Dimensions associated with ETL processes."""
14
15    data: list[dict]
16    """Data associated with the dimensions."""
17    update_fields: list[str] | None = None
18    """Fields that should be updated in the dimensions if object exists."""
19    merge_dict_fields: list[str] | None = None
20    """Dictionary fields that should be merged in the dimensions if object
21       exists."""

Dimensions associated with ETL processes.

ETLDimensions( data: list[dict], update_fields: list[str] | None = None, merge_dict_fields: list[str] | None = None)
data: list[dict]

Data associated with the dimensions.

update_fields: list[str] | None = None

Fields that should be updated in the dimensions if object exists.

merge_dict_fields: list[str] | None = None

Dictionary fields that should be merged in the dimensions if object exists.

@dataclass
class ETLDataInputObject(pumpwood_communication.type.PumpwoodDataclassMixin):
24@dataclass
25class ETLDataInputObject(PumpwoodDataclassMixin):
26    """Data input metadata for an ETL run."""
27
28    model_class: str
29    """Model class associated with the data input object."""
30    description: str | None = None
31    """Description of the data input object."""
32    notes: str | None = None
33    """Notes associated with the data input object."""
34    dimensions: list[dict] | None = None
35    """Dimensions associated with the data input object."""
36    extra_info: dict | None = None
37    """Extra info associated with the data input object."""

Data input metadata for an ETL run.

ETLDataInputObject( model_class: str, description: str | None = None, notes: str | None = None, dimensions: list[dict] | None = None, extra_info: dict | None = None)
model_class: str

Model class associated with the data input object.

description: str | None = None

Description of the data input object.

notes: str | None = None

Notes associated with the data input object.

dimensions: list[dict] | None = None

Dimensions associated with the data input object.

extra_info: dict | None = None

Extra info associated with the data input object.

@dataclass
class ETLFact(pumpwood_communication.type.PumpwoodDataclassMixin):
40@dataclass
41class ETLFact(PumpwoodDataclassMixin):
42    """Fact associated with ETL processes.
43
44    Fact data is always associated with dimensions codes, the
45    column associated with the dimension should always be [column]__code.
46
47    This is need for the process to correctly link the fact data with
48    the dimensions ids before saving the data.
49    """
50
51    model_class: str
52    """Model class associated with the fact data."""
53    data: list[dict] | pd.DataFrame
54    """Data associated with the fact."""
55    datainput: ETLDataInputObject
56    """Data input object linked to this fact load."""

Fact associated with ETL processes.

Fact data is always associated with dimensions codes, the column associated with the dimension should always be [column]__code.

This is need for the process to correctly link the fact data with the dimensions ids before saving the data.

ETLFact( model_class: str, data: list[dict] | pandas.DataFrame, datainput: ETLDataInputObject)
model_class: str

Model class associated with the fact data.

data: list[dict] | pandas.DataFrame

Data associated with the fact.

datainput: ETLDataInputObject

Data input object linked to this fact load.

@dataclass
class ETLAuxResults(pumpwood_communication.type.PumpwoodDataclassMixin):
60@dataclass
61class ETLAuxResults(PumpwoodDataclassMixin):
62    """Auxiliary results associated with ETL processes.
63
64    Auxiliary results are used to store the results of the ETL process.
65    """

Auxiliary results associated with ETL processes.

Auxiliary results are used to store the results of the ETL process.

@dataclass
class ETLResultObjectSave(pumpwood_communication.type.ETLAuxResults):
68@dataclass
69class ETLResultObjectSave(ETLAuxResults):
70    """Auxiliary results associated with ETL processes.
71
72    Auxiliary results are used to store the results of the ETL process.
73    """
74
75    object_data: dict
76    """Data associated with the object to be saved."""

Auxiliary results associated with ETL processes.

Auxiliary results are used to store the results of the ETL process.

ETLResultObjectSave(object_data: dict)
object_data: dict

Data associated with the object to be saved.

@dataclass
class ETLResultObjectDelete(pumpwood_communication.type.ETLAuxResults):
79@dataclass
80class ETLResultObjectDelete(ETLAuxResults):
81    """Auxiliary results associated with ETL processes.
82
83    Auxiliary results are used to store the results of the ETL process.
84    """
85
86    model_class: str
87    """Model class associated with the object to be deleted."""
88    pk: int | str | dict[str, Any]
89    """IDs or dict of IDs of the objects to be deleted."""

Auxiliary results associated with ETL processes.

Auxiliary results are used to store the results of the ETL process.

ETLResultObjectDelete(model_class: str, pk: int | str | dict[str, typing.Any])
model_class: str

Model class associated with the object to be deleted.

pk: int | str | dict[str, typing.Any]

IDs or dict of IDs of the objects to be deleted.

@dataclass
class ETLResultActionRun(pumpwood_communication.type.ETLAuxResults):
 92@dataclass
 93class ETLResultActionRun(ETLAuxResults):
 94    """Auxiliary results associated with ETL processes.
 95
 96    Auxiliary results are used to store the results of the ETL process.
 97    """
 98
 99    model_class: str
100    """Model class on which the action was executed."""
101    action: str
102    """Action that was run at the ETL Job."""
103    results: dict
104    """Results of the action."""
105
106    pk: int | str | None = None
107    """PK of the object at which the action was run."""
108    parameters: dict | None = None
109    """Parameters that were passed to the action."""

Auxiliary results associated with ETL processes.

Auxiliary results are used to store the results of the ETL process.

ETLResultActionRun( model_class: str, action: str, results: dict, pk: int | str | None = None, parameters: dict | None = None)
model_class: str

Model class on which the action was executed.

action: str

Action that was run at the ETL Job.

results: dict

Results of the action.

pk: int | str | None = None

PK of the object at which the action was run.

parameters: dict | None = None

Parameters that were passed to the action.

@dataclass
class ETLResultAuxInfo(pumpwood_communication.type.ETLAuxResults):
112@dataclass
113class ETLResultAuxInfo(ETLAuxResults):
114    """Auxiliary information associated with ETL processes.
115
116    Auxiliary information are used to store the information of the ETL process.
117    """
118    info_key: str
119    """Key associated with the auxiliary information."""
120    info: dict
121    """Information associated with the ETL process."""

Auxiliary information associated with ETL processes.

Auxiliary information are used to store the information of the ETL process.

ETLResultAuxInfo(info_key: str, info: dict)
info_key: str

Key associated with the auxiliary information.

info: dict

Information associated with the ETL process.