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 parameter mapping feature #820

Closed
3 tasks done
Tracked by #761
zanete opened this issue Jun 11, 2024 · 5 comments · Fixed by #923
Closed
3 tasks done
Tracked by #761

Add parameter mapping feature #820

zanete opened this issue Jun 11, 2024 · 5 comments · Fixed by #923
Assignees
Labels
core-only This issue is reserved for the IF core team only

Comments

@zanete
Copy link

zanete commented Jun 11, 2024

Why: Sub of #761 - so that we can automatically add the return values of one plugin to the inputs array under the name required by another plugin

What: Build a feature in IF that maps a parameter that is present in the input data to a new name that is expected by a particular plugin. For example, let's say a hypothetical plugin, myPlugin expects to see cpu/util in the inputs array. That p[recise parametr is not available in the array, but the precise same information is available with the cpu-utilization name. In this case, we want to use the mapping feature to pass the value of cpu-utilization to myPlugin as cpu/util.

The configuration for this should be done in the manifest, in the initialization bock for each plugin, for example:

initialize:
  plugins:
    my-plugin:
      method: MyPlugin
      path: @grnsft/dummy-plugins
      mapping:
        cpu/util: cpu-utilization

In this case, my-plugin, which expects to see cpu/util will understand that it should use the cpu-utilization values rather than throwing an error because cpu/util is not available.

Scope of work:

  • Implement mapping feature
  • Add unit tests

Acceptance criteria

  • mapping feature allows re-keying data in the inputs array for the purpose of executing an individual plugin
    GIVEN the feature is implemented
    WHEN I run the following manifest:
name: sum
description: successful path
tags:
initialize:
  plugins:
    sum:
      method: Sum
      path: "builtin"
      global-config:
        input-parameters: ["cpu/energy", "network/energy"]
        output-parameter: "energy"
      mapping:
        cpu/energy: energy-from-cpu
        network/energy: energy-from-network
tree:
  children:
    child:
      pipeline:
        - sum
      config:
        sum:
      inputs:
        - timestamp: 2023-08-06T00:00
          duration: 3600
          energy-from-cpu: 0.001
          energy-from-network: 0.001

THEN IF should map the available energy-from-cpu and energy-from-network values to the expected cpu/energy and network/energy values and correctly execute the sum plugin, yielding the following manifest:

name: sum
description: successful path
tags:
initialize:
  plugins:
    sum:
      method: Sum
      path: "builtin"
      global-config:
        input-parameters: ["cpu/energy", "network/energy"]
        output-parameter: "energy"
      mapping:
        cpu/energy: energy-from-cpu
        network/energy: energy-from-network
tree:
  children:
    child:
      pipeline:
        - sum
      config:
        sum:
      inputs:
        - timestamp: 2023-08-06T00:00
          duration: 3600
          energy-from-cpu: 0.001
          energy-from-network: 0.001
      outputs:
        - timestamp: 2023-08-06T00:00
          duration: 3600
          energy-from-cpu: 0.001
          energy-from-network: 0.001
          energy: 0.002

This behaviour should generalize to any plugin.

@zanete zanete added this to the Inputs and Outputs milestone Jun 11, 2024
@zanete zanete moved this to In Design in IF Jun 11, 2024
@zanete zanete added draft The issue is still being written, no need to respond or action on anything. core-only This issue is reserved for the IF core team only labels Jun 11, 2024
@zanete zanete changed the title Add mapping feature Add parameter mapping feature Jun 11, 2024
@jmcook1186 jmcook1186 moved this from In Design to In Refinement in IF Jun 17, 2024
@zanete
Copy link
Author

zanete commented Jun 18, 2024

@manushak @narekhovhannisyan please review ac to confirm you're ok with it

@narekhovhannisyan narekhovhannisyan removed their assignment Jun 27, 2024
@narekhovhannisyan narekhovhannisyan removed their assignment Jun 27, 2024
@zanete zanete moved this from In Refinement to Ready in IF Jun 27, 2024
@zanete zanete removed the draft The issue is still being written, no need to respond or action on anything. label Jul 25, 2024
@manushak manushak moved this from Ready to In Progress in IF Jul 25, 2024
@manushak manushak linked a pull request Jul 26, 2024 that will close this issue
9 tasks
@manushak manushak moved this from In Progress to Pending Review in IF Jul 26, 2024
@zanete
Copy link
Author

zanete commented Jul 29, 2024

caution, this contains breaking changes. review needed from @narekhovhannisyan and @jmcook1186

@zanete zanete moved this from Pending Review to In Progress in IF Aug 1, 2024
@zanete
Copy link
Author

zanete commented Aug 1, 2024

need to update unit tests for plugins

@zanete
Copy link
Author

zanete commented Aug 2, 2024

the current solution causes breaking changes for plugin, so we are changing the function to be backwards compatible (work also without mappings)

@manushak manushak moved this from In Progress to Pending Review in IF Aug 5, 2024
@zanete
Copy link
Author

zanete commented Aug 5, 2024

@narekhovhannisyan @jmcook1186 please review 🙏

@manushak manushak moved this from In Progress to Pending Review in IF Aug 12, 2024
@github-project-automation github-project-automation bot moved this from Pending Review to Done in IF Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-only This issue is reserved for the IF core team only
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants