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

Send labels to Codecov only after collecting them #191

Merged
merged 1 commit into from
Jul 14, 2023

Conversation

giovanni-guidini
Copy link
Contributor

@giovanni-guidini giovanni-guidini commented Jul 6, 2023

These changes alter the way label analysis command works by making 2 requests to Codecov instead of 1.

Why would we want to do this, if it's more time to make a second request?
Because it takes (usually) longer to collect the labels than it takes to make a second request.
Specially for bigger repos, collecting the labels can take dozens of seconds.
By making the label collection parallel with the labels processing we can speed up the total ATS time.

We still PATCH the labels in case the worker hasn't finished the calculations, and it will
correctly refresh the request labels from the DB (based on here).
However even if it misses the requested labels we recalculate the absent_labels, if needed (_potentially_calculate_absent_labels).

So we still guarantee the exact same response everytime. Potentially faster.

PS.: The file test_instantiation.py changes because of the linter

@giovanni-guidini
Copy link
Contributor Author

We can still make this behavior optional by adding some flag to enable/disable it.
It gives customers more option to fine-tune their CLI process.

@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #191 (6b548fe) into master (9d671c5) will increase coverage by 0.08%.
The diff coverage is 93.02%.

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
+ Coverage   95.67%   95.76%   +0.08%     
==========================================
  Files          70       70              
  Lines        2475     2500      +25     
==========================================
+ Hits         2368     2394      +26     
+ Misses        107      106       -1     
Flag Coverage Δ
python3.10 95.76% <93.02%> (+0.08%) ⬆️
python3.7 95.75% <93.02%> (+0.08%) ⬆️
python3.8 95.76% <93.02%> (+0.08%) ⬆️
python3.9 95.76% <93.02%> (+0.08%) ⬆️

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

Impacted Files Coverage Δ
codecov_cli/commands/labelanalysis.py 95.72% <93.02%> (+2.24%) ⬆️

else:
# Initial request with no labels failed
# Retry it
eid = _send_labelanalysis_request(payload, url, token_header)
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that we patch labels in the first trial, but we don't do that if the first one failed and we retried?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. If the first request failed, then Codecov haven't started the label analysis task yet. So instead of simply patching the labels we need to send that POST request again. Since we already have the labels at this point we can send them in the request, like it was done before.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah got it!

These changes alter the way label analysis command works by making 2 requests to Codecov instead of 1.

Why would we want to do this, if it's more time to make a second request?
Because it takes (usually) longer to collect the labels than it takes to make a second request.
Specially for bigger repos, collecting the labels can take dozens of seconds.
By making the label collection parallel with the labels processing we can speed up the total ATS time.

We still PATCH the labels in case the worker hasn't finished the calculations, and it will
correctly refresh the request labels from the DB (based on [here](https://github.com/codecov/worker/pull/1210)).
However even if it misses the requested labels we recalculate the `absent_labels`, if needed (`_potentially_calculate_absent_labels`).

So we still guarantee the exact same response everytime. Potentially faster.

PS.: The file `test_instantiation.py` changes because of the linter
@giovanni-guidini giovanni-guidini merged commit 25da9d9 into master Jul 14, 2023
@giovanni-guidini giovanni-guidini deleted the gio/change-label-analysis branch July 14, 2023 12:55
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