Skip to content

Ensure compatibilty with pydantic v1 #62

Description

@mdesmet

The main issue with using model_dump in Pydantic v1 is that this method doesn't exist in Pydantic v1. It was introduced in Pydantic v2 as part of the new serialization API.

The key evidence in your code:

1 src/datapilot/core/platforms/dbt/schemas/manifest.py uses BaseModel from Pydantic
2 Your Altimate* classes all inherit from BaseModel
3 In Pydantic v1, you should use .dict() or .json() for serialization instead
4 No indication of any compatibility layer for v1/v2 transitions

If the code attempts to call .model_dump() while running under Pydantic v1, it will raise:

AttributeError: 'AltimateManifestNode' object has no attribute 'model_dump'

💡 Recommendations if you need v1 compatibility:

1 Replace model_dump() with .dict())
2 Add version detection:

import pydantic                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
if pydantic.version.VERSION.startswith("1"):                                                                                                                                                                                                                                                                                                                                                                                                                                     
    return obj.dict()                                                                                                                                                                                                                                                                                                                                                                                                                                                            
else:                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    return obj.model_dump()                

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions