#!/usr/bin/env python
#
# Data Quality Checker also known as DQC
#
# Read the README.md for more detailed information
#
#       Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
#       Earth Sciences Department - Computational Earth Sciences
#
#     Authors:
#       Joan Sala Calero (joan.sala@bsc.es)

import os
from ecflow import Defs, Suite, Task, Edit, Family

print("Creating the DQC suite definition")

# ECFLOW home directory
ecflow_home='/data/joan/c3s512-wp1-datachecker/dqc_workflow/'

# ECFLOW definitions
defs = Defs(
    Suite('tasks',
          Edit(ECF_HOME=ecflow_home, ECF_INCLUDE=ecflow_home),
          Task("t1"), Task("t2"))
)

# ECFLOW create job
print("Checking job creation: .ecf -> .job0")
defs.check_job_creation()

print("Saving definition ...")
defs.save_as_defs("checker_workflow.def")

# We can assert, so that we only progress once job creation works
# assert len(defs.check_job_creation()) == 0, "Job generation failed"