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

"Meta" modules -- modules made of other sequences of modules #200

Closed
jywarren opened this issue Mar 12, 2018 · 27 comments · Fixed by #779
Closed

"Meta" modules -- modules made of other sequences of modules #200

jywarren opened this issue Mar 12, 2018 · 27 comments · Fixed by #779

Comments

@jywarren
Copy link
Member

If someone composes a sequence and tweaks the settings, they have a process which is really useful.

And if we can concisely store that in the URL itself, then they can share that workflow (sequence + settings) with other people, or bookmark it, and we don't have to use a database to save it. We do this now, though we don't save the settings, just the sequence:

https://publiclab.github.io/image-sequencer/examples/#steps=invert,crop

(@ccpandhare -- i think we had a partial implementation of settings, do you remember? Ah -- #127)

We wouldn't save images, just the workflow itself. But we might want to start collecting these too -- they could in theory become "meta modules" with names of their own. Maybe that's a feature in its own right?

Another aspect of this is that if we have a consistent string-based way to save a sequence and its settings, that's a good format to use for remote REST commands down the road when we decide to do that -- #198 -- and also we could base a "meta module" system around such a string.

A meta module could be a module which contains a string describing a set of modules and their configurations, that can itself be re-used.

Meta, but very powerful!

We could even, if the UI is good enough, have this prompt people to save their sequences as a module -- to propose a module based on the current state of their sequencer! This could help with #190 as well.

@jywarren
Copy link
Member Author

GitMate.io thinks the contributors most likely able to help are @ccpandhare, and @tech4GT.

Possibly related issues are #108 (Math Module), #112 (Scale module), #5 (image cropping module), #122 (Simplify module requirements?), and #157 (Add a Contrast module).

@tech4GT
Copy link
Member

tech4GT commented Mar 12, 2018

@jywarren this is so cool, i will start working on this for the node using a meta.json and i will try to implement region extraction with that only, super excited😀

@tech4GT tech4GT self-assigned this Mar 14, 2018
@tech4GT
Copy link
Member

tech4GT commented Mar 14, 2018

@jywarren if #203 is a good enough approach then maybe we can start working on an option in the CLI for defining meta-modules so that user can dynamically define and these according to needs, So that is one user uses a particular combination a lot in a specific sequence they can define a meta-module for it. This will also be in sync with what we are planning to do with modules in the summer, what say?

@tech4GT
Copy link
Member

tech4GT commented Apr 20, 2018

@jywarren
here is a simple checklist of my view on how we should go about things for this

What is a Metamodule?: A Sequence of steps which can be represented as a string or as a json and can override some values of some steps while letting others fallback to default. The metamodule can be called with custom values just like a normal module

@jywarren actually there is one more thing, we want to allow user to make and store metamodule in node but that will not be possible unless we load modules dynamically as i suggested in my summer proposal so if we want to go down this route then we should first allow dynamic loading and creation of modules.( #190 ) coz if we are going to drastically change the module system then it's better we make met-modules on top of that, what say?

@tech4GT
Copy link
Member

tech4GT commented Apr 20, 2018

@jywarren we had to discuss #190 as well, this maybe a good time since we are making important architectural choices...

@jywarren
Copy link
Member Author

This is awesome, good planning! A few responses:

  1. "default presets of its constituent modules" -- let's say "pass through default presets of its const..."
  2. "Implement a .getString and getJSON function" -- let's also specify that it'll preserve not only the steps, but the settings
  3. "Allow for storage" -- this can be a future step but for now, let's approach this along with 3. (URL) by making a method called sequencer.import(string|json) -- what do you think?

Finally, sequencer.import() and sequencer.toString() and .toJSON() could all be unit tested independently of their different use cases, which is GREAT.

What do you think???

@jywarren
Copy link
Member Author

Er, wait! I'm mixing up sequencer.toString with metaModule.toString, aren't I? How should we approach this? Should metamodules have a toString and import method just like a sequencer, that's kind of what makes them meta, right? What do you think?

@tech4GT
Copy link
Member

tech4GT commented Apr 23, 2018

@jywarren i did not get the sequencer.import(), can you please explain it a little more, Thanks!
Also I think lets not do toString() we can do a sequencer.getStringMetaModule(metamodule) and sequencer.getJsonMetaModule(metamodule) functions..

@tech4GT
Copy link
Member

tech4GT commented Apr 23, 2018

@jywarren Are you talking about importing these modules into image sequencer...if that's so then that will actually be handled in dynamic modules so for that can you please have a look at #190, I posted a nice diagram explaining the flow for dynamic modules there, Thanks :)

@tech4GT
Copy link
Member

tech4GT commented Apr 23, 2018

@jywarren And yeah metamodule should surely have every function a normal module has.. I'll keep that in mind 👍

@jywarren
Copy link
Member Author

So for metaModule.import(string) it would read a string, and construct the metamodule based on that string. For a sequencer, it could reconstruct a sequence from the string passed to sequencer.import(string). Sorry, not that we would import new modules like Dynamic, but just that we'd import a sequence of modules which had been saved as a string.

So like we could then do:

string = metaModule.toString();
...
metaModule2.import(string);

Make sense?

sequencer.getStringMetaModule() could work but why don't we build this method into the module itself, because we could call it on any given module, like:

metaModule = sequencer.images.image1.steps[0];
string = metaModule.toString();
console.log(string);
metaModule.import(string + ',invert');

... does this make any sense to you?

@tech4GT
Copy link
Member

tech4GT commented Apr 24, 2018

@jywarren Yes!! This is very clear to me now. Thanks a ton for the explanation.

metaModule = sequencer.images.image1.steps[0];

But I think this won't work as it is, since this line would assign metaModule to a step, and then calling .toString() will be calling toString on a step.
Instead what we can do is:

sequencer.createMetaModuleFromString(sequencer.images.image1.steps[0] + ',invert');

How does this sound @jywarren

@tech4GT
Copy link
Member

tech4GT commented Apr 24, 2018

@jywarren Option 2: Actually sequencer.importString( MetaModuleString ) feels more natural to me than anything else, also I was thinking if we define functions on the metaModule itself then we would have to wrap it up in an object but if we keep the import on sequencer then metaModule can be just a String.
Thanks :)

@jywarren
Copy link
Member Author

calling .toString() will be calling toString on a step.

I think this is partly a matter of paradigm. We could, in theory, build .toString() into each step -- i mean, it's an instance of a module, right? Can you explain about having to wrap it in an object?

Thanks!!!

@tech4GT
Copy link
Member

tech4GT commented Apr 26, 2018

@jywarren Yeah that's right, it's an instance of a module but it feels kind of unnatural that we are doing

metaModule = sequencer.images.image1.steps[0];

Here we assign a step into the metaModule variable.
Then where we import the metaModule, I want to ask one thing, Does the metamodule appear as an option in the list of modules to chose from or it gets applied right away??
Aah it's so difficult to explain this on text, It'll be so cool if we can have a chat in realtime, what say??

@jywarren
Copy link
Member Author

I think a metamodule could be used in two ways:

  1. most important -- as a way to generate/instantiate a module from a sequence-string
  2. as a module you can choose in the UI, supplying it a sequence-string as a parameter

They're pretty similar, you know, but does this make sense?

@jywarren
Copy link
Member Author

One advantage of building toString() and importString() into the module itself is that you could "reprogram" a metamodule, and also because the code for all of this could live in the module itself, rather than in the sequencer core, which seems cleaner. Sequencer doesn't even really need to know how it works, you know?

@tech4GT
Copy link
Member

tech4GT commented Apr 30, 2018

@jywarren actually I had a little different idea in mind, I thought maybe we can have an option in the ui where after the user builds his sequence it says save as meta-module which will store it locally and now user will see this in drop-down like a normal module. Maybe we can do all these 3 ?

@jywarren
Copy link
Member Author

jywarren commented May 7, 2018

This has many parts now -- i'm going to start breaking it up by making a new one for a toString() method:

#250

@jywarren
Copy link
Member Author

jywarren commented Jun 3, 2018

We should now be able to implement metamodules using sequencer.importStringtoJson()!! from #276

@tech4GT
Copy link
Member

tech4GT commented Jun 3, 2018

This is great!! @jywarren but we need to keep a discussion session before implementing this

@jywarren
Copy link
Member Author

jywarren commented Jun 3, 2018 via email

@tech4GT
Copy link
Member

tech4GT commented Jun 3, 2018

@jywarren Sure I'll gather everything we have discussed so far and write questions tomorow after fixing the run optimization.
Thanks Good night!!😁

@jywarren
Copy link
Member Author

jywarren commented Jun 3, 2018 via email

@tech4GT
Copy link
Member

tech4GT commented Jun 18, 2018

@jywarren I have been thinking about this and I think best way to tackle this would be having a registerMetaModule function that takes a sequence string and this would add this new meta-module to a json file "meta-modules.json" and image sequencer would have a reload-modules function which would load modules and meta-modules again. This is also consistent with the dynamic modules idea and I think doing it this way implementing that would be much less work

@tech4GT
Copy link
Member

tech4GT commented Jun 18, 2018

So basically the flow I am suggesting is this

  • user creates a sequence with his custom settings for each step, then calls saveAsMetaModule()
  • this function internally calls sequencer.toJSON() and saves this in meta-modules.json file and calls
    sequencer.reloadModules()
  • reloadModules rebinds the sequencer.modules object to the new changed modules

@tech4GT
Copy link
Member

tech4GT commented Aug 6, 2018

Now closing this!!

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