Skip to content

Commit

Permalink
Merge pull request #113 from LSSTDESC/Validation
Browse files Browse the repository at this point in the history
Validation step
  • Loading branch information
joezuntz authored Aug 10, 2024
2 parents f51c74b + 8a5a6ed commit a3f65f8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ceci/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ def get_aliased_tag(self, tag):
def run(self): # pragma: no cover
"""Run the stage and return the execution status"""
raise NotImplementedError("run")

def validate(self):
"""Check that the inputs actually have the data needed for execution,
This is called before the run method. It is an optional stage, meant
for checking that the input to the stage is actual in the form and
shape needed before an expensive run is executed."""
pass

def load_configs(self, args):
"""
Expand Down Expand Up @@ -661,6 +668,18 @@ def execute(cls, args, comm=None):
if args.memmon: # pragma: no cover
monitor = MemoryMonitor.start_in_thread(interval=args.memmon)

# Now we try to see if the validation step has been changed,
# if it has then we will run the validation step, and raise any errors
try:
stage.validate()
except Exception as error:
if stage.rank==0:
print(f"Looks like there is an validation error in: {cls.name}",
"the input data for this stage did not pass the checks implemented on it.")
print(error)
raise


try:
stage.run()
except Exception as error: # pragma: no cover
Expand Down

0 comments on commit a3f65f8

Please sign in to comment.