fractal-server 2.16.2__py3-none-any.whl → 2.16.3__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.16.2"
1
+ __VERSION__ = "2.16.3"
@@ -31,6 +31,36 @@ STATES_FINISHED = {
31
31
  }
32
32
 
33
33
 
34
+ def _get_workdir_remote(script_paths: list[str]) -> str:
35
+ """
36
+ Check that there is one and only one `workdir`, and return it.
37
+
38
+ Note: The `is_absolute` check is to filter out a `chmod` command.
39
+ """
40
+ workdirs = [
41
+ Path(script_path).parent.as_posix()
42
+ for script_path in script_paths
43
+ if Path(script_path).is_absolute()
44
+ ]
45
+ if not len(set(workdirs)) == 1:
46
+ raise ValueError(f"Invalid {script_paths=}.")
47
+ return workdirs[0]
48
+
49
+
50
+ def _read_file_if_exists(
51
+ *,
52
+ fractal_ssh: FractalSSH,
53
+ path: str,
54
+ ) -> str:
55
+ """
56
+ Read a remote file if it exists, or return an empty string.
57
+ """
58
+ if fractal_ssh.remote_exists(path=path):
59
+ return fractal_ssh.read_remote_text_file(path)
60
+ else:
61
+ return ""
62
+
63
+
34
64
  def _log_change_of_job_state(
35
65
  *,
36
66
  old_state: str | None,
@@ -99,15 +129,18 @@ def _verify_success_file_exists(
99
129
  logger = get_logger(logger_name=logger_name)
100
130
  error_msg = f"{success_file_remote=} missing."
101
131
  logger.info(error_msg)
102
- if fractal_ssh.remote_exists(stderr_remote):
103
- stderr = fractal_ssh.read_remote_text_file(stderr_remote)
132
+
133
+ stderr = _read_file_if_exists(
134
+ fractal_ssh=fractal_ssh, path=stderr_remote
135
+ )
136
+ if stderr:
104
137
  logger.info(f"SLURM-job stderr:\n{stderr}")
105
138
  raise RuntimeError(error_msg)
106
139
 
107
140
 
108
141
  def run_script_on_remote_slurm(
109
142
  *,
110
- script_path: str,
143
+ script_paths: list[str],
111
144
  slurm_config: PixiSLURMConfig,
112
145
  fractal_ssh: FractalSSH,
113
146
  logger_name: str,
@@ -127,7 +160,7 @@ def run_script_on_remote_slurm(
127
160
  settings = Inject(get_settings)
128
161
 
129
162
  # (1) Prepare remote submission script
130
- workdir_remote = Path(script_path).parent.as_posix()
163
+ workdir_remote = _get_workdir_remote(script_paths)
131
164
  submission_script_remote = os.path.join(
132
165
  workdir_remote, f"{prefix}-submit.sh"
133
166
  )
@@ -144,10 +177,11 @@ def run_script_on_remote_slurm(
144
177
  f"#SBATCH --out={stdout_remote}",
145
178
  f"#SBATCH -D {workdir_remote}",
146
179
  "",
147
- f"bash {script_path}",
148
- f"touch {success_file_remote}",
149
- "",
150
180
  ]
181
+ for script_path in script_paths:
182
+ script_lines.append(f"bash {script_path}")
183
+ script_lines.append(f"touch {success_file_remote}")
184
+
151
185
  script_contents = "\n".join(script_lines)
152
186
  fractal_ssh.write_remote_file(
153
187
  path=submission_script_remote,
@@ -209,6 +243,13 @@ def run_script_on_remote_slurm(
209
243
  stderr_remote=stderr_remote,
210
244
  )
211
245
 
246
+ stdout = _read_file_if_exists(
247
+ fractal_ssh=fractal_ssh,
248
+ path=stdout_remote,
249
+ )
250
+
212
251
  logger.info("SLURM-job execution completed successfully, continue.")
213
252
  activity.log = get_current_log(log_file_path)
214
253
  activity = add_commit_refresh(obj=activity, db=db)
254
+
255
+ return stdout
@@ -203,12 +203,21 @@ def collect_ssh_pixi(
203
203
  pyproject_toml_path=pyproject_toml_path,
204
204
  )
205
205
 
206
- # Run script 2 - run pixi-install command
206
+ # Prepare scripts 2 and 3
207
207
  remote_script2_path = _customize_and_send_template(
208
208
  template_filename="pixi_2_install.sh",
209
209
  replacements=replacements,
210
210
  **common_args,
211
211
  )
212
+ remote_script3_path = _customize_and_send_template(
213
+ template_filename="pixi_3_post_install.sh",
214
+ replacements=replacements,
215
+ **common_args,
216
+ )
217
+ logger.debug(
218
+ "Post-installation script written to "
219
+ f"{remote_script3_path=}."
220
+ )
212
221
  logger.debug(
213
222
  "Installation script written to "
214
223
  f"{remote_script2_path=}."
@@ -216,8 +225,13 @@ def collect_ssh_pixi(
216
225
  activity.log = get_current_log(log_file_path)
217
226
  activity = add_commit_refresh(obj=activity, db=db)
218
227
 
219
- run_script_on_remote_slurm(
220
- script_path=remote_script2_path,
228
+ # Run scripts 2 and 3
229
+ stdout = run_script_on_remote_slurm(
230
+ script_paths=[
231
+ remote_script2_path,
232
+ remote_script3_path,
233
+ f"chmod -R 755 {source_dir}",
234
+ ],
221
235
  slurm_config=settings.pixi.SLURM_CONFIG,
222
236
  fractal_ssh=fractal_ssh,
223
237
  logger_name=LOGGER_NAME,
@@ -229,16 +243,6 @@ def collect_ssh_pixi(
229
243
  activity.log = get_current_log(log_file_path)
230
244
  activity = add_commit_refresh(obj=activity, db=db)
231
245
 
232
- # Run script 3 - post-install
233
- stdout = _customize_and_run_template(
234
- template_filename="pixi_3_post_install.sh",
235
- replacements=replacements,
236
- **common_args,
237
- )
238
- logger.debug(f"STDOUT: {stdout}")
239
- activity.log = get_current_log(log_file_path)
240
- activity = add_commit_refresh(obj=activity, db=db)
241
-
242
246
  # Parse stdout
243
247
  parsed_output = parse_collect_stdout(stdout)
244
248
  package_root_remote = parsed_output["package_root"]
@@ -248,8 +252,6 @@ def collect_ssh_pixi(
248
252
  "project_python_wrapper"
249
253
  ]
250
254
 
251
- fractal_ssh.run_command(cmd=f"chmod -R 755 {source_dir}")
252
-
253
255
  # Read and validate remote manifest file
254
256
  manifest_path_remote = (
255
257
  f"{package_root_remote}/__FRACTAL_MANIFEST__.json"
@@ -188,12 +188,21 @@ def reactivate_ssh_pixi(
188
188
  remote=pixi_lock_remote,
189
189
  )
190
190
 
191
- # Run script 2 - run pixi-install command
191
+ # Prepare scripts 2 and 3
192
192
  remote_script2_path = _customize_and_send_template(
193
193
  template_filename="pixi_2_install.sh",
194
194
  replacements=replacements,
195
195
  **common_args,
196
196
  )
197
+ remote_script3_path = _customize_and_send_template(
198
+ template_filename="pixi_3_post_install.sh",
199
+ replacements=replacements,
200
+ **common_args,
201
+ )
202
+ logger.debug(
203
+ "Post-installation script written to "
204
+ f"{remote_script3_path=}."
205
+ )
197
206
  logger.debug(
198
207
  "Installation script written to "
199
208
  f"{remote_script2_path=}."
@@ -201,8 +210,13 @@ def reactivate_ssh_pixi(
201
210
  activity.log = get_current_log(log_file_path)
202
211
  activity = add_commit_refresh(obj=activity, db=db)
203
212
 
204
- run_script_on_remote_slurm(
205
- script_path=remote_script2_path,
213
+ # Run scripts 2 and 3
214
+ stdout = run_script_on_remote_slurm(
215
+ script_paths=[
216
+ remote_script2_path,
217
+ remote_script3_path,
218
+ f"chmod -R 755 {source_dir}",
219
+ ],
206
220
  slurm_config=settings.pixi.SLURM_CONFIG,
207
221
  fractal_ssh=fractal_ssh,
208
222
  logger_name=LOGGER_NAME,
@@ -214,18 +228,6 @@ def reactivate_ssh_pixi(
214
228
  activity.log = get_current_log(log_file_path)
215
229
  activity = add_commit_refresh(obj=activity, db=db)
216
230
 
217
- # Run script 3 - post-install
218
- stdout = _customize_and_run_template(
219
- template_filename="pixi_3_post_install.sh",
220
- replacements=replacements,
221
- **common_args,
222
- )
223
- logger.debug(f"STDOUT: {stdout}")
224
- activity.log = get_current_log(log_file_path)
225
- activity = add_commit_refresh(obj=activity, db=db)
226
-
227
- fractal_ssh.run_command(cmd=f"chmod -R 755 {source_dir}")
228
-
229
231
  # Finalize (write metadata to DB)
230
232
  activity.status = TaskGroupActivityStatusV2.OK
231
233
  activity.timestamp_ended = get_timestamp()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fractal-server
3
- Version: 2.16.2
3
+ Version: 2.16.3
4
4
  Summary: Backend component of the Fractal analytics platform
5
5
  License: BSD-3-Clause
6
6
  Author: Tommaso Comparin
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Dist: alembic (>=1.13.1,<2.0.0)
15
- Requires-Dist: cryptography (>=45.0.3,<45.1.0)
15
+ Requires-Dist: cryptography (>=46.0.0,<47.0.0)
16
16
  Requires-Dist: fabric (>=3.2.2,<3.3.0)
17
17
  Requires-Dist: fastapi (>=0.116.0,<0.117.0)
18
18
  Requires-Dist: fastapi-users[oauth] (>=14,<15)
@@ -1,4 +1,4 @@
1
- fractal_server/__init__.py,sha256=4kmWit_5SMjK3FA49cLisJxqg2JTjE1FTm94k5TFawg,23
1
+ fractal_server/__init__.py,sha256=XhckXI3NQgXzQFmbqjMIwxfxShIlVm8JhcoaOhWWvyY,23
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
@@ -204,15 +204,15 @@ fractal_server/tasks/v2/local/delete.py,sha256=TbNcg0IhbJNXzXsO2Vgv6Dq4jWmFUVtSu
204
204
  fractal_server/tasks/v2/local/reactivate.py,sha256=Q43DOadNeFyyfgNP67lUqaXmZsS6onv67XwxH_-5ANA,5756
205
205
  fractal_server/tasks/v2/local/reactivate_pixi.py,sha256=IuxDRaj8i6Rc582TIbc9HVKQ9pOvR4IepyXSaJx2PfQ,7565
206
206
  fractal_server/tasks/v2/ssh/__init__.py,sha256=dPK6BtEZVh1GiFP05j1RKTEnZvjJez8o2KkMC2hWXaw,339
207
- fractal_server/tasks/v2/ssh/_pixi_slurm_ssh.py,sha256=l1mBuzD0eGG1tvLzAIDuy3JlZjzVx9RtXLY5IjxLHjc,6508
207
+ fractal_server/tasks/v2/ssh/_pixi_slurm_ssh.py,sha256=24BX64KbnBr4Wd3k9KmSNz4WHzvLf9AF7Hh1-FDlC9w,7472
208
208
  fractal_server/tasks/v2/ssh/_utils.py,sha256=AjbH4o6-ENe-ZiHvE_pGe_yw8e2lapGMYtLX7VuBkA8,6111
209
209
  fractal_server/tasks/v2/ssh/collect.py,sha256=WesUBtNaax9ST7CtgqAD2qd-ZII4t1JFPzRzltEOuM8,14333
210
- fractal_server/tasks/v2/ssh/collect_pixi.py,sha256=oRz5hp1vkZ1MbVzTPAKZBhNVD4rgHwI-MDvUCJr_jeo,15147
210
+ fractal_server/tasks/v2/ssh/collect_pixi.py,sha256=i7_xqAy9kkF19AHHGSAmvs-QUEQIkPJvVxXUiau1WhU,15210
211
211
  fractal_server/tasks/v2/ssh/deactivate.py,sha256=7gJ2mOah0wKwUnK0S9QpaXg08_WE95P0rC-oExAGhLE,12438
212
212
  fractal_server/tasks/v2/ssh/deactivate_pixi.py,sha256=K0yK_NPUqhFMj6cp6G_0Kfn0Yo7oQux4kT5dFPulnos,4748
213
213
  fractal_server/tasks/v2/ssh/delete.py,sha256=9DCe5QXZ14pY8NRb_FCqpIr31r5Gboz6bnFrS8Oa044,4277
214
214
  fractal_server/tasks/v2/ssh/reactivate.py,sha256=NJIgMNFKaXMhbvK0iZOsMwMtsms6Boj9f8N4L01X9Bo,8271
215
- fractal_server/tasks/v2/ssh/reactivate_pixi.py,sha256=O0f9f4KKPFrzDZ8sNCPlH4rvRf79b2bUNOeZDUdVcrQ,11147
215
+ fractal_server/tasks/v2/ssh/reactivate_pixi.py,sha256=yRoq7xTCpKgx8Fxc5RTpEwQI-L0-9Tjq7vnX_v3v7JE,11210
216
216
  fractal_server/tasks/v2/templates/1_create_venv.sh,sha256=PK0jdHKtQpda1zULebBaVPORt4t6V17wa4N1ohcj5ac,548
217
217
  fractal_server/tasks/v2/templates/2_pip_install.sh,sha256=vN9DX-eucJjB-XCuQuZmkuATGBzL4FlDQJTQdVewJG8,2155
218
218
  fractal_server/tasks/v2/templates/3_pip_freeze.sh,sha256=JldREScEBI4cD_qjfX4UK7V4aI-FnX9ZvVNxgpSOBFc,168
@@ -236,8 +236,8 @@ fractal_server/types/validators/_workflow_task_arguments_validators.py,sha256=HL
236
236
  fractal_server/urls.py,sha256=QjIKAC1a46bCdiPMu3AlpgFbcv6a4l3ABcd5xz190Og,471
237
237
  fractal_server/utils.py,sha256=Vn35lApt1T1J8nc09sAVqd10Cy0sa3dLipcljI-hkuk,2185
238
238
  fractal_server/zip_tools.py,sha256=H0w7wS5yE4ebj7hw1_77YQ959dl2c-L0WX6J_ro1TY4,4884
239
- fractal_server-2.16.2.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
240
- fractal_server-2.16.2.dist-info/METADATA,sha256=RAX6WeXcABoEtBkQElrkFwqEOZF4cX8rp1expG65Dec,4334
241
- fractal_server-2.16.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
242
- fractal_server-2.16.2.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
243
- fractal_server-2.16.2.dist-info/RECORD,,
239
+ fractal_server-2.16.3.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
240
+ fractal_server-2.16.3.dist-info/METADATA,sha256=pw_mNLXMPEkIRXLZGpIG5a4T_S4ehtX1HAuqTkKZrXQ,4334
241
+ fractal_server-2.16.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
242
+ fractal_server-2.16.3.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
243
+ fractal_server-2.16.3.dist-info/RECORD,,