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

Getting protocol folder size can be problematic #486

Open
delarosatrevin opened this issue Dec 7, 2023 · 2 comments
Open

Getting protocol folder size can be problematic #486

delarosatrevin opened this issue Dec 7, 2023 · 2 comments
Assignees

Comments

@delarosatrevin
Copy link
Member

In running protocols where some tmp folders/files are deleted, it can raise the following exception:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/software/scipion/conda/lib/python3.8/tkinter/__init__.py", line 1892, in __call__
    return self.func(*args)
  File "/software/scipion/conda/lib/python3.8/tkinter/__init__.py", line 814, in callit
    func(*args)
  File "/software/scipion/source/core/scipion-pyworkflow/pyworkflow/gui/canvas.py", line 290, in <lambda>
    lambda: self._showTooltip(event.x_root,
  File "/software/scipion/source/core/scipion-pyworkflow/pyworkflow/gui/canvas.py", line 122, in _showTooltip
    self._tooltipCallback(tw, item)
  File "/software/scipion/source/core/scipion-pyworkflow/pyworkflow/gui/project/viewprotocols.py", line 1340, in _runItemTooltip
    tm += 'Folder size: %s\n' % pwutils.prettySize(prot.getSize())
  File "/software/scipion/source/core/scipion-pyworkflow/pyworkflow/protocol/protocol.py", line 2330, in getSize
    self._size = getFileSize(self.getPath())
  File "/software/scipion/source/core/scipion-pyworkflow/pyworkflow/utils/path.py", line 460, in getFileSize
    total_size += os.path.getsize(fp)
  File "/software/scipion/conda/lib/python3.8/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: 'Runs/008023_ProtRelionExtractParticles/tmp/mic_009214.mrcs'

Moreover, for some large datasets (e.g. tens of thousands of movies) this can take a long time to compute and freeze the whole GUI.

I propose to either avoid that computation or have some sort of cache value that prevents from running that many IO queries every time one hover over a protocol box.

@pconesa
Copy link
Contributor

pconesa commented Dec 15, 2023 via email

@delarosatrevin
Copy link
Member Author

Apart from being cached, might be a good idea to do the updated in a background thread. This will prevent blocking the GUI, even in the case where the size needs to be re-calculated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants