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

Python Measures break after opening OS 1.4 #767

Open
jzsustain opened this issue Nov 8, 2024 · 3 comments
Open

Python Measures break after opening OS 1.4 #767

jzsustain opened this issue Nov 8, 2024 · 3 comments
Labels
Triage Issue needs to be assessed and labeled, further information on reported might be needed

Comments

@jzsustain
Copy link

Issue overview

Python measures fail to show up after accessing measures in OS 1.4. Seems like OS 1.4 is trying to load them. This causes them not to show up in OS 1.8.

Current Behavior

Measures no longer show up in OS 1.8.

This error appears in the measure xml after accessing measures in OS 1.4:

Unable to locate primary Ruby script path for BCLMeasure 'new_measure' located at /.../OpenStudio/Measures/new_measure 1.

Expected Behavior

Python measures should still show up in OS 1.8.

Steps to Reproduce

  1. Create or already have an OS measure written in python
  2. Open OS 1.4
  3. Go to measures tab or hit apply measure now in OS 1.4
  4. Python measure no longer shows up in OS 1.8

Possible Solution

Not sure if there is a way to do it already, but a short term fix would be being able to set a different measures directory for different OS versions should fix it. When I try to change the measures directory for OS 1.4, it also changes it for OS 1.8. A way to fix the broken measures would also be helpful.

Details

Environment

Python

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): Mac M3
  • Version of OpenStudioApplication (if using an intermediate build, include SHA): 1.4/1.8

Context

Need a way to open OS 1.4 and not have all the Python measures break/not appear in OS 1.8.

@jzsustain jzsustain added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Nov 8, 2024
@jzsustain
Copy link
Author

As a temporary fix to get the measures working again, adding the below in the measure xml files section fixes the measure. Tedious to go through all the measures though.

<file>
  <version>
    <software_program>OpenStudio</software_program>
    <identifier>3.8.0</identifier>
    <min_compatible>3.8.0</min_compatible>
  </version>
  <filename>measure.py</filename>
  <filetype>py</filetype>
  <usage_type>script</usage_type>
  <checksum>00000000</checksum>
</file>

@macumber
Copy link
Collaborator

I can reproduce this. When opening OpenStudio Application 1.4.0 the file entry for measure.py is removed, that is a bug but we won't be able to fix that in an old version.

Then when you re-open OpenStudio Application 1.8.0 the code in BCLMeasure only checks for measure.rb and measure.py in the files section of the xml; https://github.com/NREL/OpenStudio/blob/develop/src/utilities/bcl/BCLMeasure.cpp#L399. I'm not sure if it would be a good idea to have that code check for the file on disk if it wasn't present in the xml?

Honestly, if this was affecting me, I would create a git repository for my measures (probably a good idea anyway). Then after working in OpenStudio Application 1.4.0, I would do a git restore . before opening OpenStudio Application 1.8.0. Here are some instructions to make a local git repo, or you could also make a repo on GitHub and clone it locally:

https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

@macumber
Copy link
Collaborator

The reason that measure.py is removed from the files in the xml by OpenStudio Application 1.4.0 is that it is not an approved root level file for 1.4.0:

https://github.com/NREL/OpenStudio/blob/v3.4.0/src/utilities/bcl/BCLMeasure.cpp#L917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage Issue needs to be assessed and labeled, further information on reported might be needed
Projects
None yet
Development

No branches or pull requests

2 participants