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

Subclasses of dict (like Label) do not work with camel_case=False #1087

Open
haakonvt opened this issue Nov 21, 2022 · 4 comments
Open

Subclasses of dict (like Label) do not work with camel_case=False #1087

haakonvt opened this issue Nov 21, 2022 · 4 comments
Labels

Comments

@haakonvt
Copy link
Contributor

System information

  • Python Version: 3.8.13
  • SDK Version: 4.11.3

Describe the bug
Argument camel_case=False for multiple Cognite classes that subclass dict doesn't work because of declared properties with camelCase names, e.g. Label and ExtractionPipelineContact.

To Reproduce
Runnable code reproducing the error.

>>> from cognite.client.data_classes import Label
>>> ll = Label(external_id="what-the-fox")
>>> ll.dump(camel_case=False)
{'externalId': 'what-the-fox'}  # not snake cased
>>> ll.dump(camel_case=True)
{'externalId': 'what-the-fox'}

Or (notice sendNotification always in camel case):

>>> from cognite.client.data_classes import ExtractionPipelineContact
>>> epc = ExtractionPipelineContact(name="Fox", email="NA", role="Singer", send_notification=False)
>>> epc.dump(camel_case=False)
{'name': 'Fox', 'email': 'NA', 'role': 'Singer', 'sendNotification': False}
>>> epc.dump(camel_case=True)
{'name': 'Fox', 'email': 'NA', 'role': 'Singer', 'sendNotification': False}
@haakonvt haakonvt added the bug label Nov 21, 2022
@haakonvt
Copy link
Contributor Author

haakonvt commented Jan 9, 2023

List of affected:

  1. AggregateResult(dict)
  2. AggregateResultItem(dict)
  3. AssetAggregate(dict)
  4. BoundingBox3D(dict)
  5. DataSetAggregate(dict)
  6. EndTimeFilter(dict)
  7. ExtractionPipelineContact(dict)
  8. FileAggregate(dict)
  9. GeoLocation(dict)
  10. GeoLocationFilter(dict)
  11. Geometry(dict)
  12. GeometryFilter(dict)
  13. Label(dict)
  14. LabelFilter(dict, CogniteFilter)
  15. RevisionCameraProperties(dict)
  16. SequenceAggregate(dict)
  17. TimeSeriesAggregate(dict)
  18. TimestampRange(dict)

@haakonvt haakonvt changed the title Subclasses of dict (like Label) does not work with camel_case=False Subclasses of dict (like Label) do not work with camel_case=False Mar 3, 2023
@ddonukis
Copy link
Contributor

ddonukis commented Oct 5, 2023

I took a look at the affected classes. And only around a quarter of them have dump() method. As I understand, if the dump method is absent there is not thing to be done there.

@haakonvt
Copy link
Contributor Author

haakonvt commented Oct 5, 2023

I took a look at the affected classes. And only around a quarter of them have dump() method. As I understand, if the dump method is absent there is not thing to be done there.

Maybe these shouldn't have a dump method? Would be a nice investigation if we could just remove them

@haakonvt
Copy link
Contributor Author

To be solved by #1452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants