# How to Install Measures to Run Models in Script?

**URL:** <https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097>\
**Category:** scripting\
**Tags:** honeybee, scripting\
**Created:** [April 23, 2022, 1:34pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097 "2022-04-23T13:34:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericoneill](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/ericoneill/32/26906_2.png) [@ericoneill](https://discourse.ladybug.tools/u/ericoneill)\
**Post date:** [April 23, 2022, 1:34pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/1 "2022-04-23T13:34:01Z")

</div>

So I’m just getting started with scripting with HB and DF. I’ve experimented building a very simple model and am trying to run it. I’ve written:

```auto
osw = to_openstudio_osw('/oswmodel', 
                        model_path=hbjson_loc,
                        epw_file='/mount/weather/USA_IL_Chicago.OHare.Intl.AP.725300_TMYx.epw',
                        additional_measures=['reports'],
                        report_units='ip',
                        schedule_directory='/scheds')

```

Which returns

```auto
AssertionError: OpenStudio report requested but the openstudio_results measure is not installed.

```

But I’m not sure where/how to install measures.

If I try to avoid installing measures and just run

```auto
osw = to_openstudio_osw('/oswmodel', 
                        model_path=hbjson_loc,
                        epw_file='/mount/weather/USA_IL_Chicago.OHare.Intl.AP.725300_TMYx.epw',
                        schedule_directory='/scheds')

```

It returns (0,0), so I have an error somewhere. But it fails silently. I think the issue is when it try to run the file run\_workflow.sh - if I navigate and run that file myself, I get:

```auto
 Found error in state 'initialization' with message ["Cannot find measure from_honeybee_model::/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:155:in `block in validate_measures'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `each'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `each_with_index'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `validate_measures'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_initialization.rb:122:in `perform'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291:in `step'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233:in `run'\n:/openstudio_cli.rb:1067:in `execute'\n:/openstudio_cli.rb:803:in `execute'\n:/openstudio_cli.rb:1855:in `<main>'\neval:186:in `eval'\neval:186:in `require_embedded_absolute'\neval:171:in `block in require_embedded'\neval:165:in `each'\neval:165:in `require_embedded'\neval:124:in `require'\neval:3:in `<main>'"]

```

So again, it appears I’m not properly installing measures. Any tips or can someone point me in the direction of the documentation for this?

Thank you!

---

<div class="post-metadata">

**Author:** ![ericoneill](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/ericoneill/32/26906_2.png) [@ericoneill](https://discourse.ladybug.tools/u/ericoneill)\
**Post date:** [April 27, 2022, 1:45pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/2 "2022-04-27T13:45:07Z")

</div>

Shoot, I realized I didn’t complete the code; what returns the empty tuple is:

```auto
osw = to_openstudio_osw('/oswmodel', 
                        model_path=hbjson_loc,
                        epw_file='/mount/weather/USA_IL_Chicago.OHare.Intl.AP.725300_TMYx.epw',
                        schedule_directory='/scheds')
run_out = run_osw(osw)

```

Any thoughts here would be appreciated!

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [April 30, 2022, 10:04pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/3 "2022-04-30T22:04:16Z")

</div>

Hey @ericoneill ,

I see you are trying to use [this method in the honeybee-energy library here](https://www.ladybug.tools/honeybee-energy/docs/honeybee_energy.run.html#honeybee_energy.run.to_openstudio_osw) and I would recommend not using `report_units` or `additional_measures` until you get the method to work correctly in the first place. The method is ectacting actual [Measure Python objects as you see here](https://www.ladybug.tools/honeybee-energy/docs/honeybee_energy.measure.html).

Looking at the code, it’s not possible for the `to_openstudio_osw` command to return `(0, 0)` so I don’t know what you are referring to here. If you want a good sample for how to use this method, I would check the source code of the “Model To OSM” component:

> <https://github.com/ladybug-tools/honeybee-grasshopper-energy/blob/master/honeybee_grasshopper_energy/src/HB%20Model%20to%20OSM.py#L211-L214>

---

<div class="post-metadata">

**Author:** ![ericoneill](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/ericoneill/32/26906_2.png) [@ericoneill](https://discourse.ladybug.tools/u/ericoneill)\
**Post date:** [May 2, 2022, 10:45pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/4 "2022-05-02T22:45:02Z")

</div>

Hey @chris!

Thank you! I realized that I had mistakenly omitted a section and tried to correct myself in my followup post.

The code that returns (0,0) is

```auto
from honeybee_energy.run import run_osw

run_osw(osw)

```

I agree I shouldn’t use measures until I get the original function working, and that’s what I was trying to do in the second part of my original post.

Once I figure that out, it seems like the measures should be pretty straightforward. Something like:

```auto
from honeybee_energy import measure

measure_1 = measure("path/to/measure_1")
measure_2 = measure("path/to/measure_2")
measures = [measure_1, measure 2]

```

Which then can be passed into the addtional\_measures parameter of to\_openstudio\_osw, I’m assuming, correct?

If so, that makes sense, and I’d love to get feedback on why run\_osw(osw) returns (0,0).

Thanks!  
Eric

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [May 3, 2022, 12:22am UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/5 "2022-05-03T00:22:26Z")

</div>

It’s still not possible to get `(0, 0)` out of that function but you can get `(None, None)` and so I imagine that is what you mean.

You will get `(None, None)` if running the OSW failed and you should check the .log file in the input osw\_json’s folder to see why OpenStudio CLI failed.

And, yes, that is how you add additional measures except that the class is called `Measure` (with a capital M) instead of 'measure`.

---

<div class="post-metadata">

**Author:** ![ericoneill](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/ericoneill/32/26906_2.png) [@ericoneill](https://discourse.ladybug.tools/u/ericoneill)\
**Post date:** [May 3, 2022, 12:51am UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/6 "2022-05-03T00:51:26Z")

</div>

Ah, yes, sorry, (None, None) is what that returns.

run.log contains the same output from the run\_workflow.sh file I included above:

```auto
[08:30:14.175866 ERROR] Found error in state 'initialization' with message ["Cannot find measure from_honeybee_model::/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:155:in `block in validate_measures'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `each'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `each_with_index'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/measure.rb:141:in `validate_measures'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_initialization.rb:122:in `perform'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291:in `step'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233:in `run'\n:/openstudio_cli.rb:1067:in `execute'\n:/openstudio_cli.rb:803:in `execute'\n:/openstudio_cli.rb:1855:in `<main>'\neval:186:in `eval'\neval:186:in `require_embedded_absolute'\neval:171:in `block in require_embedded'\neval:165:in `each'\neval:165:in `require_embedded'\neval:124:in `require'\neval:3:in `<main>'"]}

```

For more context, I’m running this all in a container built on the OpenStudio docker base image. My actual codebase with the ipynb file is here:

> **[GitHub - eloneill/LearnLBT](https://github.com/eloneill/LearnLBT)**
>
> Contribute to eloneill/LearnLBT development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [May 3, 2022, 12:53pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/7 "2022-05-03T12:53:36Z")

</div>

> [@ericoneill](#):
>
> I’m running this all in a container built on the OpenStudio docker base image.

Ah, that’s probably why you have this issue, then. It looks like your docker image does not have the [measures of the honeybee-openstudio-gem](https://github.com/ladybug-tools/honeybee-openstudio-gem/tree/master/lib/measures) installed in it and so OpenStudio CLI complains. Why not just use the honeybee-energy docker image instead, which has all of the honeybee-energy Python libraries, the honeybee-openstudio-gem and a compatible copy of OpenStudio:

[https://hub.docker.com/r/ladybugtools/honeybee-energy/](https://hub.docker.com/r/ladybugtools/honeybee-energy/)

… plus it’s a lot smaller than the OpenStudio docker image as we’ve trimmed out a lot of the parts of the OpenStudio image that have specialized use-cases.

---

<div class="post-metadata">

**Author:** ![ericoneill](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/ericoneill/32/26906_2.png) [@ericoneill](https://discourse.ladybug.tools/u/ericoneill)\
**Post date:** [July 22, 2022, 7:01pm UTC](https://discourse.ladybug.tools/t/how-to-install-measures-to-run-models-in-script/18097/8 "2022-07-22T19:01:49Z")

</div>

Hey @chris - I appologize for the long delay, but I had just started to get around to trying this out. It does seem like a good solution, but it leads me to running into a new issue:

 ![image](https://discourse.ladybug.tools/uploads/default/original/3X/8/e/8ec96a433b5f7462ff0064ad42112323cc9ce21a.png)

I’ve tried to chmod myself permissions (to both myself as well as the ladybugbot user) in the docker build file to no avail.

I’m running a jupyter notebook from docker with the following command:

```auto
docker run --rm -it -p 8888:8888 -v ${PWD}:/mount lbt jupyter notebook --ip 0.0.0.0 --no-browser --allow-root

```

And my docker file looks like:

```auto
FROM ladybugtools/honeybee-energy:latest

RUN pip3 install --upgrade pip

WORKDIR /pypip
ADD requirements.txt .
RUN pip3 install -r requirements.txt

WORKDIR /mount

```

I know enough docker to be dangerous, but it’s got me a bit stuck here. Any suggestions?

Thank you!  
Eric
