tomviz icon indicating copy to clipboard operation
tomviz copied to clipboard

Progress max must be set before value for `tomviz-pipeline`

Open psavery opened this issue 6 years ago • 0 comments

When running the tomviz-pipeline executable, if the progress value is set before the maximum (which is done in several ITK operators, including the default ITK operator) like so:

        self.progress.value = 0
        self.progress.maximum = 100

An error will occur, pasted at the bottom of this script.

It seems that the error is occurring because setting self.progress.maximum initializes the progress bar. If a value is set before setting the maximum, it attempts to call update on the un-initialized _progress_bar. This issue does not occur when running the docker pipeline in tomviz, it only occurs when running the tomviz-pipeline executable by hand.

I guess we can either fix it by setting the maximum before the value in all of our operators, or by adding some additional logic to ensure that external progress bar is initialized before updating it.

$ tomviz-pipeline -s default_itk.tvsm -d nanoparticle.emd 
[2019-10-25 11:50:07,333] INFO: Executing pipeline on nanoparticle.emd
[2019-10-25 11:50:07,622] INFO: Executing 'Transform Data' operator
Traceback (most recent call last):
  File "/home/patrick/virtualenvs/tomviz/bin/tomviz-pipeline", line 11, in <module>
    load_entry_point('tomviz-pipeline', 'console_scripts', 'tomviz-pipeline')()
  File "/home/patrick/virtualenvs/tomviz/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/patrick/virtualenvs/tomviz/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/patrick/virtualenvs/tomviz/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/patrick/virtualenvs/tomviz/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/patrick/virtualenvs/tomviz/src/tomviz/tomviz/python/tomviz/cli/__init__.py", line 122, in main
    read_options)
  File "/home/patrick/virtualenvs/tomviz/src/tomviz/tomviz/python/tomviz/executor.py", line 716, in execute
    progress)
  File "/home/patrick/virtualenvs/tomviz/src/tomviz/tomviz/python/tomviz/executor.py", line 613, in _execute_transform
    result = transform(input, **arguments)
  File "/tmp/tmp8vnj2gtv.py", line 18, in transform
  File "/home/patrick/virtualenvs/tomviz/src/tomviz/tomviz/python/tomviz/executor.py", line 84, in value
    self._progress_bar.update(value - self._progress_bar.n)
AttributeError: 'NoneType' object has no attribute 'update'

psavery avatar Oct 25 '19 16:10 psavery