Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

I bet your Job object is not actually being created properly, resulting in it being None or an Optional. This would then cause the error when you go to enqueue that Job.

Looking at the header file for createModelToIdfJob(), it wants an openstudio::path as an input. I bet if you wrapped your paths in openstudio.path() then it should work as you expect.

j = openstudio.runmanager.Job(
    openstudio.runmanager.JobFactory.createModelToIdfJob(
    openstudio.path(os.path.join(osm_path, osm_name)),
    openstudio.path(output_path)
    )
)

I bet your Job object is not actually being created properly, resulting in it being None or an Optional. This would then cause the error when you go to enqueue that Job.

Looking at the header file for createModelToIdfJob(), it wants an openstudio::path as an input. I bet if you wrapped your paths in openstudio.path() then it should work as you expect.

j = openstudio.runmanager.Job(
    openstudio.runmanager.JobFactory.createModelToIdfJob(
    openstudio.path(os.path.join(osm_path, osm_name)),
    openstudio.path(output_path)
    )
)

UPDATE:

Next if that does not work then try this...

openstudio.Application.instance().application(True)
rm = openstudio.runmanager.RunManager(rm_path, True, True, False, False)

I was able to reproduce the error on my Mac and adding openstudio.Application.instance().application(True) solved the runtime error for me.

If THAT doesn't work the follow will create an EnergyPlus job. You will need to Forward Translate from Model to IDF first...

# Forward Translate from OSM to IDF and save()
translator = openstudio.energyplus.ForwardTranslator()
idf_string = translator.translateModel(test_model)
idf_string.save(openstudio.path('/Users/local_user/Desktop/test_idf.idf'), True)

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/sizing_run.db', True, True, False, False)
ep_tool = openstudiorunmanager.ToolInfo('/Applications/EnergyPlus-8-3-0/energyplus') # ep path
job = openstudiorunmanager.JobFactory.createEnergyPlusJob(
  ep_tool,
  '/Applications/EnergyPlus-8-3-0/Energy+.idd', # idd path
  '/Users/local_user/Desktop/test_idf.idf', # idf path
  '/Applications/EnergyPlus-8-3-0/WeatherFiles/Chicago.epw', # epw path
  '/Users/local_user/Desktop' # output path
)
rm.enqueue(job, True)

While this is a lot more code, it should be similar to your intent with createModelToIdfJob and then running that file.

If you ONLY want to go from OSM to IDF then the first three lines of code are by far the best and easiest method by using ForwardTranslator.

I bet your Job object is not actually being created properly, resulting in it being None or an Optional. This would then cause the error when you go to enqueue that Job.

Looking at the header file for createModelToIdfJob(), it wants an openstudio::path as an input. I bet if you wrapped your paths in openstudio.path() then it should work as you expect.

j = openstudio.runmanager.Job(
    openstudio.runmanager.JobFactory.createModelToIdfJob(
    openstudio.path(os.path.join(osm_path, osm_name)),
    openstudio.path(output_path)
    )
)

UPDATE:

Next if Make sure that rm_path is a path to a database file.

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/test_run.db', True, True, False, False)

If the database file does not work then try this...

openstudio.Application.instance().application(True)
rm = openstudio.runmanager.RunManager(rm_path, True, True, False, False)

exist, RunManager will create one for you. I was able to reproduce the your error locally on my Mac and adding openstudio.Application.instance().application(True) solved the runtime error for me.

If THAT doesn't work the follow when I just used...

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/', True, True, False, False)

When the path points to a database file, it works.

I will create an EnergyPlus job. You will need to Forward Translate say that using RunManager to translate from Model to IDF first...is kind of overkill. You can do the same, better and faster, just using ForwardTranslator.

# Forward Translate from OSM to IDF and save()
translator = openstudio.energyplus.ForwardTranslator()
idf_string = translator.translateModel(test_model)
idf_string.save(openstudio.path('/Users/local_user/Desktop/test_idf.idf'), True)

with open('/Users/local_user/Desktop/test_idf.idf', 'w') as idf_file:
    idf_file.write(idf_string)

Then you can run that IDF file using RunManager to createEnergyPlusJob...

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/sizing_run.db', openstudiorunmanager.RunManager('/Users/local_user/Desktop/test_run.db', True, True, False, False)
ep_tool = openstudiorunmanager.ToolInfo('/Applications/EnergyPlus-8-3-0/energyplus') # ep path
job = openstudiorunmanager.JobFactory.createEnergyPlusJob(
  ep_tool,
  '/Applications/EnergyPlus-8-3-0/Energy+.idd', # idd path
  '/Users/local_user/Desktop/test_idf.idf', # idf path
  '/Applications/EnergyPlus-8-3-0/WeatherFiles/Chicago.epw', # epw path
  '/Users/local_user/Desktop' # output path
)
rm.enqueue(job, True)

While this is a lot more code, it should be similar to your intent with createModelToIdfJob and then running that file.

If you ONLY want to go from OSM to IDF then the first three lines of code are by far the best and easiest method by using ForwardTranslator.

I bet your Job object is not actually being created properly, resulting in it being None or an Optional. This would then cause the error when you go to enqueue that Job.

Looking at the header file for createModelToIdfJob(), it wants an openstudio::path as an input. I bet if you wrapped your paths in openstudio.path() then it should work as you expect.

j = openstudio.runmanager.Job(
    openstudio.runmanager.JobFactory.createModelToIdfJob(
    openstudio.path(os.path.join(osm_path, osm_name)),
    openstudio.path(output_path)
    )
)

UPDATE:

Make sure that rm_path is a path to a database file.

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/test_run.db', openstudio.runmanager.RunManager('/Users/local_user/Desktop/test_run.db', True, True, False, False)

If the database file does not exist, RunManager will create one for you. I was able to reproduce your error locally on my Mac when I just used...

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/', openstudio.runmanager.RunManager('/Users/local_user/Desktop/', True, True, False, False)

When the path points to a database file, it works.

I will say that using RunManager to translate from Model to IDF is kind of overkill. You can do the same, better and faster, just using ForwardTranslator.

# Forward Translate from OSM to IDF and save()
translator = openstudio.energyplus.ForwardTranslator()
idf_string = translator.translateModel(test_model)
with open('/Users/local_user/Desktop/test_idf.idf', 'w') as idf_file:
    idf_file.write(idf_string)

Then you can run that IDF file using RunManager to createEnergyPlusJob...

rm = openstudiorunmanager.RunManager('/Users/local_user/Desktop/test_run.db', openstudio.runmanager.RunManager('/Users/local_user/Desktop/test_run.db', True, True, False, False)
ep_tool = openstudiorunmanager.ToolInfo('/Applications/EnergyPlus-8-3-0/energyplus') openstudio.runmanager.ToolInfo('/Applications/EnergyPlus-8-3-0/energyplus') # ep path
job = openstudiorunmanager.JobFactory.createEnergyPlusJob(
openstudio.runmanager.JobFactory.createEnergyPlusJob(
  ep_tool,
  '/Applications/EnergyPlus-8-3-0/Energy+.idd', # idd path
  '/Users/local_user/Desktop/test_idf.idf', # idf path
  '/Applications/EnergyPlus-8-3-0/WeatherFiles/Chicago.epw', # epw path
  '/Users/local_user/Desktop' # output path
)
rm.enqueue(job, True)