-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: main
Are you sure you want to change the base?
Conversation
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 ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #734 +/- ##
===========================================
- Coverage 98.09% 25.14% -72.95%
===========================================
Files 432 438 +6
Lines 36332 36543 +211
===========================================
- Hits 35640 9189 -26451
- Misses 692 27354 +26662
Flags with carried forward coverage won't be shown. Click here to find out more.
|
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time. ❌ Failed Test Results:Completed 1 tests with View the full list of failed testspytest
|
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_scaffold.settings") | ||
django.setup() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
f"Updating test instances {start_repoid} {start_date} {end_date}", | ||
extra=dict(start_repoid=start_repoid, start_date=start_date, end_date=end_date), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you have all these fields in the extra
as well, I would remove them from the log message, it only makes it harder to search for all the individual logs.
/ (obj.pass_count + obj.fail_count), | ||
) | ||
|
||
rollup.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
django has a bulk_create
method as well, though I recommend to always define a reasonable chunk size.
rollup.save() | ||
|
||
|
||
def run_impl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please give this a more descriptive name :-)
f"Updating test instances {start_repoid} {start_date} {end_date}", | ||
extra=dict(start_repoid=start_repoid, start_date=start_date, end_date=end_date), | ||
) | ||
test_analytics_repos = get_test_analytics_repos(start_repoid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably also iterate over these in chunks, because you are also logging the whole list.
unless you know for certain there is only a small number of these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah there aren't many Repository
objects that would be returned from this function
).select_related("upload")[:1][0] | ||
|
||
if first_test_instance is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not 100% sure how this works with using the slicing syntax to define a limit, whether you actually get a list of appropriate length with None
filled in?
I think this might just throw because you are indexing out of bounds if no such object exists?
new_bridge = TestFlagBridge(test=test, flag=flags[flag_name]) | ||
new_bridge.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, bulk_create
should be more appropriate here.
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