Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --constraint=requirements.txt --extra=dev --output-file=dev-requirements.txt pyproject.toml
Expand All @@ -20,11 +20,11 @@ amqp==5.3.1
# via
# -c requirements.txt
# kombu
apispec[marshmallow]==6.8.0
apispec[marshmallow]==6.8.1
# via
# -c requirements.txt
# flask-smorest
attrs==24.2.0
attrs==25.1.0
# via flake8-bugbear
billiard==4.2.1
# via
Expand All @@ -38,11 +38,11 @@ blinker==1.9.0
# flask
build==1.2.2.post1
# via omotes-rest (pyproject.toml)
celery==5.3.6
celery==5.4.0
# via
# -c requirements.txt
# omotes-sdk-python
click==8.1.7
click==8.1.8
# via
# -c requirements.txt
# black
Expand All @@ -67,7 +67,7 @@ colorama==0.4.6
# via
# -c requirements.txt
# omotes-rest (pyproject.toml)
coverage[toml]==7.6.9
coverage[toml]==7.6.12
# via pytest-cov
flake8==7.1.1
# via
Expand Down Expand Up @@ -131,19 +131,19 @@ itsdangerous==2.2.0
# via
# -c requirements.txt
# flask
jinja2==3.1.4
jinja2==3.1.5
# via
# -c requirements.txt
# flask
kombu==5.4.2
# via
# -c requirements.txt
# celery
lxml==5.3.0
lxml==5.3.1
# via
# -c requirements.txt
# pyecore
mako==1.3.8
mako==1.3.9
# via
# -c requirements.txt
# alembic
Expand Down Expand Up @@ -186,11 +186,11 @@ mypy-extensions==1.0.0
# black
# mypy
# typing-inspect
omotes-sdk-protocol==0.1.13
omotes-sdk-protocol==1.0.0
# via
# -c requirements.txt
# omotes-sdk-python
omotes-sdk-python==3.2.5
omotes-sdk-python==4.0.1
# via
# -c requirements.txt
# omotes-rest (pyproject.toml)
Expand Down Expand Up @@ -220,15 +220,15 @@ platformdirs==4.3.6
# via black
pluggy==1.5.0
# via pytest
prompt-toolkit==3.0.48
prompt-toolkit==3.0.50
# via
# -c requirements.txt
# click-repl
propcache==0.2.1
# via
# -c requirements.txt
# yarl
protobuf==4.25.5
protobuf==5.29.3
# via
# -c requirements.txt
# omotes-sdk-protocol
Expand Down Expand Up @@ -266,11 +266,11 @@ python-dotenv==1.0.1
# via
# -c requirements.txt
# omotes-rest (pyproject.toml)
restrictedpython==7.4
restrictedpython==8.0
# via
# -c requirements.txt
# pyecore
setuptools-git-versioning==2.0.0
setuptools-git-versioning==2.1.0
# via omotes-rest (pyproject.toml)
six==1.17.0
# via
Expand All @@ -296,7 +296,7 @@ types-flask-cors==5.0.0.20240902
# via omotes-rest (pyproject.toml)
types-protobuf==4.24.0.20240408
# via omotes-rest (pyproject.toml)
typing-extensions==4.11.0
typing-extensions==4.12.2
# via
# -c requirements.txt
# alembic
Expand All @@ -308,7 +308,7 @@ typing-inspect==0.9.0
# via
# -c requirements.txt
# marshmallow-dataclass
tzdata==2024.2
tzdata==2025.1
# via
# -c requirements.txt
# celery
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ volumes:

services:
omotes-rest:
image: ghcr.io/project-omotes/omotes_rest:1.1.0
image: ghcr.io/project-omotes/omotes_rest:1.2.0
networks:
- omotes
#- mapeditor-net
# - mapeditor-net
ports:
- "9200:9200"
environment:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"python-dotenv ~= 1.0.0",
"structlog ~= 23.1.0",
"SQLAlchemy == 2.0.28",
"omotes-sdk-python ~= 3.2.5",
"omotes-sdk-python ~= 4.0.0",
"alembic ~= 1.13.1",
]

