fractal-server 2.11.1__py3-none-any.whl → 2.12.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.
Files changed (64) hide show
  1. fractal_server/__init__.py +1 -1
  2. fractal_server/app/models/__init__.py +0 -2
  3. fractal_server/app/models/linkuserproject.py +0 -9
  4. fractal_server/app/routes/aux/_job.py +1 -3
  5. fractal_server/app/runner/executors/slurm/ssh/executor.py +9 -6
  6. fractal_server/app/runner/executors/slurm/sudo/executor.py +1 -5
  7. fractal_server/app/runner/filenames.py +0 -2
  8. fractal_server/app/runner/shutdown.py +3 -27
  9. fractal_server/app/schemas/_validators.py +0 -19
  10. fractal_server/config.py +1 -15
  11. fractal_server/main.py +1 -12
  12. fractal_server/migrations/versions/1eac13a26c83_drop_v1_tables.py +67 -0
  13. fractal_server/string_tools.py +0 -21
  14. fractal_server/tasks/utils.py +0 -28
  15. {fractal_server-2.11.1.dist-info → fractal_server-2.12.0.dist-info}/METADATA +1 -1
  16. {fractal_server-2.11.1.dist-info → fractal_server-2.12.0.dist-info}/RECORD +19 -63
  17. fractal_server/app/models/v1/__init__.py +0 -13
  18. fractal_server/app/models/v1/dataset.py +0 -71
  19. fractal_server/app/models/v1/job.py +0 -101
  20. fractal_server/app/models/v1/project.py +0 -29
  21. fractal_server/app/models/v1/state.py +0 -34
  22. fractal_server/app/models/v1/task.py +0 -85
  23. fractal_server/app/models/v1/workflow.py +0 -133
  24. fractal_server/app/routes/admin/v1.py +0 -377
  25. fractal_server/app/routes/api/v1/__init__.py +0 -26
  26. fractal_server/app/routes/api/v1/_aux_functions.py +0 -478
  27. fractal_server/app/routes/api/v1/dataset.py +0 -554
  28. fractal_server/app/routes/api/v1/job.py +0 -195
  29. fractal_server/app/routes/api/v1/project.py +0 -475
  30. fractal_server/app/routes/api/v1/task.py +0 -203
  31. fractal_server/app/routes/api/v1/task_collection.py +0 -239
  32. fractal_server/app/routes/api/v1/workflow.py +0 -355
  33. fractal_server/app/routes/api/v1/workflowtask.py +0 -187
  34. fractal_server/app/runner/async_wrap_v1.py +0 -27
  35. fractal_server/app/runner/v1/__init__.py +0 -415
  36. fractal_server/app/runner/v1/_common.py +0 -620
  37. fractal_server/app/runner/v1/_local/__init__.py +0 -186
  38. fractal_server/app/runner/v1/_local/_local_config.py +0 -105
  39. fractal_server/app/runner/v1/_local/_submit_setup.py +0 -48
  40. fractal_server/app/runner/v1/_local/executor.py +0 -100
  41. fractal_server/app/runner/v1/_slurm/__init__.py +0 -312
  42. fractal_server/app/runner/v1/_slurm/_submit_setup.py +0 -81
  43. fractal_server/app/runner/v1/_slurm/get_slurm_config.py +0 -163
  44. fractal_server/app/runner/v1/common.py +0 -117
  45. fractal_server/app/runner/v1/handle_failed_job.py +0 -141
  46. fractal_server/app/schemas/v1/__init__.py +0 -37
  47. fractal_server/app/schemas/v1/applyworkflow.py +0 -161
  48. fractal_server/app/schemas/v1/dataset.py +0 -165
  49. fractal_server/app/schemas/v1/dumps.py +0 -64
  50. fractal_server/app/schemas/v1/manifest.py +0 -126
  51. fractal_server/app/schemas/v1/project.py +0 -66
  52. fractal_server/app/schemas/v1/state.py +0 -18
  53. fractal_server/app/schemas/v1/task.py +0 -167
  54. fractal_server/app/schemas/v1/task_collection.py +0 -110
  55. fractal_server/app/schemas/v1/workflow.py +0 -212
  56. fractal_server/tasks/v1/_TaskCollectPip.py +0 -103
  57. fractal_server/tasks/v1/__init__.py +0 -0
  58. fractal_server/tasks/v1/background_operations.py +0 -352
  59. fractal_server/tasks/v1/endpoint_operations.py +0 -156
  60. fractal_server/tasks/v1/get_collection_data.py +0 -14
  61. fractal_server/tasks/v1/utils.py +0 -67
  62. {fractal_server-2.11.1.dist-info → fractal_server-2.12.0.dist-info}/LICENSE +0 -0
  63. {fractal_server-2.11.1.dist-info → fractal_server-2.12.0.dist-info}/WHEEL +0 -0
  64. {fractal_server-2.11.1.dist-info → fractal_server-2.12.0.dist-info}/entry_points.txt +0 -0
