Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 39 additions & 21 deletions pspipe/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import datetime
import importlib
import logging
import os
import shutil
Expand Down Expand Up @@ -196,26 +195,6 @@ def parse_time(t, human=True):
raise SystemExit()
config_dict.write_to_file(updated_dict_file)

info = "Pipeline runs with the following software version:"
modules = [
"camb",
"cobaya",
"ducc0",
"fgspectra",
"mflike",
"numpy",
"pixell",
"pspy",
"pspipe_utils",
"pspipe",
"scipy",
]
for m in modules:
version = importlib.import_module(m).__version__
pipeline_dict.setdefault("modules", {}).update({m: version})
info += f"\n - {m} {version}"
logging.info(info)

# Make sure every modules params are dict
pipeline = pipeline_dict.setdefault("pipeline", {})
pipeline |= {k: v if v else {} for k, v in pipeline.items()}
Expand Down Expand Up @@ -254,6 +233,37 @@ def parse_time(t, human=True):
updated_pipeline_dict = deepcopy(pipeline_dict)
updated_pipeline_dict.update(pipeline=pipeline)

# Check podman
if podman := pipeline_dict.get("podman-hpc"):
if not (image := podman.get("image")):
logging.error("Missing 'podman-hpc' image! You must set a valid image.")
raise SystemExit()
logging.info(f"Running pipeline with podman-hpc and the following image '{image}'")
else:
info = "Pipeline runs with the following software version:"
modules = [
"camb",
"cobaya",
"ducc0",
"fgspectra",
"mflike",
"numpy",
"pixell",
"pspy",
"pspipe_utils",
"pspipe",
"scipy",
]
from importlib import metadata

for m in metadata.distributions():
name, version = m.name, m.version
if name not in modules:
continue
pipeline_dict.setdefault("modules", {}).update({name: version})
info += f"\n - {name} {version}"
logging.info(info)

# Slurm default parameters
slurm_nnodes = int(os.environ.get("SLURM_NNODES", 1))
slurm_cpus_on_node = int(os.environ.get("SLURM_CPUS_ON_NODE", 256))
Expand Down Expand Up @@ -352,6 +362,14 @@ def parse_time(t, human=True):
# If no extension is provided, assume it's a python file
if not ext:
cmd = "python -u " + cmd
if podman:
cmd = " ".join(
[
podman.get("cmd", "podman-hpc run --rm --mpi --scratch --cfs --home"),
podman.get("image"),
cmd,
]
)
# Append kwargs to command line
cmd = f"{cmd} {kwargs} {updated_dict_file if config_file else ''}"
logging.debug(f"Command line: {cmd}")
Expand Down