| 22 | namespace openstudio { |
| 23 | |
| 24 | void OSWorkflow::runInitialization() { |
| 25 | |
| 26 | state = State::Initialization; |
| 27 | |
| 28 | auto rootDir = workflowJSON.absoluteRootDir(); |
| 29 | LOG(Debug, "The root_dir for the datapoint is " << rootDir); |
| 30 | |
| 31 | detailedTimeBlock("Wiping directories", [this, &rootDir]() { |
| 32 | { |
| 33 | auto generatedFilesDir = rootDir / "generated_files"; |
| 34 | if (openstudio::filesystem::is_directory(generatedFilesDir)) { |
| 35 | LOG(Debug, "Removing existing generated files directory: " << generatedFilesDir); |
| 36 | openstudio::filesystem::remove_all(generatedFilesDir); |
| 37 | } |
| 38 | LOG(Debug, "Creating generated files directory: " << generatedFilesDir); |
| 39 | openstudio::filesystem::create_directories(generatedFilesDir); |
| 40 | |
| 41 | // insert the generated files directory in the first spot so all generated ExternalFiles go here |
| 42 | auto fps = workflowJSON.filePaths(); |
| 43 | workflowJSON.resetFilePaths(); |
| 44 | workflowJSON.addFilePath(generatedFilesDir); |
| 45 | for (const auto& fp : fps) { |
| 46 | workflowJSON.addFilePath(fp); |
| 47 | } |
| 48 | |
| 49 | auto reportsDir = rootDir / "reports"; |
| 50 | if (openstudio::filesystem::is_directory(reportsDir)) { |
| 51 | LOG(Debug, "Removing existing reports directory: " << reportsDir); |
| 52 | openstudio::filesystem::remove_all(reportsDir); |
| 53 | } |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | // TODO: Validate the OSW measures if the flag is set to true, (the default state) |
| 58 | // There isn't a 'verify_osw' key in the RunOptions, so always do it for now. Maybe don't if `fast`? |
| 59 | { |
| 60 | LOG(Info, "Attempting to validate the measure workflow"); |
| 61 | |
| 62 | if (!workflowJSON.validateMeasures()) { |
| 63 | LOG_AND_THROW("Workflow is invalid"); |
| 64 | } |
| 65 | |
| 66 | LOG(Info, "Validated the measure workflow"); |
| 67 | } |
| 68 | |
| 69 | LOG(Debug, "Finding and loading the seed file"); |
| 70 | auto seedPath_ = workflowJSON.seedFile(); |
| 71 | if (seedPath_) { |
| 72 | auto modelFullPath_ = workflowJSON.findFile(seedPath_.get()); |
| 73 | if (!modelFullPath_) { |
| 74 | state = State::Errored; |
| 75 | throw std::runtime_error(fmt::format("Seed model {} specified in OSW cannot be found", seedPath_->string())); |
| 76 | } |
| 77 | |
| 78 | if (modelFullPath_->extension() == openstudio::filesystem::path(".idf")) { |
| 79 | if (m_add_timings && m_detailed_timings) { |
| 80 | m_timers->newTimer(" Loading seed IDF"); |
| 81 | } |
nothing calls this directly
no test coverage detected