Infisical / sdk

Infisical cross-language SDK
https://infisical.com
Other
22 stars 3 forks source link

Unable to use python SDK #20

Closed CodeWithOz closed 4 months ago

CodeWithOz commented 4 months ago

Hi, I'm unable to use the python sdk because I can't import the necessary classes. Here's the basic code I'm using to test this:

import os
# from infisical import ClientSettings
from infisical_client import InfisicalClient, ClientSettings

client = InfisicalClient(ClientSettings(
    client_id=os.environ.get("INFISICAL_CLIENT_ID"),
    client_secret=os.environ.get("INFISICAL_CLIENT_SECRET"),
))

test_api_key = client.createSecret(
    secret_name="TEST_API_KEY",
    secret_value="test api key",
    project_id="local-test",
    environment="dev",
)

print(f"test api key is: {test_api_key}")

Running this code generates this error:

Traceback (most recent call last):
  File "/path/to/my/project/infisical.py", line 3, in <module>
    from infisical_client import InfisicalClient, ClientSettings
  File "/path/to/my/project/.venv/lib/python3.9/site-packages/infisical_client/__init__.py", line 3, in <module>
    from .infisical_client import InfisicalClient as InfisicalClient
  File "/path/to/my/project/.venv/lib/python3.9/site-packages/infisical_client/infisical_client.py", line 3, in <module>
    from .schemas import ClientSettings, Command, SecretElement
ModuleNotFoundError: No module named 'infisical_client.schemas'

Note that the import statements I used are from your current documentation. So I changed the import statements to the following:

from infisical import ClientSettings
from infisical_client import InfisicalClient

Using those imports, the error became the following:

Traceback (most recent call last):
  File "/path/to/my/project/infisical.py", line 2, in <module>
    from infisical import ClientSettings
  File "/path/to/my/project/infisical.py", line 2, in <module>
    from infisical import ClientSettings
ImportError: cannot import name 'ClientSettings' from partially initialized module 'infisical' (most likely due to a circular import) (/path/to/my/project/infisical.py)

Lastly, I changed the import statements again to the following:

from infisical import ClientSettings, InfisicalClient

And the error message remained the same:

Traceback (most recent call last):
  File "/path/to/my/project/infisical.py", line 2, in <module>
    from infisical import ClientSettings, InfisicalClient
  File "/path/to/my/project/infisical.py", line 2, in <module>
    from infisical import ClientSettings, InfisicalClient
ImportError: cannot import name 'ClientSettings' from partially initialized module 'infisical' (most likely due to a circular import) (/path/to/my/project/infisical.py)

I got these errors using both v2.0.6 and v2.0.7 of the SDK.


DanielHougaard commented 4 months ago

Hi @CodeWithOz, a new update has just been released (2.1.2). This should solve the schemas issue, and an issue with the python process sometimes hanging on errors. Thank you for reporting this!