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

createMetaModule generator #779

Merged
merged 11 commits into from
Feb 16, 2019
Merged

createMetaModule generator #779

merged 11 commits into from
Feb 16, 2019

Conversation

tech4GT
Copy link
Member

@tech4GT tech4GT commented Feb 16, 2019

Builds up on #765 , fixes #200, fixes #315

jywarren and others added 7 commits February 13, 2019 10:53
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

@jywarren So dow we want to support expanding meta modules? I say let's just stop supporting that API entirely and move all meta modules to this new architecture, what do you think?

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Also I am returning the complete module from createMetaModule so if the function is called from node context by a user like image-sequencer-app we can the load it directly by passing it to the loadNewModule

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

@jywarren Should I open a new pr removing the boilerplate code from modules or should we do it here itself?

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Hmm, I think we would need to make some changes to support 2 brightness modules with different inputs, since there can be only one value of options.brightness

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Maybe we can allow for making the value of an input an array, then this will be passed inside options to the module and the module can then use them as it needs?

// for example
module.exports = require('../../util/createMetaModule.js')(
  function mapFunction(options) {

    // return steps with options:
    return [
      { 'name': 'brightness', 'options': { 'brightness': options.brightness[0] } },
      { 'name': 'brightness', 'options': { 'brightness': options.brightness[1] } }
    ];
  }, {
    infoJson: require('./info.json')
  }
)[0];

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

@jywarren Actually what I am suggesting is that the infoJson of the module can define the attribute as an array and give it's default value as an array, since all the generator function is doing is getting the values from infoJson, it will work.
What we would have do do here is add support for array type inputs in sequencer UI and this should be ready to go as it is!

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

I'll demonstrate with an example, so I know my meta-module calls the brightness module 2 times, I can define it as an array in my infoJSON

{
 "inputs":
          {
"brightness": {
            "type": "array",
            "desc": "",
            "default": ["2","3"],
        }
          }
}

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

I'll get this array in my options argument of the map function and I can use it as required, so we don't need that boilerplate code still.
One more thing we can Allow this like a string too!
We can then split the input on space if the type is array, this will simplify things even further.
I'll go ahead and implement this right now, maybe It'll clearer to see it in action! :)

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Hmm, I think you are right, So let's keep the map function to allow customized mapping but still set the defaults in the create function itself, so the module just gets a list of values and can consume them whichever way it chooses to.
The UI can just display a string input which we can split on spaces.
How does that sound?

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@jywarren jywarren changed the title Generator createMetaModule generator Feb 16, 2019
@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

@jywarren On second though maybe we should leave it up to the module how it wants to consume multi-value inputs like you originally suggested. We can add a section about this in the documentation with an example using space separated values like we do for convolution, but basically the input type will be string.(They can use whatever delimiter they want).
How does that sound?

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Okay updating the docs now! We can then merge yay! 🎉

@jywarren
Copy link
Member

jywarren commented Feb 16, 2019 via email

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

@jywarren Please have a look at the docs, if we need to add something.
Let's also update a major version after this update since it breaks the old metaModule API

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2019

Okay the test pass, docs are ready. Merging this in now! Awesome!

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

Successfully merging this pull request may close these issues.

Non-expanding, fully opaque meta modules "Meta" modules -- modules made of other sequences of modules
2 participants