Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation step #113

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading