Skip to content

Commit

Permalink
Add skeleton API classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kdouda committed Sep 11, 2024
1 parent 4248fc8 commit f2df26e
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 0 deletions.
25 changes: 25 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
annotated-types==0.6.0
anyio==4.4.0
argcomplete==3.5.0
black==24.8.0
certifi==2024.8.30
charset-normalizer==3.3.2
click==8.1.7
datamodel-code-generator==0.26.0
dnspython==2.6.1
email_validator==2.2.0
genson==1.3.0
h11==0.14.0
httpcore==1.0.5
httpx==0.27.2
idna==3.8
inflect==5.6.2
install-jdk==1.1.0
isort==5.13.2
Jinja2==3.1.4
JPype1==1.5.0
MarkupSafe==2.1.5
mypy-extensions==1.0.0
numpy==2.1.1
packaging==24.0
pandas==2.2.2
pathspec==0.12.1
platformdirs==4.3.2
pydantic==2.6.4
pydantic_core==2.16.3
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.2
requests==2.32.3
six==1.16.0
sniffio==1.3.1
typing_extensions==4.10.0
tzdata==2024.1
urllib3==2.2.2
Empty file added src/pyrdfrules/api/__init__.py
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions src/pyrdfrules/api/cache/cache_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext


class CacheApi():

context: RDFRulesApiContext

def __init__(self, context: RDFRulesApiContext) -> None:
self.context = context
pass

async def get_memory_info():
"""Gets memory info.
"""

async def clear():
"""Clears the cache.
"""

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

async def alias(key: str, alias: str):
"""Creates an alias for a key.
"""
12 changes: 12 additions & 0 deletions src/pyrdfrules/api/http_rdfrules_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pyrdfrules.api.rdfrules_api import RDFRulesApi
from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext


class HTTPRDFRulesApi(RDFRulesApi):

def __init__(self, context: RDFRulesApiContext) -> None:
super().__init__(context)
self.cache = None
self.workspace = None
self.task = None
pass
11 changes: 11 additions & 0 deletions src/pyrdfrules/api/http_rdfrules_api_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pydantic import BaseModel
from pydantic_core import Url

from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext


class HTTPRDFRulesApiContext(RDFRulesApiContext):

url: Url
"""URL of the RDFRules API server.
"""
15 changes: 15 additions & 0 deletions src/pyrdfrules/api/rdfrules_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyrdfrules.api.cache.cache_api import CacheApi
from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext
from pyrdfrules.api.task.task_api import TaskApi
from pyrdfrules.api.workspace.workspace_api import WorkspaceApi


class RDFRulesApi():
cache: CacheApi
workspace: WorkspaceApi
task: TaskApi
context: RDFRulesApiContext

def __init__(self, context: RDFRulesApiContext) -> None:
self.context = context
pass
5 changes: 5 additions & 0 deletions src/pyrdfrules/api/rdfrules_api_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pydantic import BaseModel


class RDFRulesApiContext(BaseModel):
pass
Empty file.
25 changes: 25 additions & 0 deletions src/pyrdfrules/api/task/task_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext


class TaskApi():

context: RDFRulesApiContext

def __init__(self, context: RDFRulesApiContext) -> None:
self.context = context
pass

async def create_task(self):
"""Create a task.
"""
pass

async def get_task_status(self, task_id: str):
"""Get the status of a task.
"""
pass

async def interrupt_task(self, task_id: str):
"""Interrupt a task.
"""
pass
Empty file.
30 changes: 30 additions & 0 deletions src/pyrdfrules/api/workspace/workspace_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pyrdfrules.api.rdfrules_api_context import RDFRulesApiContext


class WorkspaceApi():

context: RDFRulesApiContext

def __init__(self, context: RDFRulesApiContext) -> None:
self.context = context
pass

async def get_all_files(self):
"""Get all files and directories recursively from the workspace directory.
"""
pass

async def get_file(self, path: str):
"""Get the file content.
"""
pass

async def delete_file(self, path: str):
"""Delete a file.
"""
pass

async def upload_file(self, path: str, content: bytes):
"""Upload a file.
"""
pass
23 changes: 23 additions & 0 deletions src/pyrdfrules/engine/engine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from typing import Awaitable
from pydantic import BaseModel

Expand Down Expand Up @@ -64,4 +65,26 @@ async def launch_pipeline(self, pipeline: Pipeline) -> Awaitable[PipelineRunResu
Throws:
"""
pass



@ensure_started
async def run_task(self, task: str|dict) -> Awaitable[None]:
"""
Runs a task on the engine.
Args:
task (str|dict): Task to run, either string-serialized JSON or JSON represented as a dict.
Returns:
Awaitable[None]: Returns a non-blocking future.
"""

# todo custom exception
if not isinstance(task, dict):
task = json.loads(task)



pass

0 comments on commit f2df26e

Please sign in to comment.