-
Notifications
You must be signed in to change notification settings - Fork 218
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 progress to fva #1283
base: devel
Are you sure you want to change the base?
Conversation
achillesrasquinha
commented
Sep 20, 2022
- fix Showing progress during flux variability analysis. #1279
- description of feature/fix: Add a progress bar to FVA (triggered only during logging.INFO)
- tests added/passed
- add an entry to the next release
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #1283 +/- ##
==========================================
+ Coverage 84.40% 84.44% +0.03%
==========================================
Files 66 66
Lines 5497 5516 +19
Branches 1265 1267 +2
==========================================
+ Hits 4640 4658 +18
Misses 551 551
- Partials 306 307 +1 ☔ View full report in Codecov by Sentry. |
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.
Thank you for the contribution. I think, having a dummy class is a reasonable approach but I do wonder if having two versions of the function altogether would be better? One with progress and the other without.
In any case, I would want to have a function parameter to enable or disable the progress bar altogether. Something like:
def flux_variability_analysis(..., progress: Optional[bool] = None) -> pd.DataFrame:
if progress is None and logger.getEffectiveLevel() <= logging.INFO:
# Do progress bar
elif progress:
# Do progress bar
else:
# No progress bar
This would, of course, also be nice to have for the gene and reaction knock-outs. So maybe we can solve it a little more generally.
pass | ||
|
||
def add_task(self, *args, **kwargs): | ||
return object() |
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.
In rich, add_task
returns an integer ID. So maybe just return 0
here.
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.
Do you need this at all? In rich Progress.add_task already has a visible flag that hides the progress bar. Does that have too much overhead?
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.
Didn't realize there was that option. Sounds good 🙂
pass | ||
|
||
|
||
def _update_progress_bar( |
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.
What is the point of this function? It just seems like an unnecessary level of indirection.
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.
Some questions. An example run would be nice to see if the numbers add up. Should also be added to the docs.
pass | ||
|
||
def add_task(self, *args, **kwargs): | ||
return object() |
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.
Do you need this at all? In rich Progress.add_task already has a visible flag that hides the progress bar. Does that have too much overhead?
): | ||
fva_result.at[rxn_id, what] = value | ||
_update_progress_bar( | ||
progress, progress_task, (i + 1) / num_reactions |
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 haven't tested this but does this actually show the right numbers? Like the bar is set to a maximum of nr steps but then you do 2*nr updates. Once for the min and once for the max...
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.
Yep, agreed. Didn't mention it now because it seems like we want a different design anyway. Also, use enumerate(..., start=1)
instead of adding + 1.
@Midnighter what about having the progress bar flag in the Configuration. Or having a verbosity flag there? |
I think, I would still create a specific Overall, good idea to have it on the configuration. I would not use verbosity, though, because basically people should just create a logging handler with the level that they need. |
Okay then maybe continue using the logging level as a default and have the arg in that case. |