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 to supporting Pydantic V2 #203

Merged
merged 81 commits into from
Jan 22, 2024
Merged

Commits on Nov 4, 2023

  1. Configuration menu
    Copy the full SHA
    a6f3288 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2023

  1. Configuration menu
    Copy the full SHA
    4395ad4 View commit details
    Browse the repository at this point in the history
  2. Migrate to Pydantic 2.0 using bump-pydantic 0.7.0

    Note: bump-pydantic is still in beta
    candleindark committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    1decc23 View commit details
    Browse the repository at this point in the history

Commits on Nov 17, 2023

  1. Configuration menu
    Copy the full SHA
    14f742c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3b4ecf3 View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2023

  1. Remove DandiBaseModel.json_dict

    Replace its use with
    `pydantic.BaseModel.model_dump(mode='json', exclude_none=True)`
    candleindark committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    b211bfd View commit details
    Browse the repository at this point in the history
  2. Remove DandiBaseModel.unvalidated

    Its use can be replaced with `pydantic.BaseModel.model_construct`
    candleindark committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    b697d76 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2023

  1. Keep DandiBaseModel.json_dict()

    But mark it as deprecated
    candleindark committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    e0f75ce View commit details
    Browse the repository at this point in the history
  2. Keeping DandiBaseModel.unvalidated()

    But mark it as deprecated
    candleindark committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    92b5cb9 View commit details
    Browse the repository at this point in the history

Commits on Nov 30, 2023

  1. Configuration menu
    Copy the full SHA
    739db75 View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2023

  1. Configuration menu
    Copy the full SHA
    5528c3d View commit details
    Browse the repository at this point in the history
  2. Replace the use of BaseModel.json() with BaseModel.model_dump_json()

    Specifying the most compact separators to use in JSON
    serialization, `(",", ":")`, is no longer needed for
    they are the default separators to use for JSON serialization
    in Pydantic V2
    candleindark committed Dec 1, 2023
    Configuration menu
    Copy the full SHA
    ca3fff5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1d85790 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5616209 View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2023

  1. Configuration menu
    Copy the full SHA
    e1adfb1 View commit details
    Browse the repository at this point in the history
  2. Specify default of None for PropertyValue.value

    This is the implicit default in Pydantic V1
    candleindark committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    8c0e159 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c21f918 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3b5fa3a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    acef6e1 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c5b51bb View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7fcb9be View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b9604f5 View commit details
    Browse the repository at this point in the history

Commits on Dec 5, 2023

  1. Migrate the use of BaseModel.schema and BaseModel.schema_json to …

    …`BaseModel.model_json_schema`
    candleindark committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    14b0d16 View commit details
    Browse the repository at this point in the history

