Repository navigation
Register NumPy functions wrapped with Wrap1to1Func in plugins - #416
Merged
Merged
Conversation
Since plugins register their processing with `register_1_to_1`, a NumPy function wrapped with Sigima's `Wrap1to1Func` was refused as "not a valid computation function", so the documented example `plugins/examples/datalab_custom_func.py` no longer loaded. Such a wrapper is a valid feature function: it is picklable, named after the wrapped function and returns the expected object, as Sigima documents it. 1-to-1 features now accept the `Wrap1to1Func` instances of `sigima.proc.signal` and `sigima.proc.image`, besides decorated computation functions. Other callables are still refused at registration, with a message naming the accepted forms, and so is a wrapper registered for another pattern. Assisted-by: Claude Opus 5.5
Examples were only imported, so registering their processing could fail unnoticed. A new application test loads every plugin of `plugins/examples` in DataLab from a plugin directory, checks their stable IDs and the menu of the custom function example, and runs its processing on an image, also after reloading the plugins. It fails without the fix. Unit tests cover wrapped NumPy functions registered as signal and image 1-to-1 features, and their refusal for other patterns, as well as the refusal of plain functions. Assisted-by: Claude Opus 5.5
…415) A Sigima computation function, or, for a 1-to-1 feature without parameters, a NumPy function wrapped with `Wrap1to1Func`, as in the processing plugin example. With its French translation. Assisted-by: Claude Opus 5.5
PierreRaybaut
added a commit
that referenced
this pull request
Oct 21, 2026
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
11 tasks
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 #415.
Problem
The documented processing plugin example
plugins/examples/datalab_custom_func.py, used by the Custom function tutorial and the plugin guide, no longer loaded ondevelop: registeringsipi.Wrap1to1Func(weighted_average_denoise)withregister_1_to_1raisedValueError: 'weighted_average_denoise' is not a valid computation function, so the plugin added no menu.ComputingFeatureonly accepted functions decorated with Sigima's@computation_function(), and ccb81ef had moved the example fromcompute_1_to_1, which does not check the function, toregister_1_to_1, which does. No test loaded the shipped examples in DataLab.The regression only exists on
develop: no released version is affected.Fix
ComputingFeaturevalidates its function with_check_feature_function: a decorated Sigima computation function, or, for a 1-to-1 feature, aWrap1to1Funcinstance ofsigima.proc.signalorsigima.proc.image. Such a wrapper is picklable (as the process pool requires), named after the wrapped function and returns the expected object; Sigima documents it as usable in DataLab, and DataLab already detects the plugin origin of such wrappers.Behaviour change
Wrap1to1Funcwrappers, which were refused.'<name>' is not a valid computation function.Tests
test_shipped_plugin_examples_load_in_datalab(plugins_app_test.py): loads every plugin ofplugins/examplesin DataLab from a plugin directory, checks their stable IDs, the menu of the custom function example and the result of its processing on an image, then again after Reload plugins. It also fails if an example is added without being listed. It fails ondevelopwith the error above.processor_registry_unit_test.py: wrapped NumPy functions registered as signal and image 1-to-1 features (name, implicit feature ID, lookup by function); refusal for the four other patterns; refusal of plain functions with the accepted forms.datalab/tests/backbone/plugins,datalab/tests/features/plugins, processor registry, feature identity and contract consistency tests, 243 passed.datalab/gui/processor/base.py).Documentation and translations
doc/features/advanced/plugins.rst: the functions processing plugins may register, with a link to the processing plugin example (newplugin_example_processinglabel).-W.Out of scope
datalab-plugin create(Create single-file plugins with datalab-plugin create #413, Create single-file plugins with datalab-plugin create #414) registers a decorated wrapper function; once this is merged, Create single-file plugins with datalab-plugin create #414 will be rebased and simplified to registerWrap1to1Func(sample_processing)directly.