diff --git a/src/pyrdfrules/__init__.py b/src/pyrdfrules/__init__.py index 136e4ab..48312ee 100644 --- a/src/pyrdfrules/__init__.py +++ b/src/pyrdfrules/__init__.py @@ -3,7 +3,93 @@ # SPDX-License-Identifier: MIT """ +PyRDFRules is a Python wrapper for the RDFRules tool, providing an interface to interact with RDFRules for rule mining from RDF knowledge graphs. -PyRDFRules is a Python library for working with RDFRules. It provides a simple interface for creating and managing RDFRules pipelines. +Sample usage: +```python +import pyrdfrules.application +from pyrdfrules.common.task.task import Task +from pyrdfrules.config import Config +from pyrdfrules.rdfrules.commondata import ConfidenceType, Constraint, RuleConsumer, RuleConsumerType, Threshold +from pyrdfrules.rdfrules.jsonformats import PrefixFull +from pyrdfrules.rdfrules.pipeline import ComputeConfidence, GetRules, GraphAwareRules, Index, LoadGraph, MergeDatasets, AddPrefixes, Mine, Pipeline, SortRuleset +# Create an instance of the application. +app = pyrdfrules.application.Application() + +# Connect to an existing instance of RDFRules. +rdfrules = app.start_remote( + url = Url("http://example.com/api/"), + config=Config( + task_update_interval_ms=1000 + ) +) + +# Create a pipeline, a sequence of steps to be executed. +# You do not have to use fully qualified names for the classes, as they are imported in the example. +pipeline = pyrdfrules.rdfrules.pipeline.Pipeline( + tasks=[ + pyrdfrules.rdfrules.pipeline.LoadGraph( + graphName = "", + path = "/dbpedia_yago/mappingbased_objects_sample.ttl" + ), + pyrdfrules.rdfrules.pipeline.LoadGraph( + graphName = "", + path = "/dbpedia_yago/yagoFacts.tsv", + settings = "tsvParsedUris" + ), + pyrdfrules.rdfrules.pipeline.LoadGraph( + graphName = "", + path = "/dbpedia_yago/yagoDBpediaInstances.tsv", + settings = "tsvParsedUris" + ), + pyrdfrules.rdfrules.pipeline.MergeDatasets(), + pyrdfrules.rdfrules.jsonformats.AddPrefixes( + prefixes=[ + pyrdfrules.rdfrules.jsonformats.PrefixFull(prefix="dbo", nameSpace="http://dbpedia.org/ontology/"), + pyrdfrules.rdfrules.jsonformats.PrefixFull(prefix="dbr", nameSpace="http://dbpedia.org/resource/") + ] + ), + pyrdfrules.rdfrules.pipeline.Index(train=[], test=[]), + pyrdfrules.rdfrules.pipeline.Mine( + thresholds=[ + pyrdfrules.rdfrules.commondata.Threshold(name="MinHeadSize", value=100), + pyrdfrules.rdfrules.commondata.Threshold(name="MaxRuleLength", value=3), + pyrdfrules.rdfrules.commondata.Threshold(name="Timeout", value=5), + pyrdfrules.rdfrules.commondata.Threshold(name="MinHeadCoverage", value=0.01), + ], + ruleConsumers=[ + pyrdfrules.rdfrules.commondata.RuleConsumer( + name=pyrdfrules.rdfrules.commondata.RuleConsumerType.TOP_K, + k=1000, + allowOverflow=False + ) + ], + patterns=[], + constraints=[ + pyrdfrules.rdfrules.commondata.Constraint(name="WithoutConstants") + ], + parallelism=0 + ), + pyrdfrules.rdfrules.pipeline.ComputeConfidence(confidenceType=ConfidenceType.PCA_CONFIDENCE, min=0.5, topk=50), + pyrdfrules.rdfrules.pipeline.SortRuleset(by=[]), + pyrdfrules.rdfrules.pipeline.GraphAwareRules(), + pyrdfrules.rdfrules.pipeline.GetRules() + ] +) + +# Create a task, which represents the execution of the pipeline. +task : Task = None + +# Submit the task to the RDFRules engine. +task = rdfrules.task.create_task(pipeline) + +# Run the task step by step. +for step in rdfrules.task.run_task(task): + print(step) + # You can access the result of the task using the task object, read the logs, or interrupt the task here. + +# Access the result of the task. +print(task.result) +``` """ \ No newline at end of file diff --git a/src/pyrdfrules/api/task/exception/task_not_found_exception.py b/src/pyrdfrules/api/task/exception/task_not_found_exception.py index 0d343f3..3ca9511 100644 --- a/src/pyrdfrules/api/task/exception/task_not_found_exception.py +++ b/src/pyrdfrules/api/task/exception/task_not_found_exception.py @@ -1,7 +1,8 @@ from pyrdfrules.common.exception.pyrdfrules_exception import PyRDFRulesException class TaskNotFoundException(PyRDFRulesException): - """Thrown when a task is not found in the RDFRules instance. + """ + Thrown when a task is not found in the RDFRules instance. """ def __init__(self, task_id: str): diff --git a/src/pyrdfrules/application.py b/src/pyrdfrules/application.py index bf28d21..662b502 100644 --- a/src/pyrdfrules/application.py +++ b/src/pyrdfrules/application.py @@ -9,6 +9,9 @@ from pyrdfrules.rdfrules.rdfrules import RDFRules class Application(BaseModel): + """ + The Application class provides methods to start and stop local or remote instances of RDFRules. + """ __rdfrules: RDFRules|None = None diff --git a/src/pyrdfrules/common/__init__.py b/src/pyrdfrules/common/__init__.py index e69de29..a9aba9a 100644 --- a/src/pyrdfrules/common/__init__.py +++ b/src/pyrdfrules/common/__init__.py @@ -0,0 +1,13 @@ +""" +Common module for pyRDFRules. + +This module contains the common classes and functions used by the other modules of pyRDFRules. + +Contains: +- task: Task class and related classes. +- rule: Rule class and related classes. +- result: Result class and related classes. +- logging: Logging functions. +- config: Configuration class. +- utils: Utility functions. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/base_actions.py b/src/pyrdfrules/common/base_actions.py deleted file mode 100644 index 62b82b1..0000000 --- a/src/pyrdfrules/common/base_actions.py +++ /dev/null @@ -1,2 +0,0 @@ -class BaseActions(): - pass \ No newline at end of file diff --git a/src/pyrdfrules/common/base_transformations.py b/src/pyrdfrules/common/base_transformations.py deleted file mode 100644 index 99d5bbf..0000000 --- a/src/pyrdfrules/common/base_transformations.py +++ /dev/null @@ -1,2 +0,0 @@ -class BaseTransformations(): - pass \ No newline at end of file diff --git a/src/pyrdfrules/common/event/event_dispatcher.py b/src/pyrdfrules/common/event/event_dispatcher.py index ca726e4..ca41709 100644 --- a/src/pyrdfrules/common/event/event_dispatcher.py +++ b/src/pyrdfrules/common/event/event_dispatcher.py @@ -1,14 +1,20 @@ class EventDispatcher(): + """ + The EventDispatcher class manages event listeners and dispatches events to them. + """ def __init__(self): self._listeners = [] def add_listener(self, callback: callable): + """Adds a listener to the event dispatcher.""" self._listeners.append(callback) def remove_listener(self, callback: callable): + """Removes a listener from the event dispatcher.""" self._listeners.remove(callback) def dispatch(self, *args, **kwargs): + """Dispatches an event to all listeners.""" for listener in self._listeners: listener(*args, **kwargs) diff --git a/src/pyrdfrules/common/exception/__init__.py b/src/pyrdfrules/common/exception/__init__.py index e69de29..8aa77b0 100644 --- a/src/pyrdfrules/common/exception/__init__.py +++ b/src/pyrdfrules/common/exception/__init__.py @@ -0,0 +1,3 @@ +""" +Common exceptions for pyRDFRules. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/file/__init__.py b/src/pyrdfrules/common/file/__init__.py index e69de29..767f820 100644 --- a/src/pyrdfrules/common/file/__init__.py +++ b/src/pyrdfrules/common/file/__init__.py @@ -0,0 +1,26 @@ +""" +RDFRules file representations. + +Read all files in the workspace: + +```python +rdfrules = app.start_remote( + url = Url("...") +) + +rdfrules.workspace.get_files() +``` + +Upload a file: + +```python +with open(path, "r") as file: + rdfrules.workspace.upload_file("data/asset.txt", file) +``` + +Delete a file: + +```python +rdfrules.workspace.delete_file("data/asset.txt") +``` +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/file/workspace.py b/src/pyrdfrules/common/file/workspace.py index 583f1ab..98d36f8 100644 --- a/src/pyrdfrules/common/file/workspace.py +++ b/src/pyrdfrules/common/file/workspace.py @@ -6,7 +6,7 @@ class Workspace(): """ - Path in which RDFRules can find datasets and store results. + The Workspace class provides methods to interact with the RDFRules workspace, including file management. """ api: WorkspaceApi diff --git a/src/pyrdfrules/common/file/workspace_tree.py b/src/pyrdfrules/common/file/workspace_tree.py index cc4044b..3a07404 100644 --- a/src/pyrdfrules/common/file/workspace_tree.py +++ b/src/pyrdfrules/common/file/workspace_tree.py @@ -6,6 +6,9 @@ from pyrdfrules.common.file.workspace_file import WorkspaceFile class WorkspaceTree(BaseModel): + """ + The WorkspaceTree class represents the structure of the workspace directory, including files and subdirectories. + """ root: WorkspaceDirectory|None = None diff --git a/src/pyrdfrules/common/http/__init__.py b/src/pyrdfrules/common/http/__init__.py index e69de29..01df361 100644 --- a/src/pyrdfrules/common/http/__init__.py +++ b/src/pyrdfrules/common/http/__init__.py @@ -0,0 +1,3 @@ +""" +HTTP module exposing interactions via the HTTP protocol. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/http/url.py b/src/pyrdfrules/common/http/url.py index 2ba4df6..7dc87fa 100644 --- a/src/pyrdfrules/common/http/url.py +++ b/src/pyrdfrules/common/http/url.py @@ -1,4 +1,9 @@ from pydantic_core import Url class Url(Url): + """Represents a URL. Wrapped so there is no need to explicitly import any Pydantic classes. + + Args: + Url (Url): Wrapper for a URL. + """ pass \ No newline at end of file diff --git a/src/pyrdfrules/common/logging/__init__.py b/src/pyrdfrules/common/logging/__init__.py index e69de29..98d8b01 100644 --- a/src/pyrdfrules/common/logging/__init__.py +++ b/src/pyrdfrules/common/logging/__init__.py @@ -0,0 +1,7 @@ +""" +Logging module exposing logging functionality. + +Configurable logging is provided by the `Config` class. The `Logger` class provides the logging functionality. The `log` function provides a global logger instance. The `configure_logging` function configures the logging, and is called automatically upon application startup. + +By default, the logging level is set to `logging.INFO`. This can be changed by setting the `log_level` attribute of the `Config` class. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/logging/logger.py b/src/pyrdfrules/common/logging/logger.py index aab256b..636f22b 100644 --- a/src/pyrdfrules/common/logging/logger.py +++ b/src/pyrdfrules/common/logging/logger.py @@ -2,9 +2,16 @@ from pyrdfrules.config import Config -pyrdfrules_logger = None +pyrdfrules_logger : logging.Logger = None +"""Global instance of the logger. +Empty by default. +Obtain the logger by calling the `log` function from this package. +""" class Logger(): + """ + The Logger class provides methods to configure and retrieve the logger for the application. + """ logger: logging.Logger = None diff --git a/src/pyrdfrules/common/predictontasks/predictiontasks_actions.py b/src/pyrdfrules/common/predictontasks/predictiontasks_actions.py deleted file mode 100644 index a291509..0000000 --- a/src/pyrdfrules/common/predictontasks/predictiontasks_actions.py +++ /dev/null @@ -1,21 +0,0 @@ -from pyrdfrules.common.base_actions import BaseActions -from pyrdfrules.rdfgraph import RDFGraph - -class PredictionTasksActions(BaseActions): - - def get(self) -> RDFGraph: - """Get and show prediction tasks with candidates. - - Returns: - Self: Get and show all triples. - """ - pass - - def evaluate(self) -> RDFGraph: - """Evaluate all prediction tasks. It returns ranking metrics (such as hits@k, mean reciprocal rank), and completeness/quality metrics with confusion matrix (such as precision, recall). - - Returns: - Self: Export. - """ - pass - \ No newline at end of file diff --git a/src/pyrdfrules/common/predictontasks/predictiontasks_transformations.py b/src/pyrdfrules/common/predictontasks/predictiontasks_transformations.py deleted file mode 100644 index cf9ff6b..0000000 --- a/src/pyrdfrules/common/predictontasks/predictiontasks_transformations.py +++ /dev/null @@ -1,46 +0,0 @@ -from pyrdfrules.common.base_transformations import BaseTransformations -from pyrdfrules.prediction import Prediction -from pyrdfrules.prediction_tasks import PredictionTasks -from pyrdfrules.rdfgraph import RDFGraph - -class PredictionTasksTransformations(BaseTransformations): - - def filter(self) -> PredictionTasks: - """Return a new PredictionTasks object with filtered prediction tasks. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def shrink(self) -> PredictionTasks: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def select_candidates(self) -> RDFGraph: - """Select candidates from each prediction task by a selection strategy. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def to_prediction(self) -> Prediction: - """Convert this object back to the Prediction object. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def to_dataset(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass \ No newline at end of file diff --git a/src/pyrdfrules/common/result/__init__.py b/src/pyrdfrules/common/result/__init__.py index e69de29..c486bf8 100644 --- a/src/pyrdfrules/common/result/__init__.py +++ b/src/pyrdfrules/common/result/__init__.py @@ -0,0 +1,3 @@ +""" +Package for translating the resulting JSON into internal object representations. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/result/result.py b/src/pyrdfrules/common/result/result.py index e4fa990..ad3f52c 100644 --- a/src/pyrdfrules/common/result/result.py +++ b/src/pyrdfrules/common/result/result.py @@ -4,13 +4,22 @@ class Result(): + """Class representing the result of a task. + """ ruleset: Ruleset = None """Ruleset generated by RDFRules. """ + data: dict + """Raw JSON response from RDFRules.""" + def __init__(self, data: dict) -> None: - self.id = id + """Creates a new Result object. + + Args: + data (dict): JSON response from RDFRules. + """ self.data = data self._parse_data() @@ -18,6 +27,8 @@ def __init__(self, data: dict) -> None: pass def _parse_data(self): + """Internal function translating the resulting JSON into internal object representations. + """ rules = [] @@ -35,4 +46,6 @@ def _parse_data(self): self.ruleset = Ruleset(rules = rules) def get_ruleset(self) -> Ruleset: + """Returns the ruleset generated by RDFRules. + """ return self.ruleset \ No newline at end of file diff --git a/src/pyrdfrules/common/rule/__init__.py b/src/pyrdfrules/common/rule/__init__.py index e69de29..e074eda 100644 --- a/src/pyrdfrules/common/rule/__init__.py +++ b/src/pyrdfrules/common/rule/__init__.py @@ -0,0 +1,3 @@ +""" +Contains representations of a generated rule from RDFRules. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/rule/resultrule.py b/src/pyrdfrules/common/rule/resultrule.py index ec46d3b..4dcff87 100644 --- a/src/pyrdfrules/common/rule/resultrule.py +++ b/src/pyrdfrules/common/rule/resultrule.py @@ -1,7 +1,6 @@ from typing import List from pydantic import BaseModel -from pyrdfrules.common.graph.graph import Graph from pyrdfrules.common.rule.measure.measure import RuleMeasure from pyrdfrules.common.rule.rule.body import RuleBody from pyrdfrules.common.rule.rule.head import RuleHead @@ -24,4 +23,10 @@ class ResultRule(BaseModel): """ Measures of the rule. """ - measures: List[RuleMeasure] \ No newline at end of file + measures: List[RuleMeasure] + + def as_test(self) -> str: + return '' + + def as_json(self) -> str: + return '' \ No newline at end of file diff --git a/src/pyrdfrules/common/ruleset/ruleset_actions.py b/src/pyrdfrules/common/ruleset/ruleset_actions.py deleted file mode 100644 index e0d5809..0000000 --- a/src/pyrdfrules/common/ruleset/ruleset_actions.py +++ /dev/null @@ -1,21 +0,0 @@ -from pyrdfrules.common.base_actions import BaseActions -from pyrdfrules.rdfgraph import RDFGraph - -class RulesetActions(BaseActions): - - def get(self) -> RDFGraph: - """Get and show all mined rules. - - Returns: - Self: Get and show all triples. - """ - pass - - - def export(self) -> RDFGraph: - """Export this Ruleset object into a file in some selected output format. - - Returns: - Self: Get and show all triples. - """ - pass \ No newline at end of file diff --git a/src/pyrdfrules/common/ruleset/ruleset_transformations.py b/src/pyrdfrules/common/ruleset/ruleset_transformations.py deleted file mode 100644 index da0616a..0000000 --- a/src/pyrdfrules/common/ruleset/ruleset_transformations.py +++ /dev/null @@ -1,60 +0,0 @@ -from pyrdfrules.common.base_transformations import BaseTransformations -from pyrdfrules.rdfgraph import RDFGraph - -class RulesetTransformations(BaseTransformations): - - def filter(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def shrink(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def sort(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def compute_difference(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def make_clusters(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def prune(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass - - def predict(self) -> RDFGraph: - """Return a new RDFGraph object with updated triples. - - Returns: - Self: RDFGraph object with updated triples. - """ - pass \ No newline at end of file diff --git a/src/pyrdfrules/common/task/__init__.py b/src/pyrdfrules/common/task/__init__.py index e69de29..fe4d3e2 100644 --- a/src/pyrdfrules/common/task/__init__.py +++ b/src/pyrdfrules/common/task/__init__.py @@ -0,0 +1,46 @@ +""" +Task is a pipeline sent to the engine to be executed. + +Task is a representation of the results from RDFRules. + +Tasks should not be created directly, but rather through an instance of Application. + +Tasks should also not be updated manually. + +Example task creation: + + app = pyrdfrules.application.Application() + + rdfrules = app.start_remote( + url = Url("http://example.com/api/"), + config=Config( + task_update_interval_ms=1000 + ) + ) + + task : Task = None + + with open("./tests/data/task.json", "r") as file: + task_json_from_file = file.read() + task = rdfrules.task.create_task_from_string(task_json_from_file) + +To run a task: + + task = rdfrules.task.create_task(pipeline) + + for step in rdfrules.task.run_task(task): + # do something with the step + +Tasks are run iteratively to not block control of user over the task, since a task can be interrupted during runtime. You may wish to do this in case the pipeline creates a combinatorial explosion. + +To interrupt a task: + + rdfrules.task.stop_task(task) + +Tasks may emit events, such as log messages, which can be listened to: + + task.on_log_message += lambda message: log().info(message) + task.on_finished += lambda message: log().info('Task finished') + +Events can be found in the Event submodules of the Task module. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/task/event/__init__.py b/src/pyrdfrules/common/task/event/__init__.py index e69de29..9ca28ff 100644 --- a/src/pyrdfrules/common/task/event/__init__.py +++ b/src/pyrdfrules/common/task/event/__init__.py @@ -0,0 +1,3 @@ +""" +Events emitted during the execution of a Task. +""" \ No newline at end of file diff --git a/src/pyrdfrules/common/task/event/task_finished_message.py b/src/pyrdfrules/common/task/event/task_finished_message.py index cd29b18..364a5fb 100644 --- a/src/pyrdfrules/common/task/event/task_finished_message.py +++ b/src/pyrdfrules/common/task/event/task_finished_message.py @@ -1,12 +1,22 @@ import datetime from pydantic import BaseModel -from pyrdfrules.common.event.event_dispatcher import EventDispatcher class TaskFinishedMessage(BaseModel): + """Message sent when a task has finished. + """ id: str + """ + ID of the task. + """ time_start: datetime.datetime + """ + Time when the task started. + """ - time_end: datetime.datetime \ No newline at end of file + time_end: datetime.datetime + """ + Time when the task ended. + """ \ No newline at end of file diff --git a/src/pyrdfrules/common/task/event/task_log_message.py b/src/pyrdfrules/common/task/event/task_log_message.py index 1dfa83b..6104d96 100644 --- a/src/pyrdfrules/common/task/event/task_log_message.py +++ b/src/pyrdfrules/common/task/event/task_log_message.py @@ -1,12 +1,19 @@ import datetime from pydantic import BaseModel -from pyrdfrules.common.event.event_dispatcher import EventDispatcher class TaskLogMessage(BaseModel): + """Log message for a task. + """ id: str + """Task ID. + """ message: str + """Log message. + """ - time: datetime.datetime \ No newline at end of file + time: datetime.datetime + """Time when the message was logged. + """ \ No newline at end of file diff --git a/src/pyrdfrules/common/task/task_runner.py b/src/pyrdfrules/common/task/task_runner.py index 47e427b..be8e4ce 100644 --- a/src/pyrdfrules/common/task/task_runner.py +++ b/src/pyrdfrules/common/task/task_runner.py @@ -8,6 +8,9 @@ class TaskRunner(): + """ + The TaskRunner class is responsible for running tasks on the RDFRules engine. + """ api: TaskApi diff --git a/src/pyrdfrules/common/task/task_updater.py b/src/pyrdfrules/common/task/task_updater.py index eeabc3a..8efeda9 100644 --- a/src/pyrdfrules/common/task/task_updater.py +++ b/src/pyrdfrules/common/task/task_updater.py @@ -5,7 +5,8 @@ from pyrdfrules.config import Config class TaskUpdater(): - """Utility class that handles the updating of tasks. + """ + The TaskUpdater class handles the updating of tasks. """ api: TaskApi diff --git a/src/pyrdfrules/config.py b/src/pyrdfrules/config.py index 9e5290b..3b3cda7 100644 --- a/src/pyrdfrules/config.py +++ b/src/pyrdfrules/config.py @@ -3,7 +3,8 @@ class Config(BaseModel): - """Configuration class for the instance. + """ + Configuration class for the instance. """ task_update_interval_ms: PositiveInt = 1000 diff --git a/src/pyrdfrules/engine/__init__.py b/src/pyrdfrules/engine/__init__.py index e69de29..fd30ba1 100644 --- a/src/pyrdfrules/engine/__init__.py +++ b/src/pyrdfrules/engine/__init__.py @@ -0,0 +1,3 @@ +""" +Engine is a representation of the RDFRules engine. It is a base class for RDFRules engine backends. It contains shared methods and all its descendants represent different methods to communicate with the RDFRules engine. +""" \ No newline at end of file diff --git a/src/pyrdfrules/engine/engine.py b/src/pyrdfrules/engine/engine.py index 48110b0..24d7067 100644 --- a/src/pyrdfrules/engine/engine.py +++ b/src/pyrdfrules/engine/engine.py @@ -24,6 +24,12 @@ class Engine(): Configuration of the engine.""" def __init__(self, config: Config) -> None: + """ + Initializes the engine with the given configuration. + + Args: + config (Config): Configuration of the engine. + """ self.config = config pass diff --git a/src/pyrdfrules/rdfrules/pipeline.py b/src/pyrdfrules/rdfrules/pipeline.py index 9ab78c2..f459b29 100644 --- a/src/pyrdfrules/rdfrules/pipeline.py +++ b/src/pyrdfrules/rdfrules/pipeline.py @@ -9,6 +9,8 @@ class Pipeline(BaseModel): + """Pipeline is a sequence of tasks to be executed. + """ tasks: List[RDFRulesTaskModel] @model_serializer() diff --git a/src/pyrdfrules/rdfrules/rdfrules.py b/src/pyrdfrules/rdfrules/rdfrules.py index a0136fc..09454c4 100644 --- a/src/pyrdfrules/rdfrules/rdfrules.py +++ b/src/pyrdfrules/rdfrules/rdfrules.py @@ -7,14 +7,24 @@ from pyrdfrules.engine.engine import Engine class RDFRules(): + """Represents the RDFRules engine. + """ engine: Engine + """RDFRules engine. + """ workspace: Workspace + """Workspace classes. + """ task: TaskRunner + """Task runner. + """ config: Config + """Configuration. + """ def __init__(self, engine: Engine, config: Config) -> None: self.engine = engine diff --git a/src/tests/__init__.py b/src/tests/__init__.py index f65b193..c40bf77 100644 --- a/src/tests/__init__.py +++ b/src/tests/__init__.py @@ -1,3 +1,7 @@ # SPDX-FileCopyrightText: 2023-present Karel Douda # # SPDX-License-Identifier: MIT + +""" +This module contains unit tests for the PyRDFRules library. +"""