Skip to content

Commit

Permalink
Implement skip zip results in RunOptions. It's part of the osw schema…
Browse files Browse the repository at this point in the history
… and use in openstuido-workflow-gem
  • Loading branch information
jmarrec committed Nov 13, 2023
1 parent 7ed29be commit 659cd67
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/utilities/filetypes/RunOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ namespace detail {
root["skip_energyplus_preprocess"] = m_skipEnergyPlusPreprocess;
}

if (!m_is_skipZipResults_defaulted) {
root["skip_zip_results"] = m_skipZipResults;
}

if (!m_is_cleanup_defaulted) {
root["cleanup"] = m_cleanup;
}
Expand Down Expand Up @@ -200,6 +204,27 @@ namespace detail {
onUpdate();
}

bool RunOptions_Impl::skipZipResults() const {
return m_skipZipResults;
}

bool RunOptions_Impl::isSkipZipResultsDefaulted() const {
return m_is_skipZipResults_defaulted;
}

bool RunOptions_Impl::setSkipZipResults(bool skipZipResults) {
m_skipZipResults = skipZipResults;
m_is_skipZipResults_defaulted = false;
onUpdate();
return true;
}

void RunOptions_Impl::resetSkipZipResults() {
m_skipZipResults = DEFAULT_SKIPZIPRESULTS;
m_is_skipZipResults_defaulted = true;
onUpdate();
}

bool RunOptions_Impl::cleanup() const {
return m_cleanup;
}
Expand Down Expand Up @@ -277,6 +302,10 @@ namespace detail {
setSkipEnergyPlusPreprocess(other.skipEnergyPlusPreprocess());
}

if (!other.isSkipZipResultsDefaulted()) {
setSkipZipResults(other.skipZipResults());
}

if (!other.isCleanupDefaulted()) {
setCleanup(other.cleanup());
}
Expand Down Expand Up @@ -382,6 +411,10 @@ boost::optional<RunOptions> RunOptions::fromString(const std::string& s) {
result.setSkipEnergyPlusPreprocess(value["skip_energyplus_preprocess"].asBool());
}

if (value.isMember("skip_zip_results") && value["skip_zip_results"].isBool()) {
result.setSkipZipResults(value["skip_zip_results"].asBool());
}

if (value.isMember("output_adapter")) {
Json::Value outputAdapter = value["output_adapter"];
if (outputAdapter.isMember("custom_file_name") && outputAdapter.isMember("class_name")) {
Expand Down Expand Up @@ -504,6 +537,22 @@ void RunOptions::resetSkipEnergyPlusPreprocess() {
getImpl<detail::RunOptions_Impl>()->resetSkipEnergyPlusPreprocess();
}

bool RunOptions::skipZipResults() const {
return getImpl<detail::RunOptions_Impl>()->skipZipResults();
}

bool RunOptions::isSkipZipResultsDefaulted() const {
return getImpl<detail::RunOptions_Impl>()->isSkipZipResultsDefaulted();
}

bool RunOptions::setSkipZipResults(bool skipZipResults) {
return getImpl<detail::RunOptions_Impl>()->setSkipZipResults(skipZipResults);
}

void RunOptions::resetSkipZipResults() {
getImpl<detail::RunOptions_Impl>()->resetSkipZipResults();
}

bool RunOptions::cleanup() const {
return getImpl<detail::RunOptions_Impl>()->cleanup();
}
Expand Down
14 changes: 14 additions & 0 deletions src/utilities/filetypes/RunOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@ class UTILITIES_API RunOptions
/// Serialize to JSON formatted string
std::string string() const;

/** Print debugging messages, defaults to false */
bool debug() const;
bool isDebugDefaulted() const;
bool setDebug(bool debug);
void resetDebug();

/** Create, export and run using epjson format. Default is false */
bool epjson() const;
bool isEpjsonDefaulted() const;
bool setEpjson(bool epjson);
void resetEpjson();

/** Speeds up workflow by skipping steps not needed for running simulations, defaults to false */
bool fast() const;
bool isFastDefaulted() const;
bool setFast(bool fast);
Expand All @@ -82,16 +85,27 @@ class UTILITIES_API RunOptions
bool setPreserveRunDir(bool preserveRunDir);
void resetPreserveRunDir();

/** Skips the call to the EnergyPlus ExpandObjects program, defaults to false */
bool skipExpandObjects() const;
bool isSkipExpandObjectsDefaulted() const;
bool setSkipExpandObjects(bool skipExpandObjects);
void resetSkipExpandObjects();

/** Does not add add default output requests to EnergyPlus input if true.
* Requests from reporting measures are added in either case, defaults to false */
bool skipEnergyPlusPreprocess() const;
bool isSkipEnergyPlusPreprocessDefaulted() const;
bool setSkipEnergyPlusPreprocess(bool skipEnergyPlusPreprocess);
void resetSkipEnergyPlusPreprocess();

/** Skips creating the data_point.zip file. Setting to `true` can cause issues with workflows expecting .zip files to signal completion
* (e.g., OpenStudio Analysis Framework), defaults to false */
bool skipZipResults() const;
bool isSkipZipResultsDefaulted() const;
bool setSkipZipResults(bool skipZipResults);
void resetSkipZipResults();

/** Remove unnecessary files during post processing, defaults to true */
bool cleanup() const;
bool isCleanupDefaulted() const;
bool setCleanup(bool cleanup);
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/filetypes/RunOptions_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ namespace detail {
bool setCleanup(bool cleanup);
void resetCleanup();

bool skipZipResults() const;
bool isSkipZipResultsDefaulted() const;
bool setSkipZipResults(bool skipZipResults);
void resetSkipZipResults();

boost::optional<CustomOutputAdapter> customOutputAdapter() const;
bool setCustomOutputAdapter(const CustomOutputAdapter& adapter);
void resetCustomOutputAdapter();
Expand Down Expand Up @@ -94,6 +99,7 @@ namespace detail {
static constexpr bool DEFAULT_SKIPEXPANDOBJECTS = false;
static constexpr bool DEFAULT_SKIPENERGYPLUSPREPROCESS = false;
static constexpr bool DEFAULT_CLEANUP = true;
static constexpr bool DEFAULT_SKIPZIPRESULTS = false;

bool m_debug = DEFAULT_DEBUG;
bool m_is_debug_defaulted = true;
Expand All @@ -117,6 +123,9 @@ namespace detail {
bool m_cleanup = DEFAULT_CLEANUP;
bool m_is_cleanup_defaulted = true;

bool m_skipZipResults = DEFAULT_SKIPZIPRESULTS;
bool m_is_skipZipResults_defaulted = true;

ForwardTranslatorOptions m_forwardTranslatorOptions;
boost::optional<CustomOutputAdapter> m_customOutputAdapter;
};
Expand Down
17 changes: 17 additions & 0 deletions src/utilities/filetypes/test/WorkflowJSON_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,19 @@ TEST(Filetypes, RunOptions_GettersSetters) {
ASSERT_TRUE(runOptions.isSkipEnergyPlusPreprocessDefaulted());
ASSERT_TRUE(runOptions.isSkipEnergyPlusPreprocessDefaulted());

// Ctor Default
ASSERT_FALSE(runOptions.skipZipResults());
ASSERT_TRUE(runOptions.isSkipZipResultsDefaulted());
// Set to opposite of default
ASSERT_TRUE(runOptions.setSkipZipResults(true));
ASSERT_TRUE(runOptions.skipZipResults());
ASSERT_FALSE(runOptions.isSkipZipResultsDefaulted());
// Reset
runOptions.resetSkipZipResults();
ASSERT_FALSE(runOptions.skipZipResults());
ASSERT_TRUE(runOptions.isSkipZipResultsDefaulted());
ASSERT_TRUE(runOptions.isSkipZipResultsDefaulted());

// Ctor Default
ASSERT_TRUE(runOptions.cleanup());
ASSERT_TRUE(runOptions.isCleanupDefaulted());
Expand Down Expand Up @@ -1362,6 +1375,8 @@ TEST(Filetypes, RunOptions_overrideValuesWith) {
ASSERT_TRUE(runOptions.isSkipExpandObjectsDefaulted());
ASSERT_FALSE(runOptions.skipEnergyPlusPreprocess());
ASSERT_TRUE(runOptions.isSkipEnergyPlusPreprocessDefaulted());
ASSERT_FALSE(runOptions.skipZipResults());
ASSERT_TRUE(runOptions.isSkipZipResultsDefaulted());
ASSERT_TRUE(runOptions.cleanup());
ASSERT_TRUE(runOptions.isCleanupDefaulted());

Expand Down Expand Up @@ -1401,6 +1416,8 @@ TEST(Filetypes, RunOptions_overrideValuesWith) {
ASSERT_TRUE(runOptions.isSkipExpandObjectsDefaulted());
ASSERT_FALSE(runOptions.skipEnergyPlusPreprocess());
ASSERT_TRUE(runOptions.isSkipEnergyPlusPreprocessDefaulted());
ASSERT_FALSE(runOptions.skipEnergyPlusPreprocess());
ASSERT_TRUE(runOptions.isSkipEnergyPlusPreprocessDefaulted());
ASSERT_TRUE(runOptions.cleanup());
ASSERT_TRUE(runOptions.isCleanupDefaulted());

Expand Down

0 comments on commit 659cd67

Please sign in to comment.