fractal-server 2.14.0a9__py3-none-any.whl → 2.14.0a11__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 (43) hide show
  1. fractal_server/__init__.py +1 -1
  2. fractal_server/app/models/v2/dataset.py +0 -10
  3. fractal_server/app/models/v2/job.py +3 -0
  4. fractal_server/app/routes/api/v2/__init__.py +2 -0
  5. fractal_server/app/routes/api/v2/history.py +14 -9
  6. fractal_server/app/routes/api/v2/images.py +5 -2
  7. fractal_server/app/routes/api/v2/submit.py +16 -14
  8. fractal_server/app/routes/api/v2/verify_image_types.py +64 -0
  9. fractal_server/app/routes/api/v2/workflow.py +11 -7
  10. fractal_server/app/runner/components.py +0 -3
  11. fractal_server/app/runner/exceptions.py +4 -0
  12. fractal_server/app/runner/executors/base_runner.py +16 -17
  13. fractal_server/app/runner/executors/local/{_local_config.py → get_local_config.py} +0 -7
  14. fractal_server/app/runner/executors/local/runner.py +117 -58
  15. fractal_server/app/runner/executors/{slurm_sudo → slurm_common}/_check_jobs_status.py +4 -0
  16. fractal_server/app/runner/executors/slurm_ssh/_check_job_status_ssh.py +67 -0
  17. fractal_server/app/runner/executors/slurm_ssh/executor.py +7 -5
  18. fractal_server/app/runner/executors/slurm_ssh/runner.py +707 -0
  19. fractal_server/app/runner/executors/slurm_sudo/runner.py +265 -114
  20. fractal_server/app/runner/task_files.py +8 -0
  21. fractal_server/app/runner/v2/__init__.py +0 -365
  22. fractal_server/app/runner/v2/_local.py +4 -2
  23. fractal_server/app/runner/v2/_slurm_ssh.py +4 -2
  24. fractal_server/app/runner/v2/_slurm_sudo.py +4 -2
  25. fractal_server/app/runner/v2/db_tools.py +87 -0
  26. fractal_server/app/runner/v2/runner.py +83 -89
  27. fractal_server/app/runner/v2/runner_functions.py +279 -436
  28. fractal_server/app/runner/v2/runner_functions_low_level.py +37 -39
  29. fractal_server/app/runner/v2/submit_workflow.py +366 -0
  30. fractal_server/app/runner/v2/task_interface.py +31 -0
  31. fractal_server/app/schemas/v2/dataset.py +4 -71
  32. fractal_server/app/schemas/v2/dumps.py +6 -5
  33. fractal_server/app/schemas/v2/job.py +6 -3
  34. fractal_server/migrations/versions/47351f8c7ebc_drop_dataset_filters.py +50 -0
  35. fractal_server/migrations/versions/e81103413827_add_job_type_filters.py +36 -0
  36. {fractal_server-2.14.0a9.dist-info → fractal_server-2.14.0a11.dist-info}/METADATA +1 -1
  37. {fractal_server-2.14.0a9.dist-info → fractal_server-2.14.0a11.dist-info}/RECORD +40 -36
  38. fractal_server/app/runner/executors/local/_submit_setup.py +0 -46
  39. fractal_server/app/runner/executors/slurm_common/_submit_setup.py +0 -84
  40. fractal_server/app/runner/v2/_db_tools.py +0 -48
  41. {fractal_server-2.14.0a9.dist-info → fractal_server-2.14.0a11.dist-info}/LICENSE +0 -0
  42. {fractal_server-2.14.0a9.dist-info → fractal_server-2.14.0a11.dist-info}/WHEEL +0 -0
  43. {fractal_server-2.14.0a9.dist-info → fractal_server-2.14.0a11.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,67 @@
1
+ from fractal_server.app.runner.executors.slurm_common._job_states import (
2
+ STATES_FINISHED,
3
+ )
4
+ from fractal_server.logger import set_logger
5
+ from fractal_server.ssh._fabric import FractalSSH
6
+
7
+ logger = set_logger(__name__)
8
+
9
+
10
+ def run_squeue(
11
+ *,
12
+ job_ids: list[str],
13
+ fractal_ssh: FractalSSH,
14
+ ) -> str:
15
+ job_id_single_str = ",".join([str(j) for j in job_ids])
16
+ cmd = (
17
+ f"squeue --noheader --format='%i %T' --jobs {job_id_single_str}"
18
+ " --states=all"
19
+ )
20
+ stdout = fractal_ssh.run_command(cmd)
21
+ return stdout
22
+
23
+
24
+ def get_finished_jobs_ssh(
25
+ *,
26
+ fractal_ssh: FractalSSH,
27
+ job_ids: list[str],
28
+ ) -> set[str]:
29
+ """
30
+ # FIXME: make uniform with non-ssh one
31
+
32
+ Check which ones of the given Slurm jobs already finished
33
+
34
+ The function is based on the `_jobs_finished` function from
35
+ clusterfutures (version 0.5).
36
+ Original Copyright: 2022 Adrian Sampson
37
+ (released under the MIT licence)
38
+ """
39
+
40
+ # If there is no Slurm job to check, return right away
41
+ if not job_ids:
42
+ return set()
43
+
44
+ id_to_state = dict()
45
+
46
+ try:
47
+ stdout = run_squeue(job_ids=job_ids, fractal_ssh=fractal_ssh)
48
+ id_to_state = {
49
+ line.split()[0]: line.split()[1] for line in stdout.splitlines()
50
+ }
51
+ except Exception: # FIXME
52
+ id_to_state = dict()
53
+ for j in job_ids:
54
+ try:
55
+ stdout = run_squeue([j])
56
+ id_to_state.update({stdout.split()[0]: stdout.split()[1]})
57
+ except Exception:
58
+ logger.info(f"Job {j} not found. Marked it as completed")
59
+ id_to_state.update({str(j): "COMPLETED"})
60
+
61
+ # Finished jobs only stay in squeue for a few mins (configurable). If
62
+ # a job ID isn't there, we'll assume it's finished.
63
+ return {
64
+ j
65
+ for j in job_ids
66
+ if id_to_state.get(j, "COMPLETED") in STATES_FINISHED
67
+ }
@@ -24,7 +24,6 @@ from ..slurm_common.utils_executors import get_pickle_file_path
24
24
  from ..slurm_common.utils_executors import get_slurm_file_path
25
25
  from ..slurm_common.utils_executors import get_slurm_script_file_path
26
26
  from ._executor_wait_thread import FractalSlurmSSHWaitThread
27
- from fractal_server.app.runner.components import _COMPONENT_KEY_
28
27
  from fractal_server.app.runner.compress_folder import compress_folder
29
28
  from fractal_server.app.runner.exceptions import JobExecutionError
30
29
  from fractal_server.app.runner.exceptions import TaskExecutionError
@@ -526,10 +525,13 @@ class FractalSlurmSSHExecutor(Executor):
526
525
  # `component = {"zarr_url": "/something", "param": 1}``). The
527
526
  # try/except covers the case of e.g. `executor.map([1, 2])`,
528
527
  # which is useful for testing.
529
- try:
530
- actual_component = component.get(_COMPONENT_KEY_, None)
531
- except AttributeError:
532
- actual_component = str(component)
528
+
529
+ # FIXME: the use of _COMPONENT_KEY_ is now deprecated
530
+ # try:
531
+ # actual_component = component.get(_COMPONENT_KEY_, None)
532
+ # except AttributeError:
533
+ # actual_component = str(component)
534
+ actual_component = "FAKE_INVALID_VALUE_FIXME"
533
535
 
534
536
  _task_file_paths = TaskFiles(
535
537
  root_dir_local=task_files.workflow_dir_local,