fractal-server 2.17.0a0__py3-none-any.whl → 2.17.0a1__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.17.0a0"
1
+ __VERSION__ = "2.17.0a1"
@@ -136,8 +136,8 @@ def init_db_data(
136
136
  from sqlalchemy import select, func
137
137
  from fractal_server.app.models.security import UserOAuth
138
138
  from fractal_server.app.models import Resource, Profile
139
- from fractal_server.app.schemas.v2.resource import validate_resource_data
140
- from fractal_server.app.schemas.v2.profile import validate_profile_data
139
+ from fractal_server.app.schemas.v2.resource import cast_serialize_resource
140
+ from fractal_server.app.schemas.v2.profile import cast_serialize_profile
141
141
 
142
142
  init_data_settings = Inject(get_init_data_settings)
143
143
 
@@ -203,15 +203,17 @@ def init_db_data(
203
203
 
204
204
  # Validate resource/profile data
205
205
  try:
206
- validate_resource_data(resource_data)
206
+ resource_data = cast_serialize_resource(resource_data)
207
207
  except ValidationError as e:
208
- print(e)
209
- sys.exit("ERROR: Invalid resource data.")
208
+ sys.exit(
209
+ f"ERROR: Invalid resource data.\nOriginal error:\n{str(e)}"
210
+ )
210
211
  try:
211
- validate_profile_data(profile_data)
212
+ profile_data = cast_serialize_profile(profile_data)
212
213
  except ValidationError as e:
213
- print(e)
214
- sys.exit("ERROR: Invalid profile data.")
214
+ sys.exit(
215
+ f"ERROR: Invalid profile data.\nOriginal error:\n{str(e)}"
216
+ )
215
217
 
216
218
  # Create resource/profile db objects
217
219
  resource_obj = Resource(**resource_data)
@@ -6,8 +6,8 @@ from fractal_server.app.db import AsyncSession
6
6
  from fractal_server.app.models import Profile
7
7
  from fractal_server.app.models import Resource
8
8
  from fractal_server.app.models import UserOAuth
9
- from fractal_server.app.schemas.v2.profile import validate_profile_data
10
- from fractal_server.app.schemas.v2.resource import validate_resource_data
9
+ from fractal_server.app.schemas.v2.profile import cast_serialize_profile
10
+ from fractal_server.app.schemas.v2.resource import cast_serialize_resource
11
11
  from fractal_server.logger import set_logger
12
12
 
13
13
  logger = set_logger(__name__)
@@ -38,10 +38,10 @@ async def validate_user_profile(
38
38
  profile = await db.get(Profile, user.profile_id)
39
39
  resource = await db.get(Resource, profile.resource_id)
40
40
  try:
41
- validate_resource_data(
41
+ cast_serialize_resource(
42
42
  resource.model_dump(exclude={"id", "timestamp_created"}),
43
43
  )
44
- validate_profile_data(
44
+ cast_serialize_profile(
45
45
  profile.model_dump(exclude={"resource_id", "id"}),
46
46
  )
47
47
  db.expunge(resource)
@@ -65,8 +65,14 @@ class ProfileRead(BaseModel):
65
65
 
66
66
 
67
67
  @validate_call
68
- def validate_profile_data(_data: ProfileCreate):
68
+ def cast_serialize_profile(_data: ProfileCreate) -> dict[str, Any]:
69
69
  """
70
- We use `@validate_call` because `ProfileCreate` is a `Union` type and it
70
+ Cast/serialize round-trip for `Profile` data.
71
+
72
+ We use `@validate_call` because `ProfileeCreate` is a `Union` type and it
71
73
  cannot be instantiated directly.
74
+
75
+ Return:
76
+ Serialized version of a valid profile object.
72
77
  """
78
+ return _data.model_dump()
@@ -4,6 +4,7 @@ from typing import Any
4
4
  from typing import Literal
5
5
  from typing import Self
6
6
 
7
+ from pydantic import AfterValidator
7
8
  from pydantic import BaseModel
8
9
  from pydantic import Discriminator
9
10
  from pydantic import model_validator
@@ -25,13 +26,27 @@ class ResourceType(StrEnum):
25
26
  LOCAL = "local"
26
27
 
27
28
 
29
+ def cast_serialize_pixi_settings(
30
+ v: dict[NonEmptyStr, Any],
31
+ ) -> dict[NonEmptyStr, Any]:
32
+ """
33
+ Validate current value, and enrich it with default values.
34
+ """
35
+ if v != {}:
36
+ v = TasksPixiSettings(**v).model_dump()
37
+ return v
38
+
39
+
28
40
  class _ValidResourceBase(BaseModel):
29
41
  type: ResourceType
30
42
  name: NonEmptyStr
31
43
 
32
44
  # Tasks
33
45
  tasks_python_config: TasksPythonSettings
34
- tasks_pixi_config: dict[NonEmptyStr, Any]
46
+ tasks_pixi_config: Annotated[
47
+ dict[NonEmptyStr, Any],
48
+ AfterValidator(cast_serialize_pixi_settings),
49
+ ]
35
50
  tasks_local_dir: AbsolutePathStr
36
51
 
37
52
  # Jobs
@@ -40,16 +55,15 @@ class _ValidResourceBase(BaseModel):
40
55
  jobs_poll_interval: int = 5
41
56
 
42
57
  @model_validator(mode="after")
43
- def _tasks_configurations(self) -> Self:
44
- if self.tasks_pixi_config != {}:
45
- pixi_settings = TasksPixiSettings(**self.tasks_pixi_config)
46
- if (
47
- self.type == ResourceType.SLURM_SSH
48
- and pixi_settings.SLURM_CONFIG is None
49
- ):
50
- raise ValueError(
51
- "`tasks_pixi_config` must include `SLURM_CONFIG`."
52
- )
58
+ def _pixi_slurm_config(self) -> Self:
59
+ if (
60
+ self.tasks_pixi_config != {}
61
+ and self.type == ResourceType.SLURM_SSH
62
+ and self.tasks_pixi_config["SLURM_CONFIG"] is None
63
+ ):
64
+ raise ValueError(
65
+ "`tasks_pixi_config` must include `SLURM_CONFIG`."
66
+ )
53
67
  return self
54
68
 
55
69
 
@@ -110,8 +124,14 @@ class ResourceRead(BaseModel):
110
124
 
111
125
 
112
126
  @validate_call
113
- def validate_resource_data(_data: ResourceCreate):
127
+ def cast_serialize_resource(_data: ResourceCreate) -> dict[str, Any]:
114
128
  """
129
+ Cast/serialize round-trip for `Resource` data.
130
+
115
131
  We use `@validate_call` because `ResourceCreate` is a `Union` type and it
116
132
  cannot be instantiated directly.
133
+
134
+ Return:
135
+ Serialized version of a valid resource object.
117
136
  """
137
+ return _data.model_dump()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fractal-server
3
- Version: 2.17.0a0
3
+ Version: 2.17.0a1
4
4
  Summary: Backend component of the Fractal analytics platform
5
5
  License-Expression: BSD-3-Clause
6
6
  License-File: LICENSE
@@ -1,5 +1,5 @@
1
- fractal_server/__init__.py,sha256=BGNq25uSJ4SBW9OccisNa2dOpWFs57JqU2JTIjfsO7U,25
2
- fractal_server/__main__.py,sha256=wXTddT2OrcCOcGuIPLXEX6PFYqSbWFLpRUxy8PUDaGo,10668
1
+ fractal_server/__init__.py,sha256=L3Rv58fODvev5pxb4-ztERQa1un75OhiJ3K21aCCoW0,25
2
+ fractal_server/__main__.py,sha256=UubAVie8iODHu1jj3brTFVqzsEZrL070LjnE3XacpF0,10777
3
3
  fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
4
4
  fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  fractal_server/app/db/__init__.py,sha256=sttX0mHVV0ESI1SJ1kcxUKiuEwqeP-BWsst0o_9Yo44,2810
@@ -71,7 +71,7 @@ fractal_server/app/routes/auth/users.py,sha256=tYttZjyrsTLiOb5PZyMiAo4DD2ZEuPhPp
71
71
  fractal_server/app/routes/aux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  fractal_server/app/routes/aux/_job.py,sha256=nqqdcW5B7fL_PbvHf57_TcifjUfcMgl04tKNvG2sV1U,628
73
73
  fractal_server/app/routes/aux/_runner.py,sha256=SDzI7glEfkW_XecWFuRQitbSWSvAPegI-J5c7i5d0_w,957
74
- fractal_server/app/routes/aux/validate_user_profile.py,sha256=3kJeA9iJ8c7_7H27QXYSx3gY15rc13q7JAfY-KcqVEo,1965
74
+ fractal_server/app/routes/aux/validate_user_profile.py,sha256=fGqJDdAFkbQoEIjqZ5F9-SDY_4os63R2EUMqODC7eBg,1969
75
75
  fractal_server/app/routes/aux/validate_user_settings.py,sha256=C_V5QhnBppyr-YYoni_yVrooU5bKfSTrwM-ea2m5pqU,2405
76
76
  fractal_server/app/routes/pagination.py,sha256=IGy8Ll5lYr6ENYE18h3huH5s0GMX1DCs5VdCi6j1cdk,1174
77
77
  fractal_server/app/schemas/__init__.py,sha256=stURAU_t3AOBaH0HSUbV-GKhlPKngnnIMoqWc3orFyI,135
@@ -85,9 +85,9 @@ fractal_server/app/schemas/v2/dumps.py,sha256=LCYiNF_FNYiA6HYp5GyFao3IKRX0RpzgNp
85
85
  fractal_server/app/schemas/v2/history.py,sha256=pZiMKfh6nMWbTp5MUtrnGySPKbeRFf5tM1VLFaTgGcw,1784
86
86
  fractal_server/app/schemas/v2/job.py,sha256=BuiNzAX2Kl-b7LJnAiqCGDC9h6bGEjKvsHQIgf5mjHQ,3330
87
87
  fractal_server/app/schemas/v2/manifest.py,sha256=QUpXMDB8WkB1F4UK-yYmm3O8bXoHwDGURnqwn6ayO_I,6674
88
- fractal_server/app/schemas/v2/profile.py,sha256=_cDT5t4fdbmZnPGWT7Ej5HaOeOAN9lvLetnY0OjvADI,1914
88
+ fractal_server/app/schemas/v2/profile.py,sha256=tqjG3kgoBsNl0It0icZQ0mIab2POmV_K8fsL21-WR8U,2082
89
89
  fractal_server/app/schemas/v2/project.py,sha256=7UC0aZLgtmkaAiPykeUj-9OZXhMkoyi3V-475UW_EQs,654
90
- fractal_server/app/schemas/v2/resource.py,sha256=p2ePDYVTGPBs_wV-jBvK-9J19hL7u9cUS0NssBf01Js,3268
90
+ fractal_server/app/schemas/v2/resource.py,sha256=4iXzZJeHVLcXYY08-okoJM_4gqpzhG4KglRPBm24Jwc,3718
91
91
  fractal_server/app/schemas/v2/status_legacy.py,sha256=eQT1zGxbkzSwd0EqclsOdZ60n1x6J3DB1CZ3m4LYyxc,955
92
92
  fractal_server/app/schemas/v2/task.py,sha256=IJv8loB4kx9FBkaIHoiMsswQyq02FxvyAnHK1u074fU,4364
93
93
  fractal_server/app/schemas/v2/task_collection.py,sha256=BzHQXq2_zLZTbigWauOR5Zi-mlsqCIF2NEF_z12Nqxg,4480
@@ -258,8 +258,8 @@ fractal_server/types/validators/_workflow_task_arguments_validators.py,sha256=HL
258
258
  fractal_server/urls.py,sha256=QjIKAC1a46bCdiPMu3AlpgFbcv6a4l3ABcd5xz190Og,471
259
259
  fractal_server/utils.py,sha256=SYVVUuXe_nWyrJLsy7QA-KJscwc5PHEXjvsW4TK7XQI,2180
260
260
  fractal_server/zip_tools.py,sha256=H0w7wS5yE4ebj7hw1_77YQ959dl2c-L0WX6J_ro1TY4,4884
261
- fractal_server-2.17.0a0.dist-info/METADATA,sha256=z6kUGelCWLPqV7DwG3I11F2k7kUWxmA4wQBrLJB3M70,4319
262
- fractal_server-2.17.0a0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
263
- fractal_server-2.17.0a0.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
264
- fractal_server-2.17.0a0.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
265
- fractal_server-2.17.0a0.dist-info/RECORD,,
261
+ fractal_server-2.17.0a1.dist-info/METADATA,sha256=wjRm3y1357YAUgiA9dHf3G-T4FE4gzoqEiHMkmnO9TM,4319
262
+ fractal_server-2.17.0a1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
263
+ fractal_server-2.17.0a1.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
264
+ fractal_server-2.17.0a1.dist-info/licenses/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
265
+ fractal_server-2.17.0a1.dist-info/RECORD,,