fractal-server 2.14.0a21__py3-none-any.whl → 2.14.0a22__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.14.0a21"
1
+ __VERSION__ = "2.14.0a22"
@@ -1,3 +1,4 @@
1
+ from copy import deepcopy
1
2
  from typing import Any
2
3
  from typing import Optional
3
4
 
@@ -92,7 +93,7 @@ async def get_workflow_tasks_statuses(
92
93
  db=db,
93
94
  )
94
95
 
95
- response = {}
96
+ response: dict[int, dict[str, int | str] | None] = {}
96
97
  for wftask in workflow.task_list:
97
98
  res = await db.execute(
98
99
  select(HistoryRun)
@@ -130,7 +131,18 @@ async def get_workflow_tasks_statuses(
130
131
  f"num_{target_status.value}_images"
131
132
  ] = num_images
132
133
 
133
- return JSONResponse(content=response, status_code=200)
134
+ new_response = deepcopy(response)
135
+ for key, value in response.items():
136
+ if value is not None:
137
+ num_total_images = sum(
138
+ value[f"num_{target_status.value}_images"]
139
+ for target_status in HistoryUnitStatus
140
+ )
141
+ if num_total_images > value["num_available_images"]:
142
+ value["num_available_images"] = None
143
+ new_response[key] = value
144
+
145
+ return JSONResponse(content=new_response, status_code=200)
134
146
 
135
147
 
136
148
  @router.get("/project/{project_id}/status/run/")
@@ -11,8 +11,8 @@ built-in `tarfile` library has to do with performance issues we observed
11
11
  when handling files which were just created within a SLURM job, and in the
12
12
  context of a CephFS filesystem.
13
13
  """
14
- import shutil
15
14
  import sys
15
+ import time
16
16
  from pathlib import Path
17
17
 
18
18
  from fractal_server.app.runner.run_subprocess import run_subprocess
@@ -20,21 +20,26 @@ from fractal_server.logger import get_logger
20
20
  from fractal_server.logger import set_logger
21
21
 
22
22
 
23
- def copy_subfolder(src: Path, dest: Path, logger_name: str):
23
+ def _copy_subfolder(src: Path, dest: Path, logger_name: str):
24
+ t_start = time.perf_counter()
24
25
  cmd_cp = f"cp -r {src.as_posix()} {dest.as_posix()}"
25
26
  logger = get_logger(logger_name=logger_name)
26
27
  logger.debug(f"{cmd_cp=}")
27
28
  res = run_subprocess(cmd=cmd_cp, logger_name=logger_name)
29
+ elapsed = time.perf_counter() - t_start
30
+ logger.debug(f"[_copy_subfolder] END {elapsed=} s ({dest.as_posix()})")
28
31
  return res
29
32
 
30
33
 
31
- def create_tar_archive(
32
- tarfile_path: Path,
34
+ def _create_tar_archive(
35
+ tarfile_path: str,
33
36
  subfolder_path_tmp_copy: Path,
34
37
  logger_name: str,
35
38
  remote_to_local: bool,
36
39
  ):
37
40
  logger = get_logger(logger_name)
41
+ logger.debug(f"[_create_tar_archive] START ({tarfile_path})")
42
+ t_start = time.perf_counter()
38
43
 
39
44
  if remote_to_local:
40
45
  exclude_options = "--exclude *sbatch --exclude *_in_*.pickle "
@@ -49,15 +54,24 @@ def create_tar_archive(
49
54
  )
50
55
  logger.debug(f"cmd tar:\n{cmd_tar}")
51
56
  run_subprocess(cmd=cmd_tar, logger_name=logger_name, allow_char="*")
57
+ elapsed = time.perf_counter() - t_start
58
+ logger.debug(f"[_create_tar_archive] END {elapsed=} s ({tarfile_path})")
52
59
 
53
60
 
54
- def remove_temp_subfolder(subfolder_path_tmp_copy: Path, logger_name: str):
61
+ def _remove_temp_subfolder(subfolder_path_tmp_copy: Path, logger_name: str):
55
62
  logger = get_logger(logger_name)
63
+ t_start = time.perf_counter()
56
64
  try:
57
- logger.debug(f"Now remove {subfolder_path_tmp_copy}")
58
- shutil.rmtree(subfolder_path_tmp_copy)
65
+ cmd_rm = f"rm -rf {subfolder_path_tmp_copy}"
66
+ logger.debug(f"cmd rm:\n{cmd_rm}")
67
+ run_subprocess(cmd=cmd_rm, logger_name=logger_name, allow_char="*")
59
68
  except Exception as e:
60
- logger.debug(f"ERROR during shutil.rmtree: {e}")
69
+ logger.debug(f"ERROR during {cmd_rm}: {e}")
70
+ elapsed = time.perf_counter() - t_start
71
+ logger.debug(
72
+ f"[_remove_temp_subfolder] END {elapsed=} s "
73
+ f"({subfolder_path_tmp_copy=})"
74
+ )
61
75
 
62
76
 
63
77
  def compress_folder(
@@ -91,10 +105,12 @@ def compress_folder(
91
105
  subfolder_path.parent / f"{subfolder_path.name}_copy"
92
106
  )
93
107
  try:
94
- copy_subfolder(
95
- subfolder_path, subfolder_path_tmp_copy, logger_name=logger_name
108
+ _copy_subfolder(
109
+ subfolder_path,
110
+ subfolder_path_tmp_copy,
111
+ logger_name=logger_name,
96
112
  )
97
- create_tar_archive(
113
+ _create_tar_archive(
98
114
  tarfile_path,
99
115
  subfolder_path_tmp_copy,
100
116
  logger_name=logger_name,
@@ -107,7 +123,9 @@ def compress_folder(
107
123
  sys.exit(1)
108
124
 
109
125
  finally:
110
- remove_temp_subfolder(subfolder_path_tmp_copy, logger_name=logger_name)
126
+ _remove_temp_subfolder(
127
+ subfolder_path_tmp_copy, logger_name=logger_name
128
+ )
111
129
 
112
130
 
113
131
  def main(sys_argv: list[str]):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fractal-server
3
- Version: 2.14.0a21
3
+ Version: 2.14.0a22
4
4
  Summary: Backend component of the Fractal analytics platform
5
5
  License: BSD-3-Clause
6
6
  Author: Tommaso Comparin
@@ -1,4 +1,4 @@
1
- fractal_server/__init__.py,sha256=X5Dy_f87GBiFeLzs2riLgudM2HP43U0ZuXNsU2NF7Os,26
1
+ fractal_server/__init__.py,sha256=vmLoAsXfXV-STPVYAotX-Rf--p3F2TkLnffSIuukSq4,26
2
2
  fractal_server/__main__.py,sha256=rkM8xjY1KeS3l63irB8yCrlVobR-73uDapC4wvrIlxI,6957
3
3
  fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
4
4
  fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -36,7 +36,7 @@ fractal_server/app/routes/api/v2/_aux_functions_history.py,sha256=ZlI6nwzB5r9AiY
36
36
  fractal_server/app/routes/api/v2/_aux_functions_task_lifecycle.py,sha256=qdXCb6IP8-qPEAxGZKljtjIqNzIAyRaAsQSRi5VqFHM,6773
37
37
  fractal_server/app/routes/api/v2/_aux_functions_tasks.py,sha256=uhNSs-jcS7ndIUFKiOC1yrDiViw3uvKEXi9UL04BMks,11642
38
38
  fractal_server/app/routes/api/v2/dataset.py,sha256=h5AhE0sdhQ20ZlIbEJsFnHIOUW0S1VHFpoflpBkVScs,8936
39
- fractal_server/app/routes/api/v2/history.py,sha256=lMbaybooBzzbCgD9vdzPyNxdgAZuzCH_YrW9ost-UgI,17253
39
+ fractal_server/app/routes/api/v2/history.py,sha256=FvZGl66hIdo70GvWoOhRQ__knbkbp5u440sl6qhj7nA,17748
40
40
  fractal_server/app/routes/api/v2/images.py,sha256=BGpO94gVd8BTpCN6Mun2RXmjrPmfkIp73m8RN7uiGW4,8361
41
41
  fractal_server/app/routes/api/v2/job.py,sha256=MU1sHIKk_89WrD0TD44d4ufzqnywot7On_W71KjyUbQ,6500
42
42
  fractal_server/app/routes/api/v2/project.py,sha256=uAZgATiHcOvbnRX-vv1D3HoaEUvLUd7vzVmGcqOP8ZY,4602
@@ -67,7 +67,7 @@ fractal_server/app/routes/aux/validate_user_settings.py,sha256=FLVi__8YFcm_6c_K5
67
67
  fractal_server/app/routes/pagination.py,sha256=L8F5JqekF39qz-LpeScdlhb57MQnSRXjK4ZEtsZqYLk,1210
68
68
  fractal_server/app/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  fractal_server/app/runner/components.py,sha256=-Ii5l8d_V6f5DFOd-Zsr8VYmOsyqw0Hox9fEFQiuqxY,66
70
- fractal_server/app/runner/compress_folder.py,sha256=HSc1tv7x2DBjBoXwugZlC79rm9GNBIWtQKK9yWn5ZBI,3991
70
+ fractal_server/app/runner/compress_folder.py,sha256=yEboyXe6WcNq5QUmXTJSJrC9TFfst9XYC3sVWZ6OcNE,4670
71
71
  fractal_server/app/runner/exceptions.py,sha256=JC5ufHyeA1hYD_rkZUscI30DD8D903ncag7Z3AArmUY,4215
72
72
  fractal_server/app/runner/executors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  fractal_server/app/runner/executors/base_runner.py,sha256=_elfqkuw1TGRacPG4aTTYKUTbF4A-Y2Rmft9LFi-Mwc,5554
@@ -207,8 +207,8 @@ fractal_server/tasks/v2/utils_templates.py,sha256=Kc_nSzdlV6KIsO0CQSPs1w70zLyENP
207
207
  fractal_server/urls.py,sha256=QjIKAC1a46bCdiPMu3AlpgFbcv6a4l3ABcd5xz190Og,471
208
208
  fractal_server/utils.py,sha256=PMwrxWFxRTQRl1b9h-NRIbFGPKqpH_hXnkAT3NfZdpY,3571
209
209
  fractal_server/zip_tools.py,sha256=GjDgo_sf6V_DDg6wWeBlZu5zypIxycn_l257p_YVKGc,4876
210
- fractal_server-2.14.0a21.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
211
- fractal_server-2.14.0a21.dist-info/METADATA,sha256=OZesW99axIUpT41CcJOkIszG_F5jLrDfKLT29EctIgI,4563
212
- fractal_server-2.14.0a21.dist-info/WHEEL,sha256=7dDg4QLnNKTvwIDR9Ac8jJaAmBC_owJrckbC0jjThyA,88
213
- fractal_server-2.14.0a21.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
214
- fractal_server-2.14.0a21.dist-info/RECORD,,
210
+ fractal_server-2.14.0a22.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
211
+ fractal_server-2.14.0a22.dist-info/METADATA,sha256=rfqOHrXBNtolpECEX8UmGRPTaBqE8w2bFgqccZQp_d8,4563
212
+ fractal_server-2.14.0a22.dist-info/WHEEL,sha256=7dDg4QLnNKTvwIDR9Ac8jJaAmBC_owJrckbC0jjThyA,88
213
+ fractal_server-2.14.0a22.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
214
+ fractal_server-2.14.0a22.dist-info/RECORD,,