Skip to content

Commit

Permalink
Merge pull request #95 from NREL/AddSelectionOptions
Browse files Browse the repository at this point in the history
Misc Updates
  • Loading branch information
Myoldmopar authored Nov 21, 2022
2 parents ac531e2 + 8fd6b32 commit 11d1683
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 142 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[run]
source = epregressions

[report]
omit =
epregressions/runner.py
Expand Down
83 changes: 0 additions & 83 deletions .github/workflows/build_and_test.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
- name: Set up Python 3.8
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # v4.2.0
with:
python-version: 3.7
python-version: 3.8

- name: Install Pip Dependencies
run: pip install flake8
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PyPIRelease

on:
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v2

- name: Set up Python
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # v4.2.0
with:
python-version: 3.8

- name: Install Pip Dependencies
shell: bash
run: pip install -r requirements.txt

- name: Build the Wheel
shell: bash
run: rm -rf dist/ build/ && python3 setup.py bdist_wheel sdist

- name: Deploy on Test PyPi
uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f # v1.5.1
with:
user: __token__
password: ${{ secrets.PYPIPW }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests

on: [push]

defaults:
run:
shell: bash

jobs:
unit_tests:
strategy:
matrix:
os: [ windows-latest, macos-11, ubuntu-20.04, ubuntu-22.04 ] # macos-12 is not playing well with Tk
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v2
- name: Set up Python 3.8
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # v4.2.0
with:
python-version: 3.8
- name: Install Pip Dependencies
run: pip install -r requirements.txt
- name: Run Tests
run: nosetests
- name: Coveralls
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.egg-info
.idea
*.pyc
tex_docs
Expand Down
2 changes: 1 addition & 1 deletion epregressions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.9.6'
VERSION = '1.9.7'
8 changes: 5 additions & 3 deletions epregressions/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def run_test_suite(self):
self.my_cancelled()
return

start_time = datetime.now()
self.my_starting(len(self.entries))

# run the energyplus script
Expand All @@ -144,7 +145,7 @@ def run_test_suite(self):
return
self.my_simulations_complete()

self.diff_logs_for_build()
self.diff_logs_for_build(start_time)

try:
self.my_print('Writing runtime summary file')
Expand Down Expand Up @@ -1087,13 +1088,14 @@ def process_end_file(end_path):
return [status, total_runtime_seconds]

# diff_logs_for_build creates diff logs between simulations in two build directories
def diff_logs_for_build(self):
def diff_logs_for_build(self, original_start_time):

self.completed_structure = CompletedStructure(
self.build_tree_a['source_dir'], self.build_tree_a['build_dir'],
self.build_tree_b['source_dir'], self.build_tree_b['build_dir'],
os.path.join(self.build_tree_a['build_dir'], self.test_output_dir),
os.path.join(self.build_tree_b['build_dir'], self.test_output_dir)
os.path.join(self.build_tree_b['build_dir'], self.test_output_dir),
original_start_time
)
diff_runs = []
for this_entry in self.entries:
Expand Down
8 changes: 4 additions & 4 deletions epregressions/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ def to_dict(self):


class ExtraInfo:
def __init__(self):
def __init__(self, start_time):
self.descriptions = {
'time_stamps': [
f"Start time: {datetime.now()}", "End time initialized"
f"Start time: {start_time}", "End time initialized"
]
}

Expand All @@ -389,7 +389,7 @@ def set_end_time(self):

class CompletedStructure:
def __init__(self, case_a_source_dir, case_a_build_dir, case_b_source_dir,
case_b_build_dir, results_dir_a, results_dir_b):
case_b_build_dir, results_dir_a, results_dir_b, original_start_time):
self.case_a_source_dir = case_a_source_dir
self.case_a_build_dir = case_a_build_dir
self.case_b_source_dir = case_b_source_dir
Expand All @@ -411,7 +411,7 @@ def __init__(self, case_a_source_dir, case_a_build_dir, case_b_source_dir,
self.small_table_diffs = Results()
self.text_diffs = Results()
# extra info
self.extra = ExtraInfo()
self.extra = ExtraInfo(original_start_time)

def add_test_entry(self, this_entry):
self.entries_by_file.append(this_entry)
Expand Down
25 changes: 12 additions & 13 deletions epregressions/tests/resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ This folder contains a bunch of resources for running tests.
These are extremely lightweight executable scripts that mimic the actual E+ toolchain.
There are also other files in here such as example weather files and E+ run files.

def execute_energyplus(build_tree, entry_name, test_run_directory,
run_type, min_reporting_freq, this_parametric_file, weather_file_name):
# setup a few paths
energyplus = build_tree['energyplus']
basement = build_tree['basement']
idd_path = build_tree['idd_path']
slab = build_tree['slab']
basementidd = build_tree['basementidd']
slabidd = build_tree['slabidd']
expandobjects = build_tree['expandobjects']
epmacro = build_tree['epmacro']
readvars = build_tree['readvars']
parametric = build_tree['parametric']
The windows versions of these are prebuilt using pyinstaller and placed in the `dist/` directory
To rebuild them, ensure you have pyinstaller on Windows, change dir into the `epregressions/tests/resources` directory, and run:

```
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n basement dummy.basement.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n energyplus dummy.energyplus.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n epmacro dummy.epmacro.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n expandobjects dummy.expandobjects.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n parametric dummy.parametric.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n readvars dummy.readvars.py
PYTHONPATH=. ../../../venv/Scripts/pyinstaller.exe --onefile --log-level=WARN -n slab dummy.slab.py
```
Binary file added epregressions/tests/resources/dist/basement.exe
Binary file not shown.
Binary file added epregressions/tests/resources/dist/energyplus.exe
Binary file not shown.
Binary file added epregressions/tests/resources/dist/epmacro.exe
Binary file not shown.
Binary file not shown.
Binary file added epregressions/tests/resources/dist/parametric.exe
Binary file not shown.
Binary file added epregressions/tests/resources/dist/readvars.exe
Binary file not shown.
Binary file added epregressions/tests/resources/dist/slab.exe
Binary file not shown.
19 changes: 0 additions & 19 deletions epregressions/tests/test_runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from platform import system
import shutil
from subprocess import check_call
import tempfile
import unittest

Expand Down Expand Up @@ -42,24 +41,6 @@ def establish_build_folder(
# variables and run them all. Also, we don't want to run them for every single test, just once if the dist/
# folder hasn't been created yet.
dist_folder = os.path.join(self.resources, 'dist')
if not os.path.exists(dist_folder):
# find pyinstaller -- it should be available in path I think
pyinstaller = "pyinstaller.exe"
# pyinstaller = r"C:\EnergyPlus\repos\EnergyPlusRegressionTool\venv\Scripts\pyinstaller.exe"
# run it on all these
conversions = [
['dummy.basement.py', 'basement'],
['dummy.energyplus.py', 'energyplus'],
['dummy.expandobjects.py', 'expandobjects'],
['dummy.parametric.py', 'parametric'],
['dummy.readvars.py', 'readvars'],
['dummy.slab.py', 'slab'],
['dummy.epmacro.py', 'epmacro'],
]
working_dir = self.resources
for conv in conversions:
cmd = [pyinstaller, '--onefile', '--log-level=WARN', '-n', conv[1], conv[0]]
check_call(cmd, cwd=working_dir)
products_map = {
os.path.join(self.resources, 'dummy.basement.idd'): os.path.join(products_dir, 'BasementGHT.idd'),
os.path.join(dist_folder, 'basement.exe'): os.path.join(products_dir, 'Basement.exe'),
Expand Down
16 changes: 12 additions & 4 deletions epregressions/tests/test_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ def test_workflow(self):
class TestCompletedStructure(unittest.TestCase):

def test_workflow(self):
c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2')
c = CompletedStructure(
'/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2', 'dummy_start_time'
)
t = TestEntry('filename', 'weather')
t = TestTestEntry.fully_populated_entry_successful(t)
c.add_test_entry(t)
Expand All @@ -190,7 +192,9 @@ def test_workflow(self):
c.add_test_entry(t)

def test_to_csv(self):
c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2')
c = CompletedStructure(
'/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2', 'dummy_start_time'
)
t = TestEntry('filename', 'weather')
t = TestTestEntry.fully_populated_entry_successful(t)
c.add_test_entry(t)
Expand All @@ -200,7 +204,9 @@ def test_to_csv(self):
c.to_runtime_summary('/invalid/path')

def test_to_json(self):
c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2')
c = CompletedStructure(
'/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2', 'dummy_start_time'
)
t = TestEntry('filename', 'weather')
t = TestTestEntry.fully_populated_entry_successful(t)
c.add_test_entry(t)
Expand All @@ -215,7 +221,9 @@ def test_to_json(self):
self.assertIn('results_by_file', obj)

def test_to_json_object_response(self):
c = CompletedStructure('/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2')
c = CompletedStructure(
'/a/source/dir', '/a/build/dir', '/b/source/dir', '/b/build/dir', '/r/dir1', '/r/dir2', 'dummy_start_time'
)
t = TestEntry('filename', 'weather')
t = TestTestEntry.fully_populated_entry_successful(t)
c.add_test_entry(t)
Expand Down
Loading

0 comments on commit 11d1683

Please sign in to comment.