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 pipeline to insert meter data to database #482

Merged

Conversation

truonghh99
Copy link
Contributor

@truonghh99 truonghh99 commented May 2, 2020

Add a pipeline to read, convert, validate, and insert data from Obvius, Metasys, and Mamac meters to database.

Attempt to solve issues and fixes #467 and fixes #196.

Note: this pull request also contains some modifications in the database settings to accept Obvius data. These changes can be removed if NoraCodes:obvius-old is successfully merged to development.

NoraCodes and others added 30 commits January 14, 2019 14:41
This implementation is provisional and not production ready.
And propagate errors with more info out of migrations.
Obvius ingestion currently does NOT modify existing data, even when
passed new, updated data for the same meter and time. This is now
tested; if it needs to be modified, that's ok, but it should be
deliberate.
The database connection was left open, so the process would wait for
PostgreSQL/PGPromise to time out. This commit adds a root suite
mocha.after() hook so that the database is disconnected as soon as all
the tests have run.
This includes adding the src/server/middleware/ folder, to which all
middlewares should eventually be moved.
This involves some internal restructuring of the util module, which does
not affect the public interface.
Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to note that the delay in getting this PR approved/merged relates to project considerations and nothing about the work done or the efforts of @truonghh99.
This PR is very good work and does not have any issues while running. I note the following that are global thoughts or ones that might be addressed outside this PR:

  • We need to merge in the huss branch (already has PR) to fix a number of issues. I want to record that I already did this to do more testing. There were 4 files with merge conflicts and I have a record of what to do about them. I then ran all the tests and everything passed.
  • I tested updating and viewing real Mamac meters. It works as expected.
  • There are old files in src/server/services/ that relate to new files in pipeline. Some are: addMamacMeters.js, loadFromCsvStream.js, loadMamacReadingsFromCsvFile.js, readCSV.js, readMamacData.js, readMamacMeters.js, readMetasysData.js, updateMeters.js & also consider testing files (insertMamacReadingsFromCSVTests, metasysTests, etc.). We need to decide what should be done with these seemingly related versions. This is an expansion of comment by @ak476519. Issue redundate pipeline file #510 addresses this.
  • The conditionSet is undefined in insertMamacData, insertMetasysData & insertObviusData. We need to decide what to put in for these so we actually do testing on inputted data. This may require new admin input to decide. Issue set checks in pipeline #511 addresses this.
  • It seems insertMetasysData is only used in testing now. Should it be used in the actual OED code? Issue use of Metasys pipeline in OED code #512 addresses this.
  • I want to amplify @truonghh99 comment that handleCumulative drops the logical first value. We need to think about how we deal with sorted, reverse sorted & cumulative to get what we want. Dropping a value (esp. without warning) seems undesirable. Issue first value in cumulative data #513 addresses this.
  • We can improve the tests in insertMamacDataTests by verifying the values. See Metasys test on doing one value. A better alternative would be to test a middle value or all of them by making the values regular. The same applies to insertMetasysDataTests. Issue improve pipeline tests #514 addresses this.
  • insertMetasysDataTests has issues of wrong gap on 9/26/16 at 2:00 and bad date right before this. Should this be two tests? This one is being let go.
  • There are likely changes coming to the obvius version of insertObviusData.js by @lindavin. These include logging (maybe changing) how meter creation is done & not assuming readings are 60 minutes. We need to coordinate the obvius changes with this code.
  • What happens if the meter does not exist when OED tries to create it in insertMetasysData.js? I'm concerned it will cause an issue where the code encounters but does not deal with an error. I know there are places we don't check for this, however, here this is typically data coming from another source where we are using the filename to get the meter name. Unlike the internal uses where we control the name, this seems to be a place where a mistake can really happen. I do know the original code did not check for this but I'm seeing it now. Issue missing meter on Metasys inport of data #515 addresses this.
  • The stream version (see loadCsvInput.js) cannot deal with cumulative or repeated data as the other input can. I wonder if we want to make them consistent? Issues stream data input expansion #516 addresses this.

src/server/test/db/validateReadingsTests.js Outdated Show resolved Hide resolved
src/server/test/db/validateReadingsTests.js Show resolved Hide resolved
src/server/test/db/validateReadingsTests.js Show resolved Hide resolved
@huss
Copy link
Member

huss commented Nov 30, 2020

All the updated changes seem good. I have locally tested the code and it passes. The CodeQL failures relate to Obvius and are not part of this PR. They are being addressed separately. Once the final item that is under discussion is resolved this PR is ready to be merged. I have opened issues for remaining items listed that are outside this PR.

@huss huss mentioned this pull request Dec 10, 2020
This just gets all the comments and params fixed up.
@huss
Copy link
Member

huss commented Dec 11, 2020

The Travis failure is an ongoing issue but local testing showed all is fine. This is good work that is ready for deployment.

@huss huss merged commit 3ec06bf into OpenEnergyDashboard:development Dec 11, 2020
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.

standardize API and pipeline for acquiring meter data sanity checking meter data
5 participants