Skip to content

Commit

Permalink
Merge pull request #65 from qua-platform/fix_node_without_params_crea…
Browse files Browse the repository at this point in the history
…tion

Fix node run summary with default parameters class
  • Loading branch information
nulinspiratie authored Oct 11, 2024
2 parents ef4cb0f + 505939e commit c6580e5
Showing 1 changed file with 19 additions and 2 deletions.
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

0 comments on commit c6580e5

Please sign in to comment.