Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kdouda committed Jan 4, 2025
1 parent 573d4e3 commit 6922f5c
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 245 deletions.
6 changes: 6 additions & 0 deletions src/pyrdfrules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2023-present Karel Douda <[email protected]>
#
# SPDX-License-Identifier: MIT

"""
PyRDFRules is a Python library for working with RDFRules. It provides a simple interface for creating and managing RDFRules pipelines.
"""
6 changes: 6 additions & 0 deletions src/pyrdfrules/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
API module contains the classes that are used to interact with RDFRules, mainly using the HTTP interface.
Each API domain contains a base class and concrete implementations (e.g. `CacheApi` and `CacheHttpApi`).
This allows for mocking and testing, but also future changes in the API without changing the client code.
"""
3 changes: 3 additions & 0 deletions src/pyrdfrules/api/cache/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Entities for interacting with the cache API of RDFRules.
"""
26 changes: 23 additions & 3 deletions src/pyrdfrules/api/cache/cache_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,38 @@ def __init__(self, context: RDFRulesApiContext) -> None:
self.context = context
pass

def get_memory_info(self):
def get_memory_info(self) -> dict:
"""Gets memory info.
Returns:
dict: Memory info.
"""

def clear(self):
def clear(self) -> None:
"""Clears the cache.
Returns:
None
"""

def delete(self, key: str):
def delete(self, key: str) -> None:
"""Deletes a key from the cache.
Args:
key (str): Key to delete.
Throws:
Exception: If the key does not exist.
"""

def alias(self, key: str, alias: str):
"""Creates an alias for a key.
Args:
key (str): Key to alias.
alias (str): Alias to create.
Throws:
Exception: If the key does not exist.
"""
18 changes: 4 additions & 14 deletions src/pyrdfrules/api/cache/cache_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,20 @@

class CacheHttpApi(CacheApi):

__doc__ = CacheApi.__doc__

def __init__(self, context: HTTPRDFRulesApiContext) -> None:
super().__init__(context)
pass

def get_memory_info(self) -> dict:
"""Gets memory info.
"""

return self.context.get_http_client().get(CACHE_MEMORY_URL).json()

def clear(self) -> None:
"""Clears the cache.
"""

self.context.get_http_client().get(CACHE_CLEAR_URL)

def delete(self, key: str):
"""Deletes a key from the cache.
"""

def delete(self, key: str) -> None:
self.context.get_http_client().delete(CACHE_DELETE_URL.format(key = key))

def alias(self, key: str, alias: str):
"""Creates an alias for a key.
"""

def alias(self, key: str, alias: str) -> None:
pass
3 changes: 3 additions & 0 deletions src/pyrdfrules/api/http_rdfrules_api_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from pyrdfrules.config import Config

class HTTPRDFRulesApiContext(RDFRulesApiContext):
"""
Context class for the RDFRules API, passed around for HTTP API clients.
"""

url: Url
"""URL of the RDFRules API server.
Expand Down
3 changes: 3 additions & 0 deletions src/pyrdfrules/api/rdfrules_api_context.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class RDFRulesApiContext():
"""Base context class passed around the API classes.
"""

pass
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from pyrdfrules.common.exception.pyrdfrules_exception import PyRDFRulesException

class TaskNotFoundException(PyRDFRulesException):
def __init__(self, task_id):
"""Thrown when a task is not found in the RDFRules instance.
"""

def __init__(self, task_id: str):
super(TaskNotFoundException, self).__init__(f'Task with id {task_id} not found')
2 changes: 2 additions & 0 deletions src/pyrdfrules/api/task/task_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class TaskHttpApi(TaskApi):

__doc__ = TaskApi.__doc__

context: HTTPRDFRulesApiContext

def __init__(self, context: HTTPRDFRulesApiContext) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/pyrdfrules/api/workspace/workspace_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class WorkspaceApi():

context: RDFRulesApiContext

def __init__(self, context: RDFRulesApiContext) -> None:
Expand Down
2 changes: 2 additions & 0 deletions src/pyrdfrules/api/workspace/workspace_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class WorkspaceHttpApi(WorkspaceApi):

__doc__ = WorkspaceApi.__doc__

context: HTTPRDFRulesApiContext

def __init__(self, context: HTTPRDFRulesApiContext) -> None:
Expand Down
8 changes: 0 additions & 8 deletions src/pyrdfrules/common/graph/graph.py

This file was deleted.

37 changes: 0 additions & 37 deletions src/pyrdfrules/common/graph/rdfgraph_actions.py

This file was deleted.

52 changes: 0 additions & 52 deletions src/pyrdfrules/common/graph/rdfgraph_transformations.py

This file was deleted.

10 changes: 0 additions & 10 deletions src/pyrdfrules/common/graph/remote_graph.py

This file was deleted.

20 changes: 0 additions & 20 deletions src/pyrdfrules/common/graph/workspace_graph.py

This file was deleted.

Empty file.
13 changes: 0 additions & 13 deletions src/pyrdfrules/common/index/index_actions.py

This file was deleted.

12 changes: 0 additions & 12 deletions src/pyrdfrules/common/index/index_transformations.py

This file was deleted.

21 changes: 0 additions & 21 deletions src/pyrdfrules/common/prediction/prediction_actions.py

This file was deleted.

Loading

0 comments on commit 6922f5c

Please sign in to comment.