Commits on Dec 6, 2023

  1. Configuration menu
    Copy the full SHA
    fe85089 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1d8724f View commit details
    Browse the repository at this point in the history
  3. Correct typo in kwarg to Field

    `description` instead of `descriptions`
    candleindark committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    ba04133 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    97bf307 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5b2e6af View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2023

  1. Configuration menu
    Copy the full SHA
    6d95f7c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9668104 View commit details
    Browse the repository at this point in the history
  3. Update signatures and usage for post_process_json_schema

    This commit modifies method signatures for
     `post_process_json_schema` by adding an additional
      parameter `model`. This parameter is also used in
      the method bodies to set the 'title' if it does not
      exist in the schema. These modifications are needed
      because Pydantic V2 doesn't provide the `title` in
      the JSON schema until the very end.
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    57d9600 View commit details
    Browse the repository at this point in the history
  4. Update Pydantic Metaclass import path

    This commit changes the import path for Pydantic's
    ModelMetaclass. The old path,
    `pydantic.main.ModelMetaclass`, has been replaced by
    the new path,
    `pydantic._internal._model_construction.ModelMetaclass`.
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    16be659 View commit details
    Browse the repository at this point in the history
  5. Update tests to match new schema path for definitions

    The schema's definition path has changed, so this commit
    updates the testing assertions accordingly. The key
     "definitions" has been replaced with "$defs" in Pydantic V2
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    b6443ec View commit details
    Browse the repository at this point in the history
  6. Update pydantic ModelMetaclass references in tests

    The pydantic library's location for ModelMetaclass has
    changed, so the paths had to be updated in the tests.
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    496d431 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    a976015 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    64522a6 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ecd98ed View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    be176ab View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    6d945a9 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    fc423ae View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    d251dc5 View commit details
    Browse the repository at this point in the history
  14. Update dandischema/metadata.py

    Get outer type using `type.get_origin()` instead of by stringifying.
    
    Co-authored-by: John T. Wodder II <[email protected]>
    candleindark and jwodder authored Dec 8, 2023
    Configuration menu
    Copy the full SHA
    db55273 View commit details
    Browse the repository at this point in the history
  15. Update JSON serialization methods in zarr.py

    The update modifies the JSON serialization methods used
    in the ZarrChecksumListing class. The code now uses `json.dumps`
     instead of previously used `BaseModel.model_dump_json()`.
     These changes ensure JSON serializations are done in the most
     compact manner by specifying the separators explicitly instead
     of depending on the default behavior of 'BaseModel.model_dump_json()'.
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    439d07b View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    fc72189 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    ae9a09b View commit details
    Browse the repository at this point in the history
  18. Rename args in ByteSizeJsonSchema.__get_pydantic_json_schema__()

    The new names are more appropriate per the use of the arguments
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    0b14166 View commit details
    Browse the repository at this point in the history
  19. Replace logic for checking for Pydantic models in models.py

    Use `inspect.isclass` and `issubclass` instead of relying on
    internal metaclass
    candleindark committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    7808f87 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    e095ed7 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2023

  1. Configuration menu
    Copy the full SHA
    50ee928 View commit details
    Browse the repository at this point in the history

Commits on Dec 11, 2023

  1. Use BaseModel.__get_pydantic_json_schema__()

    to modify JSON schema
    
    Use `BaseModel.__get_pydantic_json_schema__()`
    to modify JSON schema instead of
    `BaseModel.model_config["json_schema_extra"]`.
    This allows the automatically generated `title`
    attribute to be available for modification.
    candleindark committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    82f802f View commit details
    Browse the repository at this point in the history
  2. Add JSON schema to Pydantic.ByteSize through annotation

    Adding JSON schema to `Pydantic.ByteSize`
    through annotation instead of subclassing
    allows objects of type `Pydantic.ByteSize`
    to assign to a `ByteSizeJsonSchema` attribute
    without static type checker complain
    candleindark committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    ab462ec View commit details
    Browse the repository at this point in the history
  3. Add JSON schema to Pydantic.ByteSize through annotation

    Adding JSON schema to `Pydantic.ByteSize`
    through annotation instead of subclassing
    allows objects of type `Pydantic.ByteSize`
    to assign to a `ByteSizeJsonSchema` attribute
    without static type checker complain
    candleindark committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    0d38117 View commit details
    Browse the repository at this point in the history

