Skip to content

Commit 06f5646

Browse files
Merge pull request #95 from Project-OMOTES/94-enable-time-series-database-cleanup
94 enable time series database cleanup
2 parents eed8dc4 + 9e2424b commit 06f5646

File tree

7 files changed

+43
-35
lines changed

7 files changed

+43
-35
lines changed

.github/workflows/ci_linux.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v3
1515
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v4
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
cache: 'pip'
@@ -39,7 +39,7 @@ jobs:
3939
steps:
4040
- uses: actions/checkout@v3
4141
- name: Set up Python ${{ matrix.python-version }}
42-
uses: actions/setup-python@v4
42+
uses: actions/setup-python@v5
4343
with:
4444
python-version: ${{ matrix.python-version }}
4545
cache: 'pip'
@@ -64,7 +64,7 @@ jobs:
6464
steps:
6565
- uses: actions/checkout@v3
6666
- name: Set up Python ${{ matrix.python-version }}
67-
uses: actions/setup-python@v4
67+
uses: actions/setup-python@v5
6868
with:
6969
python-version: ${{ matrix.python-version }}
7070
cache: 'pip'
@@ -112,7 +112,7 @@ jobs:
112112
steps:
113113
- uses: actions/checkout@v3
114114
- name: Set up Python ${{ matrix.python-version }}
115-
uses: actions/setup-python@v4
115+
uses: actions/setup-python@v5
116116
with:
117117
python-version: ${{ matrix.python-version }}
118118
cache: 'pip'
@@ -140,7 +140,7 @@ jobs:
140140
steps:
141141
- uses: actions/checkout@v3
142142
- name: Set up Python ${{ matrix.python-version }}
143-
uses: actions/setup-python@v4
143+
uses: actions/setup-python@v5
144144
with:
145145
python-version: ${{ matrix.python-version }}
146146
cache: 'pip'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository is part of the 'Nieuwe Warmte Nu Design Toolkit' project.
44

5-
Python implementation of the OMOTES SDK through jobs which may be submitted, receive status updates for submitted jobs or cancel submitted jobs.
5+
Python implementation of the OMOTES SDK through jobs which may be submitted, receive status updates for submitted jobs or delete submitted jobs.
66

77
## Protobuf
88
Please install `protoc` on your machine and make sure it is available in your `PATH`.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
{ name = "Sebastiaan la Fleur", email = "sebastiaan.lafleur@tno.nl" },
77
{ name = "Mark Vrijlandt", email = "mark.vrijlandt@tno.nl" },
88
]
9-
description = "Python implementation of the OMOTES SDK through jobs which may be submitted, receive status updates for submitted jobs or cancel submitted jobs."
9+
description = "Python implementation of the OMOTES SDK through jobs which may be submitted, receive status updates for submitted jobs or delete submitted jobs."
1010
readme = "README.md"
1111
license = {file = "LICENSE"}
1212
classifiers = [
@@ -25,7 +25,7 @@ classifiers = [
2525

2626
dependencies = [
2727
"aio-pika ~= 9.4",
28-
"omotes-sdk-protocol ~= 0.1",
28+
"omotes-sdk-protocol ~= 0.1,>=0.1.15",
2929
"pyesdl ~= 24.2",
3030
"pamqp ~= 3.3",
3131
"celery ~= 5.3",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from esdl.esdl_handler import EnergySystemHandler
2+
3+
4+
def pyesdl_from_string(input_str: str) -> EnergySystemHandler:
5+
"""
6+
Loads esdl file from a string into memory.
7+
8+
Please note that it is not checked if the contents of the string is a valid esdl.
9+
:param input_str: string containing the contents of an esdl file.
10+
"""
11+
esh = EnergySystemHandler()
12+
esh.load_from_string(input_str)
13+
return esh

src/omotes_sdk/internal/worker/worker.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from celery.apps.worker import Worker as CeleryWorker
1212
from kombu import Queue as KombuQueue
1313
from esdl import EnergySystem
14-
from esdl.esdl_handler import EnergySystemHandler
1514

1615
from omotes_sdk.internal.orchestrator_worker_events.esdl_messages import EsdlMessage
16+
from omotes_sdk.internal.common.esdl_util import pyesdl_from_string
1717
from omotes_sdk.internal.worker.configs import WorkerConfig
1818
from omotes_sdk.internal.common.broker_interface import BrokerInterface
1919
from omotes_sdk_protocol.internal.task_pb2 import (
@@ -241,18 +241,6 @@ def on_failure(
241241
)
242242

243243

244-
def pyesdl_from_string(input_str: str) -> EnergySystemHandler:
245-
"""
246-
Loads esdl file from a string into memory.
247-
248-
Please note that it is not checked if the contents of the string is a valid esdl.
249-
:param input_str: string containing the contents of an esdl file.
250-
"""
251-
esh = EnergySystemHandler()
252-
esh.load_from_string(input_str)
253-
return esh
254-
255-
256244
def wrapped_worker_task(
257245
task: WorkerTask, job_id: UUID, job_reference: str, input_esdl: str, params_dict: ProtobufDict
258246
) -> None:

src/omotes_sdk/omotes_interface.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
JobProgressUpdate,
1717
JobStatusUpdate,
1818
JobSubmission,
19-
JobCancel,
19+
JobDelete,
2020
)
2121
from omotes_sdk_protocol.workflow_pb2 import AvailableWorkflows, RequestAvailableWorkflows
2222

@@ -372,21 +372,28 @@ def submit_job(
372372

373373
return job
374374

375-
def cancel_job(self, job: Job) -> None:
376-
"""Cancel a job.
375+
def delete_job(self, job: Job) -> None:
376+
"""Delete a job and all of its resources.
377377
378-
If this succeeds or not will be send as a job status update through the
379-
`callback_on_status_update` handler. This method will not disconnect from the submitted job
380-
events. This will need to be done separately using `disconnect_from_submitted_job`.
378+
This will delete the job regardless of its current state. If it is running, it will be
379+
cancelled. If the job produced any timeseries data, it will be deleted eventually.
381380
382-
:param job: The job to cancel.
381+
Developers note:
382+
If the jobs is successfully cancelled or not will be sent as a job status update through
383+
the `callback_on_status_update` handler. This method will not disconnect from the submitted
384+
job events. This will need to be done separately using `disconnect_from_submitted_job`
385+
after receiving the job status update.
386+
Deletion of the timeseries is done by the orchestrator. See:
387+
https://github.com/Project-OMOTES/architecture-documentation/blob/main/Feature_Time_Series_DB_Cleanup/Feature_Time_Series_DB_Cleanup.md
388+
389+
:param job: The job to delete.
383390
"""
384-
logger.info("Cancelling job %s", job.id)
385-
cancel_msg = JobCancel(uuid=str(job.id))
391+
logger.info("Deleting job %s", job.id)
392+
delete_msg = JobDelete(uuid=str(job.id))
386393
self.broker_if.send_message_to(
387394
exchange_name=OmotesQueueNames.omotes_exchange_name(),
388-
routing_key=OmotesQueueNames.job_cancel_queue_name(),
389-
message=cancel_msg.SerializeToString(),
395+
routing_key=OmotesQueueNames.job_delete_queue_name(),
396+
message=delete_msg.SerializeToString(),
390397
)
391398

392399
def connect_to_available_workflows_updates(self) -> None:

src/omotes_sdk/queue_names.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ def job_status_queue_name(job_uuid: uuid.UUID) -> str:
4848
return f"jobs.{job_uuid}.status"
4949

5050
@staticmethod
51-
def job_cancel_queue_name() -> str:
52-
"""Generate the job cancellation queue name.
51+
def job_delete_queue_name() -> str:
52+
"""Generate the job deletion queue name.
5353
5454
:return: The queue name.
5555
"""
56-
return "job_cancellations"
56+
return "job_deletions"
5757

5858
@staticmethod
5959
def available_workflows_routing_key() -> str:

0 commit comments

Comments
 (0)