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

feat: add backfill one off scripts #734

Merged
merged 7 commits into from
Oct 1, 2024
Merged

Conversation

joseph-sentry
Copy link
Contributor

these are one off python scripts to be run directly that will modify the database

the first backfills the daily test rollups starting on a given day, and ending on a given date, starting for a given repo (it will backfill in repo id order)

the second backfills the TestFlagBridge objects for all repos with the option to focus on a given repo, specified by repoid

@codecov-notifications
Copy link

codecov-notifications bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 89.09953% with 23 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
one_off_scripts/backfill_daily_test_rollups.py 87.12% 13 Missing ⚠️
one_off_script.py 0.00% 9 Missing ⚠️
one_off_scripts/backfill_test_flag_bridges.py 96.29% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
- Coverage   98.09%   98.02%   -0.07%     
==========================================
  Files         432      438       +6     
  Lines       36325    36283      -42     
==========================================
- Hits        35632    35566      -66     
- Misses        693      717      +24     
Flag Coverage Δ
integration 98.02% <89.09%> (-0.07%) ⬇️
unit 98.02% <89.09%> (-0.07%) ⬇️

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

Components Coverage Δ
NonTestCode 95.87% <83.68%> (-0.16%) ⬇️
OutsideTasks 98.03% <89.09%> (-0.10%) ⬇️
Files with missing lines Coverage Δ
one_off_scripts/__init__.py 100.00% <100.00%> (ø)
..._scripts/tests/test_backfill_daily_test_rollups.py 100.00% <100.00%> (ø)
...f_scripts/tests/test_backfill_test_flag_bridges.py 100.00% <100.00%> (ø)
one_off_scripts/backfill_test_flag_bridges.py 96.29% <96.29%> (ø)
one_off_script.py 0.00% <0.00%> (ø)
one_off_scripts/backfill_daily_test_rollups.py 87.12% <87.12%> (ø)

... and 21 files with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 89.09953% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.02%. Comparing base (85f3174) to head (e00f450).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
one_off_scripts/backfill_daily_test_rollups.py 87.12% 13 Missing ⚠️
one_off_script.py 0.00% 9 Missing ⚠️
one_off_scripts/backfill_test_flag_bridges.py 96.29% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
- Coverage   98.09%   98.02%   -0.07%     
==========================================
  Files         432      438       +6     
  Lines       36325    36283      -42     
==========================================
- Hits        35632    35566      -66     
- Misses        693      717      +24     
Flag Coverage Δ
integration 98.02% <89.09%> (-0.07%) ⬇️
unit 98.02% <89.09%> (-0.07%) ⬇️

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

Components Coverage Δ
NonTestCode 95.87% <83.68%> (-0.16%) ⬇️
OutsideTasks 98.03% <89.09%> (-0.10%) ⬇️
Files with missing lines Coverage Δ
one_off_scripts/__init__.py 100.00% <100.00%> (ø)
..._scripts/tests/test_backfill_daily_test_rollups.py 100.00% <100.00%> (ø)
...f_scripts/tests/test_backfill_test_flag_bridges.py 100.00% <100.00%> (ø)
one_off_scripts/backfill_test_flag_bridges.py 96.29% <96.29%> (ø)
one_off_script.py 0.00% <0.00%> (ø)
one_off_scripts/backfill_daily_test_rollups.py 87.12% <87.12%> (ø)

... and 21 files with indirect coverage changes

Copy link

codecov-public-qa bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 89.09953% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.02%. Comparing base (85f3174) to head (e00f450).
Report is 6 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
- Coverage   98.09%   98.02%   -0.07%     
==========================================
  Files         432      438       +6     
  Lines       36325    36283      -42     
==========================================
- Hits        35632    35566      -66     
- Misses        693      717      +24     
Flag Coverage Δ
integration 98.02% <89.09%> (-0.07%) ⬇️
unit 98.02% <89.09%> (-0.07%) ⬇️

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

Components Coverage Δ
NonTestCode 95.87% <83.68%> (-0.16%) ⬇️
OutsideTasks 98.03% <89.09%> (-0.10%) ⬇️
Files Coverage Δ
one_off_scripts/__init__.py 100.00% <100.00%> (ø)
..._scripts/tests/test_backfill_daily_test_rollups.py 100.00% <100.00%> (ø)
...f_scripts/tests/test_backfill_test_flag_bridges.py 100.00% <100.00%> (ø)
one_off_scripts/backfill_test_flag_bridges.py 96.29% <96.29%> (ø)
one_off_script.py 0.00% <0.00%> (ø)
one_off_scripts/backfill_daily_test_rollups.py 87.12% <87.12%> (ø)

