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

fix: checkpointlogger: use enum declaration order instead of value order #156

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

matt-codecov
Copy link
Contributor

i made a sloppy mistake. i treated BaseFlow subclass values as if they were sorted by declaration order, but they're just strings and they're sorted lexicographically. example:

class Foo(BaseFlow):
    PROCESSING_BEGIN = auto()
    INITIAL_PROCESSING_COMPLETE = auto()

assert Foo.PROCESSING_BEGIN < Foo.INITIAL_PROCESSING_COMPLETE

PROCESSING_BEGIN is declared before INITIAL_PROCESSING_COMPLETE, so i want PROCESSING_BEGIN < INITIAL_PROCESSING_COMPLETE to be true. but with lexicographic order, "I" is before "P" so it's flipped.

Foo._member_names_ remembers the declaration order and we can fix the bug by overriding __eq__() and friends to make them compare based on declaration order.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-qa
Copy link

codecov-qa bot commented Oct 23, 2023

Codecov Report

Merging #156 (b7ac091) into main (01fd3cd) will decrease coverage by 0.01%.
The diff coverage is 93.75%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   98.43%   98.43%   -0.01%     
==========================================
  Files         348      348              
  Lines       27375    27401      +26     
==========================================
+ Hits        26947    26971      +24     
- Misses        428      430       +2     
Flag Coverage Δ
integration 98.43% <93.75%> (-0.01%) ⬇️
latest-uploader-overall 98.43% <93.75%> (-0.01%) ⬇️
unit 98.43% <93.75%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 96.96% <88.23%> (-0.02%) ⬇️
OutsideTasks 98.22% <93.75%> (-0.01%) ⬇️
Files Coverage Δ
helpers/tests/unit/test_checkpoint_logger.py 100.00% <100.00%> (ø)
helpers/checkpoint_logger/__init__.py 96.79% <88.23%> (-1.10%) ⬇️

@codecov-public-qa
Copy link

codecov-public-qa bot commented Oct 23, 2023

Codecov Report

Merging #156 (b7ac091) into main (01fd3cd) will decrease coverage by 0.01%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   98.43%   98.43%   -0.01%     
==========================================
  Files         348      348              
  Lines       27375    27401      +26     
==========================================
+ Hits        26947    26971      +24     
- Misses        428      430       +2     
Flag Coverage Δ
integration 98.43% <93.75%> (-0.01%) ⬇️
latest-uploader-overall 98.43% <93.75%> (-0.01%) ⬇️
unit 98.43% <93.75%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 96.96% <88.23%> (-0.02%) ⬇️
OutsideTasks 98.22% <93.75%> (-0.01%) ⬇️
Files Coverage Δ
helpers/tests/unit/test_checkpoint_logger.py 100.00% <100.00%> (ø)
helpers/checkpoint_logger/__init__.py 96.79% <88.23%> (-1.10%) ⬇️

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #156 (b7ac091) into main (01fd3cd) will decrease coverage by 0.01%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   98.39%   98.39%   -0.01%     
==========================================
  Files         374      374              
  Lines       27871    27897      +26     
==========================================
+ Hits        27424    27448      +24     
- Misses        447      449       +2     
Flag Coverage Δ
integration 98.43% <93.75%> (-0.01%) ⬇️
latest-uploader-overall 98.43% <93.75%> (-0.01%) ⬇️
unit 98.43% <93.75%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 96.86% <88.23%> (-0.02%) ⬇️
OutsideTasks 98.22% <93.75%> (-0.01%) ⬇️
Files Coverage Δ
helpers/tests/unit/test_checkpoint_logger.py 100.00% <100.00%> (ø)
helpers/checkpoint_logger/__init__.py 96.83% <88.23%> (-1.09%) ⬇️

This change has been scanned for critical changes. Learn more

Copy link
Contributor

@scott-codecov scott-codecov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I wonder if just using integer enum values would be overall a bit simpler than auto() and relying on definition order.

helpers/checkpoint_logger/__init__.py Show resolved Hide resolved
@matt-codecov
Copy link
Contributor Author

matt-codecov commented Oct 23, 2023

@scott-codecov i'm not sure if we can have MyEnum.FOO.value == 1 and also have the MyEnum.FOO json serialization which helps validate checkpoints data that gets passed between tasks. but yes, a lot of the code is just for validation so if we are comfortable without the safety bumpers it could be much simpler. if this isn't the last of the bugs i'll probably start ripping stuff out

@matt-codecov matt-codecov merged commit c3f93c4 into main Oct 23, 2023
12 of 25 checks passed
@matt-codecov matt-codecov deleted the matt/another-checkpoint-bugfix branch October 23, 2023 21:52
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 this pull request may close these issues.

2 participants