From 343fe09ace1b40cd99ae8fccd375cc957c2f69a6 Mon Sep 17 00:00:00 2001 From: Karel Douda Date: Wed, 8 Jan 2025 12:45:00 +0100 Subject: [PATCH] Update doc --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3c8938d..e091045 100644 --- a/README.md +++ b/README.md @@ -126,14 +126,36 @@ task : Task = None with open("./task.json", "r") as file: task_json_from_file = file.read() - task = await rdfrules.task.create_task_from_string(task_json_from_file) + task = rdfrules.task.create_task_from_string(task_json_from_file) +``` + +You can also specify the pipeline in code. + +```python + +pipeline = Pipeline( + tasks=[ + LoadGraph( + graphName = "", + path = "/dbpedia_yago/mappingbased_objects_sample.ttl" + ), + ... # your other tasks go here + GetRules() + ] +) + +task = self.rdfrules.task.create_task(pipeline) -await rdfrules.task.run_task(task) +for step in self.rdfrules.task.run_task(task): + print(step) + +print(task.result) # access task result dictionary - pure output from RDFRules +print(task.get_result()) # returns formatted outputs ``` -This will block execution until the task is finished. You can then access the results of the task once it's done. +Task execution is non blocking and you can stop it, as long as it is not finished in RDFRules. -Full pipeline sample matching the DBpedia & YAGO example from the RDFRules web instance can be found in `sample/dbpedia.py` or DOCUMENTATION LINK (todo). +Full pipeline sample matching the DBpedia & YAGO example from the RDFRules web instance can be found in documentation [doc](https://kizi.github.io/pyrdfrules/pyrdfrules.html), or in `src/tests/test_pipeline.py`. ## Developing