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

OpenStudio CLI python GUI

asked 2019-02-21 14:54:42 -0600

ParticleSwarm's avatar

updated 2019-02-26 11:13:32 -0600

Hello Unmet!

I am currently writing a python GUI to overlay the OS CLI and need some advice on how to evoke a system call with the parameters and workflow.osw file. This issue that I am finding is that when I use a Python system call, the model does not successfully run. When I use the same call in a ruby file, the model runs perfectly.

These are the commands from both of my scripts:

 Python: subprocess.run("openstudio run -w MedOfficeSeed\modified.osw")
 Ruby:  system 'openstudio run -w MedOfficeSeed\workflow.osw'

I believe the problem could be rooted in the ruby dependency that Open Studio has. The CLI also works normally when I use the cmd prompt outside of my GUI application.

I know this question may be out of context from the bulk of the queries on here but was hoping someone could lend some advice. I would really like to avoid writing the GUI in Ruby!

Thank you, Particle Swarm

edit retag flag offensive close merge delete

Comments

@ParticleSwarm. I have successfully made command line calls for the CLI on computer that doesn't have system Ruby. I expect this issue is just related to how the command is being formed in Python.

David Goldwasser's avatar David Goldwasser  ( 2019-02-21 16:08:10 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-21 16:16:48 -0600

The OpenStudio CLI should work the same if called from Ruby, Python, batch file, or any other language. It was designed exactly for that purpose! I would second David's input that the issue is likely in how the command is formatted or interpreted by the call to subprocess.run. You might try putting in absolute paths to both the OpenStudio CLI and the OSW file. One possibility is that you have a different environment (e.g. environment variables) in your Ruby program than in your Python program, if this environment is used to launch the command then you could see issues (e.g. if PATH does not include OpenStudio CLI or if you have GEM_PATH set in Ruby but not Python).

Can you post more details about the errors you see if you continue to have issues?

edit flag offensive delete link more

Comments

Thank you for the quick response! When I am back at work I will post my environment variable configuration as well as my python script. A work around that I attempted was running the Ruby cli execution in a separate .rb file and sys calling that from python with no luck either. I currently have OS, Ruby, and Python included in my PATH variables and when opening the cmd manually all are executable from that state.

ParticleSwarm's avatar ParticleSwarm  ( 2019-02-21 16:42:24 -0600 )edit

After swapping the names to absolute file paths and changing the direction of the slashes I was able to get it to run! Thank you for the help @macumber

ParticleSwarm's avatar ParticleSwarm  ( 2019-02-26 12:54:28 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

Stats

Asked: 2019-02-21 14:54:42 -0600

Seen: 710 times

Last updated: Feb 26 '19