My Validator that checks existence of a file was unable to get recognized by atomate!

mainscript.py contains the following class i created and all other additional things that are needed to run…im just posting what is needed you to understand

class TrainFW(Firework):

    def __init__(self,  name = "flame train", flame_cmd = ">>flame_cmd<<",parents=None, **kwargs):

        t = []
        t.append(PyTask(func='pycode.write_train') # writes input files
        t.append(RunFlameCustodian(flame_cmd = flame_cmd)) # runs flame_cmd with defined handlers, validators
                 
        # t.append(RunFlameCustodian(flame_cmd = flame_cmd, validator_group = [FlameFilesValidator]))

        super().__init__(t, parents = parents, name = name, **kwargs)


fws = [TrainFW()]
wf = Workflow(fws)
                 
lpad = LaunchPad.auto_load()
lpad.add_wf(wf)
  1. Case 1 when i don’t use validator_group = [FlameFilesValidator] in class TrainFW(Firework)
    This shows that Jobs described in c = Custodian([], jobs, validators=validators) is working but not validators
    job runs successfully but state is fizzled and error is as follows

ERROR in atomate.erro file

Traceback (most recent call last):
  File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/rocket.py", line 262, in run
    m_action = t.run_task(my_spec)
  File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/atomate/atomate/vasp/firetasks/run_calc.py", line 107, in run_task
    c.run()
  File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/custodian/custodian/custodian.py", line 372, in run
    self._run_job(job_n, job)
  File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/custodian/custodian/custodian.py", line 501, in _run_job
    if v.check():
TypeError: check() missing 1 required positional argument: 'self'

#######################################################################
2) Case 2 when i use validator_group = [FlameFilesValidator] in class TrainFW(Firework)
code does not run at all…i.e if i uncomment that line and comment the immediate above line

ERROR while running on console

File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/launchpad.py", line 402, in add_wf
  reassign_all=reassign_all)
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/launchpad.py", line 1583, in _upsert_fws
  self.fireworks.insert_many((fw.to_db_dict() for fw in fws))
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/atomate_env/lib/python3.6/site-packages/pymongo/collection.py", line 757, in insert_many
  blk.ops = [doc for doc in gen()]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/atomate_env/lib/python3.6/site-packages/pymongo/collection.py", line 757, in <listcomp>
  blk.ops = [doc for doc in gen()]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/atomate_env/lib/python3.6/site-packages/pymongo/collection.py", line 747, in gen
  for document in documents:
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/launchpad.py", line 1583, in <genexpr>
  self.fireworks.insert_many((fw.to_db_dict() for fw in fws))
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/firework.py", line 312, in to_db_dict
  m_dict = self.to_dict()
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 142, in _decorator
  m_dict = func(self, *args, **kwargs)
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/firework.py", line 268, in to_dict
  spec['_tasks'] = [t.to_dict() for t in self.tasks]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/core/firework.py", line 268, in <listcomp>
  spec['_tasks'] = [t.to_dict() for t in self.tasks]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 171, in _decorator
  m_dict = func(self, *args, **kwargs)
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 143, in _decorator
  m_dict = recursive_dict(m_dict)
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 83, in recursive_dict
  for k, v in obj.items()}
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 83, in <dictcomp>
  for k, v in obj.items()}
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 86, in recursive_dict
  return [recursive_dict(v, preserve_unicode) for v in obj]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 86, in <listcomp>
  return [recursive_dict(v, preserve_unicode) for v in obj]
File "/scratch/hpc-prf-cbsc/ram/thesis/atomate_3.6/codes/fireworks/fireworks/utilities/fw_serializers.py", line 76, in recursive_dict
  return recursive_dict(obj.as_dict(), preserve_unicode)
TypeError: as_dict() missing 1 required positional argument: 'self'

and the code is running perfectly if i don’t have any handlers and validators

Validator – FlameFilesValidator – checks existince of flame_log.yaml file
Jobs—FlameJob-----runs flame_cmd (which is jus like vasp_cmd)
Firetask ----- RunFlameCustodian

Please check the details about these below

FIRETASK

@explicit_serialize
class RunFlameCustodian(FiretaskBase):

    required_params = ["flame_cmd"]
    optional_params = ["validator_group"]

    def run_task(self, fw_spec):

        validator_groups_dict = {"default": [FlameFilesValidator], "no_handler": []}
        
        # jus like vasp_cmd ...this is flame_cmd

        flame_cmd = env_chk(self["flame_cmd"], fw_spec)

        if isinstance(flame_cmd, str):
            flame_cmd = os.path.expandvars(flame_cmd)
            flame_cmd = shlex.split(flame_cmd)

        # construct jobs

        jobs = [FlameJob(flame_cmd = flame_cmd)]
            
        # construct validators
        validator_group = self.get("validator_group", "default")

        if isinstance(validator_group, str):
            validators = validator_groups_dict[validator_group]
        else:
            validators = validator_group

        c = Custodian([], jobs, validators=validators)

        c.run()

##############################################################################

JOB

class FlameJob(Job):
    """
    A basic flame job.
    """

    def __init__(self, flame_cmd, output_file="flame.out", stderr_file="std_err.txt"):

        self.flame_cmd = flame_cmd
        self.output_file = output_file
        self.stderr_file = stderr_file

    def setup(self):
        pass

    def run(self):
        """
        Perform the flame run.
        Returns:
            (subprocess.Popen) Used for monitoring.
        """
        cmd = self.flame_cmd
        logger.info("Running {}".format(" ".join(cmd)))
        with open(self.output_file, "w") as f_std, open(self.stderr_file, "w", buffering=1) as f_err:
            # use line buffering for stderr
            p = subprocess.Popen(cmd, stdout=f_std, stderr=f_err)
        return p

    def postprocess(self):
        pass

##############################################################################

Validator

class FlameFilesValidator(Validator):
    """
    Check for existence of 'flame_log.yaml' that flame
        normally create/s upon running.
    """

    def __init__(self):
        pass

    def check(self):
        for vfile in ["flame_log.yaml"]:
            if not os.path.exists(vfile):
                return True
        return False