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(): add update mechanism for input cache #626

Merged

Conversation

benflexcompute
Copy link
Collaborator

No description provided.

@@ -202,19 +202,20 @@ class GenericReferenceCondition(MultiConstructorBaseModel):
====
"""

private_attribute_input_cache: GenericReferenceConditionCache = GenericReferenceConditionCache()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does it impact type hints? I think IDE will list the options in order of definition, thus private_... and type_name should be last?

Copy link
Collaborator Author

@benflexcompute benflexcompute Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. input_cache will become the first in type hint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the ordering of private_attribute_input_cache to make type hint a bit cleaner.

Comment on lines 266 to 267
# private_attribute_input_cache has to be defined first for field validators to work.
private_attribute_input_cache: BoxCache = pd.Field(BoxCache(), frozen=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, interesting. Question how we can modify type hints..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I just tested and it seems that even though fields are validated by definition ordering but it is still accessible and has definition (None).

I thought it is like C++ where you reference an uninitialized pointer.

reference: https://docs.pydantic.dev/latest/concepts/validators/#field-validators:~:text=Validation%20is%20done%20in%20the%20order%20fields%20are%20defined%2C%20so%20you%20have%20to%20be%20careful%20when%20using%20ValidationInfo.data%20to%20not%20access%20a%20field%20that%20has%20not%20yet%20been%20validated/populated

@benflexcompute benflexcompute merged commit 34caad1 into release-candidate/24.11 Dec 16, 2024
15 checks passed
@benflexcompute benflexcompute deleted the BenY/AddSupportOfChangingMCMFields branch December 16, 2024 23:54
benflexcompute added a commit that referenced this pull request Dec 16, 2024
* fix(): add update mechanism for input cache

* More unit tests

* Fix unit test

* Refactor to reduce number of validators

* Reverted placement of private_attribute_input_cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants