Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kdouda committed Jan 8, 2025
1 parent 96079be commit 343fe09
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<dbpedia>",
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

Expand Down

0 comments on commit 343fe09

Please sign in to comment.