Green-Software-Foundation / if

Impact Framework
https://if.greensoftware.foundation/
MIT License
149 stars 40 forks source link

Add csv-import plugin to builtins #1051

Open bvickers7 opened 1 week ago

bvickers7 commented 1 week ago

What A builtin plugin that imports observations from a CSV file. Each row in the CSV is mapped to an input in the manifest.

Why Inputs can have many data points and for data sources that do not have dedicated importer plugins, a generic CSV import utility would save time by offering an alternative to manually copying in data points to the input.

Context

Prerequisites/resources None

SoW (scope of work)

Acceptance criteria

Given I have a CSV file with the following data at /path/to/my/file.csv timestamp duration cpu-util energy
2023-07-06T00:00 1 20 5
2023-07-06T00:01 1 30 10
2023-07-06T00:02 1 40 15

When I add the following to my manifest:

  plugins:
    data-import:
      method: CSVImport
      path: 'builtin'
      config:
        filepath: /path/to/my/file.csv
        output: '*'

Then the plugin has the following output:

      outputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu-util: 20
          energy: 5
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu-util: 30
          energy: 10
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu-util: 40
          energy: 15

Given I have the same data from scenario 1 available to the public internet at https://mywebsite.com/file.csv When I add the same block from scenario 1 to my manifest, except with filepath: https://mywebsite.com/file.csv Then the plugin has the same output as scenario 1

Then the plugin has the following output:

      outputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu/utilization: 20
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu/utilization: 30
        - timestamp: 2023-07-06T00:00
          duration: 1
          cpu/utilization: 40

This format for the output config was selected to be consistent with the csv-lookup plugin. I think this is not the simplest way to structure this config, and would like to discuss if complicating the config is worth keeping things consistent between plugins.

It should accept the following:

jmcook1186 commented 5 days ago

Hi @bvickers7 seems like a useful utility plugin - do you want to work on it? We typically ask open source contributors to host their plugins on their own Github repositories and share them via the Explorer to control our maintenance burden.