Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
1,321 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
## OpenStudio Pull Request Template | ||
Pull request overview | ||
--------------------- | ||
|
||
Please read [OpenStudio Pull Requests](https://github.com/NREL/OpenStudio/wiki/OpenStudio-Pull-Requests) to better understand the OpenStrudio Pull Request protocol. | ||
- Fixes #ISSUENUMBERHERE (IF THIS IS A DEFECT) | ||
- DESCRIBE PURPOSE OF THIS PULL REQUEST | ||
|
||
Please read [OpenStudio Pull Requests](https://github.com/NREL/OpenStudio/wiki/OpenStudio-Pull-Requests) to better understand the OpenStudio Pull Request protocol. | ||
|
||
### Pull Request Author | ||
|
||
Add to this list or remove from it as applicable. This is a simple templated set of guidelines. | ||
|
||
- [ ] Model API Changes / Additions | ||
- [ ] Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate) | ||
- [ ] Model API methods are tested (in `src/model/test`) | ||
- [ ] EnergyPlus ForwardTranslator Tests (in `src/energyplus/Test`) | ||
- [ ] If a new object or method, added a test in NREL/OpenStudio-resources: Add Link | ||
- [ ] If needed, added VersionTranslation rules for the objects (`src/osversion/VersionTranslator.cpp`) | ||
- [ ] Checked behavior in OpenStudioApplication, adjusted policies as needed (`src/openstudio_lib/library/OpenStudioPolicy.xml`) | ||
- [ ] Verified that C# bindings built fine on Windows, partial classes used as needed, etc. | ||
- [ ] All new and existing tests passes | ||
- [ ] If methods have been deprecated, update rest of code to use the new methods | ||
|
||
**Labels:** | ||
|
||
- [ ] If change to an IDD file, add the label `IDDChange` | ||
- [ ] If breaking existing API, add the label `APIChange` | ||
- [ ] If deemed ready, add label `Pull Request - Ready for CI` so that CI builds your PR | ||
|
||
### Review Checklist | ||
|
||
This will not be exhaustively relevant to every PR. | ||
- [ ] Perform a Code Review on GitHub | ||
- [ ] Code Style, strip trailing whitespace, etc. | ||
- [ ] All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App | ||
- [ ] Labeling is ok | ||
- [ ] If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix | ||
- [ ] If feature, test running new feature, try creative ways to break it | ||
- [ ] CI status: all green or justified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//Jenkins pipelines are stored in shared libaries. Please see: https://github.com/tijcolem/nrel_cbci_jenkins_libs | ||
|
||
@Library('cbci_shared_libs@develop') _ | ||
|
||
// Build for PR to develop branch only. | ||
if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) { | ||
|
||
openstudio_format_develop() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# This script compares two branches (eg. pr-bugfix - <> develop ) | ||
# and finds files of types cpp, hpp, c, h | ||
# that have changed between branches and processes each of these files using clang-format. | ||
# The default behavior of clang-format is to auto change the file and format according to the style guide (.clang-format). If these files change the CI will alert fail and alert the user to correct the changes. The user should run this script locally and accept the auto changes proposed by clang-format. | ||
|
||
display_usage() { | ||
echo -e "\nUsage:\ PR_BRANCH_NAME TARGET_BRANCH_NAME \n" | ||
} | ||
|
||
if [ $# -le 1 ] | ||
then | ||
display_usage | ||
exit 1 | ||
fi | ||
|
||
PR_BRANCH_NAME=$1 | ||
TARGET_BRANCH_NAME=$2 | ||
|
||
# first find if any files changed | ||
num=$(git diff $PR_BRANCH_NAME $TARGET_BRANCH_NAME --name-only | grep '.*\.\(cpp\|c\|hpp\|h\)$' | wc -l | tr -d '[:space:]') | ||
|
||
if [ $num -eq 0 ] | ||
then | ||
echo "No files of type (cpp, c, hpp, h) changed. Skipping clang-formatting" | ||
exit 0 | ||
fi | ||
|
||
git diff $PR_BRANCH_NAME $TARGET_BRANCH_NAME --name-only | grep '.*\.\(cpp\|c\|hpp\|h\)$' | xargs clang-format -style=file -i -fallback-style=none | ||
|
||
# clang-format will auto correct files so prepare the diff and use this as artifact | ||
git diff > clang_format.patch | ||
|
||
# Delete if nothhing otherwise exit 1 to indicate a failed job | ||
if [ ! -s clang_format.patch ] | ||
then | ||
rm clang_format.patch | ||
exit 0 | ||
else | ||
echo "clang-format auto corrected files:" | ||
git diff --name-only | ||
echo -e "\nPlease correct these files. You can run ci/clang-format.sh locally and commit changes" | ||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.bak | ||
deprecated_methods.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# This script aims to facilitate the reporting of deprecated methods | ||
# An amount of manual work will be necessary to add relevant information in the | ||
# resulting deprecated_methods.csv: | ||
# * Fill the 'Replace With' with any relevant method that supersedes it | ||
# * Add the 'Commit SHA' to the commit that deprecated the method in question | ||
|
||
require 'fileutils' | ||
require 'csv' | ||
|
||
ROOT_DIR = File.absolute_path(File.join(File.dirname(__FILE__), "../../")) | ||
DEPRECATED_CSV_PATH = File.join(File.dirname(__FILE__), 'deprecated_methods.csv') | ||
DEPRECATED_MD_PATH = File.join(File.dirname(__FILE__), 'deprecated_methods.md') | ||
|
||
# Parse the CMakeLists.txt for the current version | ||
# It greps for 'project(OpenStudio VERSION X.Y.Z) | ||
# It will raise if something goes wrong | ||
# | ||
# @param cmake_path [String] The path to openstudiocore CMakeLists.txt | ||
# @return [String] the resulting version, eg "2.8.0". | ||
def parse_version_from_cmakelist(cmake_path) | ||
version_line = nil | ||
File.open(cmake_path) do |f| | ||
version_line = f.grep(/project\(OpenStudio VERSION/) | ||
end | ||
|
||
if version_line.nil? | ||
raise "Couldn't find 'project(OpenStudio VERSION' in #{cmake_path}" | ||
elsif !((version_line.class == Array) && (version_line.size == 1)) | ||
raise "Expected to find only one version in #{cmake_path}, found: #{version_line}" | ||
end | ||
os_version_str = version_line[0].match(/VERSION\s+(\d+\.\d+\.\d+)/).captures[0] | ||
return os_version_str | ||
end | ||
|
||
# Parse the hpp files for newly added OS_DEPRECATED. | ||
# Checks if already present in known_deprecated in which case it won't add it | ||
# to the return new_deprecated for the current version, but wil add it to | ||
# old_deprecated. | ||
# | ||
# @param known_deprecated [Array] The Array of Hash from CSV deprecated_methods.csv | ||
# @return [Hash] keys are 'new' and 'old', each have a value that is an | ||
# Array of hash of newly-added / known deprecated | ||
def parse_new_deprecated(known_deprecated, os_version_str) | ||
new_deprecated = [] | ||
old_deprecated = [] | ||
Dir.glob( File.join(ROOT_DIR, "openstudiocore/src/**/*.hpp") ) do |p| | ||
|
||
class_name = File.basename(p).sub('.hpp', '') | ||
content = File.read(p) | ||
deprecated_signatures = content.scan(/OS_DEPRECATED.* (\w+)\(.*\).*;/).flatten | ||
next if deprecated_signatures.empty? | ||
deprecated_signatures.each do |method| | ||
found = known_deprecated.select{|h| (h['Class Name'] == class_name) && (h['Method'] == method)} | ||
if found | ||
old_deprecated << found[0] | ||
next | ||
end | ||
|
||
puts "Found new OS_DEPRECATED #{class_name}::#{method}" | ||
row = { | ||
'Namespace' => p.split('src/')[1].split('/')[0], | ||
'Class Name' => class_name, | ||
'Method' => method, | ||
# has to be right now since it's new | ||
'Deprecated Since' => os_version_str, | ||
'Commit SHA' => nil, | ||
'Replace With' => nil, | ||
'Removed In' => nil, | ||
} | ||
new_deprecated << row | ||
end | ||
end | ||
|
||
return {'new' => new_deprecated, | ||
'old' => old_deprecated} | ||
end | ||
|
||
# Any stuff that is in know_deprecated but NOT in old_deprecated was recently | ||
# removed, so we update the "Removed In" field if not already present | ||
# | ||
# @param known_deprecated [Array] The Array of Hash from CSV deprecated_methods.csv | ||
# @param old_deprecated [Array] The Array of Hash of the ones we did find | ||
# | ||
# @return None: know_deprecated is mutated with 'Removed In' | ||
def update_removed_deprecated(known_deprecated, old_deprecated, os_version_str) | ||
(known_deprecated - old_deprecated).each do |h| | ||
next if !h['Removed In'].nil? | ||
h['Removed In'] = os_version_str | ||
end | ||
end | ||
|
||
# Save to CSV (and make a copy of old CSV) | ||
def output_to_csv(new_table) | ||
# Create a copy of the old CSV | ||
FileUtils.cp('deprecated_methods.csv', 'deprecated_methods.csv.bak') | ||
|
||
CSV.open(DEPRECATED_CSV_PATH, "wb") do |csv| | ||
csv << new_table.first.keys # adds the header | ||
new_table.each do |hash| | ||
csv << hash.values | ||
end | ||
end | ||
|
||
puts "Saved CSV to disk to #{DEPRECATED_CSV_PATH} (backed up old to deprecated_methods.csv.bak)" | ||
|
||
end | ||
|
||
|
||
def add_link_to_sha(h) | ||
dep = h['Deprecated Since'] | ||
sha = h['Commit SHA'] | ||
if dep.nil? | ||
return '' | ||
elsif sha.nil? | ||
return dep | ||
else | ||
return "[#{dep}](https://github.com/NREL/OpenStudio/commit/#{sha})" | ||
end | ||
end | ||
|
||
# Format output as a Markdown table | ||
def output_to_markdown(new_table) | ||
|
||
File.open(DEPRECATED_MD_PATH, 'w') do |f| | ||
|
||
headers = ["Namespace", "Class Name", "Method", "Deprecated Since", "Replace With", "Removed In"] | ||
f.puts headers.join(' | ') | ||
f.puts headers.map{'---'}.join(' | ') | ||
|
||
new_table.each do |h| | ||
toprint = [ | ||
h['Namespace'], h['Class Name'], h['Method'], add_link_to_sha(h), h['Replace With'], h['Removed In'] | ||
] | ||
f.puts toprint.join(' | ') | ||
end | ||
end | ||
puts "Saved Markdown Table to disk to #{DEPRECATED_MD_PATH}" | ||
|
||
end | ||
|
||
cmake_path = File.join(ROOT_DIR, 'openstudiocore/CMakeLists.txt') | ||
os_version_str = parse_version_from_cmakelist(cmake_path) | ||
|
||
|
||
# Load Deprecated methods | ||
raw_data = CSV.table(DEPRECATED_CSV_PATH, {:header_converters => nil}) | ||
known_deprecated = raw_data.map { |row| row.to_hash } | ||
|
||
x = parse_new_deprecated(known_deprecated, os_version_str) | ||
new_deprecated = x['new'] | ||
old_deprecated = x['old'] | ||
update_removed_deprecated(known_deprecated, old_deprecated, os_version_str) | ||
|
||
new_table = known_deprecated + new_deprecated | ||
output_to_csv(new_table) | ||
output_to_markdown(new_table) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Namespace,Class Name,Method,Deprecated Since,Commit SHA,Replace With,Removed In | ||
measure,OSMeasure,registerWithSketchUp,,,None, | ||
measure,OSMeasure,registerWithApplication,,,None, | ||
model,AvailabilityManagerNightCycle,controlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b7,controlThermalZones, | ||
model,AvailabilityManagerNightCycle,setControlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b8,setControlThermalZones, | ||
model,AvailabilityManagerNightCycle,resetControlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b9,resetControlThermalZones, | ||
model,AirLoopHVAC,availabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b10,availabilityManagers, | ||
model,AirLoopHVAC,setAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b11,"addAvailabilityManager, setAvailabilityManagers", | ||
model,AirLoopHVAC,resetAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b12,resetAvailabilityManagers, | ||
model,PlantLoop,availabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b13,availabilityManagers, | ||
model,PlantLoop,setAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b14,"addAvailabilityManager, setAvailabilityManagers", | ||
model,PlantLoop,resetAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b15,resetAvailabilityManagers, | ||
model,Node,addSetpointManager,1.13.0,40c19546076be456f110ca542cd70ce711541961,SetpointManagerXXX::addToNode, | ||
model,Node,addSetpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541962,SetpointManagerWarmest::addToNode, | ||
model,Node,getSetpointManagerSingleZoneReheat,1.13.0,40c19546076be456f110ca542cd70ce711541963,Node::setpointManagers, | ||
model,Node,getSetpointManagerMixedAir,1.13.0,40c19546076be456f110ca542cd70ce711541964,Node::setpointManagers, | ||
model,Node,setpointManagerScheduled,1.13.0,40c19546076be456f110ca542cd70ce711541965,Node::setpointManagers, | ||
model,Node,setpointManagerFollowOutdoorAirTemperature,1.13.0,40c19546076be456f110ca542cd70ce711541966,Node::setpointManagers, | ||
model,Node,setpointManagerOutdoorAirReset,1.13.0,40c19546076be456f110ca542cd70ce711541967,Node::setpointManagers, | ||
model,Node,setpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541968,Node::setpointManagers, | ||
model,Node,removeSetpointManagerSingleZoneReheat,1.13.0,40c19546076be456f110ca542cd70ce711541969,SetpointManagerSingleZoneReheat::remove, | ||
model,Node,removeSetpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541970,SetpointManagerWarmest::remove, | ||
model,Node,removeSetpointManagerOutdoorAirReset,1.13.0,40c19546076be456f110ca542cd70ce711541971,SetpointManagerOutdoorAirReset::remove, | ||
model,Node,removeSetpointManagerFollowOutdoorAirTemperature,1.13.0,40c19546076be456f110ca542cd70ce711541972,SetpointManagerFollowOutdoorAirTemperature::remove, | ||
model,Node,removeSetpointManagerScheduled,1.13.0,40c19546076be456f110ca542cd70ce711541973,SetpointManagerScheduled::remove, | ||
model,Node,removeSetpointManagerMixedAir,1.13.0,40c19546076be456f110ca542cd70ce711541974,SetpointManagerMixedAir::remove, | ||
model,ZoneVentilationDesignFlowRate,setDesignFlowRateCalculationMethod,2.3.1,9ee9be2d0da3ed954a1e98cc3ab39ec7debffa92,"Done when calling setDesignFlowRate, setFlowRateperZoneFloorArea, setAirChangesperHour", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> | ||
<ws2:longPathAware>true</ws2:longPathAware> | ||
</windowsSettings> | ||
</application> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.