Repository navigation
Create single-file plugins with datalab-plugin create - #414
Merged
Merged
Conversation
Contributor
Author
|
Follow-up planned once #416 is merged: #416 (fixes #415) lets 1-to-1 features register a NumPy function wrapped with |
…413) `datalab-plugin create` now creates a single-file plugin by default: it only asks for the plugin name and description, then writes a `datalab_<name>.py` file to the user plugin directory, which DataLab loads once the plugins are reloaded. The file registers a sample processing, listed in the plugin submenu of the Plugins menu, whose short NumPy function is the only part to edit (signals, or images with `--object-kind image`); without the processing capability, the submenu holds an action showing a message. The layered installable project is unchanged and created with `--project`. - Python API, usable without the command line (#377): `render_single_file_plugin`, `create_single_file_plugin` and `get_default_plugin_folder`. The `datalab_` prefix is enforced and an existing file is never overwritten. - User values are written as readable Python strings, accents included, quoted as Ruff formats them. - Accents are removed from the names derived from the plugin name, e.g. `datalab_filtres_ameliores` and `FiltresAmelioresPlugin` for "Filtres améliorés", for projects too. - French translations of the new messages. Assisted-by: Claude Opus 5.5
Generated files pass Ruff, keep the typed name and description, and are discovered from any plugin directory for signals, images and application-only plugins. Only two questions are asked, the default folder is DataLab's user plugin directory, existing files are never overwritten, module names without the `datalab_` prefix are refused, and files are accepted by the Install plugins tab. In DataLab, the generated plugin adds its menu entry and processing, also after reloading the plugins. The existing project tests now pass `--project` and are otherwise unchanged. Assisted-by: Claude Opus 5.5
The plugin documentation presents `datalab-plugin create` as the way to create a single-file plugin, and the layered project with `--project`. Release notes 1.4 (Plugin project generator) with their French translation. Assisted-by: Claude Opus 5.5
Since #416 (#415), 1-to-1 features accept a NumPy function wrapped with Sigima's `Wrap1to1Func`. Generated single-file plugins now register `Wrap1to1Func(sample_processing)` directly, without the decorated `compute_sample_processing` function and the imports it needed: the generated file is shorter, and its only function is the one to edit. Assisted-by: Claude Opus 5.5
PierreRaybaut
force-pushed
the
feature/413-single-file-plugins
branch
from
October 21, 2026 15:08
6e5576c to
4a8d849
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #413.
Problem
datalab-plugin createonly created a layered installable project of about 17 files (pyproject.toml,srclayout,core/workflow/adapters, tests, release workflow). This suits plugins published in the plugin catalog, but it is far too much for DataLab users who are not software developers and simply want to add a processing, although DataLab loads a plugin that is a singledatalab_<name>.pyfile.Feature
datalab-plugin createnow creates a single-file plugin by default:datalab_<name>), plugin ID and destination are derived, and remain overridable with--package,--plugin-idand thedestinationargument;sample_processing(y)for signals,sample_processing(data)for images with--object-kind image), registered as it is, wrapped withWrap1to1Func(accepted since Register NumPy functions wrapped with Wrap1to1Func in plugins #416); without theprocessingcapability, the submenu holds an action showing a message;ruff formatandruff check(E, F, I);datalab_prefix is enforced, and an existing file is never overwritten;The layered installable project is created with
--project, with an unchanged output.Python API (foundation for #377)
datalab/plugins/generator.pyexposesrender_single_file_plugin,create_single_file_pluginandget_default_plugin_folder, usable without the command line, as #377 requires for its Plugins > New plugin... wizard. The rendering is split into fragments (imports, sample processing, menu action, plugin declaration) that the wizard may extend. The wizard, its composable templates, author and version fields, configuration updates, immediate loading and external editor remain in the scope of #377.Behaviour changes
datalab-plugin createwithout--projectcreates a single file instead of a project. The command has not been released yet (DataLab 1.4).datalab_filtres_amelioresandFiltresAmelioresPlugin, instead ofdatalab_filtres_am_lior_sandFiltresAmLiorSPlugin. ASCII names give the same results as before.Tests
plugin_generator_unit_test.py: the existing project tests now pass--projectand are otherwise unchanged. New tests: single file by default without any question; only two questions in interactive mode, with accents; signal, image and application-only files passing Ruff and discovered from a plugin directory; default folder equal toPLUGINS_DEFAULT_PATH; no overwrite, from the API and the CLI; module names withoutdatalab_refused; quotes and accents kept; generated file accepted by the plugin store (Install plugins).plugin_single_file_app_test.py: in DataLab, the generated plugin adds its menu entry, its processing computes the expected values, also after Reload plugins.developfor seven configurations (capabilities, object kinds, quotes, accents, long metadata): identical.SignalObjandImageObj(values and data type).develop(including Register NumPy functions wrapped with Wrap1to1Func in plugins #416):datalab/tests/backbone/plugins,datalab/tests/features/plugins, processor registry and feature identity tests, 253 passed.-W.Documentation and translations
doc/features/advanced/plugins.rst: new section "Creating a plugin withdatalab-plugin create"; the layered project section uses--project.Out of scope
datalab-plugincommand.plugins/examples/datalab_custom_func.py, refused by DataLab when this PR was opened, was fixed separately by Register NumPy functions wrapped with Wrap1to1Func in plugins #416 (Plugins cannot register NumPy functions wrapped with Wrap1to1Func (documented example fails) #415), on which the generated files now rely too.