Commits on Dec 12, 2023

  1. Implement TransitionalGenerateJsonSchema

    This subclass can be used to overrides
    the default JSON schema generation to match
    that of the behavior of Pydantic V1.
    candleindark committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    2c9d9e3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ce49d6a View commit details
    Browse the repository at this point in the history
  3. Update test_asset_digest

    Update the test so that it is adjusted to
    the error representation in Pydantic V2
    candleindark committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    193b4a8 View commit details
    Browse the repository at this point in the history
  4. Update test_dantimeta_1

    Update the test so that it is adjusted to
    the error representation in Pydantic V2
    candleindark committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    545adb9 View commit details
    Browse the repository at this point in the history
  5. Update test_missing_ok

    Update the test so that it is adjusted to
    the error representation in Pydantic V2
    candleindark committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    328cefa View commit details
    Browse the repository at this point in the history
  6. Update metadata.validate

    Update `metadata.validate` so that it is
    adjusted to the error representation in
    Pydantic V2
    candleindark committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    00f0e91 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2023

  1. Disable type check for unpacking dict as kwargs

    Unpacking of a dict as kwargs doesn't play
    well with mypy. See the example below.
    ```
    import json
    
    ENCODING_KWARGS = {"separators": (",", ":")}
    
    d = {"a": 1, "b": 2}
    content = json.dumps(d, **ENCODING_KWARGS)
    ```
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    a23c521 View commit details
    Browse the repository at this point in the history
  2. Convert AnyHttpURL to a str

    URL types in Pydantic V2 are no longer a
    subclass of `str`. For uses that expect
    a `str`, conversion to `str` is needed.
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    d508645 View commit details
    Browse the repository at this point in the history
  3. Check for field.json_schema_extra being a dict

    `field.json_schema_extra` can be either `None` or a callable as well
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    e9579f3 View commit details
    Browse the repository at this point in the history
  4. Cast field.json_schema_extra["nskey"] to str

    The values of `field.json_schema_extra` can
    be one of many types
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    60c51ef View commit details
    Browse the repository at this point in the history
  5. ignore[call-arg] for calling BaseModel.model_construct()

    `BaseModel.model_construct()` is purposely
    defined for use without conforming to
    requirements specified in the model.
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    5733137 View commit details
    Browse the repository at this point in the history
  6. Correct type annotation

    For `expected_errors` in `test_dantimeta_1`
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    bbee1dc View commit details
    Browse the repository at this point in the history
  7. Correct type annotation

    Of `field.json_schema_extra` in
    `test_properties_mismatch()`
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    a0e043c View commit details
    Browse the repository at this point in the history
  8. Remove unreachable code block

    Remove unreachable code block in
    `test_duplicate_classes`. According to
    Satra, this block must be outdated.
    candleindark committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    9676268 View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2023

  1. Configuration menu
    Copy the full SHA
    1e5a224 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    41f5efc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1a707e6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2fcc005 View commit details
    Browse the repository at this point in the history

Commits on Dec 19, 2023

  1. Revert marking of @container using stringification

    This solution is kept for now so that context generator
    can maintain the same behavior
    candleindark committed Dec 19, 2023
    Configuration menu
    Copy the full SHA
    0c97b8e View commit details
    Browse the repository at this point in the history

Commits on Dec 21, 2023

  1. Configuration menu
    Copy the full SHA
    a104fb2 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2024

  1. Boost dandi schema version to 0.7.0 (since exported jsonschema does h…

    …ave incompatible changes)
    yarikoptic committed Jan 16, 2024
    Configuration menu
    Copy the full SHA
    bddffd8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e36e003 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    54315ae View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2024

  1. Remove unneeded code in TransitionalGenerateJsonSchema.nullable_schema

    The logic of the result is equivalent to
    the one before the modification
    candleindark committed Jan 18, 2024
    Configuration menu
    Copy the full SHA
    7eb7272 View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2024

  1. Remove stub for migration to schema 0.7.0

    There is no change in the data model
    because of the Pydantic upgrade to V2
    candleindark committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    51d4c53 View commit details
    Browse the repository at this point in the history
  2. Use JSON Schema validator for Draft 2020-12 in _validate_obj_json

    For dandi JSON schema 0.7.0 or above
    candleindark committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    b718dc2 View commit details
    Browse the repository at this point in the history
  3. Annotate two possible type of validator in _validate_obj_json

    So that mypy doesn't complain
    candleindark committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    2e97166 View commit details
    Browse the repository at this point in the history
  4. Change the current version of the generated schema to 0.6.5 instead

    0.6.5 is more sensible since the changes
    in the schema are not breaking changes,
    and there is no change in the models and
    the JSON serialization of these models
    candleindark committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    889c775 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. Configuration menu
    Copy the full SHA
    2d48a09 View commit details
    Browse the repository at this point in the history