Skip to content

Commit db60e07

Browse files
committed
Add support for v0.20 plugins detection and warning in DataLab v1.0
1 parent e2a9ace commit db60e07

6 files changed

Lines changed: 141 additions & 12 deletions

File tree

datalab/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class MainSection(conf.Section, metaclass=conf.SectionMeta):
121121
plugins_enabled = conf.Option()
122122
plugins_path = conf.Option()
123123
tour_enabled = conf.Option()
124+
v020_plugins_warning_ignore = conf.Option() # True: do not warn, False: warn
124125

125126

126127
class ConsoleSection(conf.Section, metaclass=conf.SectionMeta):
@@ -341,6 +342,7 @@ def initialize():
341342
Conf.main.plugins_enabled.get(True)
342343
Conf.main.plugins_path.get(Conf.get_path("plugins"))
343344
Conf.main.tour_enabled.get(True)
345+
Conf.main.v020_plugins_warning_ignore.get(False)
344346
# Console section
345347
Conf.console.console_enabled.get(True)
346348
Conf.console.show_console_on_error.get(False)

datalab/gui/main.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from datalab.gui.h5io import H5InputOutput
6464
from datalab.gui.panel import base, image, macro, signal
6565
from datalab.gui.settings import edit_settings
66-
from datalab.plugins import PluginRegistry, discover_plugins
66+
from datalab.plugins import PluginRegistry, discover_plugins, discover_v020_plugins
6767
from datalab.utils import dephash
6868
from datalab.utils import qthelpers as qth
6969
from datalab.utils.qthelpers import (
@@ -641,10 +641,64 @@ def check_for_previous_crash(self) -> None: # pragma: no cover
641641
if choice == QW.QMessageBox.StandardButton.Yes:
642642
self.__show_logviewer()
643643

644+
def check_for_v020_plugins(self) -> None: # pragma: no cover
645+
"""Check for v0.20 plugins and warn user if any are found"""
646+
if Conf.main.v020_plugins_warning_ignore.get(False):
647+
return
648+
649+
v020_plugins = discover_v020_plugins()
650+
if execenv.unattended or not v020_plugins:
651+
return
652+
653+
# Build plugin list with clickable directory paths
654+
plugin_items = []
655+
for name, directory_path in v020_plugins:
656+
if directory_path:
657+
# Create clickable file:// link to directory
658+
dir_url = QC.QUrl.fromLocalFile(directory_path).toString()
659+
plugin_items.append(
660+
f'<li>{name} (<a href="{dir_url}">{directory_path}</a>)</li>'
661+
)
662+
else:
663+
plugin_items.append(f"<li>{name}</li>")
664+
plugin_list = "<ul>" + "".join(plugin_items) + "</ul>"
665+
666+
txtlist = [
667+
"<b>" + _("DataLab v0.20 plugins detected") + "</b>",
668+
"",
669+
_("The following plugins are using the old DataLab v0.20 format:"),
670+
plugin_list,
671+
_(
672+
"These plugins will <b>not be loaded</b> in DataLab v1.0 because "
673+
"they are not compatible with the new architecture."
674+
),
675+
"",
676+
_(
677+
"To use these plugins with DataLab v1.0, you need to update them. "
678+
"Please refer to the migration guide on the DataLab website "
679+
)
680+
+ '(<a href="https://datalab-platform.com/en/features/advanced/'
681+
'migration_v020_to_v100.html">Migration guide</a>)'
682+
+ _(" or in the PDF documentation."),
683+
"",
684+
_("Choosing to ignore this message will prevent it from appearing again."),
685+
]
686+
687+
answer = QW.QMessageBox.question(
688+
self,
689+
APP_NAME,
690+
"<br>".join(txtlist),
691+
QW.QMessageBox.Ok | QW.QMessageBox.Ignore,
692+
)
693+
694+
if answer == QW.QMessageBox.Ignore:
695+
Conf.main.v020_plugins_warning_ignore.set(True)
696+
644697
def execute_post_show_actions(self) -> None:
645698
"""Execute post-show actions"""
646699
self.check_stable_release()
647700
self.check_for_previous_crash()
701+
self.check_for_v020_plugins()
648702
tour = Conf.main.tour_enabled.get()
649703
if tour:
650704
Conf.main.tour_enabled.set(False)

datalab/gui/settings.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ class MainSettings(gds.DataSet):
6969
"as well as in your PYTHONPATH."
7070
),
7171
)
72+
v020_plugins_warning_ignore = gds.BoolItem(
73+
_("Ignore compatibility issues warning"),
74+
_("DataLab v0.20 plugins"),
75+
help=_(
76+
"If enabled, DataLab will not warn you about v0.20 plugins that are "
77+
"no longer compatible with v1.0."
78+
),
79+
)
7280
_g0 = gds.EndGroup("")
7381

