Skip to content
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

Fix file not found output message #8324

Merged
merged 22 commits into from
Nov 12, 2020

Conversation

ajscimone
Copy link
Contributor

@ajscimone ajscimone commented Sep 30, 2020

Pull request overview

  • Fixes EnergyPlus does not report a clear message about where it attempted to find files which were not found. #8282
  • This pull request fixes an issue with the DataSystemVariables::CheckForActualFileName function not outputting any information about where EnergyPlus searched for files it was unable to find. After this pull request, users can now pass in an optional vector which will be populated with locations that EnergyPlus looks for the file being checked, and a flag to ask for the function to output the checked locations as error messages. This will help users quickly identify why EnergyPlus cannot locate the files they are referencing in an idf.

The original idf file which caught this bug is posted here:
in.idf.txt

To demonstrate the effect of this pull request here is the .err output from develop on the above idf before this pull request:
eplusout.err.txt

And here is the .err file for this idf after this pull request.
eplusout.err.txt

The result is a much clearer output in the err stream about the issues with the files not being found, as well as a more understandable fatal error.

Additionally, these two idfs also use this file checking function, and so additional .err outputs can be seen by running them (provided you don't let EnergyPlus find the actual files it's looking for.)

ScheduleFileTest.idf.txt
SolarShadingTest.idf.txt

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • 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
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@ajscimone ajscimone requested a review from nealkruis September 30, 2020 03:27
@ajscimone ajscimone added Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze) labels Sep 30, 2020
@ajscimone ajscimone self-assigned this Sep 30, 2020
…n optional array to be filled with locations checked for, as well as the boolean value for outputting to the err file when a file is not found. This behavior of printing a list of locations checked when a file is not found to the err file is now always present. Additionally, a new string can optionally be passed to the function as a context string which will modify this printing output to give context about where this file missing output is coming from. Lastly, the table files object in curve manager has been modified to use this structure.
…ings to each, allowing for cleanup of error messages in these sections of code.
…kable for a cross platform situation and using the error stream matching function to detect the issue tested for is actually being printed in the err stream.
Comment on lines 255 to 261
{InputFileName, "InputFileName"},
{DataStringGlobals::inputDirPathName + InputFileName, "inputDirPathName"},
{envinputpath1 + InputFileName, "envinputpath1"},
{envinputpath2 + InputFileName, "envinputpath2"},
{envprogrampath + InputFileName, "envprogrampath"},
{CurrentWorkingFolder + InputFileName, "CurrentWorkingFolder"},
{ProgramPath + InputFileName, "ProgramPath"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajscimone Here are more informative descriptions for each of the strings that describe where files are searched:

  1. Current working directory
  2. IDF directory
  3. "epin" environment variable
  4. "input_path" environment variable
  5. <This variable is never used or set, I think it's supposed to be "program_path" environment variable initialized as cProgramPath, but that variable overwrites ProgramPath instead>
  6. INI directory (if it exists) <from what I can tell this is always identical to [1] -- maybe we can drop it?>
  7. "program" > "dir" from INI file

We should maybe add exeDirectory to the paths searched, too? I think that is the intent of [5] and [7], but neither of those seem reliable.

@Myoldmopar @mjwitte thoughts on any of this?

Separate question: Does/should this interact with the way python plug-in paths are searched?

… not found errors, and fix the logic flow for file not found searches in CurveManager to not throw a fatal error immediately when a file is not found. This results in more output from the Curve Manager about additional files it could not find, and a more reasonable fatal error.
@ajscimone ajscimone marked this pull request as ready for review October 1, 2020 21:42
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with these changes, it looks like it won't affect the Python stuff at all, and it looks to be in good shape. I had a couple suggestions in case additional changes are needed, but otherwise it's fine as-is. I haven't tested it, I think @mitchute is going to verify the fix, but the code itself looks good.

@@ -1750,9 +1750,13 @@ namespace CurveManager {
std::size_t rowNum = indVarInstance.at("external_file_starting_row_number").get<std::size_t>() - 1;

if (!state.dataCurveManager->btwxtManager.tableFiles.count(filePath)) {
state.dataCurveManager->btwxtManager.tableFiles.emplace(filePath, TableFile{state, filePath});
TableFile tableFile;
ErrorsFound |= tableFile.load(state, filePath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking the initialization into a separate bool load() function makes sense.

std::string contextString = "CurveManager::TableFile::load: ";
DataSystemVariables::CheckForActualFileName(state, path, fileFound, fullPath, contextString);
if(!fileFound){
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So true means error. OK. A little confusing maybe but not a big deal. If other commits are needed here for anything, I'd suggest considering a clearer convention like bool loadSuccess() where true is clearly success. Anyway, not a big deal if it's working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was kind of thinking of it as an error code return where 0/false means success.

{envprogrampath + InputFileName, "\"program_path\" Environment Variable"},
{CurrentWorkingFolder + InputFileName, "INI File Directory"},
{ProgramPath + InputFileName, "\"program\", \"dir\" from INI File"}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a small list, so it's not a big deal, but an array would've been acceptable here since I think this vector is staying fixed length.


std::string contextString = cCurrentModuleObject + ", " + cAlphaFieldNames(1) + ": ";

CheckForActualFileName(state, cAlphaArgs(1), fileExist, tempFullFileName, contextString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, just needing to add a new context string.

@@ -1165,8 +1169,6 @@ namespace ExternalInterface {
}
fullFileName(Loop) = tempFullFileName;
} else {
ShowSevereError(state, "ExternalInterface/InitExternalInterfaceFMUImport:");
ShowContinueError(state, "file not located = \"" + cAlphaArgs(1) + "\".");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then no longer needing to report the error details.

@mitchute
Copy link
Collaborator

Confirmed that this works. One minor cosmetic issue that we might consider cleaning up if there are other commits required:

Break the "Paths searched:" string, here (https://github.com/NREL/EnergyPlus/pull/8324/files#diff-c3b9eb9daf6e23f579ad991f364fc70e9416d16a05619e9cc830960094e3bbb6R284) out into a separate ShowContinueError. As it is, "Paths Searched:" comes out in the last error summary.

**  Fatal  ** GetCurveInput: Errors found in getting Curve Objects.  Preceding condition(s) cause termination.
   ...Summary of Errors that led to program termination:
   ..... Reference severe error count=4
   ..... Last severe error=CurveManager::TableFile::load: "../performanceTable_PI_168H.csv" not found. Paths searched:

@mitchute
Copy link
Collaborator

I just confirmed the changes locally. The Kiva unit test failures aren't related to this and I think we're investigating that separately anyway, so I'm going to merge this.

@mitchute mitchute merged commit 283b640 into NREL:develop Nov 12, 2020
@mjwitte
Copy link
Contributor

mjwitte commented Nov 12, 2020

I'm guessing this PR is the source of audit diffs that show up now on test files that access an external file. e.g. HybridModel_4Zone_Solve_PeopleCount_with_HVAC and 1ZoneUncontrolled_win_1

@mitchute
Copy link
Collaborator

Seems right to me. Comparing the diffs, the only real difference in the messages are the clone branch paths.

i.e. clone_baseline vs. clone_branch

@mjwitte
Copy link
Contributor

mjwitte commented Nov 12, 2020

So, we'll need to add some rules to CI to understand that these are not substantive diffs and not warn. Otherwise, we'll never get a fully green report.

@Myoldmopar
Copy link
Member

Got it: NREL/EnergyPlusRegressionTool@d04aae5

Once that PR merged, Decent CI will not show those diffs anymore.

@matthew-larson matthew-larson deleted the fix-file-not-found-output-message branch May 12, 2021 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnergyPlus does not report a clear message about where it attempted to find files which were not found.
10 participants