-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing add_result_measure_info
so that out.osw step result have the same info as before
#5044
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"measure_paths": ["../measures/"], | ||
"steps": [ | ||
{ | ||
"measure_dir_name": "FakeReport", | ||
"arguments": {} | ||
} | ||
] | ||
} |
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,107 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from workflow_helpers import run_workflow | ||
|
||
|
||
@pytest.fixture(scope="module", params=[True, False], ids=["labs", "classic"]) | ||
def runWorkflow(osclipath, request): | ||
is_labs = request.param | ||
suffix = "labs" if is_labs else "classic" | ||
runDir, r = run_workflow( | ||
osclipath=osclipath, | ||
base_osw_name="in.osw", | ||
suffix=suffix, | ||
is_labs=is_labs, | ||
verbose=False, | ||
debug=False, | ||
post_process_only=True, | ||
) | ||
r.check_returncode() | ||
return runDir, is_labs | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"is_labs", | ||
[pytest.param(True, id="labs"), pytest.param(False, id="classic")], | ||
) | ||
def test_(osclipath, is_labs: bool): | ||
suffix = "labs" if is_labs else "classic" | ||
runDir, r = run_workflow( | ||
osclipath=osclipath, | ||
base_osw_name="in.osw", | ||
suffix=suffix, | ||
is_labs=is_labs, | ||
verbose=False, | ||
debug=True, | ||
post_process_only=True, | ||
) | ||
r.check_returncode() | ||
out_osw_path = Path(f"out_in_{suffix}.osw") | ||
assert out_osw_path.is_file() | ||
out = json.loads(out_osw_path.read_text()) | ||
|
||
assert out["completed_status"] == "Success" | ||
assert out["current_step"] == 1 | ||
|
||
EXPECTED_TOPLEVEL_KEYS = { | ||
"completed_at", | ||
"completed_status", | ||
"current_step", | ||
"file_paths", | ||
"hash", | ||
"measure_paths", | ||
"out_name", | ||
"run_directory", | ||
"started_at", | ||
"steps", | ||
"updated_at", | ||
} | ||
if is_labs: | ||
EXPECTED_TOPLEVEL_KEYS.add("run_options") | ||
assert out.keys() == EXPECTED_TOPLEVEL_KEYS | ||
|
||
assert len(out["steps"]) == 1 | ||
step = out["steps"][0] | ||
step.keys() == {"arguments", "measure_dir_name", "result"} | ||
assert step["arguments"] == {} | ||
assert step["measure_dir_name"] == "FakeReport" | ||
|
||
step_result = step["result"] | ||
assert step_result.keys() == { | ||
"completed_at", | ||
"measure_class_name", | ||
"measure_display_name", | ||
"measure_name", | ||
"measure_taxonomy", | ||
"measure_type", | ||
"measure_uid", | ||
"measure_version_id", | ||
"measure_version_modified", | ||
"measure_xml_checksum", | ||
"started_at", | ||
"stderr", | ||
"stdout", | ||
"step_errors", | ||
"step_files", | ||
"step_final_condition", | ||
"step_info", | ||
"step_result", | ||
"step_values", | ||
"step_warnings", | ||
} | ||
|
||
assert step_result["step_result"] == "Success" | ||
|
||
assert len(step_result["step_info"]) == 1 | ||
assert len(step_result["step_warnings"]) == 1 | ||
assert not step_result["step_errors"] | ||
|
||
len(step_result["step_values"]) == 3 | ||
assert {x["name"] for x in step_result["step_values"]} == { | ||
"fake_report", | ||
"net_site_energy", | ||
"something_with_invalid_chars", | ||
} |
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 |
---|---|---|
|
@@ -84,6 +84,7 @@ void OSWorkflow::applyMeasures(MeasureType measureType, bool energyplus_output_r | |
LOG(Info, fmt::format("Skipping measure '{}'", measureDirName)); | ||
WorkflowStepResult result = runner.result(); | ||
runner.incrementStep(); | ||
// addResultMeasureInfo(result, bclMeasure); // TODO: Should I really instantiate the BCLMeasure just for this? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When Skip, I'm not doing it. I think that's fine. |
||
result.setStepResult(StepResult::Skip); | ||
} | ||
|
||
|
@@ -296,8 +297,10 @@ end | |
} catch (const std::exception& e) { | ||
runner.registerError(e.what()); | ||
if (!energyplus_output_requests) { | ||
WorkflowStepResult result = runner.result(); | ||
// incrementStep must be called after run | ||
runner.incrementStep(); | ||
workflow::util::addResultMeasureInfo(result, bclMeasure); | ||
} | ||
ensureBlock(true); | ||
throw std::runtime_error(fmt::format("Runner error: Measure '{}' reported an error with [{}]", scriptPath_->generic_string(), e.what())); | ||
|
@@ -309,6 +312,7 @@ end | |
|
||
// incrementStep must be called after run | ||
runner.incrementStep(); | ||
workflow::util::addResultMeasureInfo(result, bclMeasure); | ||
if (auto errors = result.stepErrors(); !errors.empty()) { | ||
ensureBlock(true); | ||
throw std::runtime_error(fmt::format("Measure '{}' reported an error with [{}]", measureDirName, fmt::join(errors, "\n"))); | ||
|
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 |
---|---|---|
|
@@ -18,6 +18,9 @@ | |
#include "../utilities/idf/IdfObject.hpp" | ||
#include "../utilities/idd/IddObject.hpp" | ||
#include "../utilities/idf/IdfExtensibleGroup.hpp" | ||
#include "../utilities/filetypes/WorkflowStepResult.hpp" | ||
#include "../utilities/bcl/BCLMeasure.hpp" | ||
#include "../utilities/time/DateTime.hpp" | ||
|
||
#include <boost/filesystem/operations.hpp> | ||
#include <utilities/idd/IddEnums.hxx> | ||
|
@@ -326,4 +329,24 @@ std::string sanitizeKey(std::string key) { | |
return key; | ||
} | ||
|
||
bool addResultMeasureInfo(WorkflowStepResult& result, BCLMeasure& measure) { | ||
try { | ||
result.setMeasureType(measure.measureType()); | ||
result.setMeasureName(measure.name()); | ||
result.setMeasureId(measure.uid()); | ||
result.setMeasureVersionId(measure.versionId()); | ||
auto version_modified_ = measure.versionModified(); | ||
if (version_modified_) { | ||
result.setMeasureVersionModified(*version_modified_); | ||
} | ||
result.setMeasureXmlChecksum(measure.xmlChecksum()); | ||
result.setMeasureClassName(measure.className()); | ||
result.setMeasureDisplayName(measure.displayName()); | ||
result.setMeasureTaxonomy(measure.taxonomyTag()); | ||
return true; | ||
} catch (...) { | ||
return false; | ||
} | ||
} | ||
Comment on lines
+332
to
+350
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
} // namespace openstudio::workflow::util |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New test before/after