Conversation
| module: Literal["flepimop2.system.wrapper"] = "flepimop2.system.wrapper" | ||
| state_change: StateChangeEnum | ||
| script: Path | ||
| options: dict[str, Any] | None = None |
There was a problem hiding this comment.
goes because inherited and not actually overridden
| expected_type = annotations[key] | ||
| try: | ||
| casted_value = expected_type(value) | ||
| combined_params[key] = casted_value | ||
| except (ValueError, TypeError) as e: | ||
| msg = ( | ||
| f"Parameter '{key}' (type {type(value).__name__}) could not be " | ||
| f"cast to {expected_type.__name__}. Error: {str(e)}" | ||
| ) | ||
| validation_errors.append(ValidationIssue(msg, "binding_values")) |
There was a problem hiding this comment.
This seems fine for now, but will quickly be obsoleted if we want to support parameters with shape. This gets a lot trickier to manage without a dedicated RealizedParameter class that contains information about the values and shape. Perhaps should expedite the axes development.
There was a problem hiding this comment.
i think we can treat validating conforming shape as a next level check, that we want to do but don't yet
| A stepper from this System with static parameters defined. | ||
|
|
||
| Raises: | ||
| ValueError: If params contains "time" or "state" keys or if value types |
There was a problem hiding this comment.
Flepimop2ValidationError?
| # Combine params and kwargs, with kwargs taking precedence | ||
| combined_params = {**params, **kwargs} | ||
|
|
||
| forbidden_keys = {"time", "state"} |
There was a problem hiding this comment.
Might be good to extract out to a constant?
| if validation_errors: | ||
| raise Flepimop2ValidationError(validation_errors) | ||
|
|
||
| return functools.partial(self._stepper, **combined_params) |
There was a problem hiding this comment.
There is a bit of a pro/con trade off returning SystemProtocol vs Self. Pro is this is more simple, but the con is that you loose the extra information that the system provides, so even with binding you still need to keep the system object around on the user side.
There was a problem hiding this comment.
i anticipate we'll need to figure out returning Self, but I suspect that would also impose that as a module developer requirement vs being able to do it generically here.
Uh oh!
There was an error while loading. Please reload this page.