fractal-server 2.18.0a5__py3-none-any.whl → 2.18.0a6__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.0a6"
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fractal-server
3
- Version: 2.18.0a5
3
+ Version: 2.18.0a6
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=fTObeLfpNEyrq6zP1iDNcN07ZgPGhNMwYCYjIVQ95yM,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
@@ -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.0a6.dist-info/METADATA,sha256=CFbDxw_nb6xWkqHVoeDf8A1T6Q2bfysDIg9xclaIJiI,4277
272
+ fractal_server-2.18.0a6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
273
+ fractal_server-2.18.0a6.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
274
+ fractal_server-2.18.0a6.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
275
+ fractal_server-2.18.0a6.dist-info/RECORD,,