File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
services/storage/src/simcore_service_storage/api/rpc Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ from pathlib import Path
3+ from uuid import uuid4
4+
5+ from fastapi import FastAPI
6+ from models_library .api_schemas_rpc_async_jobs .async_jobs import (
7+ AsyncJobGet ,
8+ AsyncJobId ,
9+ )
10+ from models_library .api_schemas_storage .data_export_async_jobs import (
11+ AccessRightError ,
12+ DataExportError ,
13+ InvalidFileIdentifierError ,
14+ )
15+ from models_library .projects_nodes_io import LocationID
16+ from models_library .users import UserID
17+ from servicelib .rabbitmq import RPCRouter
18+
19+ from ...dsm import get_dsm_provider
20+
21+ router = RPCRouter ()
22+
23+
24+ @router .expose (
25+ reraise_if_error_type = (
26+ InvalidFileIdentifierError ,
27+ AccessRightError ,
28+ DataExportError ,
29+ )
30+ )
31+ async def compute_path_size (
32+ app : FastAPI ,
33+ user_id : UserID ,
34+ location_id : LocationID ,
35+ path : Path ,
36+ ) -> AsyncJobGet :
37+ assert app # nosec
38+
39+ dsm = get_dsm_provider (app ).get (location_id )
40+ # TODO: this must be send to Celery!
41+ task = asyncio .create_task (
42+ dsm .compute_path_size (user_id , path = path ), name = "THISSHALLGOTOCELERY"
43+ )
44+ await asyncio .sleep (5 )
45+
46+ return AsyncJobGet (
47+ job_id = AsyncJobId (f"{ uuid4 ()} " ),
48+ )
You can’t perform that action at this time.
0 commit comments