-
Notifications
You must be signed in to change notification settings - Fork 119
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
Store limited number of models and clear older ones #948
Conversation
Completed marked future fixes for PR-944 Provided more detailed info regarding number of distinct users, as well as number of predictions made for the trip_list.
Clearing or trimming number of models for a particular user from the Stage_updateable_models collection. Constant K_MODELS_COUNT defines the number of models to keep. Currently tested with model data available in stage dataset snapshot. Pending - Complete testing with assertions to be added for testing.
Called the trim_model_entries function in upsert_model to delete models before inserting new ones.
commit 54659fb Merge: cf0c9e2 1159eac Author: K. Shankari <[email protected]> Date: Thu Dec 21 20:17:15 2023 -0800 Merge pull request e-mission#951 from MukuFlash03/fix-vuln Bulk deletion of site-package/tests commit 1159eac Author: Mahadik, Mukul Chandrakant <[email protected]> Date: Thu Dec 21 20:43:39 2023 -0700 Bulk deletion of site-package/tests Added a one line pipe command to remove all occurrences of site-packages/tests occurring in miniconda main directory. commit cf0c9e2 Merge: d2f38bc 3be2757 Author: K. Shankari <[email protected]> Date: Thu Dec 21 17:47:27 2023 -0800 Merge pull request e-mission#950 from MukuFlash03/fix-vuln Remove obsolete package versions commit 3be2757 Author: Mahadik, Mukul Chandrakant <[email protected]> Date: Thu Dec 21 18:05:23 2023 -0700 Remove obsolete package versions Cleaned up older versions for two packages: urllib3 - deleted stale version folders python - deleted tests folder commit d2f38bc Merge: 978a719 c1b0889 Author: K. Shankari <[email protected]> Date: Wed Dec 20 14:31:09 2023 -0800 Merge pull request e-mission#949 from MukuFlash03/fix-vuln Fixing latest Docker image vulnerabilities commit c1b0889 Author: Mahadik, Mukul Chandrakant <[email protected]> Date: Mon Dec 18 11:04:25 2023 -0700 Upgraded Ubuntu base image Latest Ubuntu base image was just released officially by Docker which contains updated version of libc6 and libc-bin. commit 07747d0 Author: Mahadik, Mukul Chandrakant <[email protected]> Date: Fri Dec 15 18:38:12 2023 -0700 Fixing latest Docker image vulnerabilities AWS Inspector found the following vulnerable packages: CRITICAL perl HIGH nghttp2, libnghttp2-14 cryptography, libssl3 cryptography libc6, libc-bin Upgraded perl, libssl3, nghttp2 packages by upgrading base Ubuntu image to latest of the same LTS version - jammy (22.04). Cryptography package was fixed by mentioning required version to be installed using conda. Libc6, Libc-bin can be fixed by using apt-get upgrade but this upgrades all packages which is not recommended as a blanket upgrade fix.
Was using pre-built models for testing that were present in stage_snapshot dataset but these won't be available in the normal dataset. Hence, took reference from emission.tests.modellingTests.TestRunGreedyModel.py for creating test models using dummy trip data. Creating multiple such models and then checking for trimming operation success.
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 am stopping at this point because there are multiple comments related to , please clean up this PR and re-submit for review.
Commit 31626ba included changes related to vulnerability fixes, hence reverted them. Had added some log statements related to scalability fixes for model loading. Removed them and will add in separate PR.
Removed redundant "esda" import added possibly during local testing. Removed get_model_limit() as K_MODEL_COUNT is a class variable and can be accessed directly using class name.
Decided upon threshold value for model count above which redundant models will be deleted. This was agreed upon to be 3 and is defined in the trip_model.config.json.sample file. Necessary changes have been made in the related files to use this config value.
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.
Looks good at a high level; but I would like some polishing changes...
- Improved logging statements to included whether model count has changed. - Skipped check for saved test data in Test file as we clear teardown() related collections in the DB.
Did this to revert a whitespace change which was possibly due to removing a line at the end of the file. We don't want it to be modified as it is unrelated to this set of PR changes. Restored using this command by pointing to specific commit hash for the first instance where the file was modified. git restore --source=79ad1cc~1 emission/analysis/classification/inference/labels/inferrers.py
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.
Where in here are you checking that the models that are deleted are the oldest ones? I see that the code does that with the sort on the metadata.write_ts
but I don't see a test for that. If I changed
edb.get_model_db().find(find_query).sort("metadata.write_ts", -1)
to
edb.get_model_db().find(find_query).sort("metadata.write_ts", 1)
I believe the test would still pass
Added test to ensure that only the latest models are stored by comparing the write_ts times.
Thank you for pointing that out; that is indeed an important test I missed. For testing purposes, I did change the sort(-1) to sort(1) which leads to ascending order of queried models based on write_ts.
So, to reinforce the testing, I’m adding another assertion to confirm that only the latest top K or max_model_count models are stored by storing the write_ts times in two different lists and checking for equality of the top K entries:
|
I do not 100% understand how the first assertion tripped, but I am satisfied with the changes and am happy to merge! |
Clearing or trimming number of models for a particular user from the Stage_updateable_models collection.
Constant K_MODELS_COUNT defines the number of models to keep.
Comparing with write_ts of Kth model entry to decide how many models to remove which are older than this write_ts.
Currently tested with model data available in stage dataset snapshot.
DONE - Testing done by generating mock models and cleaning them up.