emoncms / MyHomeEnergyPlanner

My Home Energy Planner - Open Source home energy assessment software based on emoncms framework + openbem
GNU Affero General Public License v3.0
22 stars 27 forks source link

Library implementation development #363

Closed TrystanLea closed 4 years ago

TrystanLea commented 6 years ago

Hello @cagabi

Great to spend the day yesterday working on mhep and the groups module and to discuss the software implementation of MHEP libraries. I have been going through the library helper today and have found quite a few places we can modularise the code in order to make it easier to work with

I have managed to merge almost all of the item_to_html and the get_item_to_save functions by first using a library defaults definition that provides the info required to build the html and fetch the values back from the html: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1

Then this function generates the html: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1472

and this function fetches the values: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1560

I've uploaded my work so far to a branch called library_dev here:

https://github.com/emoncms/MyHomeEnergyPlanner/tree/library_dev

It also includes the library viewer concept I showed you yesterday:

librarymanager

This is all quite far from production ready but hopefully can help our thinking as we continue to develop on this topic.

All the best

Trystan

TrystanLea commented 6 years ago

Ah and the branch includes a start on exploring the idea of storing libraries in /var/lib/mhep in .json format :)

ghost commented 6 years ago

Hey Trystan,

I’ll let Carlos comment on the code side of things, but it looks like you’ve been busy!

On the library viewer, I do like the mock up you’ve shown on the link below. Looks like it would be good to navigate and very logical.

The bit that’s sometime more of a struggle is when you’re editing the contents of the library – it’s really useful to compare some of the entries against each other to make sure that we’re consistent and also avoid unnecessary duplication. The ideal would be to find a way of showing things that allowed you to edit one entry whilst also viewing another. If you have any bright ideas on that front, they’d be very welcome!

Marianne

From: Trystan Lea notifications@github.com Reply-To: emoncms/MyHomeEnergyPlanner reply@reply.github.com Date: Friday, 23 March 2018 at 12:36 To: emoncms/MyHomeEnergyPlanner MyHomeEnergyPlanner@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [emoncms/MyHomeEnergyPlanner] Library implementation development (#363)

Hello @cagabihttps://github.com/cagabi

Great to spend the day yesterday working on mhep and the groups module and to discuss the software implementation of MHEP libraries. I have been going through the library helper today and have found quite a few places we can modularise the code in order to make it easier to work with

I have managed to merge almost all of the item_to_html and the get_item_to_save functions by first using a library defaults definition that provides the info required to build the html and fetch the values back from the html: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1

Then this function generates the html: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1472

and this function fetches the values: https://github.com/emoncms/MyHomeEnergyPlanner/blob/library_dev/js/library-helper/library-helper-r1.js#L1560

I've uploaded my work so far to a branch called library_dev here:

https://github.com/emoncms/MyHomeEnergyPlanner/tree/library_dev

It also includes the library viewer concept I showed you yesterday:

[Image removed by sender. librarymanager]https://user-images.githubusercontent.com/503186/37828930-07be7eea-2e95-11e8-9ab2-f8c23d44c656.png

This is all quite far from production ready but hopefully can help our thinking as we continue to develop on this topic.

All the best

Trystan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/emoncms/MyHomeEnergyPlanner/issues/363, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APjOKy5dkrP_7S48knkKXQDyvCat6FpQks5thOwugaJpZM4S4pVR.

TrystanLea commented 6 years ago

Thanks Marianne, yes Carlos mention this requirement and the intention for the side by side comparison. I will keep thinking on this.

cagabi commented 6 years ago

I think this way of showing the items in library would be better than the one we have now when "Adding an item from library" for example in the fabric page

TrystanLea commented 6 years ago

At present there is the option to have multiple libraries under any given high level category e.g: elements, element_measures and these are saved to the database as a separate library for each category.

Is there a reason not to have say a carboncoop library that contains: elements, heating systems etc all saved as a single library rather than split up into sub libraries?

Im interested to learn more about what led to the design decision to split up libraries?

cagabi commented 6 years ago

I don't think I had a "design" reason to make it that way and probably it had more to do with the fact that originally there was only one library (the fabric one) and then I made new libraries.

I'm not happy with the current structure of libraries and how I coded the library helper. It's super difficult to use, not very helpful as a helper and something to learn from ;)

So I'm up for having a look to remake it. The interactions between MHEP and the library helper are limited to a couple of jquery events so we can totally overwrite it and make it better.

I think we need the input from Marianne as the final user and with that think the best way to implement it

TrystanLea commented 6 years ago

Thanks Carlos.

I've made a little progress on the idea we discussed of the file based json storage of data and the idea of only storing the user modifications made to a library on a user by user basis rather than full copies of the original library.

In this screenshot I have loaded the 'master' library and then changed the U-value of the selected loft element to 0.24. This is the only change I've made so the resulting record of user changes only included the small json printed below in the 'my changes' section.

