Skip to content

Commit

Permalink
Adding an optional validation stage, that if it exists will be run be…
Browse files Browse the repository at this point in the history
…fore the main part of a stage
  • Loading branch information
empEvil committed Jul 15, 2024
1 parent f51c74b commit 0481d59
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ceci/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ 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"""
pass

def load_configs(self, args):
"""
Expand Down Expand Up @@ -661,6 +665,16 @@ 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:
print(f"Looks like there is an validation error in: {cls.name}")
print(error)
raise


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

0 comments on commit 0481d59

Please sign in to comment.