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

feature/fix listyness for computed fields #230

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

cutoffthetop
Copy link
Contributor

@cutoffthetop cutoffthetop commented Jul 19, 2024

PR Context

This unblocks the upgrade of mex-backend's mex-common dependency past 0.29.0.

It allows the follow snipped to run without errors:

class Computer(BaseModel):
    @computed_field
    def cpus(self) -> int:
        return 4

c = Computer.model_validate({"cpus": [4]})

This is needed by the backend because all relationship fields (which includes the computed stableTargetId field) are collected as lists of ids from the graph. And a model could not be validated after fetching, if the listyness was not corrected-for.

Fixed

  • add missing listyness-fix support for computed-fields

Copy link
Contributor

@mr-kamran-ali mr-kamran-ali left a comment

Choose a reason for hiding this comment

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

Good to go. 🚀

@cutoffthetop cutoffthetop merged commit ec11c92 into main Jul 23, 2024
7 checks passed
@cutoffthetop cutoffthetop deleted the feature/computed-field-listyness-fix branch July 23, 2024 13:54
mr-kamran-ali pushed a commit to robert-koch-institut/mex-backend that referenced this pull request Jul 24, 2024
# PR Context
- uses robert-koch-institut/mex-common#230

# Added
- add support for computed fields in graph queries

# Changes

- BREAKING: make `MEX_EXTRACTED_PRIMARY_SOURCE` an instance of its own
class
instead of ExtractedPrimarySource in order to set static provenance
identifiers
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