@@ -1,66 +0,0 @@
1
- from datetime import datetime
2
- from typing import Optional
3
-
4
- from pydantic import BaseModel
5
- from pydantic import validator
6
-
7
- from .._validators import valstr
8
-
9
-
10
- __all__ = (
11
- "ProjectCreateV1",
12
- "ProjectReadV1",
13
- "ProjectUpdateV1",
14
- )
15
-
16
-
17
- class _ProjectBaseV1(BaseModel):
18
- """
19
- Base class for `Project`.
20
-
21
- Attributes:
22
- name:
23
- read_only:
24
- """
25
-
26
- name: str
27
- read_only: bool = False
28
-
29
-
30
- class ProjectCreateV1(_ProjectBaseV1):
31
- """
32
- Class for `Project` creation.
33
- """
34
-
35
- # Validators
36
- _name = validator("name", allow_reuse=True)(valstr("name"))
37
-
38
-
39
- class ProjectReadV1(_ProjectBaseV1):
40
- """
41
- Class for `Project` read from database.
42
-
43
- Attributes:
44
- id:
45
- name:
46
- read_only:
47
- """
48
-
49
- id: int
50
- timestamp_created: datetime
51
-
52
-
53
- class ProjectUpdateV1(_ProjectBaseV1):
54
- """
55
- Class for `Project` update.
56
-
57
- Attributes:
58
- name:
59
- read_only:
60
- """
61
-
62
- name: Optional[str]
63
- read_only: Optional[bool]
64
-
65
- # Validators
66
- _name = validator("name", allow_reuse=True)(valstr("name"))
@@ -1,18 +0,0 @@
1
- from datetime import datetime
2
- from typing import Any
3
- from typing import Optional
4
-
5
- from pydantic import BaseModel
6
-
7
-
8
- class StateRead(BaseModel):
9
- """
10
- Class for `State` read from database.
11
-
12
- Attributes:
13
- id:
14
- """
15
-
16
- id: Optional[int]
17
- data: dict[str, Any]
18
- timestamp: datetime
@@ -1,167 +0,0 @@
1
- from typing import Any
2
- from typing import Optional
3
-
4
- from pydantic import BaseModel
5
- from pydantic import Field
6
- from pydantic import HttpUrl
7
- from pydantic import validator
8
-
9
- from .._validators import valstr
10
-
11
- __all__ = (
12
- "TaskCreateV1",
13
- "TaskUpdateV1",
14
- "TaskReadV1",
15
- "TaskImportV1",
16
- "TaskExportV1",
17
- )
18
-
19
-
20
- class _TaskBaseV1(BaseModel):
21
- """
22
-
23
- Base class for `Task`.
24
-
25
- Attributes:
26
- source:
27
- This is the information is used to match tasks across fractal
28
- installations when a workflow is imported.
29
- """
30
-
31
- source: str
32
- _source = validator("source", allow_reuse=True)(valstr("source"))
33
-
34
-
35
- class TaskUpdateV1(_TaskBaseV1):
36
- """
37
- Class for `Task` update.
38
-
39
- Attributes:
40
- name:
41
- input_type:
42
- output_type:
43
- command:
44
- source:
45
- meta:
46
- version:
47
- args_schema:
48
- args_schema_version:
49
- docs_info:
50
- docs_link:
51
- """
52
-
53
- name: Optional[str]
54
- input_type: Optional[str]
55
- output_type: Optional[str]
56
- command: Optional[str]
57
- source: Optional[str]
58
- meta: Optional[dict[str, Any]]
59
- version: Optional[str]
60
- args_schema: Optional[dict[str, Any]]
61
- args_schema_version: Optional[str]
62
- docs_info: Optional[str]
63
- docs_link: Optional[HttpUrl]
64
-
65
- # Validators
66
- _name = validator("name", allow_reuse=True)(valstr("name"))
67
- _input_type = validator("input_type", allow_reuse=True)(
68
- valstr("input_type")
69
- )
70
- _output_type = validator("output_type", allow_reuse=True)(
71
- valstr("output_type")
72
- )
73
- _command = validator("command", allow_reuse=True)(valstr("command"))
74
- _version = validator("version", allow_reuse=True)(
75
- valstr("version", accept_none=True)
76
- )
77
-
78
-
79
- class TaskImportV1(_TaskBaseV1):
80
- """
81
- Class for `Task` import.
82
- """
83
-
84
- pass
85
-
86
-
87
- class TaskExportV1(_TaskBaseV1):
88
- """
89
- Class for `Task` export.
90
- """
91
-
92
- pass
93
-
94
-
95
- class TaskReadV1(_TaskBaseV1):
96
- """
97
- Class for `Task` read from database.
98
-
99
- Attributes:
100
- id:
101
- name:
102
- command:
103
- input_type:
104
- output_type:
105
- meta:
106
- version:
107
- args_schema:
108
- args_schema_version:
109
- docs_info:
110
- docs_link:
111
- """
112
-
113
- id: int
114
- name: str
115
- command: str
116
- input_type: str
117
- output_type: str
118
- meta: Optional[dict[str, Any]] = Field(default={})
119
- owner: Optional[str]
120
- version: Optional[str]
121
- args_schema: Optional[dict[str, Any]]
122
- args_schema_version: Optional[str]
123
- docs_info: Optional[str]
124
- docs_link: Optional[HttpUrl]
125
-
126
-
127
- class TaskCreateV1(_TaskBaseV1):
128
- """
129
- Class for `Task` creation.
130
-
131
- Attributes:
132
- name:
133
- command:
134
- input_type:
135
- output_type:
136
- meta:
137
- version:
138
- args_schema:
139
- args_schema_version:
140
- docs_info:
141
- docs_link:
142
- """
143
-
144
- name: str
145
- command: str
146
- input_type: str
147
- output_type: str
148
- meta: Optional[dict[str, Any]] = Field(default={})
149
- version: Optional[str]
150
- args_schema: Optional[dict[str, Any]]
151
- args_schema_version: Optional[str]
152
- docs_info: Optional[str]
153
- docs_link: Optional[HttpUrl]
154
-
155
- # Validators
156
- _name = validator("name", allow_reuse=True)(valstr("name"))
157
- _input_type = validator("input_type", allow_reuse=True)(
158
- valstr("input_type")
159
- )
160
- _output_type = validator("output_type", allow_reuse=True)(
161
- valstr("output_type")
162
- )
163
- _command = validator("command", allow_reuse=True)(valstr("command"))
164
- _version = validator("version", allow_reuse=True)(valstr("version"))
165
- _args_schema_version = validator("args_schema_version", allow_reuse=True)(
166
- valstr("args_schema_version")
167
- )
@@ -1,110 +0,0 @@
1
- from pathlib import Path
2
- from typing import Literal
3
- from typing import Optional
4
-
5
- from pydantic import BaseModel
6
- from pydantic import Field
7
- from pydantic import validator
8
-
9
- from .._validators import valstr
10
- from .task import TaskReadV1
11
-
12
- __all__ = (
13
- "TaskCollectPipV1",
14
- "TaskCollectStatusV1",
15
- )
16
-
17
-
18
- class TaskCollectPipV1(BaseModel):
19
- """
20
- TaskCollectPip class
21
-
22
- This class only encodes the attributes required to trigger a
23
- task-collection operation. Other attributes (that are assigned *during*
24
- task collection) are defined as part of fractal-server.
25
-
26
- Two cases are supported:
27
-
28
- 1. `package` is the path of a local wheel file;
29
- 2. `package` is the name of a package that can be installed via `pip`.
30
-
31
-
32
- Attributes:
33
- package:
34
- The name of a `pip`-installable package, or the path to a local
35
- wheel file.
36
- package_version: Version of the package
37
- package_extras: Package extras to include in the `pip install` command
38
- python_version: Python version to install and run the package tasks
39
- pinned_package_versions:
40
- dictionary 'package':'version' used to pin versions for specific
41
- packages.
42
-
43
- """
44
-
45
- package: str
46
- package_version: Optional[str] = None
47
- package_extras: Optional[str] = None
48
- python_version: Optional[str] = None
49
- pinned_package_versions: Optional[dict[str, str]] = None
50
-
51
- _package_extras = validator("package_extras", allow_reuse=True)(
52
- valstr("package_extras")
53
- )
54
- _python_version = validator("python_version", allow_reuse=True)(
55
- valstr("python_version")
56
- )
57
-
58
- @validator("package")
59
- def package_validator(cls, value):
60
- if "/" in value:
61
- if not value.endswith(".whl"):
62
- raise ValueError(
63
- "Local-package path must be a wheel file "
64
- f"(given {value})."
65
- )
66
- if not Path(value).is_absolute():
67
- raise ValueError(
68
- f"Local-package path must be absolute: (given {value})."
69
- )
70
- return value
71
-
72
- @validator("package_version")
73
- def package_version_validator(cls, v, values):
74
-
75
- valstr("package_version")(v)
76
-
77
- if values["package"].endswith(".whl"):
78
- raise ValueError(
79
- "Cannot provide version when package is a Wheel file."
80
- )
81
- return v
82
-
83
-
84
- class TaskCollectStatusV1(BaseModel):
85
- """
86
- TaskCollectStatus class
87
-
88
- Attributes:
89
- status:
90
- package:
91
- venv_path:
92
- task_list:
93
- log:
94
- info:
95
- """
96
-
97
- status: Literal["pending", "installing", "collecting", "fail", "OK"]
98
- package: str
99
- venv_path: Path
100
- task_list: Optional[list[TaskReadV1]] = Field(default=[])
101
- log: Optional[str]
102
- info: Optional[str]
103
-
104
- def sanitised_dict(self):
105
- """
106
- Return `self.dict()` after casting `self.venv_path` to a string
107
- """
108
- d = self.dict()
109
- d["venv_path"] = str(self.venv_path)
110
- return d
@@ -1,212 +0,0 @@
1
- from datetime import datetime
2
- from enum import Enum
3
- from typing import Any
4
- from typing import Optional
5
-
6
- from pydantic import BaseModel
7
- from pydantic import validator
8
-
9
- from .._validators import valint
10
- from .._validators import valstr
11
- from .project import ProjectReadV1
12
- from .task import TaskExportV1
13
- from .task import TaskImportV1
14
- from .task import TaskReadV1
15
-
16
- __all__ = (
17
- "WorkflowCreateV1",
18
- "WorkflowReadV1",
19
- "WorkflowUpdateV1",
20
- "WorkflowImportV1",
21
- "WorkflowExportV1",
22
- "WorkflowTaskCreateV1",
23
- "WorkflowTaskImportV1",
24
- "WorkflowTaskExportV1",
25
- "WorkflowTaskReadV1",
26
- "WorkflowTaskUpdateV1",
27
- "WorkflowTaskStatusTypeV1",
28
- )
29
-
30
-
31
- class _WorkflowTaskBaseV1(BaseModel):
32
- """
33
- Base class for `WorkflowTask`.
34
- """
35
-
36
- meta: Optional[dict[str, Any]] = None
37
- args: Optional[dict[str, Any]] = None
38
-
39
-
40
- class WorkflowTaskCreateV1(_WorkflowTaskBaseV1):
41
- """
42
- Class for `WorkflowTask` creation.
43
-
44
- Attributes:
45
- order:
46
- """
47
-
48
- order: Optional[int]
49
- # Validators
50
- _order = validator("order", allow_reuse=True)(valint("order", min_val=0))
51
-
52
-
53
- class WorkflowTaskReadV1(_WorkflowTaskBaseV1):
54
- """
55
- Class for `WorkflowTask` read from database.
56
-
57
- Attributes:
58
- id:
59
- order:
60
- workflow_id:
61
- task_id:
62
- task:
63
- """
64
-
65
- id: int
66
- order: Optional[int]
67
- workflow_id: int
68
- task_id: int
69
- task: TaskReadV1
70
-
71
-
72
- class WorkflowTaskImportV1(_WorkflowTaskBaseV1):
73
- """
74
- Class for `WorkflowTask` import.
75
-
76
- Attributes:
77
- task:
78
- """
79
-
80
- task: TaskImportV1
81
-
82
-
83
- class WorkflowTaskExportV1(_WorkflowTaskBaseV1):
84
- """
85
- Class for `WorkflowTask` export.
86
-
87
- Attributes:
88
- task:
89
- """
90
-
91
- task: TaskExportV1
92
-
93
-
94
- class WorkflowTaskUpdateV1(_WorkflowTaskBaseV1):
95
- """
96
- Class for `WorkflowTask` update.
97
- """
98
-
99
- # Validators
100
- @validator("meta")
101
- def check_no_parallelisation_level(cls, m):
102
- if "parallelization_level" in m:
103
- raise ValueError(
104
- "Overriding task parallelization level currently not allowed"
105
- )
106
- return m
107
-
108
-
109
- class _WorkflowBaseV1(BaseModel):
110
- """
111
- Base class for `Workflow`.
112
-
113
- Attributes:
114
- name: Workflow name.
115
- """
116
-
117
- name: str
118
-
119
-
120
- class WorkflowReadV1(_WorkflowBaseV1):
121
- """
122
- Task for `Workflow` read from database.
123
-
124
- Attributes:
125
- id:
126
- project_id:
127
- task_list:
128
- project:
129
- """
130
-
131
- id: int
132
- project_id: int
133
- task_list: list[WorkflowTaskReadV1]
134
- project: ProjectReadV1
135
- timestamp_created: datetime
136
-
137
-
138
- class WorkflowCreateV1(_WorkflowBaseV1):
139
- """
140
- Task for `Workflow` creation.
141
- """
142
-
143
- # Validators
144
- _name = validator("name", allow_reuse=True)(valstr("name"))
145
-
146
-
147
- class WorkflowUpdateV1(_WorkflowBaseV1):
148
- """
149
- Task for `Workflow` update.
150
-
151
- Attributes:
152
- name:
153
- reordered_workflowtask_ids:
154
- """
155
-
156
- name: Optional[str]
157
- reordered_workflowtask_ids: Optional[list[int]]
158
-
159
- # Validators
160
- _name = validator("name", allow_reuse=True)(valstr("name"))
161
-
162
- @validator("reordered_workflowtask_ids")
163
- def check_positive_and_unique(cls, value):
164
- if any(i < 0 for i in value):
165
- raise ValueError("Negative `id` in `reordered_workflowtask_ids`")
166
- if len(value) != len(set(value)):
167
- raise ValueError("`reordered_workflowtask_ids` has repetitions")
168
- return value
169
-
170
-
171
- class WorkflowImportV1(_WorkflowBaseV1):
172
- """
173
- Class for `Workflow` import.
174
-
175
- Attributes:
176
- task_list:
177
- """
178
-
179
- task_list: list[WorkflowTaskImportV1]
180
-
181
- # Validators
182
- _name = validator("name", allow_reuse=True)(valstr("name"))
183
-
184
-
185
- class WorkflowExportV1(_WorkflowBaseV1):
186
- """
187
- Class for `Workflow` export.
188
-
189
- Attributes:
190
- task_list:
191
- """
192
-
193
- task_list: list[WorkflowTaskExportV1]
194
-
195
-
196
- class WorkflowTaskStatusTypeV1(str, Enum):
197
- """
198
- Define the available values for the status of a `WorkflowTask`.
199
-
200
- This model is used within the `Dataset.history` attribute, which is
201
- constructed in the runner and then used in the API (e.g. in the
202
- `api/v1/project/{project_id}/dataset/{dataset_id}/status` endpoint).
203
-
204
- Attributes:
205
- SUBMITTED: The `WorkflowTask` is part of a running job.
206
- DONE: The most-recent execution of this `WorkflowTask` was successful.
207
- FAILED: The most-recent execution of this `WorkflowTask` failed.
208
- """
209
-
210
- SUBMITTED = "submitted"
211
- DONE = "done"
212
- FAILED = "failed"
@@ -1,103 +0,0 @@
1
- from pathlib import Path
2
- from typing import Optional
3
-
4
- from pydantic import root_validator
5
-
6
- from fractal_server.app.schemas.v1 import ManifestV1
7
- from fractal_server.app.schemas.v1 import TaskCollectPipV1
8
-
9
-
10
- class _TaskCollectPip(TaskCollectPipV1):
11
- """
12
- Internal TaskCollectPip schema
13
-
14
- Differences with its parent class (`TaskCollectPip`):
15
-
16
- 1. We check if the package corresponds to a path in the filesystem, and
17
- whether it exists (via new validator `check_local_package`, new
18
- method `is_local_package` and new attribute `package_path`).
19
- 2. We include an additional `package_manifest` attribute.
20
- 3. We expose an additional attribute `package_name`, which is filled
21
- during task collection.
22
- """
23
-
24
- package_name: Optional[str] = None
25
- package_path: Optional[Path] = None
26
- package_manifest: Optional[ManifestV1] = None
27
-
28
- @property
29
- def is_local_package(self) -> bool:
30
- return bool(self.package_path)
31
-
32
- @root_validator(pre=True)
33
- def check_local_package(cls, values):
34
- """
35
- Checks if package corresponds to an existing path on the filesystem
36
-
37
- In this case, the user is providing directly a package file, rather
38
- than a remote one from PyPI. We set the `package_path` attribute and
39
- get the actual package name and version from the package file name.
40
- """
41
- if "/" in values["package"]:
42
- package_path = Path(values["package"])
43
- if not package_path.is_absolute():
44
- raise ValueError("Package path must be absolute")
45
- if package_path.exists():
46
- values["package_path"] = package_path
47
- (
48
- values["package"],
49
- values["version"],
50
- *_,
51
- ) = package_path.name.split("-")
52
- else:
53
- raise ValueError(f"Package {package_path} does not exist.")
54
- return values
55
-
56
- @property
57
- def package_source(self) -> str:
58
- """
59
- NOTE: As of PR #1188 in `fractal-server`, the attribute
60
- `self.package_name` is normalized; this means e.g. that `_` is
61
- replaced by `-`. To guarantee backwards compatibility with
62
- `Task.source` attributes created before this change, we still replace
63
- `-` with `_` upon generation of the `source` attribute, in this
64
- method.
65
- """
66
- if not self.package_name or not self.package_version:
67
- raise ValueError(
68
- "Cannot construct `package_source` property with "
69
- f"{self.package_name=} and {self.package_version=}."
70
- )
71
- if self.is_local_package:
72
- collection_type = "pip_local"
73
- else:
74
- collection_type = "pip_remote"
75
-
76
- package_extras = self.package_extras or ""
77
- if self.python_version:
78
- python_version = f"py{self.python_version}"
79
- else:
80
- python_version = ""
81
-
82
- source = ":".join(
83
- (
84
- collection_type,
85
- self.package_name.replace("-", "_"), # see method docstring
86
- self.package_version,
87
- package_extras,
88
- python_version,
89
- )
90
- )
91
- return source
92
-
93
- def check(self):
94
- """
95
- Verify that the package has all attributes that are needed to continue
96
- with task collection
97
- """
98
- if not self.package_name:
99
- raise ValueError("`package_name` attribute is not set")
100
- if not self.package_version:
101
- raise ValueError("`package_version` attribute is not set")
102
- if not self.package_manifest:
103
- raise ValueError("`package_manifest` attribute is not set")
File without changes