fractal-server 2.11.0a10__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 (68) 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/models/v2/dataset.py +0 -4
  5. fractal_server/app/models/v2/workflowtask.py +0 -4
  6. fractal_server/app/routes/aux/_job.py +1 -3
  7. fractal_server/app/runner/executors/slurm/ssh/executor.py +9 -6
  8. fractal_server/app/runner/executors/slurm/sudo/executor.py +1 -5
  9. fractal_server/app/runner/filenames.py +0 -2
  10. fractal_server/app/runner/shutdown.py +3 -27
  11. fractal_server/app/schemas/_validators.py +0 -19
  12. fractal_server/config.py +1 -15
  13. fractal_server/main.py +1 -12
  14. fractal_server/migrations/versions/1eac13a26c83_drop_v1_tables.py +67 -0
  15. fractal_server/migrations/versions/af8673379a5c_drop_old_filter_columns.py +54 -0
  16. fractal_server/string_tools.py +0 -21
  17. fractal_server/tasks/utils.py +0 -28
  18. {fractal_server-2.11.0a10.dist-info → fractal_server-2.12.0.dist-info}/METADATA +1 -1
  19. {fractal_server-2.11.0a10.dist-info → fractal_server-2.12.0.dist-info}/RECORD +22 -66
  20. fractal_server/app/models/v1/__init__.py +0 -13
  21. fractal_server/app/models/v1/dataset.py +0 -71
  22. fractal_server/app/models/v1/job.py +0 -101
  23. fractal_server/app/models/v1/project.py +0 -29
  24. fractal_server/app/models/v1/state.py +0 -34
  25. fractal_server/app/models/v1/task.py +0 -85
  26. fractal_server/app/models/v1/workflow.py +0 -133
  27. fractal_server/app/routes/admin/v1.py +0 -377
  28. fractal_server/app/routes/api/v1/__init__.py +0 -26
  29. fractal_server/app/routes/api/v1/_aux_functions.py +0 -478
  30. fractal_server/app/routes/api/v1/dataset.py +0 -554
  31. fractal_server/app/routes/api/v1/job.py +0 -195
  32. fractal_server/app/routes/api/v1/project.py +0 -475
  33. fractal_server/app/routes/api/v1/task.py +0 -203
  34. fractal_server/app/routes/api/v1/task_collection.py +0 -239
  35. fractal_server/app/routes/api/v1/workflow.py +0 -355
  36. fractal_server/app/routes/api/v1/workflowtask.py +0 -187
  37. fractal_server/app/runner/async_wrap_v1.py +0 -27
  38. fractal_server/app/runner/v1/__init__.py +0 -415
  39. fractal_server/app/runner/v1/_common.py +0 -620
  40. fractal_server/app/runner/v1/_local/__init__.py +0 -186
  41. fractal_server/app/runner/v1/_local/_local_config.py +0 -105
  42. fractal_server/app/runner/v1/_local/_submit_setup.py +0 -48
  43. fractal_server/app/runner/v1/_local/executor.py +0 -100
  44. fractal_server/app/runner/v1/_slurm/__init__.py +0 -312
  45. fractal_server/app/runner/v1/_slurm/_submit_setup.py +0 -81
  46. fractal_server/app/runner/v1/_slurm/get_slurm_config.py +0 -163
  47. fractal_server/app/runner/v1/common.py +0 -117
  48. fractal_server/app/runner/v1/handle_failed_job.py +0 -141
  49. fractal_server/app/schemas/v1/__init__.py +0 -37
  50. fractal_server/app/schemas/v1/applyworkflow.py +0 -161
  51. fractal_server/app/schemas/v1/dataset.py +0 -165
  52. fractal_server/app/schemas/v1/dumps.py +0 -64
  53. fractal_server/app/schemas/v1/manifest.py +0 -126
  54. fractal_server/app/schemas/v1/project.py +0 -66
  55. fractal_server/app/schemas/v1/state.py +0 -18
  56. fractal_server/app/schemas/v1/task.py +0 -167
  57. fractal_server/app/schemas/v1/task_collection.py +0 -110
  58. fractal_server/app/schemas/v1/workflow.py +0 -212
  59. fractal_server/data_migrations/2_11_0.py +0 -168
  60. fractal_server/tasks/v1/_TaskCollectPip.py +0 -103
  61. fractal_server/tasks/v1/__init__.py +0 -0
  62. fractal_server/tasks/v1/background_operations.py +0 -352
  63. fractal_server/tasks/v1/endpoint_operations.py +0 -156
  64. fractal_server/tasks/v1/get_collection_data.py +0 -14
  65. fractal_server/tasks/v1/utils.py +0 -67
  66. {fractal_server-2.11.0a10.dist-info → fractal_server-2.12.0.dist-info}/LICENSE +0 -0
  67. {fractal_server-2.11.0a10.dist-info → fractal_server-2.12.0.dist-info}/WHEEL +0 -0
  68. {fractal_server-2.11.0a10.dist-info → fractal_server-2.12.0.dist-info}/entry_points.txt +0 -0
