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

Update zocalo to pydantic 2 #255

Merged
merged 4 commits into from
Jul 19, 2024
Merged

Update zocalo to pydantic 2 #255

merged 4 commits into from
Jul 19, 2024

Conversation

ndevenish
Copy link
Contributor

  • Regenerate pydantic 1 models with latest datamodel-code-generator (so that we have a baseline to compare to)
  • Generate pydantic 2 models with latest datamodel-code-generator
  • Run bump-pydantic on RabbitMQ configurator models
  • Fix warnings, errors from running test on pydantic 2

The exact command/tool versions to regenerate models is included in the commit updating the models.

It has proven hard to reproduce the exact contents of the (automatically
generated) models.py. There seems to be differences in flags between
what is the documented way it was run vs the contents, the SLURM version,
and the fact that datamodel-code-generator output order does not seem
to be stable.

Thus, this is now regenerated with:

    datamodel-code-generator 0.25.8
    ripgrep

And the command:

    curl    -H "X-SLURM-USER-NAME: gda2" \
            -H "X-SLURM-USER-TOKEN: $(cat /dls_sw/apps/zocalo/secrets/slurmrest-gda2.tkn)" \
            https://slurm-rest.diamond.ac.uk:8443/openapi/v3 \
        | rg --passthru -N '((?:db)?v)0.0.(\d+)_' -r '${1}00$2.' \
        | datamodel-codegen --target-python-version=3.8 \
            --use-schema-description \
            --use-field-description \
            --output-model-type=pydantic.BaseModel \
            --field-constraints \
            --use-double-quotes \
            --output models \
        && cp models/v0040.py src/zocalo/util/slurm/models.py
Using:
    datamodel-code-generator 0.25.8
    ripgrep
    jq

And the command:

    curl    -H "X-SLURM-USER-NAME: gda2" \
            -H "X-SLURM-USER-TOKEN: $(cat /dls_sw/apps/zocalo/secrets/slurmrest-gda2.tkn)" \
            https://slurm-rest.diamond.ac.uk:8443/openapi/v3 \
        | rg --passthru -N '((?:db)?v)0.0.(\d+)_' -r '${1}00$2.' \
        | datamodel-codegen --target-python-version=3.8 \
            --use-schema-description \
            --use-field-description \
            --output-model-type=pydantic_v2.BaseModel \
            --field-constraints \
            --use-double-quotes \
            --output models \
        && cp models/v0040.py src/zocalo/util/slurm/models.py
@ndevenish ndevenish merged commit 82912eb into main Jul 19, 2024
8 checks passed
@ndevenish ndevenish deleted the pydantic2 branch July 19, 2024 08:25
@ndevenish ndevenish mentioned this pull request Jul 19, 2024
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.

1 participant