This is stored in /var/lib/mhep/user_1/master.json

(this file name master.json indicated that it inherits the master library stored in /var/lib/mhep/master/master.json)

When MHEP loads the assessment view it loads both the original master library and the user's changes and then merges them to produce the users modified library. Its then easy to revert back to the master library by clicking on revert changes and you could in theory add a revert change on a property level too in the interface..

librarymanagerdiff

Im edging towards the idea of still having the option to select from multiple libraries, e.g: standard, carbon coop, oem, cibse, domestic heat guide but that a library can contain multiple sub-libraries, which would mean the carbon coop library can contain elements, ventilation systems, heating systems etc.. which is just a small change from the current arrangement where the standard library was first split into libraries so that you had a carbon coop elements library and carbon coop water usage library..

small steps, hopefully in a useful direction..

TrystanLea commented 6 years ago

Part of the idea here is to have an easier version control approach.

  1. You can have a master library which can be stored in a git repository with the benefits of version control that git brings.
  2. Then specific user changes are stored, with this inheritance to the master library relationship.
  3. A user could then submit their changes for inclusion in the master library.
  4. A library administrator could review and accept.
  5. The saved result can be written straight back to the master file
  6. Changes are then visible in the git diff and commit history is also browsable so that you can check changes over time (to the main master library)
ghost commented 6 years ago

Hello,

Apologies, not been in on all of this conversation but just to add something -

It would actually be a good idea if we’re able to have multiple libraries, that users can modify, and that are not shared publicly - due mainly to issues with professional indemnity.

This actually works quite well at the moment in how the Carbon Coop Library works - I’m the only one who can edit it, but it’s shared with all the Carbon Coop assessors and can be updated quite quickly in response to feedback.

I think what you suggest would work well for the openBEM element, but we probably need to have a slightly different set up where we’re authoring the library for professional assessments - mostly cause we need to protect more detailed info from potential inappropriate/naive use.

Thanks,

Marianne


From: Trystan Lea notifications@github.com Sent: Monday, March 26, 2018 11:27:39 AM To: emoncms/MyHomeEnergyPlanner Cc: Marianne Heaslip; Comment Subject: Re: [emoncms/MyHomeEnergyPlanner] Library implementation development (#363)

Part of the idea here is to have an easier version control approach.

  1. You can have a master library which can be stored in a git repository with the benefits of version control that git brings.
  2. Then specific user changes are stored, with this inheritance to the master library relationship.
  3. A user could then submit their changes for inclusion in the master library.
  4. A library administrator could review and accept.
  5. The saved result can be written straight back to the master file
  6. Changes are then visible in the git diff and commit history is also browsable so that you can check changes over time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/emoncms/MyHomeEnergyPlanner/issues/363#issuecomment-376119984, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APjOKyU4-jvIZbkDuVYJwDiiCi0Ox1LRks5tiMKbgaJpZM4S4pVR.

TrystanLea commented 6 years ago

Hello @marianneURBED, Yes your quite right, the sharing/permissions part is missing in the above. I will keep thinking on it.

TrystanLea commented 6 years ago

A small step forward with this, I have now bought back in the library sharing/permissions code, which provides the existing mhep access control.

The main differences are now:

Im also working towards merging the measures into the base elements but with the ability to only show the items that are flagged as having the capability to be a measure in a measure selector. Avoids the case where you need to duplicate an item in both the measures category and the base category (e.g where a house starts with a well insulated wall)

libraries

ghost commented 6 years ago

Hi Trystan,

That all sounds good – merging the elements and measure is particularly useful, as that’s a bit of a current frustration in trying to manage the libraries effectively.

Thanks,

Marianne

From: Trystan Lea notifications@github.com Reply-To: emoncms/MyHomeEnergyPlanner reply@reply.github.com Date: Friday, 6 April 2018 at 11:37 To: emoncms/MyHomeEnergyPlanner MyHomeEnergyPlanner@noreply.github.com Cc: Marianne Heaslip marianne@urbed.coop, Mention mention@noreply.github.com Subject: Re: [emoncms/MyHomeEnergyPlanner] Library implementation development (#363)

A small step forward with this, I have now bought back in the library sharing/permissions code, which provides the existing mhep access control.

The main differences are now:

Im also working towards merging the measures into the base elements but with the ability to only show the items that are flagged as having the capability to be a measure in a measure selector. Avoids the case where you need to duplicate an item in both the measures category and the base category (e.g where a house starts with a well insulated wall)

[Image removed by sender. libraries]https://user-images.githubusercontent.com/503186/38416839-0476b1cc-398e-11e8-8a80-e73cd30fa446.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/emoncms/MyHomeEnergyPlanner/issues/363#issuecomment-379215889, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APjOK0HMTqsw_IJiWgnn8DSV7091tsLDks5tl0VZgaJpZM4S4pVR.

ghost commented 4 years ago

Superseded by recent work by Carbon Coop on libraries and users/ organisations.