fractal-server 2.18.0a5__py3-none-any.whl → 2.18.0a7__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.
@@ -1 +1 @@
1
- __VERSION__ = "2.18.0a5"
1
+ __VERSION__ = "2.18.0a7"
@@ -279,16 +279,6 @@ async def import_dataset(
279
279
  ),
280
280
  )
281
281
 
282
- for image in dataset.images:
283
- if not image.zarr_url.startswith(dataset.zarr_dir):
284
- raise HTTPException(
285
- status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
286
- detail=(
287
- f"Cannot import dataset: zarr_url {image.zarr_url} is not "
288
- f"relative to zarr_dir={dataset.zarr_dir}."
289
- ),
290
- )
291
-
292
282
  # Create new Dataset
293
283
  db_dataset = DatasetV2(
294
284
  project_id=project_id,
@@ -1,4 +1,5 @@
1
1
  from datetime import datetime
2
+ from pathlib import Path
2
3
 
3
4
  from pydantic import BaseModel
4
5
  from pydantic import ConfigDict
@@ -100,6 +101,15 @@ class DatasetImport(BaseModel):
100
101
  zarr_dir: ZarrDirStr
101
102
  images: list[SingleImage] = Field(default_factory=list)
102
103
 
104
+ @model_validator(mode="after")
105
+ def validate_image_zarr_url(self):
106
+ for image in self.images:
107
+ if not Path(image.zarr_url).is_relative_to(self.zarr_dir):
108
+ raise ValueError(
109
+ f"{image.zarr_url=} is not relative to {self.zarr_dir=}."
110
+ )
111
+ return self
112
+
103
113
 
104
114
  class DatasetExport(BaseModel):
105
115
  """
@@ -5,7 +5,6 @@ from fractal_server.types import DictStrAny
5
5
  from fractal_server.types import ImageAttributes
6
6
  from fractal_server.types import ImageAttributesWithNone
7
7
  from fractal_server.types import ImageTypes
8
- from fractal_server.types import ZarrDirStr
9
8
  from fractal_server.types import ZarrUrlStr
10
9
 
11
10
 
@@ -21,7 +20,7 @@ class SingleImageBase(BaseModel):
21
20
  """
22
21
 
23
22
  zarr_url: ZarrUrlStr
24
- origin: ZarrDirStr | None = None
23
+ origin: ZarrUrlStr | None = None
25
24
 
26
25
  attributes: DictStrAny = Field(default_factory=dict)
27
26
  types: ImageTypes = Field(default_factory=dict)
fractal_server/main.py CHANGED
@@ -135,14 +135,25 @@ async def lifespan(app: FastAPI):
135
135
  slow_response_logger = set_logger("slow-response")
136
136
 
137
137
 
138
+ def _endpoint_has_background_task(method: str, path: str) -> bool:
139
+ has_background_task = (method == "POST") and (
140
+ "/job/submit/" in path
141
+ or "/task/collect/pi" in path # "/pip" and "/pixi"
142
+ or "/task-group/" in path
143
+ )
144
+ return has_background_task
145
+
146
+
138
147
  class SlowResponseMiddleware:
139
148
  def __init__(self, app: FastAPI, time_threshold: float):
140
149
  self.app = app
141
150
  self.time_threshold = time_threshold
142
151
 
143
152
  async def __call__(self, scope: Scope, receive: Receive, send: Send):
144
- # Filter out any non-http scope (e.g. `type="lifespan"`)
145
- if scope["type"] != "http":
153
+ if (
154
+ scope["type"] != "http" # e.g. `scope["type"] == "lifespan"`
155
+ or _endpoint_has_background_task(scope["method"], scope["path"])
156
+ ):
146
157
  await self.app(scope, receive, send)
147
158
  return
148
159
 
@@ -34,6 +34,10 @@ class SlurmConfigSet(BaseModel):
34
34
  account:
35
35
  extra_lines:
36
36
  gpus:
37
+ sleep_after_srun:
38
+ Add a `sleep` command in the SLURM submission script, after the
39
+ `srun .. &` lines, and before the `wait` one. This may mitigate
40
+ an issue observed on SLURM 25.05.4.
37
41
  """
38
42
 
39
43
  model_config = ConfigDict(extra="forbid")
@@ -49,6 +53,7 @@ class SlurmConfigSet(BaseModel):
49
53
  account: NonEmptyStr | None = None
50
54
  extra_lines: list[NonEmptyStr] = Field(default_factory=list)
51
55
  gpus: NonEmptyStr | None = None
56
+ sleep_after_srun: int = 0
52
57
 
53
58
 
54
59
  class BatchingConfigSet(BaseModel):
@@ -396,6 +396,8 @@ class BaseSlurmRunner(BaseRunner):
396
396
  f"--mem={mem_per_task_MB}MB "
397
397
  f"{cmd} &"
398
398
  )
399
+ if slurm_config.sleep_after_srun > 0:
400
+ script_lines.append(f"sleep {slurm_config.sleep_after_srun}\n")
399
401
  script_lines.append("wait\n\n")
400
402
  script_lines.append('echo "End time: $(date +"%Y-%m-%dT%H:%M:%S%z")"')
401
403
  script = "\n".join(script_lines)
@@ -60,6 +60,10 @@ class SlurmConfig(BaseModel):
60
60
  Key-value pairs to be included as `export`-ed variables in SLURM
61
61
  submission script, after prepending values with the user's cache
62
62
  directory.
63
+ sleep_after_srun:
64
+ Add a `sleep` command in the SLURM submission script, after the
65
+ `srun .. &` lines, and before the `wait` one. This may mitigate
66
+ an issue observed on SLURM 25.05.4.
63
67
  """
64
68
 
65
69
  model_config = ConfigDict(extra="forbid")
@@ -99,6 +103,8 @@ class SlurmConfig(BaseModel):
99
103
  target_num_jobs: int
100
104
  max_num_jobs: int
101
105
 
106
+ sleep_after_srun: int = 0
107
+
102
108
  def _sorted_extra_lines(self) -> list[str]:
103
109
  """
104
110
  Return a copy of `self.extra_lines`, where lines starting with
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fractal-server
3
- Version: 2.18.0a5
3
+ Version: 2.18.0a7
4
4
  Summary: Backend component of the Fractal analytics platform
5
5
  License-Expression: BSD-3-Clause
6
6
  License-File: LICENSE
@@ -1,4 +1,4 @@
1
- fractal_server/__init__.py,sha256=JtUJqLV8j7pkQCJbYQv055n1eaT2cMBaPTLFzh3MTnU,25
1
+ fractal_server/__init__.py,sha256=DuwF9p41_x2O2lnB3pphTsGrOZmbrzmtU02F_hsYOHo,25
2
2
  fractal_server/__main__.py,sha256=QeKoAgqoiozLJDa8kSVe-Aso1WWgrk1yLUYWS8RxZVM,11405
3
3
  fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
4
4
  fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -41,7 +41,7 @@ fractal_server/app/routes/api/v2/_aux_functions_task_lifecycle.py,sha256=qTJdKC3
41
41
  fractal_server/app/routes/api/v2/_aux_functions_task_version_update.py,sha256=PKjV7r8YsPRXoNiVSnOK4KBYVV3l_Yb_ZPrqAkMkXrQ,1182
42
42
  fractal_server/app/routes/api/v2/_aux_functions_tasks.py,sha256=Hrumknv0vH5VX7SFp8WZDzsJv_z7quvFyNoDYmYoD7A,13623
43
43
  fractal_server/app/routes/api/v2/_aux_task_group_disambiguation.py,sha256=vdvMTa3San1HMTzctN5Vk7zxpqe4ccByrFBQyHfgWW8,4889
44
- fractal_server/app/routes/api/v2/dataset.py,sha256=mM5jH9Ta06mHvgPfKl76kRwzd7e3_HO1lQ8PJkFwEqQ,8911
44
+ fractal_server/app/routes/api/v2/dataset.py,sha256=HZGJezPqzbU1PYlFZfQSOj-ONmhtitCv6I7SDORGiPg,8515
45
45
  fractal_server/app/routes/api/v2/history.py,sha256=5IYb6m6vmXjNU7uatEmgdXhehyKdbK98T5wAjQpNH4g,18266
46
46
  fractal_server/app/routes/api/v2/images.py,sha256=k9wd44iwjCtEWSH9j6X6zToBwuOOo6J4FxSW7AGbPHA,8266
47
47
  fractal_server/app/routes/api/v2/job.py,sha256=05_uzX11wYWpGZLN159-7CFXGB9gnSDYdeLEvDAefpY,7250
@@ -80,7 +80,7 @@ fractal_server/app/schemas/user.py,sha256=qixLVZWeANxX5TIWoruLjYE_oh4DMZ2q3vMgMB
80
80
  fractal_server/app/schemas/user_group.py,sha256=irel29GbffKCXNcyrAYbNSN3pCgmoUQ1wG32_s6jvos,1082
81
81
  fractal_server/app/schemas/v2/__init__.py,sha256=6W1uSthuLGXs9oOYnjmScoqJYkWyUTT-9cNHFZoTmkM,4005
82
82
  fractal_server/app/schemas/v2/accounting.py,sha256=6EVUdPTkFY6Wb9-Vc0cIEZYVXwGEvJ3tP4YOXYE1hao,546
83
- fractal_server/app/schemas/v2/dataset.py,sha256=T1FkA66qvASds0DBWyxnc0rlmu7xS3qlsUzdhwTp-ag,2381
83
+ fractal_server/app/schemas/v2/dataset.py,sha256=SBS3TwHxPRHtLvFu-Bm4eQlI96DIkCiFF7oKvfcfTOc,2736
84
84
  fractal_server/app/schemas/v2/dumps.py,sha256=UPtb1Rqkd48AFpWsVfcHcAjKGzF2ZoHLdYrAJzPdsSM,2276
85
85
  fractal_server/app/schemas/v2/history.py,sha256=pZiMKfh6nMWbTp5MUtrnGySPKbeRFf5tM1VLFaTgGcw,1784
86
86
  fractal_server/app/schemas/v2/job.py,sha256=YnnxnrbI_l7EgZNzk_KgnuEuh0COg-RPoph2foHUvZo,3308
@@ -111,11 +111,11 @@ fractal_server/data_migrations/tools.py,sha256=LeMeASwYGtEqd-3wOLle6WARdTGAimoyM
111
111
  fractal_server/exceptions.py,sha256=l6aZDk_6u_9PwDaQSoIFdI40ekpzqOJaxjx5rhW-HVI,141
112
112
  fractal_server/gunicorn_fractal.py,sha256=u6U01TLGlXgq1v8QmEpLih3QnsInZD7CqphgJ_GrGzc,1230
113
113
  fractal_server/images/__init__.py,sha256=-_wjoKtSX02P1KjDxDP_EXKvmbONTRmbf7iGVTsyBpM,154
114
- fractal_server/images/models.py,sha256=dNcCW7XzRRbqL86LJ5aGc6LUAqIPsZXMq67IZyGbIpQ,1242
114
+ fractal_server/images/models.py,sha256=5wtUmX3hRy8vyOb4SgezuIWcwUaB69HyXHg4zFMJkvk,1198
115
115
  fractal_server/images/status_tools.py,sha256=Is2QWThbLCrVJuI0NpGv7TcWs1T8z8q_8Qsidr3TdBU,4932
116
116
  fractal_server/images/tools.py,sha256=37jVIU6RiAGbiyucNDlKe9J3yN3Y47NOvv-RJor9Jm0,4154
117
117
  fractal_server/logger.py,sha256=9EhRdgPnGdbJ51vxhOD42K0iaDRhKx7wuikpHoh9kzY,5302
118
- fractal_server/main.py,sha256=ksCV8BCyxQnvF26IYSzwQFZNo74J4cBNkNzqgq6mdeE,6181
118
+ fractal_server/main.py,sha256=vCDvUndmLIkxUX8EAtyA4Wu9YiIHGZge5J37Yn2U5R4,6537
119
119
  fractal_server/migrations/env.py,sha256=nfyBpMIOT3kny6t-b-tUjyRjZ4k906bb1_wCQ7me1BI,1353
120
120
  fractal_server/migrations/naming_convention.py,sha256=bSEMiMZeArmWKrUk-12lhnOw1pAFMg6LEl7yucohPqc,263
121
121
  fractal_server/migrations/versions/034a469ec2eb_task_groups.py,sha256=uuf0sJibC4Am1HDb_dX_Jdj2oinptlg2ojiHwCpjDCY,6155
@@ -177,7 +177,7 @@ fractal_server/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
177
177
  fractal_server/runner/components.py,sha256=-Ii5l8d_V6f5DFOd-Zsr8VYmOsyqw0Hox9fEFQiuqxY,66
178
178
  fractal_server/runner/config/__init__.py,sha256=a-vSrvWBeMVnxTtYoy-f5Ibt_mM8MM3F7jqnPvvjHSY,108
179
179
  fractal_server/runner/config/_local.py,sha256=IHWtxpKuJDdsQNpk8Q5bNL4DEJunNkNJkLfetfnwmQM,788
180
- fractal_server/runner/config/_slurm.py,sha256=iC4gBolGaYD8SX5FMZu7mq9xI6-kepzeZ6bETrFf0pg,3636
180
+ fractal_server/runner/config/_slurm.py,sha256=FtWQi74e_9nolpKF07zMsOr3R1_yZKqNhC_cIo9MTUk,3892
181
181
  fractal_server/runner/config/slurm_mem_to_MB.py,sha256=6KmrIC-NymQjb9-bIQjNYQx6mE0OoKoZxdi6WQnWOHw,2003
182
182
  fractal_server/runner/exceptions.py,sha256=N8DLn7tuV8zMSdr8xdJN0aIdytPveSCeQ1Y5IoxXW-8,1778
183
183
  fractal_server/runner/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -189,10 +189,10 @@ fractal_server/runner/executors/local/runner.py,sha256=0s0u5ONasXdsvS2WD5zxksQgv
189
189
  fractal_server/runner/executors/slurm_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
190
190
  fractal_server/runner/executors/slurm_common/_batching.py,sha256=YQjWRTDI1e6NeLe1R-1QWlt49i42M9ILeExEjdjgy48,8348
191
191
  fractal_server/runner/executors/slurm_common/_job_states.py,sha256=nuV-Zba38kDrRESOVB3gaGbrSPZc4q7YGichQaeqTW0,238
192
- fractal_server/runner/executors/slurm_common/base_slurm_runner.py,sha256=pU2Szcg3tv7vinLJXbzSgYlfEPLY_b0R0YDR-FSYLc8,41873
192
+ fractal_server/runner/executors/slurm_common/base_slurm_runner.py,sha256=vHm5wjZ-VkRUuVIhbrpUJqtpxOZDlFHwTT0OmTv3CAw,41995
193
193
  fractal_server/runner/executors/slurm_common/get_slurm_config.py,sha256=B6EKjob8Y-DiJ8YbXf2CeoY7B8cwvkpKvlW8Ce6bbx0,7115
194
194
  fractal_server/runner/executors/slurm_common/remote.py,sha256=8pTMTRp_LjzoUr3FtFTfdvDhuLnqzY6HT-T9pzrVLw4,3845
195
- fractal_server/runner/executors/slurm_common/slurm_config.py,sha256=VSow-JfxBkdmkMnTBeZ01nnMXXtlqV8ysaSYcdE-_PU,7896
195
+ fractal_server/runner/executors/slurm_common/slurm_config.py,sha256=rF-9Q1gWDBqtNbs9hji6oTvIQ2uV36FqCc04DdAqtHA,8153
196
196
  fractal_server/runner/executors/slurm_common/slurm_job_task_models.py,sha256=VeX40CvU5fckUpSyXlzb3EDE9xxPXkT2sZKLXq_6Ooc,3493
197
197
  fractal_server/runner/executors/slurm_ssh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
198
198
  fractal_server/runner/executors/slurm_ssh/run_subprocess.py,sha256=SyW6t4egvbiARph2YkFjc88Hj94fCamZVi50L7ph8VM,996
@@ -268,8 +268,8 @@ fractal_server/types/validators/_workflow_task_arguments_validators.py,sha256=zt
268
268
  fractal_server/urls.py,sha256=QjIKAC1a46bCdiPMu3AlpgFbcv6a4l3ABcd5xz190Og,471
269
269
  fractal_server/utils.py,sha256=-rjg8QTXQcKweXjn0NcmETFs1_uM9PGnbl0Q7c4ERPM,2181
270
270
  fractal_server/zip_tools.py,sha256=Uhn-ax4_9g1PJ32BdyaX30hFpAeVOv2tZYTUK-zVn1E,5719
271
- fractal_server-2.18.0a5.dist-info/METADATA,sha256=ifDV_PyTlPG8dTwRyUcr7fHpCcDvCEFlGUlCMujQB2s,4277
272
- fractal_server-2.18.0a5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
273
- fractal_server-2.18.0a5.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
274
- fractal_server-2.18.0a5.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
275
- fractal_server-2.18.0a5.dist-info/RECORD,,
271
+ fractal_server-2.18.0a7.dist-info/METADATA,sha256=8gfu8aos4ki_fVT2imS8dopTKPdsTnGzSQa0ah-kU1o,4277
272
+ fractal_server-2.18.0a7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
273
+ fractal_server-2.18.0a7.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
274
+ fractal_server-2.18.0a7.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
275
+ fractal_server-2.18.0a7.dist-info/RECORD,,