-
Notifications
You must be signed in to change notification settings - Fork 7
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
[BUG] update_call
assigns work to officers with no time available
#1089
Comments
Issue seems to be that within This method does not remove keys with negative values, which is the purpose of the This looks to be the cause; output of my debug log:
And in particular on the loop iteration that throws the error:
Suggestions for the cause:
|
Pinging @marghe-molaro ! |
Hi @willGraham01, indeed, the issue appears to be that the "actual" appointment footprint - which can only be calculated when actually running the event - at times relies on a different set of medical officers than those assumed by the "expected" footprint; in the case where one of these officers already had exhausted capabilities before running the event (in which case the event shouldn't have been run at all!) this throws an error when trying to remove that officer (again) from the set_capabilities_still_available. This constitutes a fundamental problem (rather than a bug) for mode 2, because by definition the actual footprint can only be obtained by running the event, and therefore we cannot determine prior running it whether enough medical capabilities were available to run it in the first place. I would need to discuss with @tbhallett what the strategy should be moving forward (there might be very few instances where the actual footprint requires an extra officer, in which case we could maybe ignore the issue of capabilities for those HSIs, but if a significant number of them do this we might need to re-evaluate how mode 2 is computed significantly). Long story short, @willGraham01 and @tamuri - for a quick fix to continue with the scale run analysis you could add a safety if statement on line 2458 in healthsystem.py to check the officer is in the set_capabilities_still_available before trying to remove them. I don't think this should significantly affect the scaling of the runs (except maybe if a huge fraction of HSIs do this, which I doubt). Otherwise, could you please pause on this issue for a bit while I consider how we can review mode 2 to account for this please. If you are happy with the "quick fix" I can submit it as a PR. |
Hi @marghe-molaro. My preference would be to switch (for the time being) the profiling runs to avoid mode 2 now that we know that mode is problematic, instead of adding the "quick fix". I can always switch them back when mode 2 is fixed (and it saves us an extra PR on top of #1012 just to fix one particular problem). Adding the "quick fix" might make us forget about this being a problem further down the line, which could be problematic for trust/reliability reasons. Also if it's of any insight, this problem seems to crop up 3 times in a month-long simulation (IE running the |
Hi @willGraham01, yes very happy with your proposed solution (although I definitely wouldn't have forgotten about it, it's pretty major in what I'm doing atm!! :) ). Thanks for the insight, can you remind me what the assumed population size would have been for the month-long simulation you're quoting? It definitely sounds rare enough, but would be good to check which HSIs are affected. I will ask on the programming channel too if anyone can think of HSIs which may use different sets of medical officers in the expected vs actual footprint. |
Initial population for the month-long simulation is 50,000. Not sure what it rises to by the end of the month/simulation, but the population dataframe has only been expanded to 51,000 rows so somewhere between 50-51 thousand. If you would like the rest of the parameters I'm using, they're saved here (that link should hopefully be permanent). And running the |
scale_run
script throws KeyError
update_call
assigns work officers with no time available
update_call
assigns work officers with no time availableupdate_call
assigns work to officers with no time available
Ok 50,000 is pretty large, hopefully that means it is truly a rare occurrence! Will check locally as you suggested. |
Agree it seems rare. Also, I don't see a better solution than ignoring it! |
The current version of the model throws a
KeyError
when attempting to run thescale_run
profiling script.Discovered after returning to issue #686's profiling PR (#1012) and the error being raised after a rebase onto
aace4d1
.To Reproduce:
In a terminal at the root of the TLOmodel repository:
The parameters passed to the
scale_run.py
script to reproduce this bug are:python src/scripts/profiling/scale_run.py \ --years 0 \ --months 1 \ --initial-population 50000 \ --tlo-dir . \ --output-dir ./outputs \ --log-filename scale_run_profiling \ --log-level DEBUG \ --show-progress-bar \ --seed 0 \ --mode-appt-constraints 2
and the KeyError is thrown approximately 35% of the way through the simulation.
Other Information
This bug is not present on commit
267c1e85f
, so was introduced at some point between then andaace4d1
.git bisect
implies that73429a738a86d618dea67cbe48155a7959d72744
is the first bad commit (Tuesday 15th Aug 2023).The text was updated successfully, but these errors were encountered: