Skip to content
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

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

achillesrasquinha
Copy link
Contributor

@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2022

Codecov Report

Attention: Patch coverage is 96.29630% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 84.44%. Comparing base (7473d13) to head (eb62c8a).
Report is 67 commits behind head on devel.

Files Patch % Lines
src/cobra/flux_analysis/variability.py 96.29% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Midnighter Midnighter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @achillesrasquinha,

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()
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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(
Copy link
Member

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.

Copy link
Member

@cdiener cdiener left a 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()
Copy link
Member

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
Copy link
Member

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...

Copy link
Member

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.

@cdiener
Copy link
Member

cdiener commented Sep 24, 2022

@Midnighter what about having the progress bar flag in the Configuration. Or having a verbosity flag there?

@Midnighter
Copy link
Member

Midnighter commented Sep 24, 2022

@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 progress parameter for those functions that show a progress bar but just like with Configuration.tolerance if the argument is unset that could be the default.

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.

@cdiener
Copy link
Member

cdiener commented Sep 24, 2022

Okay then maybe continue using the logging level as a default and have the arg in that case.

@cdiener cdiener added the stale The issue or pull request lacks activity. label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale The issue or pull request lacks activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Showing progress during flux variability analysis.
4 participants