-
Notifications
You must be signed in to change notification settings - Fork 27
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
Improve Cognite base classes #1151
Open
haakonvt
wants to merge
22
commits into
master
Choose a base branch
from
improve-base-cog-classes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
haakonvt
force-pushed
the
improve-base-cog-classes
branch
from
March 24, 2023 10:56
62d57c1
to
117e64a
Compare
haakonvt
force-pushed
the
improve-base-cog-classes
branch
2 times, most recently
from
April 5, 2023 10:04
2557697
to
9d22024
Compare
haakonvt
force-pushed
the
improve-base-cog-classes
branch
4 times, most recently
from
April 26, 2023 11:56
e6958a7
to
ba4a3f7
Compare
Codecov Report
@@ Coverage Diff @@
## master #1151 +/- ##
==========================================
+ Coverage 90.63% 90.89% +0.25%
==========================================
Files 82 82
Lines 9899 9906 +7
==========================================
+ Hits 8972 9004 +32
+ Misses 927 902 -25
|
haakonvt
force-pushed
the
improve-base-cog-classes
branch
3 times, most recently
from
April 27, 2023 13:25
4bdaba2
to
c68fc9a
Compare
- remove _load from filter classes. mypy stuff - refactor all cognite base classes - isort + fix auto merge error - remove recursive _load method (from json string) - Improve exception message of CogniteMissingClientError - remove EXCLUDE_VALUE in favor of None check
haakonvt
force-pushed
the
improve-base-cog-classes
branch
from
April 28, 2023 13:50
450cab9
to
babe328
Compare
haakonvt
changed the title
Draft: Improve base cognite classes
Improve Cognite base classes
Apr 28, 2023
This was referenced Sep 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
New faster implementation for
_cognite_client
private attr:__new__
implementation for a 2X object instantiation speed up.__new__
removed, subclasses ofCogniteResource
no longer have an implicit__init__
that just swallows allargs
and allkwargs
.__getattribute__
implementation (extra hook before regular attribute lookup). This change adds a speed up to all attribute accesses._cognite_client
as a simple property (see class_WithClientMixin
) with a setter method that guarantees a valid value (Optional[CogniteClient]
) and a getter that raisesCogniteMissingClientError
in all cases except where the attribute is an instance ofCogniteClient
.New faster
_load
implementationif hasattr -> setattr
implementation that calledto_snake_case
O(N*M)
times (N
dicts,M
elements per dict).fast_dict_load
function, which usesget_accepted_params
that caches the accepted parameters for each class it receives, returning a dict that mapscamelCase
tosnake_case
for very efficient API response translation into our data classes.New hierarchy to avoid code duplication
CogniteBase
class with__str__
,__repr__
,__eq__
anddump
methods.CogniteBaseList
class which...UserList
.id
andexternal_id
that keeps a reference to elements after deletion from the list.CogniteResponseList
(note not Resource)Other changes / optimizations:
_load
methods now forcecognite_client
to be passed as these are "only" used by the SDK. This allows better visibility into all the different classes that do not use it (and could be moved to a different parent class without the client in the future).mypy
now better understands the code base. This has resulted in 100+ issues that have been changed or fixed.CogniteMissingClientError
has been improved.TestVerifyAllCogniteSubclasses
).CogniteResponse
no longer acceptscognite_client
.CogniteFilter
and subclasses had many unused_load
functions that have been removed (these are never instantiated by the SDK, as opposed to most other resource classes).EXCLUDE_VALUE
in favor of a simpleNone
-check (was list search with one element). YAGNI 😄