- πΊπΈUnited States benjifisher Boston area
I think that
wrapper
withmethod: wrap
can be replaced by the more flexiblebuild_array
plugin from β¨ Process plugin to build an array Active ; andmethod: unwrap
can be replaced bycallback
withcallable: array_pop
.For example, the pipeline from the issue description,
- plugin: wrapper method: wrap source: my_array key: element - plugin: sub_process process: '0': plugin: flatten source: element # This should match the 'key' used when wrapping. - plugin: wrapper method: unwrap
is equivalent to
- plugin: build_array template: element: 'pipeline:' source: my_array - plugin: sub_process process: '0': plugin: flatten source: element - plugin: callback callable: array_pop
I verified that they give the same results on the example input using
migrate_sandbox
.So I suggest we close this issue in favor of β¨ Process plugin to build an array Active .
- πΊπΈUnited States danflanagan8 St. Louis, US
I'm working my way through reviewing the related
array_template
process plugin.I can confirm the part of comment #5 about replacing the wrap method using array_template.
I'm thinking about the array_pop as a replacement for unwrap...it's not exactly the same because the unwrap method fails if the argument is not a single-valued array, but that's not really a big deal.
So I'm convinced that the wrapper plugin could be completely reproduced as described by @benjifisher in #5
The only question is whether there's enough DX value in:
1. the symmetry that comes with wrap/subprocess/unwrap
2. the relative simplicity or the wrap syntax compared to the array_template syntax - π¬π§United Kingdom joachim
> The only question is whether there's enough DX value in:
> 1. the symmetry that comes with wrap/subprocess/unwrap
> 2. the relative simplicity or the wrap syntax compared to the array_template syntaxFor the syntax, the plugin from this issue is definitely nicer.
The MR from the other issue, β¨ Process plugin to build an array Active , has this example for migrating a paragraph reference:
* @code * process: * field_paragraph: * - plugin: migration_lookup * # ... * - plugin: array_template * template: * target_id: pipeline:0 * target_revision_id: pipeline:1 * @endcode
But with the plugin from this issue, my process array is simpler:
field_paragraph: - plugin: migration_lookup # SNIP - plugin: wrapper method: wrap
The array_template plugin allows much more complexity and is much more powerful for other use cases, but for this particular use case, having to specify a template for the array feels a bit redundant when I just want to nest the values down a level feels like overkill.
> 1. the symmetry that comes with wrap/subprocess/unwrap
I'd actually prefer two plugins, called 'wrap' and 'unwrap'.
This would then match the symmetry of the 'multiple_values' / 'single_value' plugins.
(An thought which may muddy the waters, if so, ignore -- what about instead of adding a wrapper plugin, we add an option to work with nesting to the 'multiple_values' / 'single_value' plugins? The functionality of the 'key' property here would be covered by the more complex 'array_template' plugin from β¨ Process plugin to build an array Active .)
- πΊπΈUnited States mikelutz Michigan, USA
I just want to note that "wrap" is just syntactical sugar for
plugin: get source: - ~
and unwrap is just syntactical sugar for
plugin: extract index: - 0
With maybe some single_value, multiple_value plugins in there if you need them, though if the purpose is to pipe a value into a handle_multiples plugin that can't handle a single value, there will often not be much point, as those plugins don't care if the value is a multiple or not.
(BTW, I'm starting to come around to just documenting the 'hack' with the get plugin above and officially supporting it. I've found enough cases where it's useful)
- Status changed to Closed: outdated
4 months ago 11:26pm 31 December 2024 - πΊπΈUnited States benjifisher Boston area
Now that β¨ Process plugin to build an array Active is fixed (and part of the 6.0.5 release) I think we can close this issue.
@mikelutz:
(BTW, I'm starting to come around to just documenting the 'hack' with the get plugin above and officially supporting it. I've found enough cases where it's useful)
Your timing is interesting. Now that we have the
array_template
plugin, we can get the same functionality (a little more verbose, but perhaps easier to read/clearer intention). So now you decide to change your mind? ;)