NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
509 stars 193 forks source link

Issue with Python bindings for v1.8.0 #1786

Closed elainethale closed 9 years ago

elainethale commented 9 years ago

I get an import error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
---> 12 import openstudio

/home/ehale/Projects/openstudio/openstudiocore/python/openstudio.py in <module>()
     15 from openstudioutilities import *
     16 
---> 17 import openstudioenergyplus as energyplus
     18 
     19 import openstudiomodel as model

/home/ehale/Projects/openstudio/build-release/OSCore-prefix/src/OSCore-build/Products/python/openstudioenergyplus.py in <module>()
    179 import openstudioutilitiesidf
    180 import openstudioutilitiesfiletypes
--> 181 import openstudiomodel
    182 class ErrorLevel(_object):
    183     __swig_setmethods__ = {}

/home/ehale/Projects/openstudio/build-release/OSCore-prefix/src/OSCore-build/Products/python/openstudiomodel.py in <module>()
     98 
     99 
--> 100 from openstudiomodelcore import *
    101 from openstudiomodelsimulation import *
    102 from openstudiomodelresources import *

/home/ehale/Projects/openstudio/build-release/OSCore-prefix/src/OSCore-build/Products/python/openstudiomodelcore.py in <module>()
   1526 
   1527 
-> 1528 def compareInputAndOutput(object, attributeName, inputResult, outputResult, tol, logLevel=Debug):
   1529     return _openstudiomodelcore.compareInputAndOutput(object, attributeName, inputResult, outputResult, tol, logLevel)
   1530 compareInputAndOutput = _openstudiomodelcore.compareInputAndOutput

NameError: name 'Debug' is not defined

Looking around at .i files, etc., I don't see any recent (last 6 month) changes that should have caused this, nonetheless, there it is. There is a workaround that I will use for now: adding

#if defined SWIGPYTHON
  %ignore openstudio::model::compareInputAndOutput;
#endif

to src/model/ModelCore.i.

macumber commented 9 years ago

@mbadams5 have you seen this?

macumber commented 9 years ago

Also @elainethale did you get this error importing bindings based on a build of the v1.8.0 tag?

mbadams5 commented 9 years ago

@macumber Yes i've seen this. I don't know why it is happening.

This is how I fixed it on my machine.

def compareInputAndOutput(object, attributeName, inputResult, outputResult, tol, logLevel=openstudioutilitiescore.Debug):
    return _openstudiomodelcore.compareInputAndOutput(object, attributeName, inputResult, outputResult, tol, logLevel)
compareInputAndOutput = _openstudiomodelcore.compareInputAndOutput

The key part is adding openstudioutilitiescore before Debug. My rough guess is that it is hitting some protected key word and it needs the fully qualified path to be correct. How to make sure this happens through the swig bindings, no clue yet.

elainethale commented 9 years ago

Yes, v1.8.0, and it did not happen previously for me. (I was probably on v1.7.0 or even v1.6.0.)

macumber commented 9 years ago

@mbadams5 or @elainethale if you want to fix this for 1.9.0 please feel free. I think Elaine's patch is reasonable.