Expand Down
28 changes: 14 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements.txt pyproject.toml
Expand All @@ -12,15 +12,15 @@ alembic==1.13.3
# via omotes-rest (pyproject.toml)
amqp==5.3.1
# via kombu
apispec[marshmallow]==6.8.0
apispec[marshmallow]==6.8.1
# via flask-smorest
billiard==4.2.1
# via celery
blinker==1.9.0
# via flask
celery==5.3.6
celery==5.4.0
# via omotes-sdk-python
click==8.1.7
click==8.1.8
# via
# celery
# click-didyoumean
Expand Down Expand Up @@ -57,13 +57,13 @@ idna==3.10
# via yarl
itsdangerous==2.2.0
# via flask
jinja2==3.1.4
jinja2==3.1.5
# via flask
kombu==5.4.2
# via celery
lxml==5.3.0
lxml==5.3.1
# via pyecore
mako==1.3.8
mako==1.3.9
# via alembic
markupsafe==3.0.2
# via
Expand All @@ -86,9 +86,9 @@ multidict==6.1.0
# via yarl
mypy-extensions==1.0.0
# via typing-inspect
omotes-sdk-protocol==0.1.13
omotes-sdk-protocol==1.0.0
# via omotes-sdk-python
omotes-sdk-python==3.2.5
omotes-sdk-python==4.0.1
# via omotes-rest (pyproject.toml)
ordered-set==4.1.0
# via pyecore
Expand All @@ -102,11 +102,11 @@ pamqp==3.3.0
# via
# aiormq
# omotes-sdk-python
prompt-toolkit==3.0.48
prompt-toolkit==3.0.50
# via click-repl
propcache==0.2.1
# via yarl
protobuf==4.25.5
protobuf==5.29.3
# via omotes-sdk-protocol
psycopg2-binary==2.9.10
# via omotes-rest (pyproject.toml)
Expand All @@ -118,7 +118,7 @@ python-dateutil==2.9.0.post0
# via celery
python-dotenv==1.0.1
# via omotes-rest (pyproject.toml)
restrictedpython==7.4
restrictedpython==8.0
# via pyecore
six==1.17.0
# via python-dateutil
Expand All @@ -130,15 +130,15 @@ streamcapture==1.2.5
# via omotes-sdk-python
structlog==23.1.0
# via omotes-rest (pyproject.toml)
typing-extensions==4.11.0
typing-extensions==4.12.2
# via
# alembic
# omotes-sdk-python
# sqlalchemy
# typing-inspect
typing-inspect==0.9.0
# via marshmallow-dataclass
tzdata==2024.2
tzdata==2025.1
# via
# celery
# kombu
Expand Down
11 changes: 0 additions & 11 deletions src/omotes_rest/apis/api_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ class JobDeleteResponse:
deleted: bool


@add_schema
@dataclass
class JobCancelResponse:
"""Response for job cancellation."""

Schema: ClassVar[Type[Schema]] = Schema

job_id: uuid.UUID
cancelled: bool


@add_schema
@dataclass
class JobLogsResponse:
Expand Down
16 changes: 1 addition & 15 deletions src/omotes_rest/apis/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
JobLogsResponse,
JobSummary,
JobDeleteResponse,
JobCancelResponse,
)
from omotes_rest.db_models.job_rest import JobRest
from omotes_rest.typed_app import current_app
Expand Down Expand Up @@ -71,24 +70,11 @@ def get(self, job_id: str) -> JobRest | None:

@api.response(200, JobDeleteResponse.Schema())
def delete(self, job_id: str) -> JobDeleteResponse:
"""Delete job, and cancel if queued or running."""
"""Delete job: terminate if running, and delete time series data if present."""
job_uuid = uuid.UUID(job_id)
return JobDeleteResponse(job_id=job_uuid, deleted=current_app.rest_if.delete_job(job_uuid))


@api.route("/<string:job_id>/cancel")
class JobCancelAPI(MethodView):
"""Requests."""

@api.response(200, JobCancelResponse.Schema())
def get(self, job_id: str) -> JobCancelResponse:
"""Cancel job if queued or running."""
job_uuid = uuid.UUID(job_id)
return JobCancelResponse(
job_id=job_uuid, cancelled=current_app.rest_if.cancel_job(job_uuid)
)


@api.route("/<string:job_id>/status")
class JobStatusAPI(MethodView):
"""Requests."""
Expand Down
22 changes: 6 additions & 16 deletions src/omotes_rest/rest_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ def get_jobs(self) -> list[JobRest]:
"""
return self.postgres_if.get_jobs()

def cancel_job(self, job_id: uuid.UUID) -> bool:
"""Cancel job by id.
def delete_job(self, job_id: uuid.UUID) -> bool:
"""Delete job by id.

:param job_id: Job id.
:return: True if job found and cancelled.
:return: True if job found and deleted.
"""
job_in_db = self.get_job(job_id)

Expand All @@ -321,22 +321,12 @@ def cancel_job(self, job_id: uuid.UUID) -> bool:
job_in_db.workflow_type
)
if not workflow_type:
raise RuntimeError(f"Unknown workflow type {job_in_db.workflow_type}")
self.error = RuntimeError(f"Unknown workflow type {job_in_db.workflow_type}")
raise self.error

job = Job(id=job_id, workflow_type=workflow_type)
self.omotes_if.cancel_job(job)
result = True
else:
result = False
return result

def delete_job(self, job_id: uuid.UUID) -> bool:
"""Delete job by id.
self.omotes_if.delete_job(job)

:param job_id: Job id.
:return: True if job found and deleted.
"""
self.cancel_job(job_id)
return self.postgres_if.delete_job(job_id)

def get_job_status(self, job_id: uuid.UUID) -> JobRestStatus | None:
Expand Down