fractal-server 2.3.10__py3-none-any.whl → 2.4.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fractal_server/__init__.py +1 -1
- fractal_server/__main__.py +25 -2
- fractal_server/app/models/__init__.py +11 -5
- fractal_server/app/models/linkusergroup.py +11 -0
- fractal_server/app/models/security.py +24 -3
- fractal_server/app/models/v1/project.py +1 -1
- fractal_server/app/models/v2/project.py +3 -3
- fractal_server/app/routes/admin/v1.py +14 -14
- fractal_server/app/routes/admin/v2.py +12 -12
- fractal_server/app/routes/api/__init__.py +2 -2
- fractal_server/app/routes/api/v1/_aux_functions.py +2 -2
- fractal_server/app/routes/api/v1/dataset.py +17 -15
- fractal_server/app/routes/api/v1/job.py +11 -9
- fractal_server/app/routes/api/v1/project.py +9 -9
- fractal_server/app/routes/api/v1/task.py +8 -8
- fractal_server/app/routes/api/v1/task_collection.py +5 -5
- fractal_server/app/routes/api/v1/workflow.py +13 -11
- fractal_server/app/routes/api/v1/workflowtask.py +6 -6
- fractal_server/app/routes/api/v2/_aux_functions.py +2 -2
- fractal_server/app/routes/api/v2/dataset.py +11 -11
- fractal_server/app/routes/api/v2/images.py +6 -6
- fractal_server/app/routes/api/v2/job.py +9 -9
- fractal_server/app/routes/api/v2/project.py +7 -7
- fractal_server/app/routes/api/v2/status.py +3 -3
- fractal_server/app/routes/api/v2/submit.py +3 -3
- fractal_server/app/routes/api/v2/task.py +8 -8
- fractal_server/app/routes/api/v2/task_collection.py +5 -5
- fractal_server/app/routes/api/v2/task_collection_custom.py +3 -3
- fractal_server/app/routes/api/v2/task_legacy.py +9 -9
- fractal_server/app/routes/api/v2/workflow.py +11 -11
- fractal_server/app/routes/api/v2/workflowtask.py +6 -6
- fractal_server/app/routes/auth/__init__.py +55 -0
- fractal_server/app/routes/auth/_aux_auth.py +107 -0
- fractal_server/app/routes/auth/current_user.py +60 -0
- fractal_server/app/routes/auth/group.py +173 -0
- fractal_server/app/routes/auth/group_names.py +34 -0
- fractal_server/app/routes/auth/login.py +25 -0
- fractal_server/app/routes/auth/oauth.py +63 -0
- fractal_server/app/routes/auth/register.py +23 -0
- fractal_server/app/routes/auth/router.py +19 -0
- fractal_server/app/routes/auth/users.py +103 -0
- fractal_server/app/runner/v2/__init__.py +1 -5
- fractal_server/app/runner/v2/_slurm_ssh/__init__.py +17 -0
- fractal_server/app/schemas/user.py +2 -0
- fractal_server/app/schemas/user_group.py +57 -0
- fractal_server/app/security/__init__.py +72 -68
- fractal_server/data_migrations/2_4_0.py +61 -0
- fractal_server/main.py +1 -9
- fractal_server/migrations/versions/091b01f51f88_add_usergroup_and_linkusergroup_table.py +53 -0
- {fractal_server-2.3.10.dist-info → fractal_server-2.4.0a0.dist-info}/METADATA +1 -1
- {fractal_server-2.3.10.dist-info → fractal_server-2.4.0a0.dist-info}/RECORD +54 -41
- fractal_server/app/routes/auth.py +0 -165
- {fractal_server-2.3.10.dist-info → fractal_server-2.4.0a0.dist-info}/LICENSE +0 -0
- {fractal_server-2.3.10.dist-info → fractal_server-2.4.0a0.dist-info}/WHEEL +0 -0
- {fractal_server-2.3.10.dist-info → fractal_server-2.4.0a0.dist-info}/entry_points.txt +0 -0
@@ -34,9 +34,6 @@ from ....schemas.v1 import JobStatusTypeV1
|
|
34
34
|
from ....schemas.v1 import ProjectCreateV1
|
35
35
|
from ....schemas.v1 import ProjectReadV1
|
36
36
|
from ....schemas.v1 import ProjectUpdateV1
|
37
|
-
from ....security import current_active_user
|
38
|
-
from ....security import current_active_verified_user
|
39
|
-
from ....security import User
|
40
37
|
from ._aux_functions import _check_project_exists
|
41
38
|
from ._aux_functions import _get_dataset_check_owner
|
42
39
|
from ._aux_functions import _get_project_check_owner
|
@@ -44,6 +41,9 @@ from ._aux_functions import _get_submitted_jobs_statement
|
|
44
41
|
from ._aux_functions import _get_workflow_check_owner
|
45
42
|
from ._aux_functions import _raise_if_v1_is_read_only
|
46
43
|
from ._aux_functions import clean_app_job_list_v1
|
44
|
+
from fractal_server.app.models import UserOAuth
|
45
|
+
from fractal_server.app.routes.auth import current_active_user
|
46
|
+
from fractal_server.app.routes.auth import current_active_verified_user
|
47
47
|
|
48
48
|
router = APIRouter()
|
49
49
|
logger = set_logger(__name__)
|
@@ -55,7 +55,7 @@ def _encode_as_utc(dt: datetime):
|
|
55
55
|
|
56
56
|
@router.get("/", response_model=list[ProjectReadV1])
|
57
57
|
async def get_list_project(
|
58
|
-
user:
|
58
|
+
user: UserOAuth = Depends(current_active_user),
|
59
59
|
db: AsyncSession = Depends(get_async_db),
|
60
60
|
) -> list[Project]:
|
61
61
|
"""
|
@@ -75,7 +75,7 @@ async def get_list_project(
|
|
75
75
|
@router.post("/", response_model=ProjectReadV1, status_code=201)
|
76
76
|
async def create_project(
|
77
77
|
project: ProjectCreateV1,
|
78
|
-
user:
|
78
|
+
user: UserOAuth = Depends(current_active_user),
|
79
79
|
db: AsyncSession = Depends(get_async_db),
|
80
80
|
) -> Optional[ProjectReadV1]:
|
81
81
|
"""
|
@@ -101,7 +101,7 @@ async def create_project(
|
|
101
101
|
@router.get("/{project_id}/", response_model=ProjectReadV1)
|
102
102
|
async def read_project(
|
103
103
|
project_id: int,
|
104
|
-
user:
|
104
|
+
user: UserOAuth = Depends(current_active_user),
|
105
105
|
db: AsyncSession = Depends(get_async_db),
|
106
106
|
) -> Optional[ProjectReadV1]:
|
107
107
|
"""
|
@@ -118,7 +118,7 @@ async def read_project(
|
|
118
118
|
async def update_project(
|
119
119
|
project_id: int,
|
120
120
|
project_update: ProjectUpdateV1,
|
121
|
-
user:
|
121
|
+
user: UserOAuth = Depends(current_active_user),
|
122
122
|
db: AsyncSession = Depends(get_async_db),
|
123
123
|
):
|
124
124
|
_raise_if_v1_is_read_only()
|
@@ -144,7 +144,7 @@ async def update_project(
|
|
144
144
|
@router.delete("/{project_id}/", status_code=204)
|
145
145
|
async def delete_project(
|
146
146
|
project_id: int,
|
147
|
-
user:
|
147
|
+
user: UserOAuth = Depends(current_active_user),
|
148
148
|
db: AsyncSession = Depends(get_async_db),
|
149
149
|
) -> Response:
|
150
150
|
"""
|
@@ -249,7 +249,7 @@ async def apply_workflow(
|
|
249
249
|
input_dataset_id: int,
|
250
250
|
output_dataset_id: int,
|
251
251
|
request: Request,
|
252
|
-
user:
|
252
|
+
user: UserOAuth = Depends(current_active_verified_user),
|
253
253
|
db: AsyncSession = Depends(get_async_db),
|
254
254
|
) -> Optional[ApplyWorkflowReadV1]:
|
255
255
|
_raise_if_v1_is_read_only()
|
@@ -17,11 +17,11 @@ from ....models.v2 import TaskV2
|
|
17
17
|
from ....schemas.v1 import TaskCreateV1
|
18
18
|
from ....schemas.v1 import TaskReadV1
|
19
19
|
from ....schemas.v1 import TaskUpdateV1
|
20
|
-
from ....security import current_active_user
|
21
|
-
from ....security import current_active_verified_user
|
22
|
-
from ....security import User
|
23
20
|
from ._aux_functions import _get_task_check_owner
|
24
21
|
from ._aux_functions import _raise_if_v1_is_read_only
|
22
|
+
from fractal_server.app.models import UserOAuth
|
23
|
+
from fractal_server.app.routes.auth import current_active_user
|
24
|
+
from fractal_server.app.routes.auth import current_active_verified_user
|
25
25
|
|
26
26
|
router = APIRouter()
|
27
27
|
|
@@ -30,7 +30,7 @@ logger = set_logger(__name__)
|
|
30
30
|
|
31
31
|
@router.get("/", response_model=list[TaskReadV1])
|
32
32
|
async def get_list_task(
|
33
|
-
user:
|
33
|
+
user: UserOAuth = Depends(current_active_user),
|
34
34
|
args_schema: bool = True,
|
35
35
|
db: AsyncSession = Depends(get_async_db),
|
36
36
|
) -> list[TaskReadV1]:
|
@@ -51,7 +51,7 @@ async def get_list_task(
|
|
51
51
|
@router.get("/{task_id}/", response_model=TaskReadV1)
|
52
52
|
async def get_task(
|
53
53
|
task_id: int,
|
54
|
-
user:
|
54
|
+
user: UserOAuth = Depends(current_active_user),
|
55
55
|
db: AsyncSession = Depends(get_async_db),
|
56
56
|
) -> TaskReadV1:
|
57
57
|
"""
|
@@ -70,7 +70,7 @@ async def get_task(
|
|
70
70
|
async def patch_task(
|
71
71
|
task_id: int,
|
72
72
|
task_update: TaskUpdateV1,
|
73
|
-
user:
|
73
|
+
user: UserOAuth = Depends(current_active_verified_user),
|
74
74
|
db: AsyncSession = Depends(get_async_db),
|
75
75
|
) -> Optional[TaskReadV1]:
|
76
76
|
"""
|
@@ -116,7 +116,7 @@ async def patch_task(
|
|
116
116
|
)
|
117
117
|
async def create_task(
|
118
118
|
task: TaskCreateV1,
|
119
|
-
user:
|
119
|
+
user: UserOAuth = Depends(current_active_verified_user),
|
120
120
|
db: AsyncSession = Depends(get_async_db),
|
121
121
|
) -> Optional[TaskReadV1]:
|
122
122
|
"""
|
@@ -170,7 +170,7 @@ async def create_task(
|
|
170
170
|
@router.delete("/{task_id}/", status_code=204)
|
171
171
|
async def delete_task(
|
172
172
|
task_id: int,
|
173
|
-
user:
|
173
|
+
user: UserOAuth = Depends(current_active_user),
|
174
174
|
db: AsyncSession = Depends(get_async_db),
|
175
175
|
) -> Response:
|
176
176
|
"""
|
@@ -22,10 +22,10 @@ from ....models.v1 import Task
|
|
22
22
|
from ....schemas.v1 import StateRead
|
23
23
|
from ....schemas.v1 import TaskCollectPipV1
|
24
24
|
from ....schemas.v1 import TaskCollectStatusV1
|
25
|
-
from ....security import current_active_user
|
26
|
-
from ....security import current_active_verified_user
|
27
|
-
from ....security import User
|
28
25
|
from ._aux_functions import _raise_if_v1_is_read_only
|
26
|
+
from fractal_server.app.models import UserOAuth
|
27
|
+
from fractal_server.app.routes.auth import current_active_user
|
28
|
+
from fractal_server.app.routes.auth import current_active_verified_user
|
29
29
|
from fractal_server.string_tools import slugify_task_name_for_source
|
30
30
|
from fractal_server.tasks.utils import get_collection_log
|
31
31
|
from fractal_server.tasks.v1._TaskCollectPip import _TaskCollectPip
|
@@ -63,7 +63,7 @@ async def collect_tasks_pip(
|
|
63
63
|
task_collect: TaskCollectPipV1,
|
64
64
|
background_tasks: BackgroundTasks,
|
65
65
|
response: Response,
|
66
|
-
user:
|
66
|
+
user: UserOAuth = Depends(current_active_verified_user),
|
67
67
|
db: AsyncSession = Depends(get_async_db),
|
68
68
|
) -> StateRead: # State[TaskCollectStatus]
|
69
69
|
"""
|
@@ -211,7 +211,7 @@ async def collect_tasks_pip(
|
|
211
211
|
@router.get("/collect/{state_id}/", response_model=StateRead)
|
212
212
|
async def check_collection_status(
|
213
213
|
state_id: int,
|
214
|
-
user:
|
214
|
+
user: UserOAuth = Depends(current_active_user),
|
215
215
|
verbose: bool = False,
|
216
216
|
db: AsyncSession = Depends(get_async_db),
|
217
217
|
) -> StateRead: # State[TaskCollectStatus]
|
@@ -33,14 +33,14 @@ from ....schemas.v1 import WorkflowImportV1
|
|
33
33
|
from ....schemas.v1 import WorkflowReadV1
|
34
34
|
from ....schemas.v1 import WorkflowTaskCreateV1
|
35
35
|
from ....schemas.v1 import WorkflowUpdateV1
|
36
|
-
from ....security import current_active_user
|
37
|
-
from ....security import User
|
38
36
|
from ._aux_functions import _check_workflow_exists
|
39
37
|
from ._aux_functions import _get_project_check_owner
|
40
38
|
from ._aux_functions import _get_submitted_jobs_statement
|
41
39
|
from ._aux_functions import _get_workflow_check_owner
|
42
40
|
from ._aux_functions import _raise_if_v1_is_read_only
|
43
41
|
from ._aux_functions import _workflow_insert_task
|
42
|
+
from fractal_server.app.models import UserOAuth
|
43
|
+
from fractal_server.app.routes.auth import current_active_user
|
44
44
|
|
45
45
|
|
46
46
|
router = APIRouter()
|
@@ -52,7 +52,7 @@ router = APIRouter()
|
|
52
52
|
)
|
53
53
|
async def get_workflow_list(
|
54
54
|
project_id: int,
|
55
|
-
user:
|
55
|
+
user: UserOAuth = Depends(current_active_user),
|
56
56
|
db: AsyncSession = Depends(get_async_db),
|
57
57
|
) -> Optional[list[WorkflowReadV1]]:
|
58
58
|
"""
|
@@ -79,7 +79,7 @@ async def get_workflow_list(
|
|
79
79
|
async def create_workflow(
|
80
80
|
project_id: int,
|
81
81
|
workflow: WorkflowCreateV1,
|
82
|
-
user:
|
82
|
+
user: UserOAuth = Depends(current_active_user),
|
83
83
|
db: AsyncSession = Depends(get_async_db),
|
84
84
|
) -> Optional[WorkflowReadV1]:
|
85
85
|
"""
|
@@ -110,7 +110,7 @@ async def create_workflow(
|
|
110
110
|
async def read_workflow(
|
111
111
|
project_id: int,
|
112
112
|
workflow_id: int,
|
113
|
-
user:
|
113
|
+
user: UserOAuth = Depends(current_active_user),
|
114
114
|
db: AsyncSession = Depends(get_async_db),
|
115
115
|
) -> Optional[WorkflowReadV1]:
|
116
116
|
"""
|
@@ -132,7 +132,7 @@ async def update_workflow(
|
|
132
132
|
project_id: int,
|
133
133
|
workflow_id: int,
|
134
134
|
patch: WorkflowUpdateV1,
|
135
|
-
user:
|
135
|
+
user: UserOAuth = Depends(current_active_user),
|
136
136
|
db: AsyncSession = Depends(get_async_db),
|
137
137
|
) -> Optional[WorkflowReadV1]:
|
138
138
|
"""
|
@@ -184,7 +184,7 @@ async def update_workflow(
|
|
184
184
|
async def delete_workflow(
|
185
185
|
project_id: int,
|
186
186
|
workflow_id: int,
|
187
|
-
user:
|
187
|
+
user: UserOAuth = Depends(current_active_user),
|
188
188
|
db: AsyncSession = Depends(get_async_db),
|
189
189
|
) -> Response:
|
190
190
|
"""
|
@@ -236,7 +236,7 @@ async def delete_workflow(
|
|
236
236
|
async def export_worfklow(
|
237
237
|
project_id: int,
|
238
238
|
workflow_id: int,
|
239
|
-
user:
|
239
|
+
user: UserOAuth = Depends(current_active_user),
|
240
240
|
db: AsyncSession = Depends(get_async_db),
|
241
241
|
) -> Optional[WorkflowExportV1]:
|
242
242
|
"""
|
@@ -269,7 +269,7 @@ async def export_worfklow(
|
|
269
269
|
async def import_workflow(
|
270
270
|
project_id: int,
|
271
271
|
workflow: WorkflowImportV1,
|
272
|
-
user:
|
272
|
+
user: UserOAuth = Depends(current_active_user),
|
273
273
|
db: AsyncSession = Depends(get_async_db),
|
274
274
|
) -> Optional[WorkflowReadV1]:
|
275
275
|
"""
|
@@ -340,14 +340,16 @@ async def import_workflow(
|
|
340
340
|
|
341
341
|
@router.get("/workflow/", response_model=list[WorkflowReadV1])
|
342
342
|
async def get_user_workflows(
|
343
|
-
user:
|
343
|
+
user: UserOAuth = Depends(current_active_user),
|
344
344
|
db: AsyncSession = Depends(get_async_db),
|
345
345
|
) -> list[WorkflowReadV1]:
|
346
346
|
"""
|
347
347
|
Returns all the workflows of the current user
|
348
348
|
"""
|
349
349
|
stm = select(Workflow)
|
350
|
-
stm = stm.join(Project).where(
|
350
|
+
stm = stm.join(Project).where(
|
351
|
+
Project.user_list.any(UserOAuth.id == user.id)
|
352
|
+
)
|
351
353
|
res = await db.execute(stm)
|
352
354
|
workflow_list = res.scalars().all()
|
353
355
|
return workflow_list
|
@@ -26,12 +26,12 @@ from ....models.v1 import Task
|
|
26
26
|
from ....schemas.v1 import WorkflowTaskCreateV1
|
27
27
|
from ....schemas.v1 import WorkflowTaskReadV1
|
28
28
|
from ....schemas.v1 import WorkflowTaskUpdateV1
|
29
|
-
from ....security import current_active_user
|
30
|
-
from ....security import User
|
31
29
|
from ._aux_functions import _get_workflow_check_owner
|
32
30
|
from ._aux_functions import _get_workflow_task_check_owner
|
33
31
|
from ._aux_functions import _raise_if_v1_is_read_only
|
34
32
|
from ._aux_functions import _workflow_insert_task
|
33
|
+
from fractal_server.app.models import UserOAuth
|
34
|
+
from fractal_server.app.routes.auth import current_active_user
|
35
35
|
|
36
36
|
router = APIRouter()
|
37
37
|
|
@@ -46,7 +46,7 @@ async def create_workflowtask(
|
|
46
46
|
workflow_id: int,
|
47
47
|
task_id: int,
|
48
48
|
new_task: WorkflowTaskCreateV1,
|
49
|
-
user:
|
49
|
+
user: UserOAuth = Depends(current_active_user),
|
50
50
|
db: AsyncSession = Depends(get_async_db),
|
51
51
|
) -> Optional[WorkflowTaskReadV1]:
|
52
52
|
"""
|
@@ -85,7 +85,7 @@ async def read_workflowtask(
|
|
85
85
|
project_id: int,
|
86
86
|
workflow_id: int,
|
87
87
|
workflow_task_id: int,
|
88
|
-
user:
|
88
|
+
user: UserOAuth = Depends(current_active_user),
|
89
89
|
db: AsyncSession = Depends(get_async_db),
|
90
90
|
):
|
91
91
|
workflow_task, _ = await _get_workflow_task_check_owner(
|
@@ -107,7 +107,7 @@ async def update_workflowtask(
|
|
107
107
|
workflow_id: int,
|
108
108
|
workflow_task_id: int,
|
109
109
|
workflow_task_update: WorkflowTaskUpdateV1,
|
110
|
-
user:
|
110
|
+
user: UserOAuth = Depends(current_active_user),
|
111
111
|
db: AsyncSession = Depends(get_async_db),
|
112
112
|
) -> Optional[WorkflowTaskReadV1]:
|
113
113
|
"""
|
@@ -162,7 +162,7 @@ async def delete_workflowtask(
|
|
162
162
|
project_id: int,
|
163
163
|
workflow_id: int,
|
164
164
|
workflow_task_id: int,
|
165
|
-
user:
|
165
|
+
user: UserOAuth = Depends(current_active_user),
|
166
166
|
db: AsyncSession = Depends(get_async_db),
|
167
167
|
) -> Response:
|
168
168
|
"""
|
@@ -22,7 +22,7 @@ from ....models.v2 import TaskV2
|
|
22
22
|
from ....models.v2 import WorkflowTaskV2
|
23
23
|
from ....models.v2 import WorkflowV2
|
24
24
|
from ....schemas.v2 import JobStatusTypeV2
|
25
|
-
from
|
25
|
+
from fractal_server.app.models import UserOAuth
|
26
26
|
from fractal_server.images import Filters
|
27
27
|
|
28
28
|
|
@@ -323,7 +323,7 @@ async def _get_job_check_owner(
|
|
323
323
|
async def _get_task_check_owner(
|
324
324
|
*,
|
325
325
|
task_id: int,
|
326
|
-
user:
|
326
|
+
user: UserOAuth,
|
327
327
|
db: AsyncSession,
|
328
328
|
) -> TaskV2:
|
329
329
|
"""
|
@@ -17,11 +17,11 @@ from ....schemas.v2 import DatasetReadV2
|
|
17
17
|
from ....schemas.v2 import DatasetUpdateV2
|
18
18
|
from ....schemas.v2.dataset import DatasetExportV2
|
19
19
|
from ....schemas.v2.dataset import DatasetImportV2
|
20
|
-
from ....security import current_active_user
|
21
|
-
from ....security import User
|
22
20
|
from ._aux_functions import _get_dataset_check_owner
|
23
21
|
from ._aux_functions import _get_project_check_owner
|
24
22
|
from ._aux_functions import _get_submitted_jobs_statement
|
23
|
+
from fractal_server.app.models import UserOAuth
|
24
|
+
from fractal_server.app.routes.auth import current_active_user
|
25
25
|
|
26
26
|
router = APIRouter()
|
27
27
|
|
@@ -34,7 +34,7 @@ router = APIRouter()
|
|
34
34
|
async def create_dataset(
|
35
35
|
project_id: int,
|
36
36
|
dataset: DatasetCreateV2,
|
37
|
-
user:
|
37
|
+
user: UserOAuth = Depends(current_active_user),
|
38
38
|
db: AsyncSession = Depends(get_async_db),
|
39
39
|
) -> Optional[DatasetReadV2]:
|
40
40
|
"""
|
@@ -59,7 +59,7 @@ async def create_dataset(
|
|
59
59
|
async def read_dataset_list(
|
60
60
|
project_id: int,
|
61
61
|
history: bool = True,
|
62
|
-
user:
|
62
|
+
user: UserOAuth = Depends(current_active_user),
|
63
63
|
db: AsyncSession = Depends(get_async_db),
|
64
64
|
) -> Optional[list[DatasetReadV2]]:
|
65
65
|
"""
|
@@ -90,7 +90,7 @@ async def read_dataset_list(
|
|
90
90
|
async def read_dataset(
|
91
91
|
project_id: int,
|
92
92
|
dataset_id: int,
|
93
|
-
user:
|
93
|
+
user: UserOAuth = Depends(current_active_user),
|
94
94
|
db: AsyncSession = Depends(get_async_db),
|
95
95
|
) -> Optional[DatasetReadV2]:
|
96
96
|
"""
|
@@ -115,7 +115,7 @@ async def update_dataset(
|
|
115
115
|
project_id: int,
|
116
116
|
dataset_id: int,
|
117
117
|
dataset_update: DatasetUpdateV2,
|
118
|
-
user:
|
118
|
+
user: UserOAuth = Depends(current_active_user),
|
119
119
|
db: AsyncSession = Depends(get_async_db),
|
120
120
|
) -> Optional[DatasetReadV2]:
|
121
121
|
"""
|
@@ -155,7 +155,7 @@ async def update_dataset(
|
|
155
155
|
async def delete_dataset(
|
156
156
|
project_id: int,
|
157
157
|
dataset_id: int,
|
158
|
-
user:
|
158
|
+
user: UserOAuth = Depends(current_active_user),
|
159
159
|
db: AsyncSession = Depends(get_async_db),
|
160
160
|
) -> Response:
|
161
161
|
"""
|
@@ -202,7 +202,7 @@ async def delete_dataset(
|
|
202
202
|
@router.get("/dataset/", response_model=list[DatasetReadV2])
|
203
203
|
async def get_user_datasets(
|
204
204
|
history: bool = True,
|
205
|
-
user:
|
205
|
+
user: UserOAuth = Depends(current_active_user),
|
206
206
|
db: AsyncSession = Depends(get_async_db),
|
207
207
|
) -> list[DatasetReadV2]:
|
208
208
|
"""
|
@@ -210,7 +210,7 @@ async def get_user_datasets(
|
|
210
210
|
"""
|
211
211
|
stm = select(DatasetV2)
|
212
212
|
stm = stm.join(ProjectV2).where(
|
213
|
-
ProjectV2.user_list.any(
|
213
|
+
ProjectV2.user_list.any(UserOAuth.id == user.id)
|
214
214
|
)
|
215
215
|
|
216
216
|
res = await db.execute(stm)
|
@@ -229,7 +229,7 @@ async def get_user_datasets(
|
|
229
229
|
async def export_dataset(
|
230
230
|
project_id: int,
|
231
231
|
dataset_id: int,
|
232
|
-
user:
|
232
|
+
user: UserOAuth = Depends(current_active_user),
|
233
233
|
db: AsyncSession = Depends(get_async_db),
|
234
234
|
) -> Optional[DatasetExportV2]:
|
235
235
|
"""
|
@@ -256,7 +256,7 @@ async def export_dataset(
|
|
256
256
|
async def import_dataset(
|
257
257
|
project_id: int,
|
258
258
|
dataset: DatasetImportV2,
|
259
|
-
user:
|
259
|
+
user: UserOAuth = Depends(current_active_user),
|
260
260
|
db: AsyncSession = Depends(get_async_db),
|
261
261
|
) -> Optional[DatasetReadV2]:
|
262
262
|
"""
|
@@ -13,8 +13,8 @@ from sqlalchemy.orm.attributes import flag_modified
|
|
13
13
|
from ._aux_functions import _get_dataset_check_owner
|
14
14
|
from fractal_server.app.db import AsyncSession
|
15
15
|
from fractal_server.app.db import get_async_db
|
16
|
-
from fractal_server.app.
|
17
|
-
from fractal_server.app.
|
16
|
+
from fractal_server.app.models import UserOAuth
|
17
|
+
from fractal_server.app.routes.auth import current_active_user
|
18
18
|
from fractal_server.images import Filters
|
19
19
|
from fractal_server.images import SingleImage
|
20
20
|
from fractal_server.images import SingleImageUpdate
|
@@ -49,7 +49,7 @@ async def post_new_image(
|
|
49
49
|
project_id: int,
|
50
50
|
dataset_id: int,
|
51
51
|
new_image: SingleImage,
|
52
|
-
user:
|
52
|
+
user: UserOAuth = Depends(current_active_user),
|
53
53
|
db: AsyncSession = Depends(get_async_db),
|
54
54
|
) -> Response:
|
55
55
|
|
@@ -104,7 +104,7 @@ async def query_dataset_images(
|
|
104
104
|
page: int = 1, # query param
|
105
105
|
page_size: Optional[int] = None, # query param
|
106
106
|
query: Optional[ImageQuery] = None, # body
|
107
|
-
user:
|
107
|
+
user: UserOAuth = Depends(current_active_user),
|
108
108
|
db: AsyncSession = Depends(get_async_db),
|
109
109
|
) -> ImagePage:
|
110
110
|
|
@@ -204,7 +204,7 @@ async def delete_dataset_images(
|
|
204
204
|
project_id: int,
|
205
205
|
dataset_id: int,
|
206
206
|
zarr_url: str,
|
207
|
-
user:
|
207
|
+
user: UserOAuth = Depends(current_active_user),
|
208
208
|
db: AsyncSession = Depends(get_async_db),
|
209
209
|
) -> Response:
|
210
210
|
|
@@ -243,7 +243,7 @@ async def patch_dataset_image(
|
|
243
243
|
project_id: int,
|
244
244
|
dataset_id: int,
|
245
245
|
image_update: SingleImageUpdate,
|
246
|
-
user:
|
246
|
+
user: UserOAuth = Depends(current_active_user),
|
247
247
|
db: AsyncSession = Depends(get_async_db),
|
248
248
|
):
|
249
249
|
output = await _get_dataset_check_owner(
|
@@ -16,20 +16,20 @@ from ....models.v2 import ProjectV2
|
|
16
16
|
from ....runner.filenames import WORKFLOW_LOG_FILENAME
|
17
17
|
from ....schemas.v2 import JobReadV2
|
18
18
|
from ....schemas.v2 import JobStatusTypeV2
|
19
|
-
from ....security import current_active_user
|
20
|
-
from ....security import User
|
21
19
|
from ...aux._job import _write_shutdown_file
|
22
20
|
from ...aux._runner import _check_shutdown_is_supported
|
23
21
|
from ._aux_functions import _get_job_check_owner
|
24
22
|
from ._aux_functions import _get_project_check_owner
|
25
23
|
from ._aux_functions import _get_workflow_check_owner
|
24
|
+
from fractal_server.app.models import UserOAuth
|
25
|
+
from fractal_server.app.routes.auth import current_active_user
|
26
26
|
|
27
27
|
router = APIRouter()
|
28
28
|
|
29
29
|
|
30
30
|
@router.get("/job/", response_model=list[JobReadV2])
|
31
31
|
async def get_user_jobs(
|
32
|
-
user:
|
32
|
+
user: UserOAuth = Depends(current_active_user),
|
33
33
|
log: bool = True,
|
34
34
|
db: AsyncSession = Depends(get_async_db),
|
35
35
|
) -> list[JobReadV2]:
|
@@ -39,7 +39,7 @@ async def get_user_jobs(
|
|
39
39
|
stm = (
|
40
40
|
select(JobV2)
|
41
41
|
.join(ProjectV2)
|
42
|
-
.where(ProjectV2.user_list.any(
|
42
|
+
.where(ProjectV2.user_list.any(UserOAuth.id == user.id))
|
43
43
|
)
|
44
44
|
res = await db.execute(stm)
|
45
45
|
job_list = res.scalars().all()
|
@@ -58,7 +58,7 @@ async def get_user_jobs(
|
|
58
58
|
async def get_workflow_jobs(
|
59
59
|
project_id: int,
|
60
60
|
workflow_id: int,
|
61
|
-
user:
|
61
|
+
user: UserOAuth = Depends(current_active_user),
|
62
62
|
db: AsyncSession = Depends(get_async_db),
|
63
63
|
) -> Optional[list[JobReadV2]]:
|
64
64
|
"""
|
@@ -81,7 +81,7 @@ async def read_job(
|
|
81
81
|
project_id: int,
|
82
82
|
job_id: int,
|
83
83
|
show_tmp_logs: bool = False,
|
84
|
-
user:
|
84
|
+
user: UserOAuth = Depends(current_active_user),
|
85
85
|
db: AsyncSession = Depends(get_async_db),
|
86
86
|
) -> Optional[JobReadV2]:
|
87
87
|
"""
|
@@ -114,7 +114,7 @@ async def read_job(
|
|
114
114
|
async def download_job_logs(
|
115
115
|
project_id: int,
|
116
116
|
job_id: int,
|
117
|
-
user:
|
117
|
+
user: UserOAuth = Depends(current_active_user),
|
118
118
|
db: AsyncSession = Depends(get_async_db),
|
119
119
|
) -> StreamingResponse:
|
120
120
|
"""
|
@@ -141,7 +141,7 @@ async def download_job_logs(
|
|
141
141
|
)
|
142
142
|
async def get_job_list(
|
143
143
|
project_id: int,
|
144
|
-
user:
|
144
|
+
user: UserOAuth = Depends(current_active_user),
|
145
145
|
log: bool = True,
|
146
146
|
db: AsyncSession = Depends(get_async_db),
|
147
147
|
) -> Optional[list[JobReadV2]]:
|
@@ -170,7 +170,7 @@ async def get_job_list(
|
|
170
170
|
async def stop_job(
|
171
171
|
project_id: int,
|
172
172
|
job_id: int,
|
173
|
-
user:
|
173
|
+
user: UserOAuth = Depends(current_active_user),
|
174
174
|
db: AsyncSession = Depends(get_async_db),
|
175
175
|
) -> Response:
|
176
176
|
"""
|
@@ -19,18 +19,18 @@ from ....models.v2 import WorkflowV2
|
|
19
19
|
from ....schemas.v2 import ProjectCreateV2
|
20
20
|
from ....schemas.v2 import ProjectReadV2
|
21
21
|
from ....schemas.v2 import ProjectUpdateV2
|
22
|
-
from ....security import current_active_user
|
23
|
-
from ....security import User
|
24
22
|
from ._aux_functions import _check_project_exists
|
25
23
|
from ._aux_functions import _get_project_check_owner
|
26
24
|
from ._aux_functions import _get_submitted_jobs_statement
|
25
|
+
from fractal_server.app.models import UserOAuth
|
26
|
+
from fractal_server.app.routes.auth import current_active_user
|
27
27
|
|
28
28
|
router = APIRouter()
|
29
29
|
|
30
30
|
|
31
31
|
@router.get("/project/", response_model=list[ProjectReadV2])
|
32
32
|
async def get_list_project(
|
33
|
-
user:
|
33
|
+
user: UserOAuth = Depends(current_active_user),
|
34
34
|
db: AsyncSession = Depends(get_async_db),
|
35
35
|
) -> list[ProjectV2]:
|
36
36
|
"""
|
@@ -50,7 +50,7 @@ async def get_list_project(
|
|
50
50
|
@router.post("/project/", response_model=ProjectReadV2, status_code=201)
|
51
51
|
async def create_project(
|
52
52
|
project: ProjectCreateV2,
|
53
|
-
user:
|
53
|
+
user: UserOAuth = Depends(current_active_user),
|
54
54
|
db: AsyncSession = Depends(get_async_db),
|
55
55
|
) -> Optional[ProjectReadV2]:
|
56
56
|
"""
|
@@ -76,7 +76,7 @@ async def create_project(
|
|
76
76
|
@router.get("/project/{project_id}/", response_model=ProjectReadV2)
|
77
77
|
async def read_project(
|
78
78
|
project_id: int,
|
79
|
-
user:
|
79
|
+
user: UserOAuth = Depends(current_active_user),
|
80
80
|
db: AsyncSession = Depends(get_async_db),
|
81
81
|
) -> Optional[ProjectReadV2]:
|
82
82
|
"""
|
@@ -93,7 +93,7 @@ async def read_project(
|
|
93
93
|
async def update_project(
|
94
94
|
project_id: int,
|
95
95
|
project_update: ProjectUpdateV2,
|
96
|
-
user:
|
96
|
+
user: UserOAuth = Depends(current_active_user),
|
97
97
|
db: AsyncSession = Depends(get_async_db),
|
98
98
|
):
|
99
99
|
project = await _get_project_check_owner(
|
@@ -118,7 +118,7 @@ async def update_project(
|
|
118
118
|
@router.delete("/project/{project_id}/", status_code=204)
|
119
119
|
async def delete_project(
|
120
120
|
project_id: int,
|
121
|
-
user:
|
121
|
+
user: UserOAuth = Depends(current_active_user),
|
122
122
|
db: AsyncSession = Depends(get_async_db),
|
123
123
|
) -> Response:
|
124
124
|
"""
|
@@ -13,11 +13,11 @@ from ....db import get_async_db
|
|
13
13
|
from ....models.v2 import JobV2
|
14
14
|
from ....schemas.v2.dataset import WorkflowTaskStatusTypeV2
|
15
15
|
from ....schemas.v2.status import StatusReadV2
|
16
|
-
from ....security import current_active_user
|
17
|
-
from ....security import User
|
18
16
|
from ._aux_functions import _get_dataset_check_owner
|
19
17
|
from ._aux_functions import _get_submitted_jobs_statement
|
20
18
|
from ._aux_functions import _get_workflow_check_owner
|
19
|
+
from fractal_server.app.models import UserOAuth
|
20
|
+
from fractal_server.app.routes.auth import current_active_user
|
21
21
|
from fractal_server.app.runner.filenames import HISTORY_FILENAME
|
22
22
|
|
23
23
|
router = APIRouter()
|
@@ -33,7 +33,7 @@ async def get_workflowtask_status(
|
|
33
33
|
project_id: int,
|
34
34
|
dataset_id: int,
|
35
35
|
workflow_id: int,
|
36
|
-
user:
|
36
|
+
user: UserOAuth = Depends(current_active_user),
|
37
37
|
db: AsyncSession = Depends(get_async_db),
|
38
38
|
) -> Optional[StatusReadV2]:
|
39
39
|
"""
|
@@ -27,11 +27,11 @@ from ....runner.v2 import submit_workflow
|
|
27
27
|
from ....schemas.v2 import JobCreateV2
|
28
28
|
from ....schemas.v2 import JobReadV2
|
29
29
|
from ....schemas.v2 import JobStatusTypeV2
|
30
|
-
from ....security import current_active_verified_user
|
31
|
-
from ....security import User
|
32
30
|
from ._aux_functions import _get_dataset_check_owner
|
33
31
|
from ._aux_functions import _get_workflow_check_owner
|
34
32
|
from ._aux_functions import clean_app_job_list_v2
|
33
|
+
from fractal_server.app.models import UserOAuth
|
34
|
+
from fractal_server.app.routes.auth import current_active_verified_user
|
35
35
|
|
36
36
|
|
37
37
|
def _encode_as_utc(dt: datetime):
|
@@ -54,7 +54,7 @@ async def apply_workflow(
|
|
54
54
|
job_create: JobCreateV2,
|
55
55
|
background_tasks: BackgroundTasks,
|
56
56
|
request: Request,
|
57
|
-
user:
|
57
|
+
user: UserOAuth = Depends(current_active_verified_user),
|
58
58
|
db: AsyncSession = Depends(get_async_db),
|
59
59
|
) -> Optional[JobReadV2]:
|
60
60
|
|