core
core
Classes:
-
Check– -
Collect–A class representing the file collection process.
-
Context–A shared context object for storing and accessing data across different processes.
-
ErrorProcess–Class to represent an error that occurs during process execution.
-
Extract–A class representing the file extraction process.
-
Manager–Manager class that manages the registration and execution
-
Process–Abstract base class for all processes in the task publishing pipeline. -
Push–A class representing the process to push data to the database.
-
StatusProcess–Enum-like class representing the status of a process.
Functions:
-
log_execution–Decorator to log the execution of process methods.
Check
Check(manager: Manager)
flowchart LR
publisher.core.Check[Check]
publisher.core.Process[Process]
publisher.core.Process --> publisher.core.Check
click publisher.core.Check href "" "publisher.core.Check"
click publisher.core.Process href "" "publisher.core.Process"
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
add_error–Adds an error to the list of errors.
-
fix_method–Provides a method to fix issues detected by the check.
-
process–The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
-
set_status–Sets the status of the process.
Attributes:
-
callbacks(Dict[Type[Callback], Callable]) –Returns the dict of registered callbacks.
-
context(Context) –Returns the shared context.
-
errors(List[ErrorProcess]) –Returns the list of errors encountered during execution.
-
status(StatusProcess) –Returns the current status of the process.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
add_error
add_error(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None) -> None
Adds an error to the list of errors.
Parameters:
-
(errorstr, default:'Unknown error') –The error message or name.
-
(detailsstr, default:'Unknown details') –Detailed description of the error.
-
(itemslist, default:None) –Optional list of items related to the error.
process
abstractmethod
The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
Parameters:
-
(contextContext) –The shared context for accessing and storing data during execution.
Raises:
-
NotImplementedError–If the subclass does not implement this method.
set_status
set_status(status: StatusProcess) -> None
Collect
flowchart LR
publisher.core.Collect[Collect]
publisher.core.Process[Process]
publisher.core.Process --> publisher.core.Collect
click publisher.core.Collect href "" "publisher.core.Collect"
click publisher.core.Process href "" "publisher.core.Process"
A class representing the file collection process.
This class is responsible for handling the collection of files, storing the collected value, and updating the shared context with the collected data.
Attributes:
-
name(str) –The name of the collection process.
-
collect_type(Type) –The expected type of the collected data (default is
str). -
_value(Any) –The collected value, initially set to None.
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
add_error–Adds an error to the list of errors.
-
process–The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
-
set_status–Sets the status of the process.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
add_error
add_error(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None) -> None
Adds an error to the list of errors.
Parameters:
-
(errorstr, default:'Unknown error') –The error message or name.
-
(detailsstr, default:'Unknown details') –Detailed description of the error.
-
(itemslist, default:None) –Optional list of items related to the error.
process
abstractmethod
The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
Parameters:
-
(contextContext) –The shared context for accessing and storing data during execution.
Raises:
-
NotImplementedError–If the subclass does not implement this method.
set_status
set_status(status: StatusProcess) -> None
Context
A shared context object for storing and accessing data across different processes.
Methods:
-
get_data–Retrieves data from the context by key.
-
set_data–Stores or updates data in the context.
get_data
get_data(key: str) -> Any
Retrieves data from the context by key.
Parameters:
-
(keystr) –The key or identifier for the data.
Returns:
-
Any(Any) –The value associated with the key, or None if not found.
Example
files = context.get_data('collected_files')
ErrorProcess
ErrorProcess(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None)
Class to represent an error that occurs during process execution.
Attributes:
Extract
Extract(manager: Manager)
flowchart LR
publisher.core.Extract[Extract]
publisher.core.Process[Process]
publisher.core.Process --> publisher.core.Extract
click publisher.core.Extract href "" "publisher.core.Extract"
click publisher.core.Process href "" "publisher.core.Process"
A class representing the file extraction process.
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
add_error–Adds an error to the list of errors.
-
process–The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
-
set_status–Sets the status of the process.
Attributes:
-
callbacks(Dict[Type[Callback], Callable]) –Returns the dict of registered callbacks.
-
context(Context) –Returns the shared context.
-
errors(List[ErrorProcess]) –Returns the list of errors encountered during execution.
-
status(StatusProcess) –Returns the current status of the process.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
add_error
add_error(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None) -> None
Adds an error to the list of errors.
Parameters:
-
(errorstr, default:'Unknown error') –The error message or name.
-
(detailsstr, default:'Unknown details') –Detailed description of the error.
-
(itemslist, default:None) –Optional list of items related to the error.
process
abstractmethod
The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
Parameters:
-
(contextContext) –The shared context for accessing and storing data during execution.
Raises:
-
NotImplementedError–If the subclass does not implement this method.
set_status
set_status(status: StatusProcess) -> None
Manager
Manager class that manages the registration and execution of different processes, including collecting, checking, extraction, and pushing to the database.
Attributes:
-
context(Context) –The shared context for managing data among the different processes.
-
collectors(List[Collect]) –A list of collecting processes.
-
checks(List[Check]) –A list of checking processes.
-
extractors(List[Extract]) –A list of extraction processes.
-
pushes(List[Push]) –A list of push processes for database operations.
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
processes–Returns a dictionary with all the registered processes.
-
publish–Executes the registered processes in sequence.
-
register–Registers a process in the correct category based on its type.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
Process
Process(manager: Manager)
flowchart LR
publisher.core.Process[Process]
click publisher.core.Process href "" "publisher.core.Process"
Abstract base class for all processes in the task publishing pipeline.
Attributes:
name (str): The name of the process.
compulsory (bool): Indicates if the process is mandatory.
status (bool): The status of the process (True for success, False for failure, None for not yet executed).
info (str): Information or description of the process.
errors (list): A list of ErrorProcess objects representing errors encountered during execution.
context (Context): A reference to the shared Context object for data exchange.
callbacks (dict): A dict of callback functions to be executed when a specified action occurs.
.
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
add_error–Adds an error to the list of errors.
-
process–The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
-
set_status–Sets the status of the process.
Attributes:
-
callbacks(Dict[Type[Callback], Callable]) –Returns the dict of registered callbacks.
-
context(Context) –Returns the shared context.
-
errors(List[ErrorProcess]) –Returns the list of errors encountered during execution.
-
status(StatusProcess) –Returns the current status of the process.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
add_error
add_error(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None) -> None
Adds an error to the list of errors.
Parameters:
-
(errorstr, default:'Unknown error') –The error message or name.
-
(detailsstr, default:'Unknown details') –Detailed description of the error.
-
(itemslist, default:None) –Optional list of items related to the error.
process
abstractmethod
The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
Parameters:
-
(contextContext) –The shared context for accessing and storing data during execution.
Raises:
-
NotImplementedError–If the subclass does not implement this method.
set_status
set_status(status: StatusProcess) -> None
Push
Push(manager: Manager)
flowchart LR
publisher.core.Push[Push]
publisher.core.Process[Process]
publisher.core.Process --> publisher.core.Push
click publisher.core.Push href "" "publisher.core.Push"
click publisher.core.Process href "" "publisher.core.Process"
A class representing the process to push data to the database.
Methods:
-
add_callback–Adds a callback function to be executed after the process finishes.
-
add_error–Adds an error to the list of errors.
-
process–The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
-
set_status–Sets the status of the process.
Attributes:
-
callbacks(Dict[Type[Callback], Callable]) –Returns the dict of registered callbacks.
-
context(Context) –Returns the shared context.
-
errors(List[ErrorProcess]) –Returns the list of errors encountered during execution.
-
status(StatusProcess) –Returns the current status of the process.
callbacks
property
callbacks: Dict[Type[Callback], Callable]
Returns the dict of registered callbacks.
add_callback
add_callback(callback_type: Callback, callback: callable) -> None
Adds a callback function to be executed after the process finishes.
add_error
add_error(error: Optional[str] = 'Unknown error', details: Optional[str] = 'Unknown details', items: Optional[List[str]] = None) -> None
Adds an error to the list of errors.
Parameters:
-
(errorstr, default:'Unknown error') –The error message or name.
-
(detailsstr, default:'Unknown details') –Detailed description of the error.
-
(itemslist, default:None) –Optional list of items related to the error.
process
abstractmethod
The core logic of the process. This method should be implemented by subclasses with specific logic for the process.
Parameters:
-
(contextContext) –The shared context for accessing and storing data during execution.
Raises:
-
NotImplementedError–If the subclass does not implement this method.
set_status
set_status(status: StatusProcess) -> None
StatusProcess
Enum-like class representing the status of a process.