fractal-server 2.0.6__py3-none-any.whl → 2.1.0__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/api/v2/submit.py +5 -10
- fractal_server/app/runner/executors/slurm/executor.py +12 -0
- fractal_server/app/runner/v1/__init__.py +5 -10
- fractal_server/app/security/__init__.py +4 -5
- fractal_server/config.py +21 -0
- fractal_server/main.py +22 -26
- {fractal_server-2.0.6.dist-info → fractal_server-2.1.0.dist-info}/METADATA +1 -1
- {fractal_server-2.0.6.dist-info → fractal_server-2.1.0.dist-info}/RECORD +12 -12
- {fractal_server-2.0.6.dist-info → fractal_server-2.1.0.dist-info}/LICENSE +0 -0
- {fractal_server-2.0.6.dist-info → fractal_server-2.1.0.dist-info}/WHEEL +0 -0
- {fractal_server-2.0.6.dist-info → fractal_server-2.1.0.dist-info}/entry_points.txt +0 -0
fractal_server/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__VERSION__ = "2.0
|
1
|
+
__VERSION__ = "2.1.0"
|
@@ -195,21 +195,16 @@ async def apply_workflow(
|
|
195
195
|
|
196
196
|
# Define server-side job directory
|
197
197
|
timestamp_string = get_timestamp().strftime("%Y%m%d_%H%M%S")
|
198
|
-
WORKFLOW_DIR = (
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
f"_{timestamp_string}"
|
203
|
-
)
|
204
|
-
).resolve()
|
198
|
+
WORKFLOW_DIR = settings.FRACTAL_RUNNER_WORKING_BASE_DIR / (
|
199
|
+
f"proj_v2_{project_id:07d}_wf_{workflow_id:07d}_job_{job.id:07d}"
|
200
|
+
f"_{timestamp_string}"
|
201
|
+
)
|
205
202
|
|
206
203
|
# Define user-side job directory
|
207
204
|
if FRACTAL_RUNNER_BACKEND == "local":
|
208
205
|
WORKFLOW_DIR_USER = WORKFLOW_DIR
|
209
206
|
elif FRACTAL_RUNNER_BACKEND == "slurm":
|
210
|
-
WORKFLOW_DIR_USER = (
|
211
|
-
Path(user.cache_dir) / f"{WORKFLOW_DIR.name}"
|
212
|
-
).resolve()
|
207
|
+
WORKFLOW_DIR_USER = Path(user.cache_dir) / f"{WORKFLOW_DIR.name}"
|
213
208
|
|
214
209
|
# Update job folders in the db
|
215
210
|
job.working_dir = WORKFLOW_DIR.as_posix()
|
@@ -1188,3 +1188,15 @@ class FractalSlurmExecutor(SlurmExecutor):
|
|
1188
1188
|
raise JobExecutionError(info=error_msg)
|
1189
1189
|
|
1190
1190
|
logger.debug("Executor shutdown: end")
|
1191
|
+
|
1192
|
+
def __exit__(self, *args, **kwargs):
|
1193
|
+
"""
|
1194
|
+
See
|
1195
|
+
https://github.com/fractal-analytics-platform/fractal-server/issues/1508
|
1196
|
+
"""
|
1197
|
+
logger.debug(
|
1198
|
+
"[FractalSlurmExecutor.__exit__] Stop and join `wait_thread`"
|
1199
|
+
)
|
1200
|
+
self.wait_thread.stop()
|
1201
|
+
self.wait_thread.join()
|
1202
|
+
logger.debug("[FractalSlurmExecutor.__exit__] End")
|
@@ -137,13 +137,10 @@ async def submit_workflow(
|
|
137
137
|
# Define and create server-side working folder
|
138
138
|
project_id = workflow.project_id
|
139
139
|
timestamp_string = get_timestamp().strftime("%Y%m%d_%H%M%S")
|
140
|
-
WORKFLOW_DIR = (
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
f"_{timestamp_string}"
|
145
|
-
)
|
146
|
-
).resolve()
|
140
|
+
WORKFLOW_DIR = settings.FRACTAL_RUNNER_WORKING_BASE_DIR / (
|
141
|
+
f"proj_{project_id:07d}_wf_{workflow_id:07d}_job_{job_id:07d}"
|
142
|
+
f"_{timestamp_string}"
|
143
|
+
)
|
147
144
|
|
148
145
|
if WORKFLOW_DIR.exists():
|
149
146
|
raise RuntimeError(f"Workflow dir {WORKFLOW_DIR} already exists.")
|
@@ -162,9 +159,7 @@ async def submit_workflow(
|
|
162
159
|
_mkdir_as_user,
|
163
160
|
)
|
164
161
|
|
165
|
-
WORKFLOW_DIR_USER = (
|
166
|
-
Path(user_cache_dir) / f"{WORKFLOW_DIR.name}"
|
167
|
-
).resolve()
|
162
|
+
WORKFLOW_DIR_USER = Path(user_cache_dir) / f"{WORKFLOW_DIR.name}"
|
168
163
|
_mkdir_as_user(folder=str(WORKFLOW_DIR_USER), user=slurm_user)
|
169
164
|
else:
|
170
165
|
raise ValueError(f"{FRACTAL_RUNNER_BACKEND=} not supported")
|
@@ -57,9 +57,8 @@ from sqlmodel import select
|
|
57
57
|
from ...config import get_settings
|
58
58
|
from ...syringe import Inject
|
59
59
|
from ..db import get_async_db
|
60
|
-
from
|
61
|
-
from
|
62
|
-
from fractal_server.app.models.security import UserOAuth
|
60
|
+
from fractal_server.app.models.security import OAuthAccount
|
61
|
+
from fractal_server.app.models.security import UserOAuth as User
|
63
62
|
from fractal_server.app.schemas.user import UserCreate
|
64
63
|
from fractal_server.logger import get_logger
|
65
64
|
|
@@ -287,8 +286,8 @@ async def _create_first_user(
|
|
287
286
|
|
288
287
|
if is_superuser is True:
|
289
288
|
# If a superuser already exists, exit
|
290
|
-
stm = select(
|
291
|
-
|
289
|
+
stm = select(User).where(
|
290
|
+
User.is_superuser == True # noqa E712
|
292
291
|
)
|
293
292
|
res = await session.execute(stm)
|
294
293
|
existing_superuser = res.scalars().first()
|
fractal_server/config.py
CHANGED
@@ -289,6 +289,27 @@ class Settings(BaseSettings):
|
|
289
289
|
)
|
290
290
|
return FRACTAL_TASKS_DIR_path
|
291
291
|
|
292
|
+
@validator("FRACTAL_RUNNER_WORKING_BASE_DIR", always=True)
|
293
|
+
def make_FRACTAL_RUNNER_WORKING_BASE_DIR_absolute(cls, v):
|
294
|
+
"""
|
295
|
+
(Copy of make_FRACTAL_TASKS_DIR_absolute)
|
296
|
+
If `FRACTAL_RUNNER_WORKING_BASE_DIR` is a non-absolute path,
|
297
|
+
make it absolute (based on the current working directory).
|
298
|
+
"""
|
299
|
+
if v is None:
|
300
|
+
return None
|
301
|
+
FRACTAL_RUNNER_WORKING_BASE_DIR_path = Path(v)
|
302
|
+
if not FRACTAL_RUNNER_WORKING_BASE_DIR_path.is_absolute():
|
303
|
+
FRACTAL_RUNNER_WORKING_BASE_DIR_path = (
|
304
|
+
FRACTAL_RUNNER_WORKING_BASE_DIR_path.resolve()
|
305
|
+
)
|
306
|
+
logging.warning(
|
307
|
+
f'FRACTAL_RUNNER_WORKING_BASE_DIR="{v}" is not an absolute '
|
308
|
+
"path; converting it to "
|
309
|
+
f'"{str(FRACTAL_RUNNER_WORKING_BASE_DIR_path)}"'
|
310
|
+
)
|
311
|
+
return FRACTAL_RUNNER_WORKING_BASE_DIR_path
|
312
|
+
|
292
313
|
FRACTAL_RUNNER_BACKEND: Literal["local", "slurm"] = "local"
|
293
314
|
"""
|
294
315
|
Select which runner backend to use.
|
fractal_server/main.py
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
|
16
16
|
This module sets up the FastAPI application that serves the Fractal Server.
|
17
17
|
"""
|
18
|
+
from contextlib import asynccontextmanager
|
19
|
+
|
18
20
|
from fastapi import FastAPI
|
19
21
|
|
20
22
|
from .app.security import _create_first_user
|
@@ -77,15 +79,27 @@ def check_settings() -> None:
|
|
77
79
|
reset_logger_handlers(logger)
|
78
80
|
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
It should only be called from a `@app.on_event("startup")`-decorated
|
85
|
-
callable.
|
86
|
-
"""
|
82
|
+
@asynccontextmanager
|
83
|
+
async def lifespan(app: FastAPI):
|
84
|
+
logger = set_logger("fractal_server.lifespan")
|
85
|
+
logger.info("Start application startup")
|
87
86
|
check_settings()
|
87
|
+
settings = Inject(get_settings)
|
88
|
+
await _create_first_user(
|
89
|
+
email=settings.FRACTAL_DEFAULT_ADMIN_EMAIL,
|
90
|
+
password=settings.FRACTAL_DEFAULT_ADMIN_PASSWORD,
|
91
|
+
username=settings.FRACTAL_DEFAULT_ADMIN_USERNAME,
|
92
|
+
is_superuser=True,
|
93
|
+
is_verified=True,
|
94
|
+
)
|
88
95
|
config_uvicorn_loggers()
|
96
|
+
logger.info("End application startup")
|
97
|
+
reset_logger_handlers(logger)
|
98
|
+
yield
|
99
|
+
logger = set_logger("fractal_server.lifespan")
|
100
|
+
logger.info("Start application shutdown")
|
101
|
+
logger.info("End application shutdown")
|
102
|
+
reset_logger_handlers(logger)
|
89
103
|
|
90
104
|
|
91
105
|
def start_application() -> FastAPI:
|
@@ -96,27 +110,9 @@ def start_application() -> FastAPI:
|
|
96
110
|
app:
|
97
111
|
The fully initialised application.
|
98
112
|
"""
|
99
|
-
app = FastAPI()
|
113
|
+
app = FastAPI(lifespan=lifespan)
|
100
114
|
collect_routers(app)
|
101
115
|
return app
|
102
116
|
|
103
117
|
|
104
118
|
app = start_application()
|
105
|
-
|
106
|
-
|
107
|
-
@app.on_event("startup")
|
108
|
-
async def on_startup() -> None:
|
109
|
-
"""
|
110
|
-
Register the starup calls
|
111
|
-
|
112
|
-
If the calls raise any error, the application startup is aborted.
|
113
|
-
"""
|
114
|
-
settings = Inject(get_settings)
|
115
|
-
await _create_first_user(
|
116
|
-
email=settings.FRACTAL_DEFAULT_ADMIN_EMAIL,
|
117
|
-
password=settings.FRACTAL_DEFAULT_ADMIN_PASSWORD,
|
118
|
-
username=settings.FRACTAL_DEFAULT_ADMIN_USERNAME,
|
119
|
-
is_superuser=True,
|
120
|
-
is_verified=True,
|
121
|
-
)
|
122
|
-
await __on_startup()
|
@@ -1,4 +1,4 @@
|
|
1
|
-
fractal_server/__init__.py,sha256=
|
1
|
+
fractal_server/__init__.py,sha256=M-UCl3baEQIODOL7Zae_0jXfPyeyyPZypKzTHK83oM0,22
|
2
2
|
fractal_server/__main__.py,sha256=CocbzZooX1UtGqPi55GcHGNxnrJXFg5tUU5b3wyFCyo,4958
|
3
3
|
fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
|
4
4
|
fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -42,7 +42,7 @@ fractal_server/app/routes/api/v2/images.py,sha256=4r_HblPWyuKSZSJZfn8mbDaLv1ncwZ
|
|
42
42
|
fractal_server/app/routes/api/v2/job.py,sha256=BtaxErBDbLwjY2zgGD1I6eRpsffoMonifcS1CMEXmLU,5325
|
43
43
|
fractal_server/app/routes/api/v2/project.py,sha256=qyvizYZ4aUFgF3tGdfp4z8AwWgfo19N_KbFEljfUaC8,5594
|
44
44
|
fractal_server/app/routes/api/v2/status.py,sha256=osLexiMOSqmYcEV-41tlrwt9ofyFbtRm5HmPS5BU0t4,6394
|
45
|
-
fractal_server/app/routes/api/v2/submit.py,sha256=
|
45
|
+
fractal_server/app/routes/api/v2/submit.py,sha256=mdY1fN9VA8-8DkqeAGrzHa4n37QSPP-gN3sc4z-c-wc,7592
|
46
46
|
fractal_server/app/routes/api/v2/task.py,sha256=bRTtGgL8BBGbT7csVeRB-a54clgU2xHydi5XpcByDxg,8297
|
47
47
|
fractal_server/app/routes/api/v2/task_collection.py,sha256=eN3NkZaZHkrqnLGRKE7Xd5mo0cHc8aK2lojCt26ErOQ,8988
|
48
48
|
fractal_server/app/routes/api/v2/task_legacy.py,sha256=P_VJv9v0yzFUBuS-DQHhMVSOe20ecGJJcFBqiiFciOM,1628
|
@@ -64,12 +64,12 @@ fractal_server/app/runner/executors/slurm/_check_jobs_status.py,sha256=8d29a7DQ2
|
|
64
64
|
fractal_server/app/runner/executors/slurm/_executor_wait_thread.py,sha256=J3tjAx33nBgW4eHAXDte7hDs7Oe9FLEZaElEt8inrbg,4421
|
65
65
|
fractal_server/app/runner/executors/slurm/_slurm_config.py,sha256=rF37XDImX1QoWx37MC5hSM9AuY_KfHU5gaWwN4vl4Zk,15552
|
66
66
|
fractal_server/app/runner/executors/slurm/_subprocess_run_as_user.py,sha256=YwfJzZr_y4FL_hirHJdWK0vWzrldjoZZhXVFlO2AOMU,5131
|
67
|
-
fractal_server/app/runner/executors/slurm/executor.py,sha256=
|
67
|
+
fractal_server/app/runner/executors/slurm/executor.py,sha256=z2MbI9He1lPhKBPMs0pqoQ9wUiAsxOIZY62s5VFHs-0,45044
|
68
68
|
fractal_server/app/runner/executors/slurm/remote.py,sha256=wLziIsGdSMiO-jIXM8x77JRK82g_2hx0iBKTiMghuIo,5852
|
69
69
|
fractal_server/app/runner/filenames.py,sha256=9lwu3yB4C67yiijYw8XIKaLFn3mJUt6_TCyVFM_aZUQ,206
|
70
70
|
fractal_server/app/runner/set_start_and_last_task_index.py,sha256=-q4zVybAj8ek2XlbENKlfOAJ39hT_zoJoZkqzDqiAMY,1254
|
71
71
|
fractal_server/app/runner/task_files.py,sha256=b5aRDi35QemBQnHT_AU6L_IPJJU_k_f5sJn-JXzkzy0,3180
|
72
|
-
fractal_server/app/runner/v1/__init__.py,sha256=
|
72
|
+
fractal_server/app/runner/v1/__init__.py,sha256=kMiQJJ-XUp2ecI0tUAUYD_Em1vcct9iXULMoI5SGdU4,13520
|
73
73
|
fractal_server/app/runner/v1/_common.py,sha256=2-NScI-7qCIw14Od90so1onw-psIt8x1kx6EXq489Vk,21246
|
74
74
|
fractal_server/app/runner/v1/_local/__init__.py,sha256=ZcWftuGRLmN8-S6QZXm6FhNehsxwmwZRhuRv-a7zA6s,6839
|
75
75
|
fractal_server/app/runner/v1/_local/_local_config.py,sha256=hM7SPxR07luXPcXdrWXRpEB2uOyjSSRUdqW3QBKJn9c,3147
|
@@ -120,15 +120,15 @@ fractal_server/app/schemas/v2/task.py,sha256=7IfxiZkaVqlARy7WYE_H8m7j_IEcuQaZORU
|
|
120
120
|
fractal_server/app/schemas/v2/task_collection.py,sha256=sY29NQfJrbjiidmVkVjSIH-20wIsmh7G1QOdr05KoDQ,3171
|
121
121
|
fractal_server/app/schemas/v2/workflow.py,sha256=Zzx3e-qgkH8le0FUmAx9UrV5PWd7bj14PPXUh_zgZXM,1827
|
122
122
|
fractal_server/app/schemas/v2/workflowtask.py,sha256=atVuVN4aXsVEOmSd-vyg-8_8OnPmqx-gT75rXcn_AlQ,6552
|
123
|
-
fractal_server/app/security/__init__.py,sha256=
|
124
|
-
fractal_server/config.py,sha256=
|
123
|
+
fractal_server/app/security/__init__.py,sha256=2-QbwuR-nsuHM_uwKS_WzYvkhnuhO5jUv8UVROetyVk,11169
|
124
|
+
fractal_server/config.py,sha256=7fF_lTGH_mH_16aYr8m3E5Dv81jH9wdJuGu-2p1x9H0,16081
|
125
125
|
fractal_server/data_migrations/README.md,sha256=_3AEFvDg9YkybDqCLlFPdDmGJvr6Tw7HRI14aZ3LOIw,398
|
126
126
|
fractal_server/images/__init__.py,sha256=xO6jTLE4EZKO6cTDdJsBmK9cdeh9hFTaSbSuWgQg7y4,196
|
127
127
|
fractal_server/images/models.py,sha256=9ipU5h4N6ogBChoB-2vHoqtL0TXOHCv6kRR-fER3mkM,4167
|
128
128
|
fractal_server/images/tools.py,sha256=gxeniYy4Z-cp_ToK2LHPJUTVVUUrdpogYdcBUvBuLiY,2209
|
129
129
|
fractal_server/logger/__init__.py,sha256=Q_e03Lj30VWdCqGBJrKw9A2QEeDbCKC_OOkDQVW9Dyw,5132
|
130
130
|
fractal_server/logger/gunicorn_logger.py,sha256=vb5s7mruCHPkKWGrTTOPyrB_658Y2Z05ECdHhCCBhp0,644
|
131
|
-
fractal_server/main.py,sha256=
|
131
|
+
fractal_server/main.py,sha256=faQfINM4k3G7Oakkn8R_EfHLma6Dd-U_TeyWesjs0js,3613
|
132
132
|
fractal_server/migrations/README,sha256=4rQvyDfqodGhpJw74VYijRmgFP49ji5chyEemWGHsuw,59
|
133
133
|
fractal_server/migrations/env.py,sha256=bsl0HGZpjhommztgcs7wQ94sJzI1Orgnij97K8P_uyo,2630
|
134
134
|
fractal_server/migrations/script.py.mako,sha256=oMXw9LC3zRbinWWPPDgeZ4z9FJrV2zhRWiYdS5YgNbI,526
|
@@ -163,8 +163,8 @@ fractal_server/tasks/v2/background_operations.py,sha256=MAMBn6W2bhkdK59kfUGiD7a1
|
|
163
163
|
fractal_server/tasks/v2/get_collection_data.py,sha256=Qhf2T_aaqAfqu9_KpUSlXsS7EJoZQbEPEreHHa2jco8,502
|
164
164
|
fractal_server/urls.py,sha256=5o_qq7PzKKbwq12NHSQZDmDitn5RAOeQ4xufu-2v9Zk,448
|
165
165
|
fractal_server/utils.py,sha256=b7WwFdcFZ8unyT65mloFToYuEDXpQoHRcmRNqrhd_dQ,2115
|
166
|
-
fractal_server-2.0.
|
167
|
-
fractal_server-2.0.
|
168
|
-
fractal_server-2.0.
|
169
|
-
fractal_server-2.0.
|
170
|
-
fractal_server-2.0.
|
166
|
+
fractal_server-2.1.0.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
|
167
|
+
fractal_server-2.1.0.dist-info/METADATA,sha256=kyfeNStKB16vegug3_OV6wxtnxDT1Mo1pqj5HKKXG1w,4222
|
168
|
+
fractal_server-2.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
169
|
+
fractal_server-2.1.0.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
|
170
|
+
fractal_server-2.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|