Skip to content

Python import: DataAugmentationUtils -- pydantic errors #2367

Open
@siboles

Description

@siboles

Description

Importing DataAugmentationUtils raises a TypeError with classes inheriting from ApiModel. I was able to resolve the issue, but posting here in case others have the same problem.

Details

Release: v6.5.1
OS: PopOS 22.04

To Reproduce Error

import DataAugmentationUtils

Error Trace

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/DataAugmentationUtils/__init__.py", line 1, in <module>
    from DataAugmentationUtils import DataAugmentation
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/DataAugmentationUtils/DataAugmentation.py", line 6, in <module>
    from DataAugmentationUtils import Utils
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/DataAugmentationUtils/Utils.py", line 1, in <module>
    import shapeworks as sw
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/shapeworks/__init__.py", line 13, in <module>
    from .portal import download_dataset
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/shapeworks/portal.py", line 16, in <module>
    from swcc.models import Dataset
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/swcc/models/__init__.py", line 2, in <module>
    from .other_models import (
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/site-packages/swcc/models/other_models.py", line 19, in <module>
    class Segmentation(ApiModel):
  File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
  File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 751, in pydantic.fields.ModelField._type_analysis
  File "pydantic/fields.py", line 808, in pydantic.fields.ModelField._create_sub_type
  File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
  File "/home/scotts/miniforge3/envs/shapeworks/lib/python3.9/typing.py", line 852, in __subclasscheck__
    return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class

My Fix

Updating pydantic from 1.10.7 (from release python_requirements.txt) to 1.10.13 seems to resolve the issue.

conda activate shapeworks
pip install pydantic==1.10.13

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