FXC-3800 fix: improve validation 'run_only' field in component modelers #2922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Overview
Updated On: 2025-10-22 19:15:24 UTC
Greptile Summary
This PR adds validation for the
run_onlyfield in component modelers by checking for duplicate entries and verifying that all specified indices correspond to valid port/mode combinations. The implementation extracts matrix indices construction logic into a new abstract static method_construct_matrix_indices_monitorin the base class, which is then implemented by bothModalComponentModelerandTerminalComponentModeler. A pydantic validator_validate_run_onlyinAbstractComponentModeleruses this method to validate user-providedrun_onlyvalues during object construction, before cached properties are initialized. The refactoring maintains backward compatibility while enabling early error detection with clear error messages.Changed Files
_validate_run_onlyvalidator and abstract static method_construct_matrix_indices_monitorto enable validation ofrun_onlyfield for duplicate and invalid indices_construct_matrix_indices_monitorimplementing base class abstract method, delegated from cached propertymatrix_indices_monitorto use new static method_construct_matrix_indices_monitorthat handles bothLumpedPortandWavePorttypesrun_onlyuniqueness and membership constraints forModalComponentModelerrun_onlyvalidation for duplicates, invalid indices, andWavePortcompatibility inTerminalComponentModelerrun_onlyfield under "Added" categoryConfidence score: 4/5
@staticmethodand@abstractmethoddecorators in the validation contextSequence Diagram
sequenceDiagram participant User participant AbstractComponentModeler participant Validator participant HelperMethod User->>AbstractComponentModeler: Create/update modeler with run_only AbstractComponentModeler->>Validator: @pd.validator("run_only") alt run_only is None Validator->>AbstractComponentModeler: return val (skip validation) else run_only has value Validator->>Validator: Check for duplicates alt duplicates found Validator->>User: raise SetupError("duplicate entries") end Validator->>Validator: Get ports from values alt ports is None Validator->>AbstractComponentModeler: return val else ports exist Validator->>HelperMethod: _construct_matrix_indices_monitor(ports) HelperMethod->>Validator: return valid_indices set Validator->>Validator: Check membership of run_only indices alt invalid indices found Validator->>User: raise SetupError("not present in matrix_indices_monitor") else all indices valid Validator->>AbstractComponentModeler: return val end end end AbstractComponentModeler->>User: Validation completeContext used:
dashboard- Use changelog categories correctly: "Fixed" for bug fixes, "Changed" for modifications to existing f... (source)