openstudio-extension 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +8 -1
- data/Rakefile +1 -1
- data/lib/change_log.rb +104 -120
- data/lib/measures/openstudio_extension_test_measure/measure.xml +20 -19
- data/lib/openstudio/extension/rake_task.rb +200 -15
- data/lib/openstudio/extension/runner.rb +2 -1
- data/lib/openstudio/extension/version.rb +1 -1
- data/openstudio-extension.gemspec +4 -3
- metadata +27 -14
- data/lib/measures/openstudio_extension_test_measure/tests/openstudio_extension_test_measure_test.rb +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27dbd08d5d11f58ea9839b1d8a3750e860964ad4f5075371cacb6f4c1c642c92
|
4
|
+
data.tar.gz: 3353e644a7b21fe23bd9e50dcc4f844e478237868f88001a2c6538c2092464ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c593e49a37e0851ee1886f54f1c1a7b6ed83ef882f6d25ff803c9aefc4067766299f0fa94845cb284101ba02766c6b4c0e8e572a41c25d954ebb4f14314052c
|
7
|
+
data.tar.gz: 10b1a4dade5d911b1611e0d7262fdd3f59d8b7671e1cef0b593e318b50ed4099227b024ed433fe3003d5270984d4e37dd46cf1924d2c978d0061e6a9d1483197
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# OpenStudio Extension Gem
|
2
2
|
|
3
|
+
## Version 0.2.2
|
4
|
+
|
5
|
+
* Exclude measure tests from being released with the gem (reduces the size of the installed gem significantly)
|
6
|
+
* Add BCL commands to upload measures
|
7
|
+
* Update GitHub changelog gem to use Octokit compared to github_api (which was last released 3 years ago)
|
8
|
+
* Promote GitHub changelog creation to a rake task to be inherited by all downstream extension gems
|
9
|
+
|
3
10
|
## Version 0.2.1
|
4
11
|
|
5
12
|
* Changes from 0.1.5 (runner.conf bug)
|
@@ -40,4 +47,4 @@
|
|
40
47
|
|
41
48
|
## Version 0.1.1
|
42
49
|
|
43
|
-
* Initial release
|
50
|
+
* Initial release
|
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
36
36
|
require 'openstudio/extension/rake_task'
|
37
37
|
require 'openstudio/extension'
|
38
38
|
rake_task = OpenStudio::Extension::RakeTask.new
|
39
|
-
rake_task.set_extension_class(OpenStudio::Extension::Extension)
|
39
|
+
rake_task.set_extension_class(OpenStudio::Extension::Extension, 'nrel/openstudio-extension-gem')
|
40
40
|
|
41
41
|
require 'rubocop/rake_task'
|
42
42
|
RuboCop::RakeTask.new
|
data/lib/change_log.rb
CHANGED
@@ -1,148 +1,132 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'octokit'
|
5
5
|
require 'date'
|
6
6
|
require 'optparse'
|
7
7
|
require 'optparse/date'
|
8
8
|
|
9
9
|
# Instructions:
|
10
|
-
# Get a token from github's settings (https://github.com/settings/tokens)
|
11
10
|
#
|
12
11
|
# Example:
|
13
12
|
# ruby change_log.rb -t abcdefghijklmnopqrstuvwxyz -s 2017-09-06
|
14
13
|
#
|
14
|
+
#
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
class ChangeLog
|
17
|
+
def initialize(user_and_repo, start_date = Date.today - 90, end_date = Date.today, apikey = nil)
|
18
|
+
@user_and_repo = user_and_repo
|
19
|
+
@apikey = apikey
|
20
|
+
@start_date = start_date
|
21
|
+
@end_date = end_date
|
22
|
+
|
23
|
+
# Convert dates to time objects
|
24
|
+
@start_date = Time.parse(@start_date.to_s) if start_date.is_a? String
|
25
|
+
@end_date = Time.parse(@end_date.to_s) if end_date.is_a? String
|
26
|
+
# GitHub API uses Time and not the Date class, so ensure that we have Time
|
27
|
+
@start_date = Time.parse(@start_date.to_s)
|
28
|
+
@end_date = Time.parse(@end_date.to_s)
|
29
|
+
|
30
|
+
@total_open_issues = []
|
31
|
+
@total_open_pull_requests = []
|
32
|
+
@new_issues = []
|
33
|
+
@closed_issues = []
|
34
|
+
@accepted_pull_requests = []
|
35
|
+
|
36
|
+
begin
|
37
|
+
@github = Octokit::Client.new
|
38
|
+
if apikey
|
39
|
+
@github = Octokit::Client.new(access_token: apikey)
|
40
|
+
end
|
41
|
+
@github.auto_paginate = true
|
42
|
+
rescue StandardError => e
|
43
|
+
puts e.message
|
44
|
+
# write out the help message
|
45
|
+
ChangeLog.help
|
46
|
+
exit(1)
|
47
|
+
end
|
34
48
|
end
|
35
|
-
end.parse!
|
36
|
-
|
37
|
-
# Convert dates to time objects
|
38
|
-
options[:start_date] = Time.parse(options[:start_date].to_s)
|
39
|
-
options[:end_date] = Time.parse(options[:end_date].to_s)
|
40
|
-
puts options
|
41
|
-
|
42
|
-
### Repository options
|
43
|
-
repo_owner = 'NREL'
|
44
|
-
repo = 'openstudio-extension-gem'
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def get_html_url(issue)
|
67
|
-
issue.html_url
|
68
|
-
end
|
69
|
-
|
70
|
-
def get_title(issue)
|
71
|
-
issue.title
|
72
|
-
end
|
73
|
-
|
74
|
-
def print_issue(issue)
|
75
|
-
is_feature = false
|
76
|
-
issue.labels.each { |label| is_feature = true if label.name == 'Feature Request' }
|
77
|
-
|
78
|
-
if is_feature
|
79
|
-
"- Improved [#{get_issue_num(issue)}]( #{get_html_url(issue)} ), #{get_title(issue)}"
|
80
|
-
else
|
81
|
-
"- Fixed [#{get_issue_num(issue)}]( #{get_html_url(issue)} ), #{get_title(issue)}"
|
50
|
+
# Class method to show how to use the API through Rake.
|
51
|
+
def self.help
|
52
|
+
puts 'Usage: bundle exec rake openstudio:change_log[<start_date>,<end_date>,<apikey>]'
|
53
|
+
puts ' <start_date> = [Optional] Start of data (e.g., 2020-09-06), defaults to 90 days before today'
|
54
|
+
puts ' <end_date> = [Optional] End of data (e.g., 2020-10-06), default to today'
|
55
|
+
puts ' <apikey> = [Optional] GitHub API Key (used for private repos)'
|
56
|
+
puts
|
57
|
+
puts ' Ensure that the GitHub user/repo is set in your Rakefile, for example, '
|
58
|
+
puts " rake_task.set_extension_class(OpenStudio::Extension::Extension, 'nrel/openstudio-extension-gem')"
|
59
|
+
puts
|
60
|
+
puts ' Example usages:'
|
61
|
+
puts ' bundle exec rake openstudio:change_log[2020-01-01]'
|
62
|
+
puts ' bundle exec rake openstudio:change_log[2020-01-01,2020-06-30]'
|
63
|
+
puts ' bundle exec rake openstudio:change_log[2020-01-01,2020-01-10,<private_api_key>]'
|
64
|
+
puts
|
65
|
+
puts ' Notes:'
|
66
|
+
puts ' For creating token, see https://github.com/settings/tokens.'
|
67
|
+
puts ' Note that if passing apikey, then you must pass start_date and end_date as well. There must be no spaces'
|
68
|
+
puts ' between the arguments (see examples above).'
|
82
69
|
end
|
83
|
-
end
|
84
70
|
|
85
|
-
# Process Open Issues
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
71
|
+
# Process Open Issues
|
72
|
+
def process
|
73
|
+
@github.list_issues(@user_and_repo, state: 'all').each do |issue|
|
74
|
+
if issue.state == 'open'
|
75
|
+
if issue.pull_request
|
76
|
+
if issue.created_at >= @start_date && issue.created_at <= @end_date
|
77
|
+
@total_open_pull_requests << issue
|
78
|
+
end
|
79
|
+
else
|
80
|
+
@total_open_issues << issue
|
81
|
+
if issue.created_at >= @start_date && issue.created_at <= @end_date
|
82
|
+
@new_issues << issue
|
83
|
+
end
|
84
|
+
end
|
85
|
+
else
|
86
|
+
# the issue is closed
|
87
|
+
if issue.closed_at >= @start_date && issue.closed_at <= @end_date
|
88
|
+
if issue.pull_request
|
89
|
+
@accepted_pull_requests << issue
|
90
|
+
else
|
91
|
+
@closed_issues << issue
|
92
|
+
end
|
93
|
+
end
|
98
94
|
end
|
99
|
-
else
|
100
|
-
total_open_pull_requests << issue
|
101
95
|
end
|
96
|
+
|
97
|
+
@closed_issues.sort! { |x, y| x.number <=> y.number }
|
98
|
+
@new_issues.sort! { |x, y| x.number <=> y.number }
|
99
|
+
@accepted_pull_requests.sort! { |x, y| x.number <=> y.number }
|
100
|
+
@total_open_pull_requests.sort! { |x, y| x.number <=> y.number }
|
101
|
+
rescue StandardError => e
|
102
|
+
puts e.message
|
103
|
+
ChangeLog.help
|
104
|
+
exit(1)
|
102
105
|
end
|
103
106
|
|
104
|
-
|
105
|
-
|
107
|
+
def print_issue(issue)
|
108
|
+
is_feature = false
|
109
|
+
issue.labels.each { |label| is_feature = true if label.name == 'Feature Request' }
|
106
110
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
resp = github.issues.list user: repo_owner, repo: repo, sort: 'created', direction: 'asc',
|
112
|
-
state: 'closed', per_page: 100, page: page
|
113
|
-
results = resp.length
|
114
|
-
resp.env[:body].each do |issue, _index|
|
115
|
-
created = Time.parse(issue.created_at)
|
116
|
-
closed = Time.parse(issue.closed_at)
|
117
|
-
if !issue.key?(:pull_request)
|
118
|
-
if created >= options[:start_date] && created <= options[:end_date]
|
119
|
-
new_issues << issue
|
120
|
-
end
|
121
|
-
if closed >= options[:start_date] && closed <= options[:end_date]
|
122
|
-
closed_issues << issue
|
123
|
-
end
|
124
|
-
elsif closed >= options[:start_date] && closed <= options[:end_date]
|
125
|
-
accepted_pull_requests << issue
|
111
|
+
if is_feature
|
112
|
+
"- Improved [##{issue.number}]( #{issue.html_url} ), #{issue.title}"
|
113
|
+
else
|
114
|
+
"- Fixed [\##{issue.number}]( #{issue.html_url} ), #{issue.title}"
|
126
115
|
end
|
127
116
|
end
|
128
117
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
new_issues.
|
134
|
-
accepted_pull_requests.sort! { |x, y| get_num(x) <=> get_num(y) }
|
135
|
-
total_open_pull_requests.sort! { |x, y| get_num(x) <=> get_num(y) }
|
136
|
-
|
137
|
-
puts "Total Open Issues: #{total_open_issues.length}"
|
138
|
-
puts "Total Open Pull Requests: #{total_open_pull_requests.length}"
|
139
|
-
puts "\nDate Range: #{options[:start_date].strftime('%m/%d/%y')} - #{options[:end_date].strftime('%m/%d/%y')}:"
|
140
|
-
puts "\nNew Issues: #{new_issues.length} (" + new_issues.map { |issue| get_issue_num(issue) }.join(', ') + ')'
|
118
|
+
def print_issues
|
119
|
+
puts "Total Open Issues: #{@total_open_issues.length}"
|
120
|
+
puts "Total Open Pull Requests: #{@total_open_pull_requests.length}"
|
121
|
+
puts "\nDate Range: #{@start_date.strftime('%m/%d/%y')} - #{@end_date.strftime('%m/%d/%y')}:"
|
122
|
+
puts "\nNew Issues: #{@new_issues.length} (" + @new_issues.map { |issue| issue.number }.join(', ') + ')'
|
141
123
|
|
142
|
-
puts "\nClosed Issues: #{closed_issues.length}"
|
143
|
-
closed_issues.each { |issue| puts print_issue(issue) }
|
124
|
+
puts "\nClosed Issues: #{@closed_issues.length}"
|
125
|
+
@closed_issues.each { |issue| puts print_issue(issue) }
|
144
126
|
|
145
|
-
puts "\nAccepted Pull Requests: #{accepted_pull_requests.length}"
|
146
|
-
accepted_pull_requests.each { |issue| puts print_issue(issue) }
|
127
|
+
puts "\nAccepted Pull Requests: #{@accepted_pull_requests.length}"
|
128
|
+
@accepted_pull_requests.each { |issue| puts print_issue(issue) }
|
147
129
|
|
148
|
-
puts "\nAll Open Issues: #{total_open_issues.length} (" + total_open_issues.map { |issue|
|
130
|
+
puts "\nAll Open Issues: #{@total_open_issues.length} (" + @total_open_issues.map { |issue| "\##{issue.number}" }.join(', ') + ')'
|
131
|
+
end
|
132
|
+
end
|
@@ -1,17 +1,18 @@
|
|
1
|
+
<?xml version="1.0"?>
|
1
2
|
<measure>
|
2
3
|
<schema_version>3.0</schema_version>
|
3
4
|
<name>openstudio_extension_test_measure</name>
|
4
5
|
<uid>36b99a29-41e1-4d85-9272-85d43b966e5a</uid>
|
5
|
-
<version_id>
|
6
|
-
<version_modified>
|
6
|
+
<version_id>edf7f103-9f51-4944-a5af-1d8fa2b0c9b7</version_id>
|
7
|
+
<version_modified>20200427T230714Z</version_modified>
|
7
8
|
<xml_checksum>49BEF039</xml_checksum>
|
8
9
|
<class_name>OpenStudioExtensionTestMeasure</class_name>
|
9
10
|
<display_name>OpenStudio Extension Test Measure</display_name>
|
10
|
-
<description>
|
11
|
-
<modeler_description>
|
12
|
-
<arguments/>
|
13
|
-
<outputs/>
|
14
|
-
<provenances/>
|
11
|
+
<description>A measure that tests OpenStudio Extension gem functionality</description>
|
12
|
+
<modeler_description>This is a test measure that tests OpenStudio Extension gem functionality.</modeler_description>
|
13
|
+
<arguments />
|
14
|
+
<outputs />
|
15
|
+
<provenances />
|
15
16
|
<tags>
|
16
17
|
<tag>Envelope.Form</tag>
|
17
18
|
</tags>
|
@@ -38,12 +39,6 @@
|
|
38
39
|
</attribute>
|
39
40
|
</attributes>
|
40
41
|
<files>
|
41
|
-
<file>
|
42
|
-
<filename>LICENSE.md</filename>
|
43
|
-
<filetype>md</filetype>
|
44
|
-
<usage_type>license</usage_type>
|
45
|
-
<checksum>9640B6CB</checksum>
|
46
|
-
</file>
|
47
42
|
<file>
|
48
43
|
<filename>README.md.erb</filename>
|
49
44
|
<filetype>erb</filetype>
|
@@ -51,16 +46,16 @@
|
|
51
46
|
<checksum>703C9964</checksum>
|
52
47
|
</file>
|
53
48
|
<file>
|
54
|
-
<filename>
|
49
|
+
<filename>LICENSE.md</filename>
|
55
50
|
<filetype>md</filetype>
|
56
|
-
<usage_type>
|
57
|
-
<checksum>
|
51
|
+
<usage_type>license</usage_type>
|
52
|
+
<checksum>E0468DD6</checksum>
|
58
53
|
</file>
|
59
54
|
<file>
|
60
55
|
<filename>OpenStudioExtensionTestMeasure_Test.rb</filename>
|
61
56
|
<filetype>rb</filetype>
|
62
57
|
<usage_type>test</usage_type>
|
63
|
-
<checksum>
|
58
|
+
<checksum>66A00EA8</checksum>
|
64
59
|
</file>
|
65
60
|
<file>
|
66
61
|
<version>
|
@@ -71,13 +66,19 @@
|
|
71
66
|
<filename>measure.rb</filename>
|
72
67
|
<filetype>rb</filetype>
|
73
68
|
<usage_type>script</usage_type>
|
74
|
-
<checksum>
|
69
|
+
<checksum>51BB85EF</checksum>
|
75
70
|
</file>
|
76
71
|
<file>
|
77
72
|
<filename>os_lib_helper_methods.rb</filename>
|
78
73
|
<filetype>rb</filetype>
|
79
74
|
<usage_type>resource</usage_type>
|
80
|
-
<checksum>
|
75
|
+
<checksum>07B01D67</checksum>
|
76
|
+
</file>
|
77
|
+
<file>
|
78
|
+
<filename>README.md</filename>
|
79
|
+
<filetype>md</filetype>
|
80
|
+
<usage_type>readme</usage_type>
|
81
|
+
<checksum>7258830F</checksum>
|
81
82
|
</file>
|
82
83
|
</files>
|
83
84
|
</measure>
|
@@ -51,14 +51,16 @@ module OpenStudio
|
|
51
51
|
setup_subtasks(@name)
|
52
52
|
end
|
53
53
|
|
54
|
-
def set_extension_class(extension_class)
|
54
|
+
def set_extension_class(extension_class, github_repo='')
|
55
55
|
@extension_class = extension_class
|
56
56
|
@extension = extension_class.new
|
57
57
|
@root_dir = @extension.root_dir
|
58
58
|
@measures_dir = @extension.measures_dir
|
59
|
+
@staged_path = @measures_dir + '/staged'
|
59
60
|
@core_dir = @extension.core_dir
|
60
61
|
@doc_templates_dir = @extension.doc_templates_dir
|
61
62
|
@files_dir = @extension.files_dir
|
63
|
+
@github_repo = github_repo
|
62
64
|
end
|
63
65
|
|
64
66
|
private
|
@@ -67,14 +69,14 @@ module OpenStudio
|
|
67
69
|
namespace name do
|
68
70
|
desc 'Run the CLI task to check for measure updates'
|
69
71
|
task update_measures: ['measures:add_license', 'measures:add_readme', 'measures:copy_resources', 'update_copyright'] do
|
70
|
-
puts 'updating measures
|
72
|
+
puts 'updating measures'
|
71
73
|
runner = OpenStudio::Extension::Runner.new(Dir.pwd)
|
72
74
|
runner.update_measures(@measures_dir)
|
73
75
|
end
|
74
76
|
|
75
77
|
desc 'List measures'
|
76
78
|
task :list_measures do
|
77
|
-
puts 'Listing measures
|
79
|
+
puts 'Listing measures'
|
78
80
|
runner = OpenStudio::Extension::Runner.new(Dir.pwd)
|
79
81
|
runner.list_measures(@measures_dir)
|
80
82
|
end
|
@@ -92,12 +94,6 @@ module OpenStudio
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
|
-
# TODO: Implement this eventually... comment out for now.
|
96
|
-
# desc 'Use openstudio docker image to run tests'
|
97
|
-
# task :test_with_docker do
|
98
|
-
# puts 'testing with docker'
|
99
|
-
# end
|
100
|
-
|
101
97
|
# namespace for measure operations
|
102
98
|
namespace 'measures' do
|
103
99
|
desc 'Copy the resources files to individual measures'
|
@@ -145,14 +141,203 @@ module OpenStudio
|
|
145
141
|
runner.update_copyright(@root_dir, @doc_templates_dir)
|
146
142
|
end
|
147
143
|
|
148
|
-
desc '
|
149
|
-
task :
|
150
|
-
|
144
|
+
desc 'Print the change log from GitHub'
|
145
|
+
task :change_log, [:start_date, :end_date, :apikey] do |t, args|
|
146
|
+
require 'change_log'
|
147
|
+
cl = ChangeLog.new(@github_repo, *args)
|
148
|
+
cl.process
|
149
|
+
cl.print_issues
|
151
150
|
end
|
152
151
|
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
namespace 'bcl' do
|
153
|
+
desc 'Test BCL login'
|
154
|
+
task :test_login do
|
155
|
+
puts 'test BCL login'
|
156
|
+
bcl = ::BCL::ComponentMethods.new
|
157
|
+
bcl.login
|
158
|
+
end
|
159
|
+
|
160
|
+
# for custom search, populate env var: bcl_search_keyword
|
161
|
+
desc 'Search BCL'
|
162
|
+
task :search_measures do
|
163
|
+
puts 'test search BCL'
|
164
|
+
bcl = ::BCL::ComponentMethods.new
|
165
|
+
bcl.login
|
166
|
+
|
167
|
+
# check for env var specifying keyword first
|
168
|
+
if ENV['bcl_search_keyword']
|
169
|
+
keyword = ENV['bcl_search_keyword']
|
170
|
+
else
|
171
|
+
keyword = 'Space'
|
172
|
+
end
|
173
|
+
num_results = 10
|
174
|
+
# bcl.search params: search_string, filter_string, return_all_results?
|
175
|
+
puts "searching BCL measures for keyword: #{keyword}"
|
176
|
+
results = bcl.search(keyword, "fq[]=bundle:nrel_measure&show_rows=#{num_results}", false)
|
177
|
+
puts "there are #{results[:result].count} results"
|
178
|
+
results[:result].each do |res|
|
179
|
+
puts (res[:measure][:name]).to_s
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# to call with argument: "openstudio:bcl:stage[true]" (true = remove existing staged content)
|
184
|
+
desc 'Copy the measures/components to a location that can be uploaded to BCL'
|
185
|
+
task :stage, [:reset] do |t, args|
|
186
|
+
puts 'Staging measures for BCL'
|
187
|
+
# initialize BCL and login
|
188
|
+
bcl = ::BCL::ComponentMethods.new
|
189
|
+
bcl.login
|
190
|
+
|
191
|
+
# process reset options: true to clear out old staged content
|
192
|
+
options = { reset: false }
|
193
|
+
if args[:reset].to_s == 'true'
|
194
|
+
options[:reset] = true
|
195
|
+
end
|
196
|
+
|
197
|
+
# ensure staged dir exists
|
198
|
+
FileUtils.mkdir_p(@staged_path)
|
199
|
+
|
200
|
+
# delete existing tarballs if reset is true
|
201
|
+
if options[:reset]
|
202
|
+
puts 'Deleting existing staged content'
|
203
|
+
FileUtils.rm_rf(Dir.glob("#{@staged_path}/*"))
|
204
|
+
end
|
205
|
+
|
206
|
+
# create new and existing directories
|
207
|
+
FileUtils.mkdir_p(@staged_path.to_s + '/update')
|
208
|
+
FileUtils.mkdir_p(@staged_path.to_s + '/push/component')
|
209
|
+
FileUtils.mkdir_p(@staged_path.to_s + '/push/measure')
|
210
|
+
|
211
|
+
# keep track of noop, update, push
|
212
|
+
noops = 0
|
213
|
+
new_ones = 0
|
214
|
+
updates = 0
|
215
|
+
|
216
|
+
# get all content directories to process
|
217
|
+
dirs = Dir.glob("#{@measures_dir}/*")
|
218
|
+
|
219
|
+
dirs.each do |dir|
|
220
|
+
next if dir.include?('Rakefile') || File.basename(dir) == 'staged'
|
221
|
+
current_d = Dir.pwd
|
222
|
+
content_name = File.basename(dir)
|
223
|
+
puts '', '---'
|
224
|
+
puts "Generating #{content_name}"
|
225
|
+
|
226
|
+
Dir.chdir(dir)
|
227
|
+
|
228
|
+
# figure out whether to upload new or update existing
|
229
|
+
files = Pathname.glob('**/*')
|
230
|
+
uuid = nil
|
231
|
+
vid = nil
|
232
|
+
content_type = 'measure'
|
233
|
+
|
234
|
+
paths = []
|
235
|
+
files.each do |file|
|
236
|
+
# don't tar tests/outputs directory
|
237
|
+
next if file.to_s.start_with?('tests/output') # From measure testing process
|
238
|
+
next if file.to_s.start_with?('tests/test') # From openstudio-measure-tester-gem
|
239
|
+
next if file.to_s.start_with?('tests/coverage') # From openstudio-measure-tester-gem
|
240
|
+
next if file.to_s.start_with?('test_results') # From openstudio-measure-tester-gem
|
241
|
+
paths << file.to_s
|
242
|
+
if file.to_s =~ /^.{0,2}component.xml$/ || file.to_s =~ /^.{0,2}measure.xml$/
|
243
|
+
if file.to_s.match?(/^.{0,2}component.xml$/)
|
244
|
+
content_type = 'component'
|
245
|
+
end
|
246
|
+
# extract uuid and vid
|
247
|
+
uuid, vid = bcl.uuid_vid_from_xml(file)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
puts "UUID: #{uuid}, VID: #{vid}"
|
251
|
+
|
252
|
+
# note: if uuid is missing, will assume new content
|
253
|
+
action = bcl.search_by_uuid(uuid, vid)
|
254
|
+
puts "#{content_name} ACTION TO TAKE: #{action}"
|
255
|
+
# new content functionality needs to know if measure or component. update is agnostic.
|
256
|
+
if action == 'noop' # ignore up-to-date content
|
257
|
+
puts " - WARNING: local #{content_name} uuid and vid match BCL... no update will be performed"
|
258
|
+
noops += 1
|
259
|
+
next
|
260
|
+
elsif action == 'update'
|
261
|
+
# puts "#{content_name} labeled as update for BCL"
|
262
|
+
destination = @staged_path + '/' + action + '/' + "#{content_name}.tar.gz"
|
263
|
+
updates += 1
|
264
|
+
elsif action == 'push'
|
265
|
+
# puts "#{content_name} labeled as new content for BCL"
|
266
|
+
destination = @staged_path + '/' + action + '/' + content_type + "/#{content_name}.tar.gz"
|
267
|
+
new_ones += 1
|
268
|
+
end
|
269
|
+
|
270
|
+
puts "destination: #{destination}"
|
271
|
+
|
272
|
+
# copy over only if 'reset_receipts' is set to TRUE. otherwise ignore if file exists already
|
273
|
+
if File.exist?(destination)
|
274
|
+
if reset
|
275
|
+
FileUtils.rm(destination)
|
276
|
+
::BCL.tarball(destination, paths)
|
277
|
+
else
|
278
|
+
puts "*** WARNING: File #{content_name}.tar.gz already exists in staged directory... keeping existing file. To overwrite, set reset_receipts arg to true ***"
|
279
|
+
end
|
280
|
+
else
|
281
|
+
::BCL.tarball(destination, paths)
|
282
|
+
end
|
283
|
+
Dir.chdir(current_d)
|
284
|
+
end
|
285
|
+
puts '', "****STAGING DONE**** #{new_ones} new content, #{updates} updates, #{noops} skipped (already up-to-date on BCL)", ''
|
286
|
+
end
|
287
|
+
|
288
|
+
desc 'Upload measures from the specified location.'
|
289
|
+
task :push do
|
290
|
+
puts 'Push measures to BCL'
|
291
|
+
|
292
|
+
# initialize BCL and login
|
293
|
+
bcl = ::BCL::ComponentMethods.new
|
294
|
+
bcl.login
|
295
|
+
reset = false
|
296
|
+
|
297
|
+
total_count = 0
|
298
|
+
successes = 0
|
299
|
+
errors = 0
|
300
|
+
skipped = 0
|
301
|
+
|
302
|
+
# grab all the new measure and component tar files and push to bcl
|
303
|
+
['measure', 'component'].each do |content_type|
|
304
|
+
items = []
|
305
|
+
paths = Pathname.glob(@staged_path.to_s + "/push/#{content_type}/*.tar.gz")
|
306
|
+
paths.each do |path|
|
307
|
+
# puts path
|
308
|
+
items << path.to_s
|
309
|
+
end
|
310
|
+
|
311
|
+
items.each do |item|
|
312
|
+
puts item.split('/').last
|
313
|
+
total_count += 1
|
314
|
+
|
315
|
+
receipt_file = File.dirname(item) + '/' + File.basename(item, '.tar.gz') + '.receipt'
|
316
|
+
if !reset && File.exist?(receipt_file)
|
317
|
+
skipped += 1
|
318
|
+
puts 'SKIP: receipt file found'
|
319
|
+
next
|
320
|
+
end
|
321
|
+
|
322
|
+
valid, res = bcl.push_content(item, true, "nrel_#{content_type}")
|
323
|
+
if valid
|
324
|
+
successes += 1
|
325
|
+
else
|
326
|
+
errors += 1
|
327
|
+
if res.key?(:error)
|
328
|
+
puts " ERROR MESSAGE: #{res[:error]}"
|
329
|
+
else
|
330
|
+
puts "ERROR: #{res.inspect.chomp}"
|
331
|
+
end
|
332
|
+
end
|
333
|
+
puts '', '---'
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
# grab all the updated content (measures and components) tar files and push to bcl
|
338
|
+
items = []
|
339
|
+
paths = Pathname.glob(@staged_path.to_s + '/update/*.tar.gz')
|
340
|
+
end
|
156
341
|
end
|
157
342
|
end
|
158
343
|
end
|
@@ -43,6 +43,7 @@ require 'openstudio'
|
|
43
43
|
require 'yaml'
|
44
44
|
require 'fileutils'
|
45
45
|
require 'parallel'
|
46
|
+
require 'bcl'
|
46
47
|
|
47
48
|
module OpenStudio
|
48
49
|
module Extension
|
@@ -57,7 +58,7 @@ module OpenStudio
|
|
57
58
|
# compatible with the OpenStudio CLI.
|
58
59
|
##
|
59
60
|
# @param [String] dirname Directory to run commands in, defaults to Dir.pwd. If directory includes a Gemfile then create a local bundle.
|
60
|
-
# @param bundle_without [
|
61
|
+
# @param bundle_without [Array] List of strings of the groups to exclude when running the bundle command
|
61
62
|
# @param options [Hash] Hash describing options for running the simulation. These are the defaults for all runs unless overriden within the run_* methods. Note if options is used, then a local runner.conf file will not be loaded.
|
62
63
|
# @option options [String] :max_datapoints Max number of datapoints to run
|
63
64
|
# @option options [String] :num_parallel Number of simulations to run in parallel at a time
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
}
|
23
23
|
|
24
24
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
f.match(%r{^(test|spec|features)/})
|
25
|
+
f.match(%r{^(test|lib.measures.*tests|spec|features)/})
|
26
26
|
end
|
27
27
|
spec.bindir = 'exe'
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -30,12 +30,13 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.required_ruby_version = '~> 2.5.0'
|
32
32
|
|
33
|
+
spec.add_dependency 'bcl', '~> 0.6.0'
|
33
34
|
spec.add_dependency 'bundler', '~> 2.1'
|
34
|
-
spec.add_dependency '
|
35
|
+
spec.add_dependency 'octokit', '~> 4.18.0' # for change logs
|
35
36
|
spec.add_dependency 'openstudio_measure_tester', '~> 0.2.2'
|
37
|
+
spec.add_dependency 'openstudio-workflow', '~> 2.0.0'
|
36
38
|
spec.add_dependency 'parallel', '~> 1.19.1'
|
37
39
|
|
38
|
-
spec.add_development_dependency 'github_api', '~> 0.18.0'
|
39
40
|
spec.add_development_dependency 'rake', '~> 13.0'
|
40
41
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
41
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstudio-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katherine Fleming
|
@@ -10,8 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bcl
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.6.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 0.6.0
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: bundler
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -27,19 +41,19 @@ dependencies:
|
|
27
41
|
- !ruby/object:Gem::Version
|
28
42
|
version: '2.1'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
44
|
+
name: octokit
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
47
|
- - "~>"
|
34
48
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
49
|
+
version: 4.18.0
|
36
50
|
type: :runtime
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
54
|
- - "~>"
|
41
55
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
56
|
+
version: 4.18.0
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: openstudio_measure_tester
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,33 +69,33 @@ dependencies:
|
|
55
69
|
- !ruby/object:Gem::Version
|
56
70
|
version: 0.2.2
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
72
|
+
name: openstudio-workflow
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
60
74
|
requirements:
|
61
75
|
- - "~>"
|
62
76
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
77
|
+
version: 2.0.0
|
64
78
|
type: :runtime
|
65
79
|
prerelease: false
|
66
80
|
version_requirements: !ruby/object:Gem::Requirement
|
67
81
|
requirements:
|
68
82
|
- - "~>"
|
69
83
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
84
|
+
version: 2.0.0
|
71
85
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
86
|
+
name: parallel
|
73
87
|
requirement: !ruby/object:Gem::Requirement
|
74
88
|
requirements:
|
75
89
|
- - "~>"
|
76
90
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
type: :
|
91
|
+
version: 1.19.1
|
92
|
+
type: :runtime
|
79
93
|
prerelease: false
|
80
94
|
version_requirements: !ruby/object:Gem::Requirement
|
81
95
|
requirements:
|
82
96
|
- - "~>"
|
83
97
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
98
|
+
version: 1.19.1
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: rake
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +168,6 @@ files:
|
|
154
168
|
- lib/measures/openstudio_extension_test_measure/measure.rb
|
155
169
|
- lib/measures/openstudio_extension_test_measure/measure.xml
|
156
170
|
- lib/measures/openstudio_extension_test_measure/resources/os_lib_helper_methods.rb
|
157
|
-
- lib/measures/openstudio_extension_test_measure/tests/openstudio_extension_test_measure_test.rb
|
158
171
|
- lib/openstudio-extension.rb
|
159
172
|
- lib/openstudio/extension.rb
|
160
173
|
- lib/openstudio/extension/core/CreateResults.rb
|
@@ -205,7 +218,7 @@ licenses: []
|
|
205
218
|
metadata:
|
206
219
|
bug_tracker_uri: https://github.com/NREL/openstudio-extension-gem/issues
|
207
220
|
changelog_uri: https://github.com/NREL/openstudio-extension-gem/blob/develop/CHANGELOG.md
|
208
|
-
source_code_uri: https://github.com/NREL/openstudio-extension-gem/tree/v0.2.
|
221
|
+
source_code_uri: https://github.com/NREL/openstudio-extension-gem/tree/v0.2.2
|
209
222
|
post_install_message:
|
210
223
|
rdoc_options: []
|
211
224
|
require_paths:
|
data/lib/measures/openstudio_extension_test_measure/tests/openstudio_extension_test_measure_test.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# *******************************************************************************
|
4
|
-
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
-
# All rights reserved.
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# (1) Redistributions of source code must retain the above copyright notice,
|
10
|
-
# this list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# (3) Neither the name of the copyright holder nor the names of any contributors
|
17
|
-
# may be used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission from the respective party.
|
19
|
-
#
|
20
|
-
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
21
|
-
# of modifications or other derivative works may not use the "OpenStudio"
|
22
|
-
# trademark, "OS", "os", or any other confusingly similar designation without
|
23
|
-
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
24
|
-
#
|
25
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
26
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
27
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
28
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
29
|
-
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
30
|
-
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
31
|
-
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
32
|
-
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
33
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
34
|
-
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
35
|
-
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
|
-
# *******************************************************************************
|
37
|
-
|
38
|
-
require 'openstudio'
|
39
|
-
require 'openstudio/measure/ShowRunnerOutput'
|
40
|
-
|
41
|
-
require_relative '../measure.rb'
|
42
|
-
require 'minitest/autorun'
|
43
|
-
|
44
|
-
class OpenStudioExtensionTestMeasureTest < Minitest::Test
|
45
|
-
# def setup
|
46
|
-
# end
|
47
|
-
|
48
|
-
# def teardown
|
49
|
-
# end
|
50
|
-
|
51
|
-
def test_OpenStudioExtensionTestMeasure
|
52
|
-
# create an instance of the measure
|
53
|
-
measure = OpenStudioExtensionTestMeasure.new
|
54
|
-
|
55
|
-
# create an instance of a runner
|
56
|
-
runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
|
57
|
-
|
58
|
-
# make an empty model
|
59
|
-
model = OpenStudio::Model::Model.new
|
60
|
-
|
61
|
-
# get arguments and test that they are what we are expecting
|
62
|
-
arguments = measure.arguments(model)
|
63
|
-
assert_equal(0, arguments.size)
|
64
|
-
|
65
|
-
# set argument values to good values and run the measure on model with spaces
|
66
|
-
arguments = measure.arguments(model)
|
67
|
-
argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
|
68
|
-
|
69
|
-
measure.run(model, runner, argument_map)
|
70
|
-
result = runner.result
|
71
|
-
# show_output(result)
|
72
|
-
assert(result.value.valueName == 'Success')
|
73
|
-
assert(result.warnings.empty?)
|
74
|
-
assert(result.info.empty?)
|
75
|
-
end
|
76
|
-
end
|