... and 21 files with indirect coverage changes

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 89.09953% with 23 lines in your changes missing coverage. Please review.

Project coverage is 98.02%. Comparing base (85f3174) to head (e00f450).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
one_off_scripts/backfill_daily_test_rollups.py 87.12% 13 Missing ⚠️
one_off_script.py 0.00% 9 Missing ⚠️
one_off_scripts/backfill_test_flag_bridges.py 96.29% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #734      +/-   ##
==========================================
- Coverage   98.09%   98.02%   -0.07%     
==========================================
  Files         432      438       +6     
  Lines       36325    36283      -42     
==========================================
- Hits        35632    35566      -66     
- Misses        693      717      +24     
Flag Coverage Δ
integration 98.02% <89.09%> (-0.07%) ⬇️
unit 98.02% <89.09%> (-0.07%) ⬇️

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

Components Coverage Δ
NonTestCode 95.87% <83.68%> (-0.16%) ⬇️
OutsideTasks 98.03% <89.09%> (-0.10%) ⬇️
Files with missing lines Coverage Δ
one_off_scripts/__init__.py 100.00% <100.00%> (ø)
..._scripts/tests/test_backfill_daily_test_rollups.py 100.00% <100.00%> (ø)
...f_scripts/tests/test_backfill_test_flag_bridges.py 100.00% <100.00%> (ø)
one_off_scripts/backfill_test_flag_bridges.py 96.29% <96.29%> (ø)
one_off_script.py 0.00% <0.00%> (ø)
one_off_scripts/backfill_daily_test_rollups.py 87.12% <87.12%> (ø)

... and 21 files with indirect coverage changes

Comment on lines +5 to +6
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_scaffold.settings")
django.setup()
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason this is duplicated from the main script? does this actually run twice when you import one of the child scripts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These scripts are meant to be run separately from the actual application running on a pod so we'd invoke it directly using python one_off_script.py and that means we have to setup django separately

one_off_scripts/backfill_daily_test_rollups.py Outdated Show resolved Hide resolved
one_off_scripts/backfill_daily_test_rollups.py Outdated Show resolved Hide resolved
one_off_scripts/backfill_daily_test_rollups.py Outdated Show resolved Hide resolved
one_off_scripts/backfill_test_flag_bridges.py Outdated Show resolved Hide resolved
one_off_scripts/backfill_test_flag_bridges.py Outdated Show resolved Hide resolved
Comment on lines 34 to 41
try:
first_test_instance = TestInstance.objects.filter(
test_id=test.id
).select_related("upload")[0]
except IndexError:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

The first method might be an alternative here, it even mentions it being the same pattern in its doc example.

these are one off python scripts to be run directly that will
modify the database

the first backfills the daily test rollups starting on a given day,
and ending on a given date, starting for a given repo (it will
backfill in repo id order)

the second backfills the TestFlagBridge objects for all repos with the
option to focus on a given repo, specified by repoid
first_test_instance = (
TestInstance.objects.filter(test_id=test.id)
.select_related("upload")
.first()
Copy link
Contributor

Choose a reason for hiding this comment

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

my comment might have been confusing. I believe first returns None if the element does not exist instead of the IndexError.

@joseph-sentry joseph-sentry force-pushed the joseph/backfill-rollups branch from e795f6d to 66a56d1 Compare October 1, 2024 17:43
Copy link

github-actions bot commented Oct 1, 2024

This PR includes changes to shared. Please review them here: codecov/shared@106b0ae...36791fe

@joseph-sentry joseph-sentry requested a review from a team October 1, 2024 17:57
).order_by("repoid")

if start_repoid is not None:
test_analytics_repos = test_analytics_repos.filter(repoid__gte=start_repoid)
Copy link
Contributor

Choose a reason for hiding this comment

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

smart

@joseph-sentry joseph-sentry added this pull request to the merge queue Oct 1, 2024
Merged via the queue into main with commit d4d1fa4 Oct 1, 2024
15 of 27 checks passed
@joseph-sentry joseph-sentry deleted the joseph/backfill-rollups branch October 1, 2024 18:43
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.

3 participants