fractal-server 2.9.0a2__py3-none-any.whl → 2.9.0a4__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/app/routes/admin/v2/__init__.py +4 -0
- fractal_server/app/routes/admin/v2/task_group_lifecycle.py +260 -0
- fractal_server/app/routes/api/v2/task_collection.py +3 -10
- fractal_server/app/routes/api/v2/task_group_lifecycle.py +50 -6
- fractal_server/app/schemas/_validators.py +0 -14
- fractal_server/app/schemas/v1/applyworkflow.py +0 -8
- fractal_server/app/schemas/v1/dataset.py +0 -5
- fractal_server/app/schemas/v1/project.py +0 -5
- fractal_server/app/schemas/v1/state.py +0 -5
- fractal_server/app/schemas/v1/workflow.py +0 -5
- fractal_server/app/schemas/v2/dataset.py +0 -6
- fractal_server/app/schemas/v2/job.py +0 -8
- fractal_server/app/schemas/v2/project.py +0 -5
- fractal_server/app/schemas/v2/workflow.py +0 -5
- fractal_server/ssh/_fabric.py +4 -2
- fractal_server/tasks/v2/local/{utils_local.py → _utils.py} +25 -0
- fractal_server/tasks/v2/local/collect.py +2 -2
- fractal_server/tasks/v2/local/deactivate.py +1 -1
- fractal_server/tasks/v2/local/reactivate.py +1 -1
- fractal_server/tasks/v2/ssh/__init__.py +3 -0
- fractal_server/tasks/v2/ssh/_utils.py +87 -0
- fractal_server/tasks/v2/ssh/collect.py +4 -79
- fractal_server/tasks/v2/ssh/deactivate.py +243 -2
- fractal_server/tasks/v2/ssh/reactivate.py +199 -2
- fractal_server/tasks/v2/utils_background.py +0 -24
- fractal_server/zip_tools.py +21 -4
- {fractal_server-2.9.0a2.dist-info → fractal_server-2.9.0a4.dist-info}/METADATA +1 -1
- {fractal_server-2.9.0a2.dist-info → fractal_server-2.9.0a4.dist-info}/RECORD +32 -30
- {fractal_server-2.9.0a2.dist-info → fractal_server-2.9.0a4.dist-info}/LICENSE +0 -0
- {fractal_server-2.9.0a2.dist-info → fractal_server-2.9.0a4.dist-info}/WHEEL +0 -0
- {fractal_server-2.9.0a2.dist-info → fractal_server-2.9.0a4.dist-info}/entry_points.txt +0 -0
fractal_server/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__VERSION__ = "2.9.
|
1
|
+
__VERSION__ = "2.9.0a4"
|
@@ -7,6 +7,7 @@ from .job import router as job_router
|
|
7
7
|
from .project import router as project_router
|
8
8
|
from .task import router as task_router
|
9
9
|
from .task_group import router as task_group_router
|
10
|
+
from .task_group_lifecycle import router as task_group_lifecycle_router
|
10
11
|
|
11
12
|
router_admin_v2 = APIRouter()
|
12
13
|
|
@@ -14,3 +15,6 @@ router_admin_v2.include_router(job_router, prefix="/job")
|
|
14
15
|
router_admin_v2.include_router(project_router, prefix="/project")
|
15
16
|
router_admin_v2.include_router(task_router, prefix="/task")
|
16
17
|
router_admin_v2.include_router(task_group_router, prefix="/task-group")
|
18
|
+
router_admin_v2.include_router(
|
19
|
+
task_group_lifecycle_router, prefix="/task-group"
|
20
|
+
)
|
@@ -0,0 +1,260 @@
|
|
1
|
+
from fastapi import APIRouter
|
2
|
+
from fastapi import BackgroundTasks
|
3
|
+
from fastapi import Depends
|
4
|
+
from fastapi import HTTPException
|
5
|
+
from fastapi import Request
|
6
|
+
from fastapi import Response
|
7
|
+
from fastapi import status
|
8
|
+
|
9
|
+
from fractal_server.app.db import AsyncSession
|
10
|
+
from fractal_server.app.db import get_async_db
|
11
|
+
from fractal_server.app.models import UserOAuth
|
12
|
+
from fractal_server.app.models.v2 import TaskGroupActivityV2
|
13
|
+
from fractal_server.app.routes.api.v2._aux_functions_task_lifecycle import (
|
14
|
+
check_no_ongoing_activity,
|
15
|
+
)
|
16
|
+
from fractal_server.app.routes.api.v2._aux_functions_tasks import (
|
17
|
+
_get_task_group_or_404,
|
18
|
+
)
|
19
|
+
from fractal_server.app.routes.auth import current_active_superuser
|
20
|
+
from fractal_server.app.routes.aux.validate_user_settings import (
|
21
|
+
validate_user_settings,
|
22
|
+
)
|
23
|
+
from fractal_server.app.schemas.v2 import TaskGroupActivityActionV2
|
24
|
+
from fractal_server.app.schemas.v2 import TaskGroupActivityStatusV2
|
25
|
+
from fractal_server.app.schemas.v2 import TaskGroupActivityV2Read
|
26
|
+
from fractal_server.app.schemas.v2 import TaskGroupReadV2
|
27
|
+
from fractal_server.app.schemas.v2 import TaskGroupV2OriginEnum
|
28
|
+
from fractal_server.config import get_settings
|
29
|
+
from fractal_server.logger import set_logger
|
30
|
+
from fractal_server.syringe import Inject
|
31
|
+
from fractal_server.tasks.v2.local import deactivate_local
|
32
|
+
from fractal_server.tasks.v2.local import reactivate_local
|
33
|
+
from fractal_server.tasks.v2.ssh import deactivate_ssh
|
34
|
+
from fractal_server.tasks.v2.ssh import reactivate_ssh
|
35
|
+
from fractal_server.utils import get_timestamp
|
36
|
+
|
37
|
+
router = APIRouter()
|
38
|
+
|
39
|
+
logger = set_logger(__name__)
|
40
|
+
|
41
|
+
|
42
|
+
@router.post(
|
43
|
+
"/{task_group_id}/deactivate/",
|
44
|
+
response_model=TaskGroupActivityV2Read,
|
45
|
+
)
|
46
|
+
async def deactivate_task_group(
|
47
|
+
task_group_id: int,
|
48
|
+
background_tasks: BackgroundTasks,
|
49
|
+
response: Response,
|
50
|
+
request: Request,
|
51
|
+
superuser: UserOAuth = Depends(current_active_superuser),
|
52
|
+
db: AsyncSession = Depends(get_async_db),
|
53
|
+
) -> TaskGroupReadV2:
|
54
|
+
"""
|
55
|
+
Deactivate task-group venv
|
56
|
+
"""
|
57
|
+
task_group = await _get_task_group_or_404(
|
58
|
+
task_group_id=task_group_id, db=db
|
59
|
+
)
|
60
|
+
|
61
|
+
# Check no other activity is ongoing
|
62
|
+
await check_no_ongoing_activity(task_group_id=task_group_id, db=db)
|
63
|
+
|
64
|
+
# Check that task-group is active
|
65
|
+
if not task_group.active:
|
66
|
+
raise HTTPException(
|
67
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
68
|
+
detail=(
|
69
|
+
f"Cannot deactivate a task group with {task_group.active=}."
|
70
|
+
),
|
71
|
+
)
|
72
|
+
|
73
|
+
# Shortcut for task-group with origin="other"
|
74
|
+
if task_group.origin == TaskGroupV2OriginEnum.OTHER:
|
75
|
+
task_group.active = False
|
76
|
+
task_group_activity = TaskGroupActivityV2(
|
77
|
+
user_id=task_group.user_id,
|
78
|
+
taskgroupv2_id=task_group.id,
|
79
|
+
status=TaskGroupActivityStatusV2.OK,
|
80
|
+
action=TaskGroupActivityActionV2.DEACTIVATE,
|
81
|
+
pkg_name=task_group.pkg_name,
|
82
|
+
version=(task_group.version or "N/A"),
|
83
|
+
log=(
|
84
|
+
f"Task group has {task_group.origin=}, set "
|
85
|
+
"task_group.active to False and exit."
|
86
|
+
),
|
87
|
+
timestamp_started=get_timestamp(),
|
88
|
+
timestamp_ended=get_timestamp(),
|
89
|
+
)
|
90
|
+
db.add(task_group)
|
91
|
+
db.add(task_group_activity)
|
92
|
+
await db.commit()
|
93
|
+
response.status_code = status.HTTP_202_ACCEPTED
|
94
|
+
return task_group_activity
|
95
|
+
|
96
|
+
task_group_activity = TaskGroupActivityV2(
|
97
|
+
user_id=task_group.user_id,
|
98
|
+
taskgroupv2_id=task_group.id,
|
99
|
+
status=TaskGroupActivityStatusV2.PENDING,
|
100
|
+
action=TaskGroupActivityActionV2.DEACTIVATE,
|
101
|
+
pkg_name=task_group.pkg_name,
|
102
|
+
version=task_group.version,
|
103
|
+
timestamp_started=get_timestamp(),
|
104
|
+
)
|
105
|
+
task_group.active = False
|
106
|
+
db.add(task_group)
|
107
|
+
db.add(task_group_activity)
|
108
|
+
await db.commit()
|
109
|
+
|
110
|
+
# Submit background task
|
111
|
+
settings = Inject(get_settings)
|
112
|
+
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
113
|
+
# Validate user settings (backend-specific)
|
114
|
+
user = await db.get(UserOAuth, task_group.user_id)
|
115
|
+
user_settings = await validate_user_settings(
|
116
|
+
user=user, backend=settings.FRACTAL_RUNNER_BACKEND, db=db
|
117
|
+
)
|
118
|
+
# User appropriate FractalSSH object
|
119
|
+
ssh_credentials = dict(
|
120
|
+
user=user_settings.ssh_username,
|
121
|
+
host=user_settings.ssh_host,
|
122
|
+
key_path=user_settings.ssh_private_key_path,
|
123
|
+
)
|
124
|
+
fractal_ssh_list = request.app.state.fractal_ssh_list
|
125
|
+
fractal_ssh = fractal_ssh_list.get(**ssh_credentials)
|
126
|
+
|
127
|
+
background_tasks.add_task(
|
128
|
+
deactivate_ssh,
|
129
|
+
task_group_id=task_group.id,
|
130
|
+
task_group_activity_id=task_group_activity.id,
|
131
|
+
fractal_ssh=fractal_ssh,
|
132
|
+
tasks_base_dir=user_settings.ssh_tasks_dir,
|
133
|
+
)
|
134
|
+
else:
|
135
|
+
background_tasks.add_task(
|
136
|
+
deactivate_local,
|
137
|
+
task_group_id=task_group.id,
|
138
|
+
task_group_activity_id=task_group_activity.id,
|
139
|
+
)
|
140
|
+
|
141
|
+
logger.debug(
|
142
|
+
"Admin task group deactivation endpoint: start deactivate "
|
143
|
+
"and return task_group_activity"
|
144
|
+
)
|
145
|
+
response.status_code = status.HTTP_202_ACCEPTED
|
146
|
+
return task_group_activity
|
147
|
+
|
148
|
+
|
149
|
+
@router.post(
|
150
|
+
"/{task_group_id}/reactivate/",
|
151
|
+
response_model=TaskGroupActivityV2Read,
|
152
|
+
)
|
153
|
+
async def reactivate_task_group(
|
154
|
+
task_group_id: int,
|
155
|
+
background_tasks: BackgroundTasks,
|
156
|
+
response: Response,
|
157
|
+
request: Request,
|
158
|
+
superuser: UserOAuth = Depends(current_active_superuser),
|
159
|
+
db: AsyncSession = Depends(get_async_db),
|
160
|
+
) -> TaskGroupReadV2:
|
161
|
+
"""
|
162
|
+
Deactivate task-group venv
|
163
|
+
"""
|
164
|
+
|
165
|
+
task_group = await _get_task_group_or_404(
|
166
|
+
task_group_id=task_group_id, db=db
|
167
|
+
)
|
168
|
+
|
169
|
+
# Check that task-group is not active
|
170
|
+
if task_group.active:
|
171
|
+
raise HTTPException(
|
172
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
173
|
+
detail=(
|
174
|
+
f"Cannot reactivate a task group with {task_group.active=}."
|
175
|
+
),
|
176
|
+
)
|
177
|
+
|
178
|
+
# Check no other activity is ongoing
|
179
|
+
await check_no_ongoing_activity(task_group_id=task_group_id, db=db)
|
180
|
+
|
181
|
+
# Shortcut for task-group with origin="other"
|
182
|
+
if task_group.origin == TaskGroupV2OriginEnum.OTHER:
|
183
|
+
task_group.active = True
|
184
|
+
task_group_activity = TaskGroupActivityV2(
|
185
|
+
user_id=task_group.user_id,
|
186
|
+
taskgroupv2_id=task_group.id,
|
187
|
+
status=TaskGroupActivityStatusV2.OK,
|
188
|
+
action=TaskGroupActivityActionV2.REACTIVATE,
|
189
|
+
pkg_name=task_group.pkg_name,
|
190
|
+
version=(task_group.version or "N/A"),
|
191
|
+
log=(
|
192
|
+
f"Task group has {task_group.origin=}, set "
|
193
|
+
"task_group.active to True and exit."
|
194
|
+
),
|
195
|
+
timestamp_started=get_timestamp(),
|
196
|
+
timestamp_ended=get_timestamp(),
|
197
|
+
)
|
198
|
+
db.add(task_group)
|
199
|
+
db.add(task_group_activity)
|
200
|
+
await db.commit()
|
201
|
+
response.status_code = status.HTTP_202_ACCEPTED
|
202
|
+
return task_group_activity
|
203
|
+
|
204
|
+
if task_group.pip_freeze is None:
|
205
|
+
raise HTTPException(
|
206
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
207
|
+
detail=(
|
208
|
+
"Cannot reactivate a task group with "
|
209
|
+
f"{task_group.pip_freeze=}."
|
210
|
+
),
|
211
|
+
)
|
212
|
+
|
213
|
+
task_group_activity = TaskGroupActivityV2(
|
214
|
+
user_id=task_group.user_id,
|
215
|
+
taskgroupv2_id=task_group.id,
|
216
|
+
status=TaskGroupActivityStatusV2.PENDING,
|
217
|
+
action=TaskGroupActivityActionV2.REACTIVATE,
|
218
|
+
pkg_name=task_group.pkg_name,
|
219
|
+
version=task_group.version,
|
220
|
+
timestamp_started=get_timestamp(),
|
221
|
+
)
|
222
|
+
db.add(task_group_activity)
|
223
|
+
await db.commit()
|
224
|
+
|
225
|
+
# Submit background task
|
226
|
+
settings = Inject(get_settings)
|
227
|
+
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
228
|
+
# Validate user settings (backend-specific)
|
229
|
+
user = await db.get(UserOAuth, task_group.user_id)
|
230
|
+
user_settings = await validate_user_settings(
|
231
|
+
user=user, backend=settings.FRACTAL_RUNNER_BACKEND, db=db
|
232
|
+
)
|
233
|
+
# Use appropriate FractalSSH object
|
234
|
+
ssh_credentials = dict(
|
235
|
+
user=user_settings.ssh_username,
|
236
|
+
host=user_settings.ssh_host,
|
237
|
+
key_path=user_settings.ssh_private_key_path,
|
238
|
+
)
|
239
|
+
fractal_ssh_list = request.app.state.fractal_ssh_list
|
240
|
+
fractal_ssh = fractal_ssh_list.get(**ssh_credentials)
|
241
|
+
|
242
|
+
background_tasks.add_task(
|
243
|
+
reactivate_ssh,
|
244
|
+
task_group_id=task_group.id,
|
245
|
+
task_group_activity_id=task_group_activity.id,
|
246
|
+
fractal_ssh=fractal_ssh,
|
247
|
+
tasks_base_dir=user_settings.ssh_tasks_dir,
|
248
|
+
)
|
249
|
+
else:
|
250
|
+
background_tasks.add_task(
|
251
|
+
reactivate_local,
|
252
|
+
task_group_id=task_group.id,
|
253
|
+
task_group_activity_id=task_group_activity.id,
|
254
|
+
)
|
255
|
+
logger.debug(
|
256
|
+
"Admin task group reactivation endpoint: start reactivate "
|
257
|
+
"and return task_group_activity"
|
258
|
+
)
|
259
|
+
response.status_code = status.HTTP_202_ACCEPTED
|
260
|
+
return task_group_activity
|
@@ -37,6 +37,7 @@ from fractal_server.app.schemas.v2 import TaskGroupV2OriginEnum
|
|
37
37
|
from fractal_server.tasks.v2.local.collect import (
|
38
38
|
collect_local,
|
39
39
|
)
|
40
|
+
from fractal_server.tasks.v2.ssh import collect_ssh
|
40
41
|
from fractal_server.tasks.v2.utils_package_names import _parse_wheel_filename
|
41
42
|
from fractal_server.tasks.v2.utils_package_names import normalize_package_name
|
42
43
|
from fractal_server.tasks.v2.utils_python_interpreter import (
|
@@ -63,10 +64,7 @@ async def collect_tasks_pip(
|
|
63
64
|
db: AsyncSession = Depends(get_async_db),
|
64
65
|
) -> TaskGroupActivityV2Read:
|
65
66
|
"""
|
66
|
-
Task
|
67
|
-
|
68
|
-
Trigger the creation of a dedicated virtual environment, the installation
|
69
|
-
of a package and the collection of tasks as advertised in the manifest.
|
67
|
+
Task-collection endpoint
|
70
68
|
"""
|
71
69
|
|
72
70
|
# Get settings
|
@@ -246,12 +244,7 @@ async def collect_tasks_pip(
|
|
246
244
|
|
247
245
|
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
248
246
|
# SSH task collection
|
249
|
-
|
250
|
-
from fractal_server.tasks.v2.ssh.collect import (
|
251
|
-
collect_ssh,
|
252
|
-
)
|
253
|
-
|
254
|
-
# User appropriate FractalSSH object
|
247
|
+
# Use appropriate FractalSSH object
|
255
248
|
ssh_credentials = dict(
|
256
249
|
user=user_settings.ssh_username,
|
257
250
|
host=user_settings.ssh_host,
|
@@ -2,9 +2,11 @@ from fastapi import APIRouter
|
|
2
2
|
from fastapi import BackgroundTasks
|
3
3
|
from fastapi import Depends
|
4
4
|
from fastapi import HTTPException
|
5
|
+
from fastapi import Request
|
5
6
|
from fastapi import Response
|
6
7
|
from fastapi import status
|
7
8
|
|
9
|
+
from ...aux.validate_user_settings import validate_user_settings
|
8
10
|
from ._aux_functions_task_lifecycle import check_no_ongoing_activity
|
9
11
|
from ._aux_functions_tasks import _get_task_group_full_access
|
10
12
|
from fractal_server.app.db import AsyncSession
|
@@ -22,6 +24,8 @@ from fractal_server.logger import set_logger
|
|
22
24
|
from fractal_server.syringe import Inject
|
23
25
|
from fractal_server.tasks.v2.local import deactivate_local
|
24
26
|
from fractal_server.tasks.v2.local import reactivate_local
|
27
|
+
from fractal_server.tasks.v2.ssh import deactivate_ssh
|
28
|
+
from fractal_server.tasks.v2.ssh import reactivate_ssh
|
25
29
|
from fractal_server.utils import get_timestamp
|
26
30
|
|
27
31
|
router = APIRouter()
|
@@ -38,6 +42,7 @@ async def deactivate_task_group(
|
|
38
42
|
task_group_id: int,
|
39
43
|
background_tasks: BackgroundTasks,
|
40
44
|
response: Response,
|
45
|
+
request: Request,
|
41
46
|
user: UserOAuth = Depends(current_active_user),
|
42
47
|
db: AsyncSession = Depends(get_async_db),
|
43
48
|
) -> TaskGroupReadV2:
|
@@ -103,10 +108,29 @@ async def deactivate_task_group(
|
|
103
108
|
# Submit background task
|
104
109
|
settings = Inject(get_settings)
|
105
110
|
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
106
|
-
|
107
|
-
|
108
|
-
|
111
|
+
|
112
|
+
# Validate user settings (backend-specific)
|
113
|
+
user_settings = await validate_user_settings(
|
114
|
+
user=user, backend=settings.FRACTAL_RUNNER_BACKEND, db=db
|
115
|
+
)
|
116
|
+
|
117
|
+
# User appropriate FractalSSH object
|
118
|
+
ssh_credentials = dict(
|
119
|
+
user=user_settings.ssh_username,
|
120
|
+
host=user_settings.ssh_host,
|
121
|
+
key_path=user_settings.ssh_private_key_path,
|
122
|
+
)
|
123
|
+
fractal_ssh_list = request.app.state.fractal_ssh_list
|
124
|
+
fractal_ssh = fractal_ssh_list.get(**ssh_credentials)
|
125
|
+
|
126
|
+
background_tasks.add_task(
|
127
|
+
deactivate_ssh,
|
128
|
+
task_group_id=task_group.id,
|
129
|
+
task_group_activity_id=task_group_activity.id,
|
130
|
+
fractal_ssh=fractal_ssh,
|
131
|
+
tasks_base_dir=user_settings.ssh_tasks_dir,
|
109
132
|
)
|
133
|
+
|
110
134
|
else:
|
111
135
|
background_tasks.add_task(
|
112
136
|
deactivate_local,
|
@@ -130,6 +154,7 @@ async def reactivate_task_group(
|
|
130
154
|
task_group_id: int,
|
131
155
|
background_tasks: BackgroundTasks,
|
132
156
|
response: Response,
|
157
|
+
request: Request,
|
133
158
|
user: UserOAuth = Depends(current_active_user),
|
134
159
|
db: AsyncSession = Depends(get_async_db),
|
135
160
|
) -> TaskGroupReadV2:
|
@@ -203,10 +228,29 @@ async def reactivate_task_group(
|
|
203
228
|
# Submit background task
|
204
229
|
settings = Inject(get_settings)
|
205
230
|
if settings.FRACTAL_RUNNER_BACKEND == "slurm_ssh":
|
206
|
-
|
207
|
-
|
208
|
-
|
231
|
+
|
232
|
+
# Validate user settings (backend-specific)
|
233
|
+
user_settings = await validate_user_settings(
|
234
|
+
user=user, backend=settings.FRACTAL_RUNNER_BACKEND, db=db
|
235
|
+
)
|
236
|
+
|
237
|
+
# Use appropriate FractalSSH object
|
238
|
+
ssh_credentials = dict(
|
239
|
+
user=user_settings.ssh_username,
|
240
|
+
host=user_settings.ssh_host,
|
241
|
+
key_path=user_settings.ssh_private_key_path,
|
242
|
+
)
|
243
|
+
fractal_ssh_list = request.app.state.fractal_ssh_list
|
244
|
+
fractal_ssh = fractal_ssh_list.get(**ssh_credentials)
|
245
|
+
|
246
|
+
background_tasks.add_task(
|
247
|
+
reactivate_ssh,
|
248
|
+
task_group_id=task_group.id,
|
249
|
+
task_group_activity_id=task_group_activity.id,
|
250
|
+
fractal_ssh=fractal_ssh,
|
251
|
+
tasks_base_dir=user_settings.ssh_tasks_dir,
|
209
252
|
)
|
253
|
+
|
210
254
|
else:
|
211
255
|
background_tasks.add_task(
|
212
256
|
reactivate_local,
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import os
|
2
|
-
from datetime import datetime
|
3
|
-
from datetime import timezone
|
4
2
|
from typing import Any
|
5
3
|
from typing import Optional
|
6
4
|
|
@@ -103,15 +101,3 @@ def val_unique_list(attribute: str):
|
|
103
101
|
return must_be_unique
|
104
102
|
|
105
103
|
return val
|
106
|
-
|
107
|
-
|
108
|
-
def valutc(attribute: str):
|
109
|
-
def val(timestamp: Optional[datetime]) -> Optional[datetime]:
|
110
|
-
"""
|
111
|
-
Replace `tzinfo` with `timezone.utc`.
|
112
|
-
"""
|
113
|
-
if timestamp is not None:
|
114
|
-
return timestamp.replace(tzinfo=timezone.utc)
|
115
|
-
return None
|
116
|
-
|
117
|
-
return val
|
@@ -7,7 +7,6 @@ from pydantic import validator
|
|
7
7
|
from pydantic.types import StrictStr
|
8
8
|
|
9
9
|
from .._validators import valstr
|
10
|
-
from .._validators import valutc
|
11
10
|
from .dumps import DatasetDumpV1
|
12
11
|
from .dumps import ProjectDumpV1
|
13
12
|
from .dumps import WorkflowDumpV1
|
@@ -150,13 +149,6 @@ class ApplyWorkflowReadV1(_ApplyWorkflowBaseV1):
|
|
150
149
|
first_task_index: Optional[int]
|
151
150
|
last_task_index: Optional[int]
|
152
151
|
|
153
|
-
_start_timestamp = validator("start_timestamp", allow_reuse=True)(
|
154
|
-
valutc("start_timestamp")
|
155
|
-
)
|
156
|
-
_end_timestamp = validator("end_timestamp", allow_reuse=True)(
|
157
|
-
valutc("end_timestamp")
|
158
|
-
)
|
159
|
-
|
160
152
|
|
161
153
|
class ApplyWorkflowUpdateV1(BaseModel):
|
162
154
|
"""
|
@@ -8,7 +8,6 @@ from pydantic import validator
|
|
8
8
|
|
9
9
|
from .._validators import val_absolute_path
|
10
10
|
from .._validators import valstr
|
11
|
-
from .._validators import valutc
|
12
11
|
from .dumps import WorkflowTaskDumpV1
|
13
12
|
from .project import ProjectReadV1
|
14
13
|
from .workflow import WorkflowTaskStatusTypeV1
|
@@ -151,10 +150,6 @@ class DatasetReadV1(_DatasetBaseV1):
|
|
151
150
|
project: ProjectReadV1
|
152
151
|
timestamp_created: datetime
|
153
152
|
|
154
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
155
|
-
valutc("timestamp_created")
|
156
|
-
)
|
157
|
-
|
158
153
|
|
159
154
|
class DatasetStatusReadV1(BaseModel):
|
160
155
|
"""
|
@@ -5,7 +5,6 @@ from pydantic import BaseModel
|
|
5
5
|
from pydantic import validator
|
6
6
|
|
7
7
|
from .._validators import valstr
|
8
|
-
from .._validators import valutc
|
9
8
|
|
10
9
|
|
11
10
|
__all__ = (
|
@@ -50,10 +49,6 @@ class ProjectReadV1(_ProjectBaseV1):
|
|
50
49
|
id: int
|
51
50
|
timestamp_created: datetime
|
52
51
|
|
53
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
54
|
-
valutc("timestamp_created")
|
55
|
-
)
|
56
|
-
|
57
52
|
|
58
53
|
class ProjectUpdateV1(_ProjectBaseV1):
|
59
54
|
"""
|
@@ -3,9 +3,6 @@ from typing import Any
|
|
3
3
|
from typing import Optional
|
4
4
|
|
5
5
|
from pydantic import BaseModel
|
6
|
-
from pydantic import validator
|
7
|
-
|
8
|
-
from fractal_server.app.schemas._validators import valutc
|
9
6
|
|
10
7
|
|
11
8
|
class StateRead(BaseModel):
|
@@ -19,5 +16,3 @@ class StateRead(BaseModel):
|
|
19
16
|
id: Optional[int]
|
20
17
|
data: dict[str, Any]
|
21
18
|
timestamp: datetime
|
22
|
-
|
23
|
-
_timestamp = validator("timestamp", allow_reuse=True)(valutc("timestamp"))
|
@@ -8,7 +8,6 @@ from pydantic import validator
|
|
8
8
|
|
9
9
|
from .._validators import valint
|
10
10
|
from .._validators import valstr
|
11
|
-
from .._validators import valutc
|
12
11
|
from .project import ProjectReadV1
|
13
12
|
from .task import TaskExportV1
|
14
13
|
from .task import TaskImportV1
|
@@ -135,10 +134,6 @@ class WorkflowReadV1(_WorkflowBaseV1):
|
|
135
134
|
project: ProjectReadV1
|
136
135
|
timestamp_created: datetime
|
137
136
|
|
138
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
139
|
-
valutc("timestamp_created")
|
140
|
-
)
|
141
|
-
|
142
137
|
|
143
138
|
class WorkflowCreateV1(_WorkflowBaseV1):
|
144
139
|
"""
|
@@ -7,7 +7,6 @@ from pydantic import Field
|
|
7
7
|
from pydantic import validator
|
8
8
|
|
9
9
|
from .._validators import valstr
|
10
|
-
from .._validators import valutc
|
11
10
|
from .dumps import WorkflowTaskDumpV2
|
12
11
|
from .project import ProjectReadV2
|
13
12
|
from .workflowtask import WorkflowTaskStatusTypeV2
|
@@ -62,11 +61,6 @@ class DatasetReadV2(BaseModel):
|
|
62
61
|
zarr_dir: str
|
63
62
|
filters: Filters = Field(default_factory=Filters)
|
64
63
|
|
65
|
-
# Validators
|
66
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
67
|
-
valutc("timestamp_created")
|
68
|
-
)
|
69
|
-
|
70
64
|
|
71
65
|
class DatasetUpdateV2(BaseModel, extra=Extra.forbid):
|
72
66
|
|
@@ -8,7 +8,6 @@ from pydantic import validator
|
|
8
8
|
from pydantic.types import StrictStr
|
9
9
|
|
10
10
|
from .._validators import valstr
|
11
|
-
from .._validators import valutc
|
12
11
|
from .dumps import DatasetDumpV2
|
13
12
|
from .dumps import ProjectDumpV2
|
14
13
|
from .dumps import WorkflowDumpV2
|
@@ -101,13 +100,6 @@ class JobReadV2(BaseModel):
|
|
101
100
|
last_task_index: Optional[int]
|
102
101
|
worker_init: Optional[str]
|
103
102
|
|
104
|
-
_start_timestamp = validator("start_timestamp", allow_reuse=True)(
|
105
|
-
valutc("start_timestamp")
|
106
|
-
)
|
107
|
-
_end_timestamp = validator("end_timestamp", allow_reuse=True)(
|
108
|
-
valutc("end_timestamp")
|
109
|
-
)
|
110
|
-
|
111
103
|
|
112
104
|
class JobUpdateV2(BaseModel, extra=Extra.forbid):
|
113
105
|
|
@@ -6,7 +6,6 @@ from pydantic import Extra
|
|
6
6
|
from pydantic import validator
|
7
7
|
|
8
8
|
from .._validators import valstr
|
9
|
-
from .._validators import valutc
|
10
9
|
|
11
10
|
|
12
11
|
class ProjectCreateV2(BaseModel, extra=Extra.forbid):
|
@@ -21,10 +20,6 @@ class ProjectReadV2(BaseModel):
|
|
21
20
|
id: int
|
22
21
|
name: str
|
23
22
|
timestamp_created: datetime
|
24
|
-
# Validators
|
25
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
26
|
-
valutc("timestamp_created")
|
27
|
-
)
|
28
23
|
|
29
24
|
|
30
25
|
class ProjectUpdateV2(BaseModel, extra=Extra.forbid):
|
@@ -6,7 +6,6 @@ from pydantic import Extra
|
|
6
6
|
from pydantic import validator
|
7
7
|
|
8
8
|
from .._validators import valstr
|
9
|
-
from .._validators import valutc
|
10
9
|
from .project import ProjectReadV2
|
11
10
|
from .workflowtask import WorkflowTaskExportV2
|
12
11
|
from .workflowtask import WorkflowTaskImportV2
|
@@ -31,10 +30,6 @@ class WorkflowReadV2(BaseModel):
|
|
31
30
|
project: ProjectReadV2
|
32
31
|
timestamp_created: datetime
|
33
32
|
|
34
|
-
_timestamp_created = validator("timestamp_created", allow_reuse=True)(
|
35
|
-
valutc("timestamp_created")
|
36
|
-
)
|
37
|
-
|
38
33
|
|
39
34
|
class WorkflowReadV2WithWarnings(WorkflowReadV2):
|
40
35
|
task_list: list[WorkflowTaskReadV2WithWarning]
|
fractal_server/ssh/_fabric.py
CHANGED
@@ -321,8 +321,10 @@ class FractalSSH(object):
|
|
321
321
|
f"{prefix} END running '{cmd}' over SSH, "
|
322
322
|
f"elapsed {t_1-t_0:.3f}"
|
323
323
|
)
|
324
|
-
self.logger.debug(
|
325
|
-
self.logger.debug(
|
324
|
+
self.logger.debug("STDOUT:")
|
325
|
+
self.logger.debug(res.stdout)
|
326
|
+
self.logger.debug("STDERR:")
|
327
|
+
self.logger.debug(res.stderr)
|
326
328
|
return res.stdout
|
327
329
|
except NoValidConnectionsError as e:
|
328
330
|
# Case 2: Command fails with a connection error
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from pathlib import Path
|
2
2
|
|
3
|
+
from fractal_server.app.schemas.v2 import TaskCreateV2
|
3
4
|
from fractal_server.logger import get_logger
|
4
5
|
from fractal_server.tasks.v2.utils_templates import customize_template
|
5
6
|
from fractal_server.utils import execute_command_sync
|
@@ -43,3 +44,27 @@ def _customize_and_run_template(
|
|
43
44
|
stdout = execute_command_sync(command=cmd, logger_name=logger_name)
|
44
45
|
logger.debug(f"_customize_and_run_template {template_filename} - END")
|
45
46
|
return stdout
|
47
|
+
|
48
|
+
|
49
|
+
def check_task_files_exist(task_list: list[TaskCreateV2]) -> None:
|
50
|
+
"""
|
51
|
+
Check that the modules listed in task commands point to existing files.
|
52
|
+
|
53
|
+
Args:
|
54
|
+
task_list:
|
55
|
+
"""
|
56
|
+
for _task in task_list:
|
57
|
+
if _task.command_non_parallel is not None:
|
58
|
+
_task_path = _task.command_non_parallel.split()[1]
|
59
|
+
if not Path(_task_path).exists():
|
60
|
+
raise FileNotFoundError(
|
61
|
+
f"Task `{_task.name}` has `command_non_parallel` "
|
62
|
+
f"pointing to missing file `{_task_path}`."
|
63
|
+
)
|
64
|
+
if _task.command_parallel is not None:
|
65
|
+
_task_path = _task.command_parallel.split()[1]
|
66
|
+
if not Path(_task_path).exists():
|
67
|
+
raise FileNotFoundError(
|
68
|
+
f"Task `{_task.name}` has `command_parallel` "
|
69
|
+
f"pointing to missing file `{_task_path}`."
|
70
|
+
)
|
@@ -6,7 +6,7 @@ from pathlib import Path
|
|
6
6
|
from tempfile import TemporaryDirectory
|
7
7
|
|
8
8
|
from ..utils_database import create_db_tasks_and_update_task_group
|
9
|
-
from .
|
9
|
+
from ._utils import _customize_and_run_template
|
10
10
|
from fractal_server.app.db import get_sync_db
|
11
11
|
from fractal_server.app.models.v2 import TaskGroupActivityV2
|
12
12
|
from fractal_server.app.models.v2 import TaskGroupV2
|
@@ -16,9 +16,9 @@ from fractal_server.app.schemas.v2.manifest import ManifestV2
|
|
16
16
|
from fractal_server.logger import get_logger
|
17
17
|
from fractal_server.logger import set_logger
|
18
18
|
from fractal_server.tasks.utils import get_log_path
|
19
|
+
from fractal_server.tasks.v2.local._utils import check_task_files_exist
|
19
20
|
from fractal_server.tasks.v2.utils_background import _prepare_tasks_metadata
|
20
21
|
from fractal_server.tasks.v2.utils_background import add_commit_refresh
|
21
|
-
from fractal_server.tasks.v2.utils_background import check_task_files_exist
|
22
22
|
from fractal_server.tasks.v2.utils_background import fail_and_cleanup
|
23
23
|
from fractal_server.tasks.v2.utils_background import get_current_log
|
24
24
|
from fractal_server.tasks.v2.utils_package_names import compare_package_names
|