Skip to content
Snippets Groups Projects
Commit bf043449 authored by Timo Millenaar's avatar Timo Millenaar
Browse files

Merge branch 'scatter_and_aggregate' into 'master'

Make dir references absolute

See merge request !16
parents 02ecc134 c9504e82
No related branches found
No related tags found
1 merge request!16Make dir references absolute
Pipeline #94341 passed
...@@ -3,12 +3,16 @@ class: CommandLineTool ...@@ -3,12 +3,16 @@ class: CommandLineTool
requirements: requirements:
- class: DockerRequirement - class: DockerRequirement
dockerPull: git.astron.nl:5000/ldv/imaging_compress_pipeline:v0.4.1 dockerPull: git.astron.nl:5000/ldv/imaging_compress_pipeline:v0.5.1
baseCommand: python3 baseCommand: python3
arguments: arguments:
- /src/aggregate_and_plot.py - $(inputs.workdir)/imaging_compress_pipeline.git/aggregate_and_plot.py
inputs: {} inputs:
workdir:
type: string
inputBinding:
position: 1 # The first argument after the script will be the workdir
outputs: [] outputs: []
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
from lofar_quality.manipulate.common import join_inspect_ds from lofar_quality.manipulate.common import join_inspect_ds
from lofar_quality.inspect.inspect_dataset import plot_inspect_ds from lofar_quality.inspect.inspect_dataset import plot_inspect_ds
from pathlib import Path from pathlib import Path
...@@ -7,28 +8,38 @@ import logging ...@@ -7,28 +8,38 @@ import logging
FORMAT = '%(levelname)-15s %(asctime)s: %(message)s' FORMAT = '%(levelname)-15s %(asctime)s: %(message)s'
logging.basicConfig(format=FORMAT, level="INFO") logging.basicConfig(format=FORMAT, level="INFO")
if __name__ == "__main__": def main():
# Set up argument parser
parser = argparse.ArgumentParser(description="Process H5 files and output results to a specified directory.")
parser.add_argument('workdir', type=str, help='Path to the working directory')
# Parse the arguments
args = parser.parse_args()
workdir = Path(args.workdir) # The first command-line argument
h5_paths = [] h5_paths = []
with open("/mnt/workdir/inputs.txt", "r") as file: with open(workdir / "inputs.txt", "r") as file:
for line in file: for line in file:
line = str(line.strip()) # remove white space line = str(line.strip()) # Remove white space
path = Path(line) path = Path(line)
if path.exists(): if path.exists():
if path.suffix.lower() == ".h5": if path.suffix.lower() == ".h5":
h5_paths.append(line) h5_paths.append(line)
else: else:
logging.info(f"File exists but is not an h5 file: {line}") logging.info(f"File exists but is not an h5 file: {line}")
else: else:
logging.info(f"Could not find the following input file: {line}") logging.info(f"Could not find the following input file: {line}")
logging.info(f"Found {len(h5_paths)} h5 files") logging.info(f"Found {len(h5_paths)} h5 files")
h5_output_path = "/mnt/workdir/inspect.h5" h5_output_path = workdir / "inspect.h5"
join_inspect_ds(h5_paths, h5_output_path) join_inspect_ds(h5_paths, h5_output_path)
plot_paths = plot_inspect_ds(h5_output_path, "/mnt/workdir", min_elevation=15) plot_paths = plot_inspect_ds(h5_output_path, workdir, min_elevation=15)
with open("/mnt/workdir/outputs.txt", "w") as file: with open(workdir / "outputs.txt", "w") as file:
file.write(str(Path(h5_output_path).absolute()) + "\n") file.write(str(h5_output_path.absolute()) + "\n")
for file_path in plot_paths: for file_path in plot_paths:
path = Path(file_path).absolute() path = Path(file_path).absolute()
file.write(str(path) + "\n") file.write(str(path) + "\n")
if __name__ == "__main__":
main()
#!/usr/bin/sh #!/usr/bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR
TOIL_VENV_DIR="${SCRIPT_DIR}/toil_venv"
if [ -d "toil_venv" ]; then if [ -d "toil_venv" ]; then
echo "Activating existing virtual environment." echo "Activating existing virtual environment."
source toil_venv/bin/activate source "${TOIL_VENV_DIR}/bin/activate"
else else
echo "Creating new virtual environment for using toil" echo "Creating new virtual environment for using toil"
python3.9 -m venv toil_venv python3.9 -m venv $TOIL_VENV_DIR
source toil_venv/bin/activate source "${TOIL_VENV_DIR}/bin/activate"
pip install --upgrade pip setuptools wheel pip install --upgrade pip setuptools wheel
pip install toil[cwl] singularity pip install toil[cwl] singularity
fi fi
export SINGULARITY_BIND="$PWD:/mnt/workdir,/project:/project" export SINGULARITY_BIND="/project:/project"
toil-cwl-runner --singularity imaging_compress_pipeline.git/aggregate_and_plot.cwl export TOIL_SLURM_ARGS="--exclusive"
toil-cwl-runner "${SCRIPT_DIR}/imaging_compress_pipeline.git/aggregate_and_plot.cwl" --workdir $SCRIPT_DIR --logDebug --singularity --batchSystem slurm --batchLogsDir ./logs --jobStore ./job_store
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment