Skip to main content
Question

Issue with client.iam.groups.list() in Python 3.12 (TypeError in Enum Action)

  • 23 September 2024
  • 2 replies
  • 30 views

zgchina
Committed
Forum|alt.badge.img

Hi all,

 

I am encountering an issue when calling the client.iam.groups.list(all=True) method in my Python 3.12 environment within Azure Batch. The code runs without issues in my local setup (also Python 3.12), but it fails in Azure Batch with the following traceback:

 

Traceback (most recent call last): File "GroupMembersCapabilities.py", line 55, in <module> groups = client.iam.groups.list(all=True) File "D:\Users\...\site-packages\cognite\client\_api\iam.py", line 297, in list return GroupList._load(res.json()["items"], cognite_client=self._cognite_client, allow_unknown=True) File "D:\Users\...\site-packages\cognite\client\data_classes\iam.py", line 224, in _load [cls._RESOURCE._load(res, cognite_client, allow_unknown) for res in resource_list] File "D:\Users\...\site-packages\cognite\client\data_classes\iam.py", line 147, in _load capabilities=[Capability.load(c, allow_unknown) for c in resource.get("capabilities", [])] or None File "D:\Users\...\site-packages\cognite\client\data_classes\capabilities.py", line 193, in load actions=[UnknownAcl.Action.load(act, allow_unknown) for act in data["actions"]] File "D:\Users\...\site-packages\cognite\client\data_classes\capabilities.py", line 106, in load return cls(action) File "C:\Python312\Lib\enum.py", line 748, in __call__ raise TypeError: <enum 'Action'> has no members; specify `names=()` if you meant to create a new, empty, enum

It seems like the issue lies with the Enum for Action not having members or being improperly loaded. I’ve confirmed that both my local environment and Azure Batch are using Python 3.12 and the cognite-sdk version is 7.62.1 in both environments.

Could you provide any guidance on why this is happening in Azure Batch but not locally, or if there’s a compatibility issue with Python 3.12 and cognite-sdk 7.62.1?

Thank you for your assistance!

2 replies

Forum|alt.badge.img

Hi and thanks for the SDK bug report!

I vaguely remember fixing this at the start of the year. Could you please double-check that you are in fact running on the latest SDK version in Azure Batch? The enum we instantiate, when given an unknown action, are given the type so I don’t think missing names can ever raise by looking at the source:

# from https://github.com/python/cpython/blob/3.12/Lib/enum.py
if names is _not_given and type is None:
  # no body? no data-type? possibly wrong usage
  raise TypeError(
    f"{cls} has no members; specify `names=()` if you meant to create a new, empty, enum")

Edit:

Can confirm this was fixed in 7.24.4, released at the end of February. Link to PR: https://github.com/cognitedata/cognite-sdk-python/pull/1647/files


Isha Thapliyal
Seasoned Practitioner
Forum|alt.badge.img+3
  • Seasoned Practitioner
  • 212 replies
  • September 25, 2024

Hi @zgchina ,

Could you please let us know if the issue was resolved by upgrading to the latest SDK version?

Thanks


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings