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

Fix issue in utils.progress for disable=True #5964

Merged
merged 6 commits into from
Jun 20, 2023

Conversation

constantinpape
Copy link
Contributor

@constantinpape constantinpape commented Jun 19, 2023

Fixes/Closes

Closes #5961

Description and references

This PR changes the progress.__init__ such that if the progress bar is disabled, the 'desc' property is set to a dummy value, because otherwise it is not set by the tqdm super constructor and throws an error.

Type of change

  • Bug-fix (non-breaking change which fixes an issue)

How has this been tested?

I checked locally that this test fixes this code:

# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass

which throws an AttributeError without the fix.

Final checklist:

  • My PR is the minimum possible work for the desired functionality
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • If I included new strings, I have used trans. to make them localizable.
    For more information see our translations guide.

@constantinpape
Copy link
Contributor Author

@DragaDoncila here's the PR for #5961

@psobolewskiPhD psobolewskiPhD added the bugfix PR with bugfix label Jun 19, 2023
@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Merging #5964 (2ac83e0) into main (efa55a5) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5964      +/-   ##
==========================================
- Coverage   90.19%   90.19%   -0.01%     
==========================================
  Files         615      615              
  Lines       52039    52045       +6     
==========================================
+ Hits        46939    46942       +3     
- Misses       5100     5103       +3     
Impacted Files Coverage Δ
napari/utils/_tests/test_progress.py 100.00% <100.00%> (ø)
napari/utils/progress.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@Czaki
Copy link
Collaborator

Czaki commented Jun 19, 2023

Could you add test? It looks like a nice thing to backport to 0.4.18 but I will appreciate tests for any such thing to not need manually test it.

@constantinpape
Copy link
Contributor Author

Are there any tests for the progressbar already where I could just add this one, @Czaki ?

@psobolewskiPhD
Copy link
Member

@constantinpape looks like here would work?
https://github.com/napari/napari/blob/main/napari/utils/_tests/test_progress.py
Maybe after/around:

def test_progress_set_description():

Also, before this is merged, could you just ensure the PR description is self-sufficient, rather than the See Issue...?
The PR description will be the commit message, so we'd like titles and descriptions to be descriptive, grammatically correct, and thorough, so we have a nice commit history and nice release notes.

@Czaki Czaki added this to the 0.4.18 milestone Jun 19, 2023
@github-actions github-actions bot added the tests Something related to our tests label Jun 19, 2023
@Czaki Czaki requested a review from a team June 19, 2023 11:21
@constantinpape
Copy link
Contributor Author

I have added a test now and updated the PR description.

@psobolewskiPhD
Copy link
Member

Maybe the reproducer and error (which are in the issue) could be replaced with something like:

In this PR a change is made to the progress.__init__ such that if the progress bar is set to be disabled, the 'desc' property set it to a dummy value, because otherwise it is not set by the tqdm super constructor and throws an error.

(if i'm getting the nature of the change correctly from the code and comment)

@Czaki
Copy link
Collaborator

Czaki commented Jun 19, 2023

@constantinpape There is a need to update the test as they are failing.

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@psobolewskiPhD psobolewskiPhD added the ready to merge Last chance for comments! Will be merged in ~24h label Jun 19, 2023
@constantinpape
Copy link
Contributor Author

Thanks for fixing the tests @psobolewskiPhD. This is good to go from my side now.

@Czaki
Copy link
Collaborator

Czaki commented Jun 19, 2023

@constantinpape as it is your first contribution to napari, and it will be backported to 0.4.18. Could you provide data to be put in https://github.com/napari/napari/blob/main/CITATION.cff ?

@constantinpape
Copy link
Contributor Author

I have added the citation info in 2ac73e0.

@constantinpape
Copy link
Contributor Author

PR Test / ubuntu-latest 3.9 pyside6 (pull_request) is timing out. This seems to be unrelated to the changes here.

@Czaki Czaki mentioned this pull request Jun 19, 2023
Copy link
Contributor

@DragaDoncila DragaDoncila left a 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 @constantinpape! 🎉

@GenevieveBuckley GenevieveBuckley merged commit a0fa476 into napari:main Jun 20, 2023
35 checks passed
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5961

# Description and references
This PR changes the `progress.__init__` such that if the progress bar is
disabled, the 'desc' property is set to a dummy value, because otherwise
it is not set by the tqdm super constructor and throws an error.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
A test `test_progress_set_disable` has been added to napari/utils/_tests/test_progress.py

I checked locally that this test fixes this code:
```python
# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass
```
which throws an `AttributeError` without the fix.

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5961

# Description and references
This PR changes the `progress.__init__` such that if the progress bar is
disabled, the 'desc' property is set to a dummy value, because otherwise
it is not set by the tqdm super constructor and throws an error.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
A test `test_progress_set_disable` has been added to napari/utils/_tests/test_progress.py

I checked locally that this test fixes this code:
```python
# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass
```
which throws an `AttributeError` without the fix.

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5961

# Description and references
This PR changes the `progress.__init__` such that if the progress bar is
disabled, the 'desc' property is set to a dummy value, because otherwise
it is not set by the tqdm super constructor and throws an error.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
A test `test_progress_set_disable` has been added to napari/utils/_tests/test_progress.py

I checked locally that this test fixes this code:
```python
# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass
```
which throws an `AttributeError` without the fix.

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@psobolewskiPhD psobolewskiPhD removed the ready to merge Last chance for comments! Will be merged in ~24h label Jun 21, 2023
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5961

# Description and references
This PR changes the `progress.__init__` such that if the progress bar is
disabled, the 'desc' property is set to a dummy value, because otherwise
it is not set by the tqdm super constructor and throws an error.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
A test `test_progress_set_disable` has been added to napari/utils/_tests/test_progress.py

I checked locally that this test fixes this code:
```python
# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass
```
which throws an `AttributeError` without the fix.

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
melissawm pushed a commit to melissawm/napari that referenced this pull request Jul 3, 2023
# Fixes/Closes
Closes napari#5961

# Description and references
This PR changes the `progress.__init__` such that if the progress bar is
disabled, the 'desc' property is set to a dummy value, because otherwise
it is not set by the tqdm super constructor and throws an error.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# How has this been tested?
A test `test_progress_set_disable` has been added to napari/utils/_tests/test_progress.py

I checked locally that this test fixes this code:
```python
# from tqdm import tqdm
from napari.utils import progress as tqdm

for z in tqdm(range(10), total=10, desc="Count to 10", disable=True):
    pass
```
which throws an `AttributeError` without the fix.

## Final checklist:
- [x] My PR is the minimum possible work for the desired functionality
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Napari progress throws AttributeError if a description is set and it is disabled
5 participants