Skip to content

Commit

Permalink
oarepo_model_builder.events..before_model_loaded and oarepo_model_bui…
Browse files Browse the repository at this point in the history
…lder.events.after_model_loaded entrypoints (#271)

Co-authored-by: Ronald Krist <[email protected]>
  • Loading branch information
SilvyPuzzlewell and Ronald Krist authored Sep 18, 2024
1 parent 3579c3e commit 676cac7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions oarepo_model_builder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ def run_internal(
x.split("=", maxsplit=1)[0]: x.split("=", maxsplit=1)[1] for x in includes
}

for entrypoint in load_entry_points_dict(
"oarepo_model_builder.events.before_model_loaded"
).values():
entrypoint(
model_filename=model_filename,
configs=configs,
sets=sets,
included_models=included_models,
includes=includes,
)

# load model (and resolve includes) and optionally save it before the processing (for debugging)
model = load_model(
model_filename,
Expand All @@ -202,6 +213,19 @@ def run_internal(
merged_models=included_models,
extra_included=includes,
)

for entrypoint in load_entry_points_dict(
"oarepo_model_builder.events.after_model_loaded"
).values():
entrypoint(
model=model,
model_filename=model_filename,
configs=configs,
sets=sets,
included_models=included_models,
includes=includes,
)

if save_model:
with open(save_model, "w") as f:
yaml.dump(json.loads(json.dumps(model.schema)), f)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-model-builder
version = 4.0.90
version = 4.0.91
description = A utility library that generates OARepo required data model files from a JSON specification file
authors = Miroslav Bauer <[email protected]>, Miroslav Simek <[email protected]>
readme = README.md
Expand Down

0 comments on commit 676cac7

Please sign in to comment.