-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
perf: BOM Update Tool #31072
perf: BOM Update Tool #31072
Commits on May 18, 2022
-
perf:
get_boms_in_bottom_up_order
- Create child-parent map once and fetch value from child key to get parents - Get parents recursively for a leaf node (get all ancestors) - Approx. 44 secs for 4lakh 70k boms
Configuration menu - View commit details
-
Copy full SHA for b6e46ee - Browse repository at this point
Copy the full SHA b6e46eeView commit details
Commits on May 19, 2022
-
fix: DB update child items, remove redundancy, fix perf
- Move `get_boms_in_bottom_up_order` in bom update tool’s file - Remove repeated rm cost update from `update_cost`. `calculate_cost` handles RM cost update - db_update children in `calculate_cost` optionally - Don’t call `update_exploded_items` and regenerate exploded items in `update_cost`. They will stay the same (except cost)
Configuration menu - View commit details
-
Copy full SHA for 5932e9d - Browse repository at this point
Copy the full SHA 5932e9dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9dc3083 - Browse repository at this point
Copy the full SHA 9dc3083View commit details -
perf: Use cached doc instead of
get_doc
- Doc is only used to iterate over items(which wont change) and change rate/amount of rows - These changes are inserted in db via `db_update`, so no harm - Tested locally: refetching cached doc after db update, reflects fresh data.
Configuration menu - View commit details
-
Copy full SHA for 9a7e9d9 - Browse repository at this point
Copy the full SHA 9a7e9d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for dd99c00 - Browse repository at this point
Copy the full SHA dd99c00View commit details -
fix:
test_work_order_with_non_stock_item
- Use the right price list and currency to avoid rate conversion (1000/62.9), since rates are reset correctly now - Use RM rate based on Price List in BOM. Non stock item has no valuation
Configuration menu - View commit details
-
Copy full SHA for 90d4dc0 - Browse repository at this point
Copy the full SHA 90d4dc0View commit details
Commits on May 25, 2022
-
feat: Level-wise BOM cost updation
- Process BOMs level wise and Pause after level is complete - Cron job will resume Paused jobs, which will again process the new level and pause at the end - This will go on until all BOMs are updated - Added Progress section with fields to track updated BOMs in Log - Cleanup: Add BOM Updation utils file to contain helper functions/sub-functions - Cleanup: BOM Update Log file will only contain functions that are in direct context of the Log Co-authored-by: Gavin D'souza <gavin18d@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for ab2d95a - Browse repository at this point
Copy the full SHA ab2d95aView commit details -
style: Update docstrings and fix/add type hints + Collapsible progres…
…s section in Log
Configuration menu - View commit details
-
Copy full SHA for 9f5f18e - Browse repository at this point
Copy the full SHA 9f5f18eView commit details
Commits on May 27, 2022
-
feat: Only update exploded items rate and amount
- Generate RM-Rate map from Items table (will include subassembly items with rate) - Function to reset exploded item rate from above map - `db_update` exploded item rate only if rate is changed - Via Update Cost, only update exploded items rate, do not regenerate table again - Exploded Items are regenerated on Save and Replace BOM job - `calculate_exploded_cost` is run only via non doc events (Update Cost button, Update BOMs Cost Job)
Configuration menu - View commit details
-
Copy full SHA for eabd829 - Browse repository at this point
Copy the full SHA eabd829View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5949946 - Browse repository at this point
Copy the full SHA 5949946View commit details -
perf:
get_next_higher_level_boms
- Separate getting dependants and checking if they are valid (loop within loop led to redundant processing that slowed down function) - Adding to above, the same dependant(parent) was repeatedly processed as many children shared it. Expensive. - Use a parent-child map similar to child-parent map to check if all children are resolved - `map.get()` reduced time: 10 mins -> 0.9s~1 second (as compared to `get_cached_doc` or query) - Total time: 17 seconds to process 6599 leaf boms and 4.2L parent boms - Previous Total time: >10 mins (I terminated it due to not wanting to waste time XD)
Configuration menu - View commit details
-
Copy full SHA for 2de2491 - Browse repository at this point
Copy the full SHA 2de2491View commit details -
Configuration menu - View commit details
-
Copy full SHA for 978ba52 - Browse repository at this point
Copy the full SHA 978ba52View commit details
Commits on May 31, 2022
-
chore: Limit Update Cost jobs &
db_update
only if changed values- If `Update Cost` job is ongoing, then block creation of new ones since all BOMs are updated - `db_update` in `calculate_rm_cost` only if changed values to reduce redundant row updates - Misc: Use variable for batch size
Configuration menu - View commit details
-
Copy full SHA for a62bc9b - Browse repository at this point
Copy the full SHA a62bc9bView commit details
Commits on Jun 2, 2022
-
feat: Track progress in Log Batch/Job wise
- This was done due to stale reads while the background jobs tried updating status of the log - Added a table where all bom jobs within log will be tracked with what level they are processing - Cron job will check if table jobs are all processed every 5 mins - If yes, it will prepare parents and call `process_boms_cost_level_wise` to start next level - If pending jobs, do nothing - Current BOM Level is being tracked that helps adding rows to the table - Individual bom cost jobs (that are queued) will process and update boms > will update BOM Update Batch table row with list of updated BOMs
Configuration menu - View commit details
-
Copy full SHA for 62857e3 - Browse repository at this point
Copy the full SHA 62857e3View commit details
Commits on Jun 6, 2022
-
chore: Miscellanous fixes/enhancements
- `get_valuation_rate`: if no bins are found return 0, SLEs do not exist either - `get_valuation_rate`: Compute average valuation rate via query - `get_rm_rate_map`: set order_by as None to avoid creating sort index (modified) each time query runs (seen in process list) - BOM Update Batch: add status field and hide `boms_updated` so that users can see progress without loading all updated boms (too much data) - BOM Update Batch: set batch row status to completed after job runs - BOM Update Log: remove `parent_boms` field (just pass parent boms to processing function) & remove Paused state (not used) - Move job to long queue to avoid choking default queue - `update_cost_in_boms`: use `get_doc` as each BOM is accessed only once. Use `for_update` to lock BOM row - Commit after every 100 BOMs
Configuration menu - View commit details
-
Copy full SHA for 934db57 - Browse repository at this point
Copy the full SHA 934db57View commit details -
chore:
get_valuation_rate
in bom.py must always return float & goto…… Item master if no bins
Configuration menu - View commit details
-
Copy full SHA for 1510119 - Browse repository at this point
Copy the full SHA 1510119View commit details
Commits on Jun 7, 2022
-
test: Util to update cost in all BOMs
- Utility to update cost in all BOMs without cron jobs or background jobs (run immediately) - Re-use util wherever all bom costs are to be updated - Skip explicit commits if in test - Specify company in test records (dirty data sometimes, company wh mismatch) - Skip background jobs queueing if in test
Configuration menu - View commit details
-
Copy full SHA for 6bde1bb - Browse repository at this point
Copy the full SHA 6bde1bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for ff0a6b7 - Browse repository at this point
Copy the full SHA ff0a6b7View commit details
Commits on Jun 8, 2022
-
test: Fix
test_update_bom_cost_in_all_boms
- Use base_rate for assertions as rate is subject to change due to conversion factor (USD)
Configuration menu - View commit details
-
Copy full SHA for 9f2793c - Browse repository at this point
Copy the full SHA 9f2793cView commit details -
chore:
get_valuation_rate
sider fixes- Use qb instead of db.sql - Don't use `args` as argument for function - Cleaner variable names
Configuration menu - View commit details
-
Copy full SHA for 7e41d84 - Browse repository at this point
Copy the full SHA 7e41d84View commit details
Commits on Jun 9, 2022
-
Configuration menu - View commit details
-
Copy full SHA for a6edce2 - Browse repository at this point
Copy the full SHA a6edce2View commit details -
chore: Less hacky tests, versioning (replace bom) and clearing log da…
…ta (update cost) - Remove `auto_commit_on_many_writes` in `update_cost_in_level()` as commits happen every N BOMs - Auto commit every 50 BOMs - test: Remove hacky `frappe.flags.in_test` returns - test: Enqueue `now` if in tests (for update cost and replace bom) - Replace BOM: Copy bom object to `_doc_before_save` so that version.py finds a difference between the two - Replace BOM: Add reference to version - Update Cost: Unset `processed_boms` if Log is completed (useless after completion) - test: `update_cost_in_all_boms_in_test` works close to actual prod implementation (only call Cron job manually) - Test: use `enqueue_replace_bom` so that test works closest to production behaviour Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 3fa0a46 - Browse repository at this point
Copy the full SHA 3fa0a46View commit details