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

Plugin Factory #989

Open
2 tasks
narekhovhannisyan opened this issue Aug 22, 2024 · 3 comments
Open
2 tasks

Plugin Factory #989

narekhovhannisyan opened this issue Aug 22, 2024 · 3 comments
Assignees

Comments

@narekhovhannisyan
Copy link
Member

What

As a developer, I want simple user experience while developing plugins. For that I need to less care about utility functions like mapConfigIfNeeded, mapOutputIfNeeded and so on.
As a proposal for solution is to incapsulate mapConfigIfNeeded function in validateConfig (which is abstraction over out old validate function from if-core). mapInputIfNeeded can be incapsulated into validate function.

Why

Context

Prerequisites/resources

SoW (scope of work)

  • documentation updated
  • test cases added

Acceptance criteria

Given (Setup): Describes the initial state of the system or the preconditions for a change.

When (Action): Describes the specific action or behavior that is being tested/changed.

Then (Assertion): Defines the expected outcome or behavior of the system after the action in the "When" step is performed.

@zanete
Copy link

zanete commented Sep 2, 2024

please post your thoughts on the solution to improve plugin developer experience as discussed in the planning call

@narekhovhannisyan
Copy link
Member Author

narekhovhannisyan commented Sep 2, 2024

const utils = require('@grnsft/if-core/utils/validations');
const {validate} = utils;

// This one should be in if-core, which will make if-core more reasonable
const PluginInterface = params => input => {
  const {metadata, callback, validateInput, validateConfig, evaluateInput} =
    params;

  return {
    metadata,
    execute: () => {
      const safeInput = validateInput(input);

      const result = callback(safeInput);

      return result;
    },
  };
};

const metadata = {
  inputs: {},
  outputs: {},
};

const callback = inputs => {
  const result = inputs.map(input => (input['carbon-embodied'] = 1));

  return result;
};

module.exports = PluginInterface({metadata, callback});

@zanete
Copy link

zanete commented Sep 17, 2024

will integrate the inline arithmetic into this as well after merging #970

@zanete zanete added this to the IF Lifecycle Assessment milestone Sep 23, 2024
@zanete zanete changed the title Incapsulate map config, input and output functions in if-core validator Plugin Factory Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

3 participants