Skip to content
Snippets Groups Projects
Commit 442b5e11 authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Add a compress job.

parent f6ccac8c
No related branches found
No related tags found
No related merge requests found
#!/bin/env python3
def main():
import os
from pathlib import Path
import enstools.compression
# Move the outputs to the proper destination
# Get some variables provided by autosubmit.
WORKDIR = Path("%HPCROOTDIR%")
STARTDATE = "%SDATE%"
MEMBER = "%MEMBER%"
OUTPUT_FILES = eval("%simulation.OUTPUT_FILES%")
# Define rundir
RUNDIR = WORKDIR / STARTDATE / MEMBER
# Define output dir and create it in case it doesn't exist
OUTPUT_DIR = WORKDIR / "output" / STARTDATE / MEMBER
if not OUTPUT_DIR.exists():
os.makedirs(OUTPUT_DIR.as_posix())
# Copy the output files
for file_name in OUTPUT_FILES:
source_file_path = RUNDIR / file_name
destination_file_path = OUTPUT_DIR / file_name
if destination_file_path.exists():
raise AssertionError(f"File {destination_file_path.as_posix()!r} already exists!")
enstools.compression.compress(source_file_path, destination_file_path, compression="lossless")
# Remove source files
# if destination_file_path.exists():
# source_file_path.unlink()
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment