fractal-server 2.7.0a2__py3-none-any.whl → 2.7.0a4__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 (49) hide show
  1. fractal_server/__init__.py +1 -1
  2. fractal_server/__main__.py +3 -9
  3. fractal_server/app/models/v2/collection_state.py +1 -0
  4. fractal_server/app/models/v2/task.py +27 -3
  5. fractal_server/app/routes/admin/v2/task.py +5 -13
  6. fractal_server/app/routes/admin/v2/task_group.py +21 -0
  7. fractal_server/app/routes/api/v1/task_collection.py +2 -2
  8. fractal_server/app/routes/api/v2/_aux_functions_tasks.py +75 -2
  9. fractal_server/app/routes/api/v2/task.py +16 -42
  10. fractal_server/app/routes/api/v2/task_collection.py +148 -187
  11. fractal_server/app/routes/api/v2/task_collection_custom.py +31 -58
  12. fractal_server/app/routes/api/v2/task_group.py +25 -1
  13. fractal_server/app/routes/api/v2/workflow.py +18 -34
  14. fractal_server/app/routes/auth/_aux_auth.py +15 -12
  15. fractal_server/app/routes/auth/group.py +46 -23
  16. fractal_server/app/runner/v2/task_interface.py +4 -9
  17. fractal_server/app/schemas/v2/dataset.py +2 -7
  18. fractal_server/app/schemas/v2/dumps.py +1 -1
  19. fractal_server/app/schemas/v2/job.py +1 -1
  20. fractal_server/app/schemas/v2/project.py +1 -1
  21. fractal_server/app/schemas/v2/task.py +5 -5
  22. fractal_server/app/schemas/v2/task_collection.py +8 -6
  23. fractal_server/app/schemas/v2/task_group.py +31 -3
  24. fractal_server/app/schemas/v2/workflow.py +2 -2
  25. fractal_server/app/schemas/v2/workflowtask.py +2 -2
  26. fractal_server/data_migrations/2_7_0.py +1 -11
  27. fractal_server/images/models.py +2 -4
  28. fractal_server/main.py +1 -1
  29. fractal_server/migrations/versions/034a469ec2eb_task_groups.py +184 -0
  30. fractal_server/string_tools.py +6 -2
  31. fractal_server/tasks/v1/_TaskCollectPip.py +1 -1
  32. fractal_server/tasks/v1/background_operations.py +2 -2
  33. fractal_server/tasks/v2/_venv_pip.py +62 -70
  34. fractal_server/tasks/v2/background_operations.py +168 -49
  35. fractal_server/tasks/v2/background_operations_ssh.py +35 -77
  36. fractal_server/tasks/v2/database_operations.py +7 -17
  37. fractal_server/tasks/v2/endpoint_operations.py +0 -134
  38. fractal_server/tasks/v2/templates/_1_create_venv.sh +9 -5
  39. fractal_server/tasks/v2/utils.py +5 -0
  40. fractal_server/utils.py +3 -2
  41. {fractal_server-2.7.0a2.dist-info → fractal_server-2.7.0a4.dist-info}/METADATA +1 -1
  42. {fractal_server-2.7.0a2.dist-info → fractal_server-2.7.0a4.dist-info}/RECORD +45 -48
  43. fractal_server/migrations/versions/742b74e1cc6e_revamp_taskv2_and_taskgroupv2.py +0 -101
  44. fractal_server/migrations/versions/7cf1baae8fb4_task_group_v2.py +0 -66
  45. fractal_server/migrations/versions/df7cc3501bf7_linkusergroup_timestamp_created.py +0 -42
  46. fractal_server/tasks/v2/_TaskCollectPip.py +0 -132
  47. {fractal_server-2.7.0a2.dist-info → fractal_server-2.7.0a4.dist-info}/LICENSE +0 -0
  48. {fractal_server-2.7.0a2.dist-info → fractal_server-2.7.0a4.dist-info}/WHEEL +0 -0
  49. {fractal_server-2.7.0a2.dist-info → fractal_server-2.7.0a4.dist-info}/entry_points.txt +0 -0
