Skip to content

Commit 83c71c3

Browse files
committed
BUG: Fix update notice when idc-index-data has a new version
idc-index-data would be marked as out of date, however it would not be upgraded, making it impossible to get rid of the update required message. Fixed by calling --upgrade on idx-index-data to trigger the update. Also reload the idc-index library after updating so that the new library is used.
1 parent a3fbf83 commit 83c71c3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

IDCBrowser/IDCBrowser.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from random import randint
1919
import tempfile
2020
import inspect
21+
import importlib
2122

2223
# Third-party imports
2324
import pydicom
@@ -476,7 +477,8 @@ def onPythonRequirementsCheckTimeout(self):
476477
self.pythonRequirementsCheckTimer.stop()
477478

478479
requiredLibraries = [
479-
"idc-index"
480+
"idc-index",
481+
"idc-index-data"
480482
]
481483

482484
outdatedLibraries = []
@@ -1521,8 +1523,19 @@ def setupPythonRequirements(self, update=False):
15211523
userMessage = "The module requires idc-index python package, which will now be installed."
15221524
logging.info(userMessage)
15231525
with slicer.util.displayPythonShell() as shell, slicer.util.tryWithErrorDisplay(message=errorMessage, waitCursor=True) as errorDisplay:
1524-
slicer.util.pip_install(f"{'--upgrade ' if update else ''}idc-index>=0.7.0")
1526+
if update:
1527+
slicer.util.pip_install("--no-cache-dir --upgrade idc-index>=0.7.0")
1528+
slicer.util.pip_install("--no-cache-dir --upgrade idc-index-data")
1529+
else:
1530+
slicer.util.pip_install("idc-index>=0.7.0 idc-index-data")
15251531
installed = True
1532+
# Force reload of the module to pick up the new version
1533+
if 'idc_index' in sys.modules:
1534+
import idc_index
1535+
importlib.reload(idc_index)
1536+
if 'idc_index.index' in sys.modules:
1537+
from idc_index import index
1538+
importlib.reload(index)
15261539
else:
15271540
installed = True
15281541

0 commit comments

Comments
 (0)