Skip to content

Commit c8871f0

Browse files
Add cancel_jobs option to automation client delete (#6)
1 parent 978606c commit c8871f0

11 files changed

Lines changed: 354 additions & 268 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: end-of-file-fixer
77
- repo: https://github.com/charliermarsh/ruff-pre-commit
88
# keep the version here in sync with the version in uv.lock
9-
rev: "v0.12.0"
9+
rev: "v0.12.2"
1010
hooks:
1111
- id: ruff-check
1212
args: [--fix, --exit-non-zero-on-fix]

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `tilebox-workflows`: Added `cancel_jobs` argument to `AutomationClient.delete` to optionally cancel all currently queued or running jobs of the automation.
13+
1014
## [0.38.0] - 2025-06-24
1115

1216
### Added

tilebox-datasets/tilebox/datasets/datasetsv1/datasets_pb2.py

Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tilebox-datasets/tilebox/datasets/datasetsv1/datasets_pb2.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ class UpdateDatasetDescriptionRequest(_message.Message):
6565
description: str
6666
def __init__(self, id: _Optional[_Union[_core_pb2.ID, _Mapping]] = ..., description: _Optional[str] = ...) -> None: ...
6767

68+
class DeleteDatasetRequest(_message.Message):
69+
__slots__ = ("id",)
70+
ID_FIELD_NUMBER: _ClassVar[int]
71+
id: _core_pb2.ID
72+
def __init__(self, id: _Optional[_Union[_core_pb2.ID, _Mapping]] = ...) -> None: ...
73+
74+
class DeleteDatasetResponse(_message.Message):
75+
__slots__ = ("trashed",)
76+
TRASHED_FIELD_NUMBER: _ClassVar[int]
77+
trashed: bool
78+
def __init__(self, trashed: bool = ...) -> None: ...
79+
6880
class ListDatasetsRequest(_message.Message):
6981
__slots__ = ("client_info",)
7082
CLIENT_INFO_FIELD_NUMBER: _ClassVar[int]

tilebox-datasets/tilebox/datasets/datasetsv1/datasets_pb2_grpc.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def __init__(self, channel):
3636
request_serializer=datasets_dot_v1_dot_datasets__pb2.UpdateDatasetDescriptionRequest.SerializeToString,
3737
response_deserializer=datasets_dot_v1_dot_core__pb2.Dataset.FromString,
3838
_registered_method=True)
39+
self.DeleteDataset = channel.unary_unary(
40+
'/datasets.v1.DatasetService/DeleteDataset',
41+
request_serializer=datasets_dot_v1_dot_datasets__pb2.DeleteDatasetRequest.SerializeToString,
42+
response_deserializer=datasets_dot_v1_dot_datasets__pb2.DeleteDatasetResponse.FromString,
43+
_registered_method=True)
3944
self.ListDatasets = channel.unary_unary(
4045
'/datasets.v1.DatasetService/ListDatasets',
4146
request_serializer=datasets_dot_v1_dot_datasets__pb2.ListDatasetsRequest.SerializeToString,
@@ -71,6 +76,12 @@ def UpdateDatasetDescription(self, request, context):
7176
context.set_details('Method not implemented!')
7277
raise NotImplementedError('Method not implemented!')
7378

79+
def DeleteDataset(self, request, context):
80+
"""Missing associated documentation comment in .proto file."""
81+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
82+
context.set_details('Method not implemented!')
83+
raise NotImplementedError('Method not implemented!')
84+
7485
def ListDatasets(self, request, context):
7586
"""Missing associated documentation comment in .proto file."""
7687
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -100,6 +111,11 @@ def add_DatasetServiceServicer_to_server(servicer, server):
100111
request_deserializer=datasets_dot_v1_dot_datasets__pb2.UpdateDatasetDescriptionRequest.FromString,
101112
response_serializer=datasets_dot_v1_dot_core__pb2.Dataset.SerializeToString,
102113
),
114+
'DeleteDataset': grpc.unary_unary_rpc_method_handler(
115+
servicer.DeleteDataset,
116+
request_deserializer=datasets_dot_v1_dot_datasets__pb2.DeleteDatasetRequest.FromString,
117+
response_serializer=datasets_dot_v1_dot_datasets__pb2.DeleteDatasetResponse.SerializeToString,
118+
),
103119
'ListDatasets': grpc.unary_unary_rpc_method_handler(
104120
servicer.ListDatasets,
105121
request_deserializer=datasets_dot_v1_dot_datasets__pb2.ListDatasetsRequest.FromString,
@@ -225,6 +241,33 @@ def UpdateDatasetDescription(request,
225241
metadata,
226242
_registered_method=True)
227243

244+
@staticmethod
245+
def DeleteDataset(request,
246+
target,
247+
options=(),
248+
channel_credentials=None,
249+
call_credentials=None,
250+
insecure=False,
251+
compression=None,
252+
wait_for_ready=None,
253+
timeout=None,
254+
metadata=None):
255+
return grpc.experimental.unary_unary(
256+
request,
257+
target,
258+
'/datasets.v1.DatasetService/DeleteDataset',
259+
datasets_dot_v1_dot_datasets__pb2.DeleteDatasetRequest.SerializeToString,
260+
datasets_dot_v1_dot_datasets__pb2.DeleteDatasetResponse.FromString,
261+
options,
262+
channel_credentials,
263+
insecure,
264+
call_credentials,
265+
compression,
266+
wait_for_ready,
267+
timeout,
268+
metadata,
269+
_registered_method=True)
270+
228271
@staticmethod
229272
def ListDatasets(request,
230273
target,

tilebox-workflows/tests/automations/test_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
uuid_to_uuid_message,
1919
)
2020
from tilebox.workflows.workflowsv1.automation_pb2 import AutomationPrototype as AutomationPrototypeMessage
21-
from tilebox.workflows.workflowsv1.automation_pb2 import Automations
21+
from tilebox.workflows.workflowsv1.automation_pb2 import Automations, DeleteAutomationRequest
2222
from tilebox.workflows.workflowsv1.automation_pb2 import CronTrigger as CronTriggerMessage
2323
from tilebox.workflows.workflowsv1.automation_pb2 import StorageEventTrigger as StorageEventTriggerMessage
2424
from tilebox.workflows.workflowsv1.automation_pb2_grpc import AutomationServiceStub
@@ -65,8 +65,8 @@ def GetAutomation(self, req: UUIDMessage) -> AutomationPrototypeMessage: # noqa
6565
return self.automations[automation_id]
6666
raise NotFoundError(f"Automation {automation_id} not found")
6767

68-
def DeleteAutomation(self, req: UUIDMessage) -> None: # noqa: N802
69-
automation_id = uuid_message_to_uuid(req)
68+
def DeleteAutomation(self, req: DeleteAutomationRequest) -> None: # noqa: N802
69+
automation_id = uuid_message_to_uuid(req.automation_id)
7070
if automation_id in self.automations:
7171
del self.automations[automation_id]
7272
else:
@@ -114,7 +114,7 @@ def create_cron_automation(
114114
cron_triggers: list[CronTrigger],
115115
) -> AutomationPrototype:
116116
self.count_automations += 1
117-
triggers = [t.schedule for t in cron_triggers]
117+
schedules = [t.schedule for t in cron_triggers]
118118

119119
class TestCronTask(CronTask):
120120
some_arg: str
@@ -125,7 +125,7 @@ def identifier() -> tuple[str, str]:
125125

126126
task = TestCronTask(task_name) # task_name reused to serialize the task input
127127

128-
return self.client.create_cron_automation(task_name, task, triggers, cluster_slug)
128+
return self.client.create_cron_automation(task_name, task, schedules, cluster_slug)
129129

130130
@rule(
131131
target=inserted_automations,

tilebox-workflows/tilebox/workflows/automations/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ def create_storage_event_automation(
133133
)
134134
return self._service.create(automation)
135135

136-
def delete(self, automation_or_id: AutomationPrototype | UUID | str) -> None:
136+
def delete(self, automation_or_id: AutomationPrototype | UUID | str, cancel_jobs: bool = False) -> None:
137137
"""Delete an automation by id.
138138
139139
Args:
140140
automation_or_id: The id of the automation to delete or the automation object itself.
141+
cancel_jobs: Whether to cancel all currently queued or running jobs of the automation. Defaults to False.
141142
"""
142143
if isinstance(automation_or_id, str):
143144
automation_id = UUID(automation_or_id)
@@ -146,4 +147,4 @@ def delete(self, automation_or_id: AutomationPrototype | UUID | str) -> None:
146147
else:
147148
automation_id = automation_or_id
148149

149-
self._service.delete(automation_id)
150+
self._service.delete(automation_id, cancel_jobs)

tilebox-workflows/tilebox/workflows/automations/service.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
uuid_to_uuid_message,
1111
)
1212
from tilebox.workflows.workflowsv1.automation_pb2 import AutomationPrototype as AutomationPrototypeMessage
13-
from tilebox.workflows.workflowsv1.automation_pb2 import Automations, StorageLocations
13+
from tilebox.workflows.workflowsv1.automation_pb2 import Automations, DeleteAutomationRequest, StorageLocations
1414
from tilebox.workflows.workflowsv1.automation_pb2_grpc import AutomationServiceStub
1515

1616

@@ -45,5 +45,7 @@ def update(self, automation: AutomationPrototype) -> AutomationPrototype:
4545
response: AutomationPrototypeMessage = self.service.UpdateAutomation(automation.to_message())
4646
return AutomationPrototype.from_message(response)
4747

48-
def delete(self, automation_id: UUID) -> None:
49-
self.service.DeleteAutomation(uuid_to_uuid_message(automation_id))
48+
def delete(self, automation_id: UUID, cancel_jobs: bool = False) -> None:
49+
self.service.DeleteAutomation(
50+
DeleteAutomationRequest(automation_id=uuid_to_uuid_message(automation_id), cancel_jobs=cancel_jobs)
51+
)

0 commit comments

Comments
 (0)