Skip to content

Commit f3b3704

Browse files
committed
Merge branch 'master' into 1870-start-program-section-of-api-server
2 parents 27082c9 + 5f1c5d7 commit f3b3704

File tree

26 files changed

+910
-178
lines changed

26 files changed

+910
-178
lines changed

api/specs/web-server/_storage.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
PresignedLink,
2323
)
2424
from models_library.api_schemas_webserver.storage import (
25+
BatchDeletePathsBodyParams,
2526
DataExportPost,
2627
ListPathsQueryParams,
2728
StorageLocationPathParams,
@@ -80,6 +81,19 @@ async def compute_path_size(_path: Annotated[StoragePathComputeSizeParams, Depen
8081
"""Compute the size of a path"""
8182

8283

84+
@router.post(
85+
"/storage/locations/{location_id}/-/paths:batchDelete",
86+
response_model=Envelope[TaskGet],
87+
status_code=status.HTTP_202_ACCEPTED,
88+
description="Deletes Paths",
89+
)
90+
async def batch_delete_paths(
91+
_path: Annotated[StorageLocationPathParams, Depends()],
92+
_body: Annotated[BatchDeletePathsBodyParams, Depends()],
93+
):
94+
"""deletes files/folders if user has the rights to"""
95+
96+
8397
@router.get(
8498
"/storage/locations/{location_id}/datasets",
8599
response_model=Envelope[list[DatasetMetaData]],

packages/models-library/src/models_library/api_schemas_webserver/storage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class ListPathsQueryParams(InputSchema, CursorQueryParameters):
3636
] = DEFAULT_NUMBER_OF_PATHS_PER_PAGE
3737

3838

39+
class BatchDeletePathsBodyParams(InputSchema):
40+
paths: set[Path]
41+
42+
3943
class DataExportPost(InputSchema):
4044
paths: list[StorageFileID]
4145

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/storage/paths.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ async def compute_path_size(
3232
path=path,
3333
)
3434
return async_job_rpc_get, job_id_data
35+
36+
37+
async def delete_paths(
38+
client: RabbitMQRPCClient,
39+
*,
40+
user_id: UserID,
41+
product_name: ProductName,
42+
location_id: LocationID,
43+
paths: set[Path],
44+
) -> tuple[AsyncJobGet, AsyncJobNameData]:
45+
job_id_data = AsyncJobNameData(user_id=user_id, product_name=product_name)
46+
async_job_rpc_get = await submit(
47+
rabbitmq_rpc_client=client,
48+
rpc_namespace=STORAGE_RPC_NAMESPACE,
49+
method_name=RPCMethodName("delete_paths"),
50+
job_id_data=job_id_data,
51+
location_id=location_id,
52+
paths=paths,
53+
)
54+
return async_job_rpc_get, job_id_data

scripts/maintenance/computational-clusters/autoscaled_monitor/cli.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def main(
129129
def summary(
130130
user_id: Annotated[int, typer.Option(help="filters by the user ID")] = 0,
131131
wallet_id: Annotated[int, typer.Option(help="filters by the wallet ID")] = 0,
132+
as_json: Annotated[bool, typer.Option(help="outputs as json")] = False,
132133
) -> None:
133134
"""Show a summary of the current situation of autoscaled EC2 instances.
134135
@@ -140,7 +141,9 @@ def summary(
140141
141142
"""
142143

143-
if not asyncio.run(api.summary(state, user_id or None, wallet_id or None)):
144+
if not asyncio.run(
145+
api.summary(state, user_id or None, wallet_id or None, output_json=as_json)
146+
):
144147
raise typer.Exit(1)
145148

146149

@@ -152,7 +155,7 @@ def cancel_jobs(
152155
typer.Option(help="the wallet ID"),
153156
] = None,
154157
*,
155-
force: Annotated[
158+
abort_in_db: Annotated[
156159
bool,
157160
typer.Option(
158161
help="will also force the job to abort in the database (use only if job is in WAITING FOR CLUSTER/WAITING FOR RESOURCE)"
@@ -166,23 +169,26 @@ def cancel_jobs(
166169
Keyword Arguments:
167170
user_id -- the user ID
168171
wallet_id -- the wallet ID
172+
abort_in_db -- will also force the job to abort in the database (use only if job is in WAITING FOR CLUSTER/WAITING FOR RESOURCE)
169173
"""
170-
asyncio.run(api.cancel_jobs(state, user_id, wallet_id, force=force))
174+
asyncio.run(api.cancel_jobs(state, user_id, wallet_id, abort_in_db=abort_in_db))
171175

172176

173177
@app.command()
174178
def trigger_cluster_termination(
175179
user_id: Annotated[int, typer.Option(help="the user ID")],
176180
wallet_id: Annotated[int, typer.Option(help="the wallet ID")],
181+
force: Annotated[bool, typer.Option(help="will not ask for confirmation")] = False,
177182
) -> None:
178183
"""this will set the Heartbeat tag on the primary machine to 1 hour, thus ensuring the
179184
clusters-keeper will properly terminate that cluster.
180185
181186
Keyword Arguments:
182187
user_id -- the user ID
183188
wallet_id -- the wallet ID
189+
force -- will not ask for confirmation (VERY RISKY! USE WITH CAUTION!)
184190
"""
185-
asyncio.run(api.trigger_cluster_termination(state, user_id, wallet_id))
191+
asyncio.run(api.trigger_cluster_termination(state, user_id, wallet_id, force=force))
186192

187193

188194
@app.command()

0 commit comments

Comments
 (0)