Skip to content

Commit

Permalink
Enable invalidating stored calculators in runner (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-nml authored Jun 28, 2023
1 parent 352191a commit 5560a10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions nannyml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class StoreConfig(BaseModel):
path: str
credentials: Optional[Dict[str, Any]]
filename: Optional[str]
invalidate: bool = False


class CalculatorConfig(BaseModel):
Expand Down
9 changes: 7 additions & 2 deletions nannyml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ def run( # noqa: C901
f"[{context.current_step}/{context.total_steps}] '{context.current_calculator}': "
f"loading calculator from store"
)
calc = store.load(filename=calculator_config.store.filename, as_type=calc_cls)
if calculator_config.store.invalidate:
calc = None
else:
calc = store.load(filename=calculator_config.store.filename, as_type=calc_cls)

if calc is None:
reason = 'invalidated' if calculator_config.store.invalidate else 'not found in store'
run_logger.log(
f"calculator '{context.current_calculator}' not found in store. "
f"calculator '{context.current_calculator}' {reason}. "
f"Creating, fitting and storing new instance",
log_level=logging.DEBUG,
)
Expand Down

0 comments on commit 5560a10

Please sign in to comment.