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

Add module options to CLI #97

Closed
4 tasks
ccpandhare opened this issue Aug 28, 2017 · 2 comments
Closed
4 tasks

Add module options to CLI #97

ccpandhare opened this issue Aug 28, 2017 · 2 comments

Comments

@ccpandhare
Copy link
Collaborator

ccpandhare commented Aug 28, 2017

First Timers Only

Hi, this is a first-timers-only issue. This means this has been worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

The Problem

Image Sequencer processes images sequentially and every algorithm which is responsible for processing the image and generating output is called a step. Some such steps need the user to give an input in order for it to work. For example a Crop module. The user must provide which part of the image has to be cropped (If the user doesn't, the step assumes some default inputs. FOr example, the crop module crops the image to 50% of it's original with and height starting from the top left corner of the image).

We recently added a basic Command Line Interface (CLI) to Image Sequencer, but it isn't complete yet. Currently there is no way for the user to give any input to steps. So all steps requiring inputs, assume the default inputs.

So we need to update the CLI to accept the necessary inputs from the user.

Towards the solution

The file which handles the CLI is ./index.js.

The following line in ./index.js is responsible for adding a step:

  sequencer.addSteps(program.step);

The way to pass in options (User Inputs) to a step is by paasing in a JavaScript object to the addSteps() method with input names as the key and inputs as the value.

var options = {
    "inputName1": "value",
    "inputName2": "value"
}

sequencer.addSteps(program.step, options);

Naturally, different steps accept different inputs. Every step has a info.json specifying what inputs it accepts and what outputs it gives. These JSON files can be found at ./src/modules/[ModuleName]/info.json.

example : info.json of Crop Module:

{
  "name": "Crop",
  "inputs": {
    "x": {
      "type": "integer",
      "desc": "X-position (measured from left) from where cropping starts",
      "default": 0
    },
    ...
  }
  ...
}

You can access the input.json for different modules like this:

// If no step-name is given, an object with info.jsons of all steps is returned
sequencer.modulesInfo('step-name');

The Solution

What you'll have to do is read the inputs for the particular step requested by the user. The requested step is stored in program.step.

Then for every "input" required by the step, take inputs from the user. This could be of the form

$ ./index.js -i [PATH] -s step-name (This is how you run the CLI)
--
[step-name] : Enter a value for $input1 : (Take input)
[step-name] : Enter a value for $input2 : (Take input)

Then, store all this data in a JavaScript Object options and pass it into the method addSteps as shown above.

This is how the options Object should look for the Crop module, for example:

{
    "x": some_value,
    "y": some_value,
    "w": some_value,
    "h": some_value
}

Steps to Fix

  • Claim this issue with a comment here, and ask for any issues/clarifications.
  • Clone this repository locally.
  • Try to fix the issue as described above, but even before you have completed doing so, you can:
  • Commit your work and initiate a Pull Request (Mark it as work-needed if you haven't completed the work on the issue)
@ROODAY
Copy link

ROODAY commented Aug 28, 2017

Claimed!

@ccpandhare
Copy link
Collaborator Author

Great work! Could you open a Pull Request, please?

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

No branches or pull requests

2 participants