@@ -1,156 +0,0 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Optional
4
- from typing import Union
5
- from zipfile import ZipFile
6
-
7
- from ..v2.utils_package_names import normalize_package_name
8
- from ._TaskCollectPip import _TaskCollectPip as _TaskCollectPipV1
9
- from .utils import get_python_interpreter_v1
10
- from fractal_server.app.schemas.v1 import ManifestV1
11
- from fractal_server.config import get_settings
12
- from fractal_server.logger import get_logger
13
- from fractal_server.syringe import Inject
14
- from fractal_server.utils import execute_command_async
15
-
16
-
17
- FRACTAL_PUBLIC_TASK_SUBDIR = ".fractal"
18
-
19
-
20
- async def download_package(
21
- *,
22
- task_pkg: _TaskCollectPipV1,
23
- dest: Union[str, Path],
24
- ) -> Path:
25
- """
26
- Download package to destination
27
- """
28
- interpreter = get_python_interpreter_v1(version=task_pkg.python_version)
29
- pip = f"{interpreter} -m pip"
30
- version = (
31
- f"=={task_pkg.package_version}" if task_pkg.package_version else ""
32
- )
33
- package_and_version = f"{task_pkg.package}{version}"
34
- cmd = f"{pip} download --no-deps {package_and_version} -d {dest}"
35
- stdout = await execute_command_async(command=cmd, cwd=Path("."))
36
- pkg_file = next(
37
- line.split()[-1] for line in stdout.split("\n") if "Saved" in line
38
- )
39
- return Path(pkg_file)
40
-
41
-
42
- def _load_manifest_from_wheel(
43
- path: Path, wheel: ZipFile, logger_name: Optional[str] = None
44
- ) -> ManifestV1:
45
- logger = get_logger(logger_name)
46
- namelist = wheel.namelist()
47
- try:
48
- manifest = next(
49
- name for name in namelist if "__FRACTAL_MANIFEST__.json" in name
50
- )
51
- except StopIteration:
52
- msg = f"{path.as_posix()} does not include __FRACTAL_MANIFEST__.json"
53
- logger.error(msg)
54
- raise ValueError(msg)
55
- with wheel.open(manifest) as manifest_fd:
56
- manifest_dict = json.load(manifest_fd)
57
- manifest_version = str(manifest_dict["manifest_version"])
58
- if manifest_version == "1":
59
- pkg_manifest = ManifestV1(**manifest_dict)
60
- return pkg_manifest
61
- else:
62
- msg = f"Manifest version {manifest_version=} not supported"
63
- logger.error(msg)
64
- raise ValueError(msg)
65
-
66
-
67
- def inspect_package(path: Path, logger_name: Optional[str] = None) -> dict:
68
- """
69
- Inspect task package to extract version, name and manifest
70
-
71
- Note that this only works with wheel files, which have a well-defined
72
- dist-info section. If we need to generalize to to tar.gz archives, we would
73
- need to go and look for `PKG-INFO`.
74
-
75
- Note: package name is normalized via `_normalize_package_name`.
76
-
77
- Args:
78
- path: Path
79
- the path in which the package is saved
80
-
81
- Returns:
82
- version_manifest: A dictionary containing `version`, the version of the
83
- pacakge, and `manifest`, the Fractal manifest object relative to the
84
- tasks.
85
- """
86
-
87
- logger = get_logger(logger_name)
88
-
89
- if not path.as_posix().endswith(".whl"):
90
- raise ValueError(
91
- f"Only wheel packages are supported, given {path.as_posix()}."
92
- )
93
-
94
- with ZipFile(path) as wheel:
95
- namelist = wheel.namelist()
96
-
97
- # Read and validate task manifest
98
- logger.debug(f"Now reading manifest for {path.as_posix()}")
99
- pkg_manifest = _load_manifest_from_wheel(
100
- path, wheel, logger_name=logger_name
101
- )
102
- logger.debug("Manifest read correctly.")
103
-
104
- # Read package name and version from *.dist-info/METADATA
105
- logger.debug(
106
- f"Now reading package name and version for {path.as_posix()}"
107
- )
108
- metadata = next(
109
- name for name in namelist if "dist-info/METADATA" in name
110
- )
111
- with wheel.open(metadata) as metadata_fd:
112
- meta = metadata_fd.read().decode("utf-8")
113
- pkg_name = next(
114
- line.split()[-1]
115
- for line in meta.splitlines()
116
- if line.startswith("Name")
117
- )
118
- pkg_version = next(
119
- line.split()[-1]
120
- for line in meta.splitlines()
121
- if line.startswith("Version")
122
- )
123
- logger.debug("Package name and version read correctly.")
124
-
125
- # Normalize package name:
126
- pkg_name = normalize_package_name(pkg_name)
127
-
128
- info = dict(
129
- pkg_name=pkg_name,
130
- pkg_version=pkg_version,
131
- pkg_manifest=pkg_manifest,
132
- )
133
- return info
134
-
135
-
136
- def create_package_dir_pip(
137
- *,
138
- task_pkg: _TaskCollectPipV1,
139
- create: bool = True,
140
- ) -> Path:
141
- """
142
- Create venv folder for a task package and return corresponding Path object
143
- """
144
- settings = Inject(get_settings)
145
- user = FRACTAL_PUBLIC_TASK_SUBDIR
146
- if task_pkg.package_version is None:
147
- raise ValueError(
148
- f"Cannot create venv folder for package `{task_pkg.package}` "
149
- "with `version=None`."
150
- )
151
- normalized_package = normalize_package_name(task_pkg.package)
152
- package_dir = f"{normalized_package}{task_pkg.package_version}"
153
- venv_path = settings.FRACTAL_TASKS_DIR / user / package_dir
154
- if create:
155
- venv_path.mkdir(exist_ok=False, parents=True)
156
- return venv_path
@@ -1,14 +0,0 @@
1
- import json
2
- from pathlib import Path
3
-
4
- from fractal_server.app.schemas.v1 import TaskCollectStatusV1
5
- from fractal_server.tasks.utils import get_absolute_venv_path_v1
6
- from fractal_server.tasks.utils import get_collection_path
7
-
8
-
9
- def get_collection_data(venv_path: Path) -> TaskCollectStatusV1:
10
- package_path = get_absolute_venv_path_v1(venv_path)
11
- collection_path = get_collection_path(package_path)
12
- with collection_path.open() as f:
13
- data = json.load(f)
14
- return TaskCollectStatusV1(**data)
@@ -1,67 +0,0 @@
1
- from pathlib import Path
2
- from typing import Optional
3
-
4
- from fractal_server.logger import get_logger
5
- from fractal_server.utils import execute_command_async
6
-
7
-
8
- def get_python_interpreter_v1(version: Optional[str] = None) -> str:
9
- """
10
- Return the path to the python interpreter
11
-
12
- Args:
13
- version: Python version
14
-
15
- Raises:
16
- ValueError: If the python version requested is not available on the
17
- host.
18
-
19
- Returns:
20
- interpreter: string representing the python executable or its path
21
- """
22
- import shutil
23
- import sys
24
-
25
- if version:
26
- interpreter = shutil.which(f"python{version}")
27
- if not interpreter:
28
- raise ValueError(
29
- f"Python version {version} not available on host."
30
- )
31
- else:
32
- interpreter = sys.executable
33
-
34
- return interpreter
35
-
36
-
37
- async def _init_venv_v1(
38
- *,
39
- path: Path,
40
- python_version: Optional[str] = None,
41
- logger_name: str,
42
- ) -> Path:
43
- """
44
- Set a virtual environment at `path/venv`
45
-
46
- Args:
47
- path : Path
48
- path to directory in which to set up the virtual environment
49
- python_version : default=None
50
- Python version the virtual environment will be based upon
51
-
52
- Returns:
53
- python_bin : Path
54
- path to python interpreter
55
- """
56
- logger = get_logger(logger_name)
57
- logger.debug(f"[_init_venv] {path=}")
58
- interpreter = get_python_interpreter_v1(version=python_version)
59
- logger.debug(f"[_init_venv] {interpreter=}")
60
- await execute_command_async(
61
- cwd=path,
62
- command=f"{interpreter} -m venv venv",
63
- logger_name=logger_name,
64
- )
65
- python_bin = path / "venv/bin/python"
66
- logger.debug(f"[_init_venv] {python_bin=}")
67
- return python_bin