image-processing-pipeline icon indicating copy to clipboard operation
image-processing-pipeline copied to clipboard

Conditional pipe execution

Open TheDelta opened this issue 3 years ago • 5 comments

Checklist

  • [x] read and understood the contributing guidelines
  • [x] updated tests
  • [x] updated documentation (https://github.com/MarcusCemes/image-processing-pipeline-website/pull/2)
  • [x] npm run build and npm test passes

Affected core subsystem(s) core & cli

Description of change Added a test parameter, to allow one CLI execution to handle different files based on conditions. For example, this allows to use different settings based on filename, etc.

It is a bit old and I'm not sure if I'm feature complete yet, would love to get some feedback and suggestions if I should add something.

TheDelta avatar Aug 11 '22 05:08 TheDelta

Thanks for the PR.

I've always wanted to add conditional execution of different pipes, similar to what GitHub actions have for their steps, the difficulty in implementing this properly is maintaining compatibility with YAML and JSON configuration for CLI usage where it's impossible to embed lambda functions, such as with JS configs.

The regex approach seems interesting, although I imagine that this is only to test that the source filename matches a particular pattern, and doesn't other metadata into account?

MarcusCemes avatar Aug 11 '22 07:08 MarcusCemes

Exactly, regex is for filename only. I first wanted to do a glob handling but realized it would require a dependency and I think regexp should be fine. For more advanced stuff, the callback function (PipelineTestCallback ) can be used to check for metadata.

I try to test it on my project today to see if it works, it has been a few weeks since I was working on it and I'm unsure if I missed something (thats why it's still in draft mode :D)

TheDelta avatar Aug 11 '22 13:08 TheDelta

So far this only works for the CLI TypeScript version, I don't use YAML or anything atm, but I guess it shouldn't be an issue to have more advanced handling only for TypeScript CLI atm. Or we must rework this probably^^

TheDelta avatar Aug 11 '22 13:08 TheDelta

I added input filters, to filter out initial files before the processing starts. This allows to ignore certain file names, types, etc.

TheDelta avatar Aug 14 '22 12:08 TheDelta

I need some more testing but I noticed somehow that the pipelines are very slow and I'm not sure if it's my logic / chain of multuple sharp commands with toBuffer, etc or if something is slowing it down. Eventually also the amount of file(size) is simply taking that long. Need to run some traces when I find some time.

TheDelta avatar Sep 11 '22 06:09 TheDelta