@@ -1,132 +0,0 @@
1
- import logging
2
- from pathlib import Path
3
- from typing import Optional
4
-
5
- from pydantic import BaseModel
6
- from pydantic import Extra
7
- from pydantic import Field
8
- from pydantic import root_validator
9
- from pydantic import validator
10
-
11
- from fractal_server.app.schemas._validators import valdictkeys
12
- from fractal_server.app.schemas._validators import valstr
13
- from fractal_server.app.schemas.v2 import ManifestV2
14
- from fractal_server.tasks.utils import _normalize_package_name
15
- from fractal_server.tasks.v2.utils import _parse_wheel_filename
16
-
17
-
18
- class _TaskCollectPip(BaseModel, extra=Extra.forbid):
19
- """
20
- Internal task-collection model.
21
-
22
- This model is similar to the API request-body model (`TaskCollectPip`), but
23
- with enough differences that we keep them separated (and they do not have a
24
- common base).
25
-
26
- Attributes:
27
- package: Either a PyPI package name or the absolute path to a wheel
28
- file.
29
- package_name: The actual normalized name of the package, which is set
30
- internally through a validator.
31
- package_version: Package version. For local packages, it is set
32
- internally through a validator.
33
- """
34
-
35
- package: str
36
- package_name: str
37
- python_version: str
38
- package_extras: Optional[str] = None
39
- pinned_package_versions: dict[str, str] = Field(default_factory=dict)
40
- package_version: Optional[str] = None
41
- package_path: Optional[Path] = None
42
- package_manifest: Optional[ManifestV2] = None
43
-
44
- _pinned_package_versions = validator(
45
- "pinned_package_versions", allow_reuse=True
46
- )(valdictkeys("pinned_package_versions"))
47
- _package_extras = validator("package_extras", allow_reuse=True)(
48
- valstr("package_extras")
49
- )
50
- _python_version = validator("python_version", allow_reuse=True)(
51
- valstr("python_version")
52
- )
53
-
54
- @property
55
- def is_local_package(self) -> bool:
56
- return bool(self.package_path)
57
-
58
- @root_validator(pre=True)
59
- def set_package_info(cls, values):
60
- """
61
- Depending on whether the package is a local wheel file or a PyPI
62
- package, set some of its metadata.
63
- """
64
- if "/" in values["package"]:
65
- # Local package: parse wheel filename
66
- package_path = Path(values["package"])
67
- if not package_path.is_absolute():
68
- raise ValueError("Package path must be absolute")
69
- if not package_path.exists():
70
- logging.warning(
71
- f"Package {package_path} does not exist locally."
72
- )
73
- values["package_path"] = package_path
74
- wheel_metadata = _parse_wheel_filename(package_path.name)
75
- values["package_name"] = _normalize_package_name(
76
- wheel_metadata["distribution"]
77
- )
78
- values["package_version"] = wheel_metadata["version"]
79
- else:
80
- # Remote package: use `package` as `package_name`
81
- _package = values["package"]
82
- if _package.endswith(".whl"):
83
- raise ValueError(
84
- f"ERROR: package={_package} ends with '.whl' "
85
- "but it is not the absolute path to a wheel file."
86
- )
87
- values["package_name"] = _normalize_package_name(values["package"])
88
- return values
89
-
90
- @property
91
- def package_source(self) -> str:
92
- """
93
- NOTE: As of PR #1188 in `fractal-server`, the attribute
94
- `self.package_name` is normalized; this means e.g. that `_` is
95
- replaced by `-`. To guarantee backwards compatibility with
96
- `Task.source` attributes created before this change, we still replace
97
- `-` with `_` upon generation of the `source` attribute, in this
98
- method.
99
- """
100
- if not self.package_name or not self.package_version:
101
- raise ValueError(
102
- "Cannot construct `package_source` property with "
103
- f"{self.package_name=} and {self.package_version=}."
104
- )
105
- if self.is_local_package:
106
- collection_type = "pip_local"
107
- else:
108
- collection_type = "pip_remote"
109
-
110
- package_extras = self.package_extras or ""
111
- python_version = f"py{self.python_version}"
112
-
113
- source = ":".join(
114
- (
115
- collection_type,
116
- self.package_name.replace("-", "_"), # see method docstring
117
- self.package_version,
118
- package_extras,
119
- python_version,
120
- )
121
- )
122
- return source
123
-
124
- def check(self):
125
- """
126
- Verify that the package has all attributes that are needed to continue
127
- with task collection
128
- """
129
- if not self.package_version:
130
- raise ValueError("`package_version` attribute is not set")
131
- if not self.package_manifest:
132
- raise ValueError("`package_manifest` attribute is not set")