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

Running latest version doesn't work #46

Closed
stevemar opened this issue Sep 8, 2023 · 4 comments · Fixed by #47
Closed

Running latest version doesn't work #46

stevemar opened this issue Sep 8, 2023 · 4 comments · Fixed by #47

Comments

@stevemar
Copy link

stevemar commented Sep 8, 2023

Installing metal-python and running a simple import returns an error. The reason for this is that pydantic v2 is being pulled in and has backwards incompatible changes.

>>> import equinix_metal
/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/pydantic/_internal/_config.py:269: UserWarning: Valid config keys have changed in V2:
* 'allow_population_by_field_name' has been renamed to 'populate_by_name'
  warnings.warn(message, UserWarning)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/__init__.py", line 23, in <module>
    from equinix_metal.api.authentication_api import AuthenticationApi
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/api/__init__.py", line 6, in <module>
    from equinix_metal.api.authentication_api import AuthenticationApi
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/api/authentication_api.py", line 27, in <module>
    from equinix_metal.models.auth_token import AuthToken
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/models/__init__.py", line 53, in <module>
    from equinix_metal.models.create_device_request import CreateDeviceRequest
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/models/create_device_request.py", line 24, in <module>
    from equinix_metal.models.device_create_in_facility_input import DeviceCreateInFacilityInput
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/models/device_create_in_facility_input.py", line 25, in <module>
    from equinix_metal.models.facility_input_facility import FacilityInputFacility
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/models/facility_input_facility.py", line 29, in <module>
    class FacilityInputFacility(BaseModel):
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/equinix_metal/models/facility_input_facility.py", line 39, in FacilityInputFacility
    any_of_schemas: List[str] = Field(FACILITYINPUTFACILITY_ANY_OF_SCHEMAS, const=True)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smartinelli/src/myvenvvv/lib/python3.11/site-packages/pydantic/fields.py", line 757, in Field
    raise PydanticUserError('`const` is removed, use `Literal` instead', code='removed-kwargs')
pydantic.errors.PydanticUserError: `const` is removed, use `Literal` instead

For further information visit https://errors.pydantic.dev/2.3/u/removed-kwargs
>>> 
@ctreatma
Copy link
Contributor

ctreatma commented Sep 8, 2023

This was reported earlier as #44 as well. For now, the workaround is to limit pydantic to < 2 in the requirements file for a project that uses metal-python.

It looks like the fix that was mentioned in #44 has been merged and included in a generator release, so when this SDK is updated to use v7+ of openapi-generator, this issue will be resolved more directly: OpenAPITools/openapi-generator#15189

@t0mk
Copy link
Contributor

t0mk commented Sep 11, 2023

@stevemar Thanks for reporting.

@ctreatma I think it's time for update, both API spec and also Openapi gen. I'll do it in order 1. Openapi gen version, 2. API spec

@t0mk
Copy link
Contributor

t0mk commented Sep 15, 2023

@stevemar, we fixed and released. Can you please check if the issue si fixed with the latest equinix-metal from pip?

@stevemar
Copy link
Author

@t0mk LGTM

❯ pip install equinix-metal
Collecting equinix-metal
  Downloading equinix_metal-0.3.0-py3-none-any.whl (911 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 911.4/911.4 kB 9.5 MB/s eta 0:00:00
Collecting urllib3<2.1.0,>=1.25.3
  Using cached urllib3-2.0.4-py3-none-any.whl (123 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pydantic<2,>=1.10.5
  Using cached pydantic-1.10.12-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB)
Collecting aenum
  Using cached aenum-3.1.15-py3-none-any.whl (137 kB)
Collecting typing-extensions>=4.2.0
  Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting six>=1.5
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: aenum, urllib3, typing-extensions, six, python-dateutil, pydantic, equinix-metal
Successfully installed aenum-3.1.15 equinix-metal-0.3.0 pydantic-1.10.12 python-dateutil-2.8.2 six-1.16.0 typing-extensions-4.7.1 urllib3-2.0.4

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip

❯ python
Python 3.11.2 (main, Mar 13 2023, 03:34:04) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import equinix_metal
>>> 

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 a pull request may close this issue.

3 participants