7482

@@ -137,17 +145,17 @@ class ProcSettings(gds.DataSet):
137145
% ("→", "→"),
138146
)
139147
use_signal_bounds = gds.BoolItem(
140-
"",
141-
_("Use signal bounds for new signals"),
148+
_("Use current signal bounds"),
149+
_("New signals"),
142150
help=_(
143151
"If enabled, when creating a new signal, the xmin and xmax values will be "
144152
"initialized from the current signal's bounds.<br>"
145153
"If disabled, the default values from the New Signal dialog will be used."
146154
),
147155
)
148156
use_image_dims = gds.BoolItem(
149-
"",
150-
_("Use image dimensions for new images"),
157+
_("Use current image dimensions"),
158+
_("New images"),
151159
help=_(
152160
"If enabled, when creating a new image, the width and height values will "
153161
"be initialized from the current image's dimensions.<br>"

datalab/locale/fr/LC_MESSAGES/datalab.po

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: datalab\n"
88
"Report-Msgid-Bugs-To: p.raybaut@codra.fr\n"
9-
"POT-Creation-Date: 2025-10-16 17:55+0200\n"
9+
"POT-Creation-Date: 2025-10-18 11:18+0200\n"
1010
"PO-Revision-Date: 2025-05-22 15:46+0200\n"
1111
"Last-Translator: Christophe Debonnel <c.debonnel@codra.fr>\n"
1212
"Language: fr\n"
@@ -622,6 +622,24 @@ msgstr "Cela signifie que l'application n'a pas été officiellement qualifiée
622622
msgid "Do you want to see available log files?"
623623
msgstr "Souhaitez-vous consulter les journaux de bord disponibles ?"
624624

625+
msgid "DataLab v0.20 plugins detected"
626+
msgstr "Plugins DataLab v0.20 détectés"
627+
628+
msgid "The following plugins are using the old DataLab v0.20 format:"
629+
msgstr "Les plugins suivants utilisent l'ancien format DataLab v0.20 :"
630+
631+
msgid "These plugins will <b>not be loaded</b> in DataLab v1.0 because they are not compatible with the new architecture."
632+
msgstr "Ces plugins ne seront <b>pas chargés</b> dans DataLab v1.0 car ils ne sont pas compatibles avec la nouvelle architecture."
633+
634+
msgid "To use these plugins with DataLab v1.0, you need to update them. Please refer to the migration guide on the DataLab website "
635+
msgstr "Pour utiliser ces plugins avec DataLab v1.0, vous devez les mettre à jour. Veuillez vous référer au guide de migration sur le site web de DataLab "
636+
637+
msgid " or in the PDF documentation."
638+
msgstr " ou dans la documentation PDF."
639+
640+
msgid "Choosing to ignore this message will prevent it from appearing again."
641+
msgstr "Ignorer ce message empêchera son affichage ultérieur."
642+
625643
#, python-format
626644
msgid "Welcome to %s!"
627645
msgstr "Bienvenue dans %s !"
@@ -1846,6 +1864,15 @@ msgstr "Chemin des plugins"
18461864
msgid "Path to third-party plugins.<br><br>DataLab will discover plugins in this path, as well as in your PYTHONPATH."
18471865
msgstr "Chemin d'accès aux plugins tiers.<br><br>DataLab découvrira les plugins dans ce chemin, ainsi que dans votre PYTHONPATH."
18481866

1867+
msgid "Ignore compatibility issues warning"
1868+
msgstr "Ignorer l'avertissement de compatibilité"
1869+
1870+
msgid "DataLab v0.20 plugins"
1871+
msgstr "Plugins DataLab v0.20"
1872+
1873+
msgid "If enabled, DataLab will not warn you about v0.20 plugins that are no longer compatible with v1.0."
1874+
msgstr "Si activé, DataLab ne vous avertira pas des plugins v0.20 qui ne sont plus compatibles avec v1.0."
1875+
18491876
msgid "Settings for internal console, used for debugging or advanced users"
18501877
msgstr "Réglages de la console interne, utilisée pour le débogage ou les utilisateurs avancés"
18511878

@@ -1895,14 +1922,20 @@ msgstr "Mode d'opération"
18951922
msgid "Operation mode for computations taking <i>N</i> inputs:<ul><li><b>single</b>: single operand mode</li><li><b>pairwise</b>: pairwise operation mode</li></ul><br>Computations taking <i>N</i> inputs are the ones where:<ul><li>N(>=2) objects in %s 1 object out</li><li>N(>=1) objects + 1 object in %s N objects out</li></ul>"
18961923
msgstr "Mode d'opération pour les calculs prenant <i>N</i> entrées:<ul><li><b>single</b>: mode d'opération avec un seul opérande</li><li><b>pairwise</b>: mode d'opération par paire</li></ul><br>Les calculs prenant <i>N</i> entrées sont ceux où :<ul><li>N(>=2) objets en %s 1 objet en sortie</li><li>N(>=1) objets + 1 objet en %s N objets en sortie</li></ul>"
18971924

1898-
msgid "Use signal bounds for new signals"
1899-
msgstr "Utiliser les bornes du signal pour les nouveaux signaux"
1925+
msgid "Use current signal bounds"
1926+
msgstr "Utiliser les bornes du signal courant"
1927+
1928+
msgid "New signals"
1929+
msgstr "Nouveaux signaux"
19001930

19011931
msgid "If enabled, when creating a new signal, the xmin and xmax values will be initialized from the current signal's bounds.<br>If disabled, the default values from the New Signal dialog will be used."
19021932
msgstr "Si activé, lors de la création d'un nouveau signal, les valeurs xmin et xmax seront initialisées à partir des bornes du signal actuel.<br>Si désactivé, les valeurs par défaut de la boîte de dialogue Nouveau signal seront utilisées."
19031933

1904-
msgid "Use image dimensions for new images"
1905-
msgstr "Utiliser les dimensions de l'image pour les nouvelles images"
1934+
msgid "Use current image dimensions"
1935+
msgstr "Utiliser les dimensions de l'image courante"
1936+
1937+
msgid "New images"
1938+
msgstr "Nouvelles images"
19061939

19071940
msgid "If enabled, when creating a new image, the width and height values will be initialized from the current image's dimensions.<br>If disabled, the default values from the New Image dialog will be used."
19081941
msgstr "Si activé, lors de la création d'une nouvelle image, les valeurs de largeur et de hauteur seront initialisées à partir des dimensions de l'image actuelle.<br>Si désactivé, les valeurs par défaut de la boîte de dialogue Nouvelle image seront utilisées."
@@ -2852,4 +2885,3 @@ msgstr "Merci de sélectionner le fichier à importer."
28522885

28532886
msgid "Example Wizard"
28542887
msgstr "Assistant exemple"
2855-

datalab/plugins.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,33 @@ def discover_plugins() -> list[type[PluginBase]]:
316316
return []
317317

318318

319+
def discover_v020_plugins() -> list[tuple[str, str]]:
320+
"""Discover v0.20 plugins (with ``cdl_`` prefix) without importing them
321+
322+
Returns:
323+
List of tuples (plugin_name, directory_path) for discovered v0.20 plugins
324+
"""
325+
v020_plugins = []
326+
if Conf.main.plugins_enabled.get():
327+
for path in [
328+
Conf.main.plugins_path.get(),
329+
PLUGINS_DEFAULT_PATH,
330+
] + OTHER_PLUGINS_PATHLIST:
331+
rpath = osp.realpath(path)
332+
if rpath not in sys.path:
333+
sys.path.append(rpath)
334+
for finder, name, _ispkg in pkgutil.iter_modules():
335+
if name.startswith("cdl_"):
336+
# Get the directory path from the module finder
337+
if hasattr(finder, "path"):
338+
directory_path = finder.path
339+
v020_plugins.append((name, directory_path))
340+
else:
341+
# Fallback if path is not available
342+
v020_plugins.append((name, ""))
343+
return v020_plugins
344+
345+
319346
def get_available_plugins() -> list[PluginBase]:
320347
"""Instantiate and get available plugins
321348

doc/locale/fr/LC_MESSAGES/features/advanced/plugins.po

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: DataLab \n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-10-18 09:53+0200\n"
11+
"POT-Creation-Date: 2025-10-18 10:43+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -281,6 +281,12 @@ msgstr "Découvrir les plugins en utilisant la convention de nommage"
281281
msgid "List of discovered plugins (as classes)"
282282
msgstr "Liste des plugins découverts (en tant que classes)"
283283

284+
msgid "Discover v0.20 plugins (with ``cdl_`` prefix) without importing them"
285+
msgstr "Découvrir les plugins v0.20 (avec le préfixe ``cdl_``) sans les importer"
286+
287+
msgid "List of discovered v0.20 plugin names"
288+
msgstr "Liste des noms de plugins v0.20 découverts"
289+
284290
msgid "Instantiate and get available plugins"
285291
msgstr "Instancier et obtenir les plugins disponibles"
286292

0 commit comments

Comments
 (0)