Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-expanding, fully opaque meta modules #315

Closed
jywarren opened this issue Aug 4, 2018 · 16 comments · Fixed by #779
Closed

Non-expanding, fully opaque meta modules #315

jywarren opened this issue Aug 4, 2018 · 16 comments · Fixed by #779

Comments

@jywarren
Copy link
Member

jywarren commented Aug 4, 2018

The new meta modules is very powerful! You can select one like NDVI-Colormap, and it expands to:

https://publiclab.github.io/image-sequencer/examples/#steps=ndvi(filter:red),colormap(colormap:default)

But, right now, if you want to use a meta module like NDVI-Colormap, you can't just use it in a string like:

https://publiclab.github.io/image-sequencer/examples/#steps=ndvi-colormap

Module NDVI-Colormap not found.

A modification of meta-modules would be great, where:

  1. they are, to all external appearances, just normal modules that don't expand
  2. they contain other modules, but 'secretly' -- i.e. they run a mini-sequencer inside themselves, so they simply accept an incoming image, and produce an output image, and act in every way like a normal module
  3. they would remain shown as a single step, permanently

Then you could modify the internals of a meta module -- say, to optimize it -- and nobody would ever know!

@tech4GT this may be too much to accomplish before the end of SoC, but I'm interested to hear your thoughts!

@gitmate gitmate bot added the new-feature label Aug 4, 2018
@gitmate
Copy link

gitmate bot commented Aug 4, 2018

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are #200 ("Meta" modules -- modules made of other sequences of modules), #108 (Math Module), #5 (image cropping module), #112 (Scale module), and #205 (add "drag to crop" UI feature to Crop module).

1 similar comment
@gitmate
Copy link

gitmate bot commented Aug 4, 2018

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are #200 ("Meta" modules -- modules made of other sequences of modules), #108 (Math Module), #5 (image cropping module), #112 (Scale module), and #205 (add "drag to crop" UI feature to Crop module).

@tech4GT
Copy link
Member

tech4GT commented Aug 4, 2018

@jywarren this is a very interesting idea and yes I don't think we can do this before the end of soc but I will surely work on this afterwards.
One good thing is that our architecture is perfect and all we need to do in order to achieve this is change the expand steps function.

@tech4GT
Copy link
Member

tech4GT commented Aug 4, 2018

This will be very interesting to implement

@gitmate gitmate bot added the enhancement label Aug 4, 2018
@jywarren
Copy link
Member Author

jywarren commented Aug 4, 2018 via email

@Mridul97
Copy link

Mridul97 commented Oct 1, 2018

I would like to give this issue a try. Can I work on this issue?

@jywarren
Copy link
Member Author

jywarren commented Oct 1, 2018 via email

@tech4GT
Copy link
Member

tech4GT commented Oct 2, 2018

Actually I've been working on this one already. I hope you don't mind @Mridul97

@Mridul97
Copy link

Mridul97 commented Oct 2, 2018

No, not at all!

@tech4GT
Copy link
Member

tech4GT commented Oct 2, 2018

Thanks!

@jywarren
Copy link
Member Author

jywarren commented Feb 8, 2019

Hi @tech4GT would you mind sharing any work you've done so far in a PR, or maybe outlining a couple steps towards this goal? I'd love to see progress made on it and if we could do it in parts, even better!

@jywarren
Copy link
Member Author

jywarren commented Feb 8, 2019

For example, would you consider simply building a module which starts a unique separate instance of ImageSequencer inside itself, passes in a string, and then replies with the output?

@tech4GT
Copy link
Member

tech4GT commented Feb 9, 2019

@jywarren Sure, I'll open a PR today!

@jywarren
Copy link
Member Author

To make creating these new meta-modules easier, we may be able to create a generator for these, which is to say, a way to automate the creation of opaque meta modules given:

  1. a JSON object or string of steps
  2. a function which maps the outer module options to the options objects of the internal steps (or falling back to the defaults if mapping is not provided)
  3. a set of overriding defaults for internal steps (which could be done via the mapping function too)

This could take the form:

module.exports = require('generateMetaModule')(function mapOptions(options) {

  var defaults = require('./../../util/getDefaults.js')(require('./info.json')); // standard defaults fetch

  options.x = options.x || defaults.x;
  options.y = options.y || defaults.y;
  options.colormap = options.colormap || defaults.colormap;
  options.h = options.h || defaults.h;

  // map above defaults into internal steps options:
  return [
    { 'name': 'gradient', 'options': {} },
    { 'name': 'colormap', 'options': { colormap: options.colormap } },
    { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
    { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
  ];
});

@tech4GT
Copy link
Member

tech4GT commented Feb 12, 2019

@jywarren Let us first finalize the structure of the meta module itself, after that I'll integrate it into createMetaModule function! We can use a flag like options.opaque.
This way we can use all the earlier meta-module work we did, since all that will be changing is the internal structure of the meta-module but the api layer can stay as it is!! This will need minimal code change!! Super exciting!! 🎉

@tech4GT
Copy link
Member

tech4GT commented Feb 12, 2019

So I was able to figure out 2 ways in which circular dependencies can occur

  1. Dynamically loading a module, we can check for it while loading it
  2. From the source code, this though rare can occur due to a programming error so let's make a test for this.

I will add to this list if I am able to think of more. Thoughts?
cc @publiclab/is-reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants