Skip to content

Commit

Permalink
Update to openstudio 3.8, e+ 24.1 and pyfmi 2.11 (#491)
Browse files Browse the repository at this point in the history
* update to openstudio 3.8, e+ 24.1 and pyfmi 2.11

* clean up RunPeriod and Timestep substitution

* update refrig case model

* point worker image to main branch of dependencies repo

* point dockerfile to released alfalfa dependencies
  • Loading branch information
TShapinsky committed Jun 20, 2024
1 parent fbff97a commit ea141e2
Show file tree
Hide file tree
Showing 42 changed files with 415 additions and 1,846 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ repos:
"--ignore-init-module-imports"
]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
args: ["--ignore=E501,E402,W503,W504,E731,F401"]
Expand Down
7 changes: 3 additions & 4 deletions alfalfa_worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/nrel/alfalfa-dependencies:2.0.0 AS base
FROM ghcr.io/nrel/alfalfa-dependencies:3.0.0 AS base

USER root

Expand All @@ -11,6 +11,7 @@ ENV DEBIAN_FRONTEND noninteractive

# Install poetry
RUN pip3 install poetry==1.8.3
RUN poetry config virtualenvs.options.system-site-packages true

# Copy and install poetry-based dependencies
COPY pyproject.toml /alfalfa
Expand All @@ -23,9 +24,7 @@ RUN poetry install --only main
ENV PYTHONPATH="/alfalfa:${PYTHONPATH}"

COPY ./alfalfa_worker /alfalfa/alfalfa_worker
RUN cd alfalfa_worker/jobs/openstudio/lib/alfalfa-lib-gem \
&& gem build alfalfa-lib-gem.gemspec \
&& gem install ./alfalfa-lib-0.0.0.gem

COPY ./deploy /alfalfa/deploy
COPY ./deploy/wait-for-it.sh /usr/local/wait-for-it.sh

Expand Down
2 changes: 1 addition & 1 deletion alfalfa_worker/jobs/openstudio/create_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def exec(self):
check_output(['openstudio', str(lib_dir / 'merge_osws.rb'), str(default_workflow_path), str(submitted_osw_path)])

# run workflow
check_output(['openstudio', '--gem_path', '/var/lib/gems/2.7.0', 'run', '-m', '-w', str(submitted_osw_path)])
check_output(['openstudio', '-I', '/alfalfa/alfalfa_worker/jobs/openstudio/lib/alfalfa-lib-gem/lib', 'run', '-m', '-w', str(submitted_osw_path)])

self.logger.info('Loading Building Metadata')
metadata_json_path = submitted_workflow_path / 'reports' / 'alfalfa_metadata_report_metadata.json'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# *******************************************************************************
# OpenStudio(R), Copyright (c) 2008-2022, Alliance for Sustainable Energy, LLC.
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -33,20 +33,57 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

require_relative '../spec_helper'
# start the measure
class AlfalfaPrepareIDF < OpenStudio::Ruleset::WorkspaceUserScript

RSpec.describe OpenStudio::Alfalfa do
it 'has a version number' do
expect(OpenStudio::Alfalfa::VERSION).not_to be nil
# human readable name
def name
return 'Alfalfa Prepare IDF'
end

it 'has a measures directory' do
instance = OpenStudio::Alfalfa::Alfalfa.new
expect(File.exist?(instance.measures_dir)).to be true
# human readable description
def description
return 'Remove RunPeriod and Timestep IDF Objects in preparation for Alfalfa execution'
end

it 'exists' do
x = OpenStudio::Alfalfa::Tagger.new
expect(x.class.to_s == 'OpenStudio::Alfalfa::Tagger').to be true
# human readable description of modeling approach
def modeler_description
return 'Remove RunPeriod and Timestep IDF Objects in preparation for Alfalfa execution'
end

# define the arguments that the user will input
def arguments(workspace)
args = OpenStudio::Ruleset::OSArgumentVector.new
return args
end

# define what happens when the measure is run
def run(ws, runner, user_args)

# call the parent class method
super(ws, runner, user_args)

# use the built-in error checking
return false unless runner.validateUserArguments(
arguments(ws),
user_args
)

timestep_objs = ws.getObjectsByType('Timestep'.to_IddObjectType)
runperiod_objs = ws.getObjectsByType('RunPeriod'.to_IddObjectType)

timestep_objs.each do |timestep|
timestep.remove()
end

runperiod_objs.each do |runperiod|
runperiod.remove()
end

return true
end

end

# register the measure to be used by the application
AlfalfaPrepareIDF.new.registerWithApplication
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.1</schema_version>
<name>alfalfa_prepare_idf</name>
<uid>16125428-fcf9-4986-9d9b-3644225a2b6d</uid>
<version_id>ed0d5b56-97c3-4dde-bf4a-937d382043fe</version_id>
<version_modified>2024-05-10T15:00:59Z</version_modified>
<xml_checksum>7A4781A5</xml_checksum>
<class_name>AlfalfaPrepareIDF</class_name>
<display_name>Alfalfa Prepare IDF</display_name>
<description>Remove RunPeriod and Timestep IDF Objects in preparation for Alfalfa execution</description>
<modeler_description>Remove RunPeriod and Timestep IDF Objects in preparation for Alfalfa execution</modeler_description>
<arguments />
<outputs />
<provenances />
<tags>
<tag>Tool.Alfalfa</tag>
</tags>
<attributes>
<attribute>
<name>Measure Type</name>
<value>EnergyPlusMeasure</value>
<datatype>string</datatype>
</attribute>
<attribute>
<name>Intended Software Tool</name>
<value>OpenStudio Application</value>
<datatype>string</datatype>
</attribute>
</attributes>
<files>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>2.3.0</identifier>
<min_compatible>2.3.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>0267B29F</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def run(ws, runner, user_args)
i += 1
end
end
return true
end

end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<error>uninitialized constant Python</error>
<schema_version>3.1</schema_version>
<name>alfalfa_python_environment</name>
<uid>16125428-fcf9-4986-9d9b-3644225a2b6d</uid>
<version_id>310e60b6-6215-4d58-b10b-e21eddaaf129</version_id>
<version_modified>20221031T173904Z</version_modified>
<version_id>39ffcfe8-5902-44dd-9d1a-5aae2502d8c7</version_id>
<version_modified>2024-05-03T20:06:06Z</version_modified>
<xml_checksum>9D2F1A23</xml_checksum>
<class_name>AlfalfaPythonEnvironment</class_name>
<display_name>Alfalfa Python Environment</display_name>
Expand All @@ -14,7 +13,9 @@
<arguments />
<outputs />
<provenances />
<tags />
<tags>
<tag>Tool.Alfalfa</tag>
</tags>
<attributes>
<attribute>
<name>Measure Type</name>
Expand All @@ -37,7 +38,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>4A5B6A8D</checksum>
<checksum>91260911</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<schema_version>3.1</schema_version>
<error>Failed to infer measure name from '/Users/tshapins/Documents/Projects/alfalfa/alfalfa_worker/jobs/openstudio/lib/workflow/measures/./alfalfa_setpoint_control/measure.rb'</error>
<name>alfalfa_setpoint_control</name>
<uid>870213d3-36a2-4da2-9a04-c377a37fd4fe</uid>
<version_id>bf35c981-cffe-41a8-ac34-606ebbc44c7d</version_id>
<version_modified>20230125T214417Z</version_modified>
<version_id>035cbac7-2f31-4ba1-a9ea-daf5250333ac</version_id>
<version_modified>2024-05-03T20:06:07Z</version_modified>
<xml_checksum>70995EFB</xml_checksum>
<class_name>AlfalfaSetpointControl</class_name>
<display_name>Alfalfa Setpoint Control</display_name>
Expand Down Expand Up @@ -33,19 +34,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>6F11EE21</checksum>
</file>
<file>
<filename>output.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>4553AB66</checksum>
</file>
<file>
<filename>input.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>9C7F46CA</checksum>
<checksum>2453D3C6</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<error>cannot load such file -- alfalfa</error>
<schema_version>3.1</schema_version>
<error>Failed to infer measure name from '/Users/tshapins/Documents/Projects/alfalfa/alfalfa_worker/jobs/openstudio/lib/workflow/measures/./alfalfa_site_sensors/measure.rb'</error>
<name>alfalfa_site_sensors</name>
<uid>870213d3-36a2-4da2-9a04-c377a37fd4fe</uid>
<version_id>f0fb23f6-6d8d-41a7-be6d-8d8f27416c33</version_id>
<version_modified>20230127T210421Z</version_modified>
<version_id>40c05e7b-834f-41f7-857a-baf8e251ebf9</version_id>
<version_modified>2024-05-03T20:06:06Z</version_modified>
<xml_checksum>70995EFB</xml_checksum>
<class_name>AlfalfaSiteSensors</class_name>
<display_name>Alfalfa Site Sensors</display_name>
Expand Down Expand Up @@ -34,7 +34,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>4FCE96E6</checksum>
<checksum>FC5DA746</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<error>cannot load such file -- alfalfa</error>
<schema_version>3.1</schema_version>
<error>Failed to infer measure name from '/Users/tshapins/Documents/Projects/alfalfa/alfalfa_worker/jobs/openstudio/lib/workflow/measures/./alfalfa_zone_sensors/measure.rb'</error>
<name>alfalfa_zone_sensors</name>
<uid>870213d3-36a2-4da2-9a04-c377a37fd4fe</uid>
<version_id>f0fb23f6-6d8d-41a7-be6d-8d8f27416c33</version_id>
<version_modified>20230127T210421Z</version_modified>
<version_id>df638ad5-4910-40df-bd19-09e407424262</version_id>
<version_modified>2024-05-03T20:06:06Z</version_modified>
<xml_checksum>70995EFB</xml_checksum>
<class_name>AlfalfaZoneSensors</class_name>
<display_name>Alfalfa Setpoint Control</display_name>
Expand Down Expand Up @@ -34,7 +34,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>4FCE96E6</checksum>
<checksum>0977BFBC</checksum>
</file>
</files>
</measure>
Loading

0 comments on commit ea141e2

Please sign in to comment.