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

Remove dependency for tqdm #232

Merged
merged 3 commits into from
Apr 5, 2017

Conversation

JoostJM
Copy link
Collaborator

@JoostJM JoostJM commented Mar 29, 2017

Remove dependency for the tqdm package, as this is rarely used (only for GLCM and GLSZM in full-python mode).
Instead provide 3 variables which can hold function definitions used for instantiating and interacting with a progress bar.

In the helloRadiomics script and notebook, this changed functionality is illustrated with a commented out section in the script and a separate cell in the notebook. This section and cell assume the tqdm package is installed and use it to show a progressbar during calculation of the glcm matrix in full-python mode.

TODO before merge:

  • Document the requirements for the progressReporter specification in the developers documentation
  • Add documentation to the _getProgressReporter function in __init__.py

Remove dependency for the tqdm package, as this is rarely used (only for GLCM and GLSZM in full-python mode).
Instead provide 3 variables which can hold function definitions used for instantiating and interacting with a progress bar.

In the helloRadiomics script and notebook, this changed functionality is illustrated with a commented out section in the script and a separate cell in the notebook. This section and cell assume the `tqdm` package is installed and use it to show a progressbar during calculation of the glcm matrix in full-python mode.
@JoostJM JoostJM mentioned this pull request Mar 29, 2017
3 tasks
else:
# Ensure that even if progress functions are defined, progress is only given if 'verbose' is True
self.initProgress = None

Copy link
Collaborator

Choose a reason for hiding this comment

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

This code should probably be moved to the base class.

@@ -161,6 +161,18 @@ def getInputImageTypes():
return _inputImages


def getProgressFunctions():
Copy link
Collaborator

Choose a reason for hiding this comment

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

should that function be private: _getProgressFunctions() ? Or should the variable (init|report|close)progress be private global ?

Either way we need to document the signature of the functions too.

JoostJM added 2 commits March 30, 2017 12:05
As @jcfr showed in AIM-Harvard#230, the progress reporting can be simplified, requiring the user only to specify one variable that holds a progress reporter.

Update PyRadiomics to this implementation and add examples for both use with `tqdm.tqdm` (which can be used directly) or `click.progressbar` (which requires a simple wrapper class). Examples are provided in both the helloRadiomics script and notebook.

Progress reporting in full-python mode in GLCM and GLSZM now uses a progress reporter that is instantiated with an interator (as opposed to a length) and uses this progress reporter in the loop to iterate over the gray levels. This is encapsulated in a `with` statement to ensure correct closure.
Finally, a dummy progress reporter is provided for the cases where no progressbar is needed (none specified or verbosity level > INFO). In those cases the `_dummyProgressReporter` (defined in `__init__.py`) is used, which accepts the arguments from PyRadiomics and iterates over the gray levels passed in the iterable, but does not report any progress back to the user.
Add documentation on how to add a progress reporter in the developers section of the documentation.

The `_DummyProgressReporter` class and `_getProgressReporter` function also have documentation, but these are not included in the sphinx-generated documentation.
@JoostJM JoostJM force-pushed the remove-tqdm-dependency branch from a393b13 to c5620fc Compare March 30, 2017 11:45
@JoostJM JoostJM merged commit 913473e into AIM-Harvard:master Apr 5, 2017
@JoostJM JoostJM deleted the remove-tqdm-dependency branch April 5, 2017 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants