Common Artifact
Overview seeknal.common_artifact
seeknal.common_artifact
The Common Artifact module encapsulates the business logic for managing data sources and rules within the Seeknal framework. It provides classes and methods for creating, updating, and listing sources and rules, as well as handling common data operations.
Source
Overview
The Source
class manages data sources, allowing users to define and interact with them.
Source Name
The name of the source, used to identify it within the framework.
Source Details
Additional details about the dataset associated with the source.
Source Description
A brief description of the source, providing context and purpose.
Entity
The entity associated with the source, if applicable.
The Source
class provides methods to create, update, and list sources, ensuring that all source-related information is organized and accessible.
Source Class
Class
Attributes
name
(str): The name of the source.details
(Optional[Dataset]): Additional details about the dataset associated with the source.description
(str): A brief description of the source.entity
(Optional[Entity]): The entity associated with the source.
Methods
require_saved(func)
: A decorator that ensures the source has been saved before executing the wrapped function.get_or_create(self) -> Source
:Retrieves an existing source by name or creates a new one if it does not exist.
Updates the source ID and associated details.
Returns the
Source
object.
list() -> None
:Lists all sources associated with the current project.
Displays source names, descriptions, and details in a tabular format.
update(self, name=None, details=None, description=None, entity=None) -> Source
:Updates the source details.
Raises a
ValueError
if the source does not exist.Returns the updated
Source
object.
delete(self) -> None
:Deletes the source by its ID.
Rule
Overview
The Rule
class manages rules that can be applied to data sources.
Rule Name
The name of the rule, used to identify it within the framework.
Rule Value
The value associated with the rule, which can be a string or a list.
Rule Description
A brief description of the rule, providing context and purpose.
The Rule
class provides methods to create, update, and list rules, ensuring that all rule-related information is organized and accessible.
Rule Class
Class
Attributes
name
(str): The name of the rule.value
(Optional[Union[str, List]]): The value associated with the rule.description
(str): A brief description of the rule.
Methods
require_saved(func)
: A decorator that ensures the rule has been saved before executing the wrapped function.get_or_create(self) -> Rule
:Retrieves an existing rule by name or creates a new one if it does not exist.
Updates the rule ID and associated details.
Returns the
Rule
object.
list() -> None
:Lists all rules associated with the current project.
Displays rule names, values, and descriptions in a tabular format.
update(self, name=None, value=None, description=None) -> Rule
:Updates the rule details.
Raises a
ValueError
if the rule does not exist.Returns the updated
Rule
object.
delete(self) -> None
:Deletes the rule by its ID.
Common
Overview
The Common
class provides utility methods for managing collections of sources and rules.
Sources
A list of sources associated with the current project.
Rules
A list of rules associated with the current project.
CommonClass
Class
Methods
as_dict() -> dict
:Retrieves all sources and rules associated with the current project.
Returns a dictionary containing lists of sources and rules.
as_yaml() -> str
:Converts the sources and rules to a YAML format string.
Last updated