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

Fix node run summary with default parameters class #65

Merged
merged 1 commit into from
Oct 11, 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
21 changes: 19 additions & 2 deletions qualibrate/qualibration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import matplotlib
from matplotlib.rcsetup import interactive_bk
from pydantic import ValidationError
from pydantic import ValidationError, create_model

from qualibrate.models.outcome import Outcome
from qualibrate.models.run_mode import RunModes
Expand Down Expand Up @@ -154,7 +154,24 @@ def _validate_passed_parameters_options(
)
return parameters
if parameters_class is None:
return NodeCreateParametersType()
fields = {
name: copy(field)
for name, field in NodeParameters.model_fields.items()
}
# Create subclass of NodeParameters. It's needed because otherwise
# there will be an issue with type checking of subclasses.
# For example: NodeRunSummary.parameters
new_model = create_model( # type: ignore
NodeParameters.__name__,
__doc__=NodeParameters.__doc__,
__base__=NodeParameters,
__module__=NodeParameters.__module__,
**{
name: (info.annotation, info)
for name, info in fields.items()
},
)
return cast(NodeParameters, new_model())
logger.warning(
"parameters_class argument is deprecated. Please use "
f"parameters argument for initializing node '{name}'."
Expand Down