Data Types¶
DataType¶
-
class
panda_core_data.data_type.
DataType
(*args, **kwargs)¶ Base for all the model types, be it template or model
Internally it uses the TinyDB database
-
__getattr__
(name)¶ This is here just to make this method back to the default that was overwritten by TinyDB
Parameters: name (str) – name of the attribute to get
-
static
__new__
(cls, *_, db_file=False, **__)¶ Method that handles the instancing of the models and templates, this is necessary because dataclasses create a custom __init__ method. Which we doesn’t use at all if a raw file is supplied.
Parameters:
-
__repr__
()¶ Return repr(self).
-
__setattr__
(attr_name, value)¶ This is here just to make this method back to the default that was overwritten by TinyDB
Parameters: - name (str) – name of the attribute to write
- value (any) – value of the attribute.
-
static
_add_into
(data_type, data_type_dict, **kwargs)¶ You can use the prefix dataclass_ with a dataclass parameter to configure it. They can be found in this link: https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass
For example:
from panda_core_data.model import Model class ModelName(Model, dataclass_init=False): out: int def __init__(self, num): self.out = num ** num
Will make the library not create a __init__ method and use yours instead.
Parameters:
-
add_dependencies
()¶ add all dependencies for the model
-
has_dependencies
¶ If the model has any dependencies
Return bool: If the instance have dependencies or not.
-
load_db
(db_file, *init_args, default_table='data', **kwargs)¶ Method that load raw files and assign each field to an attribute.
Parameters: - db_file (str) – Path to a raw file
- storage (tinydb.storages.Storage) – storage class to be used, it needs to inherit
Storage
- default_table (str) – default main field in the raw file.
-
Model¶
-
class
panda_core_data.model.
Model
(*args, **kwargs)¶ Bases:
panda_core_data.data_type.DataType
-
classmethod
__init_subclass__
(core_name=None, **kwargs)¶ Method that automatically registers class types into data_core. You can use the same parameters as
_add_into()
-
classmethod
Template¶
-
class
panda_core_data.model.
Template
(*args, **kwargs)¶ Bases:
panda_core_data.data_type.DataType
Class that will be used to make ModelTemplates
-
classmethod
__init_subclass__
(core_name=None, **kwargs)¶ Method that automatically registers class types into data_core. You can use the same parameters as
_add_into()
-
classmethod