-
Notifications
You must be signed in to change notification settings - Fork 422
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
Fix file not found output message #8324
Conversation
…and output as error messages if the file is not found.
… of locations to check for a file instead of checking them with multiple blocks of code.
… the file not found error outputs.
…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.
{InputFileName, "InputFileName"}, | ||
{DataStringGlobals::inputDirPathName + InputFileName, "inputDirPathName"}, | ||
{envinputpath1 + InputFileName, "envinputpath1"}, | ||
{envinputpath2 + InputFileName, "envinputpath2"}, | ||
{envprogrampath + InputFileName, "envprogrampath"}, | ||
{CurrentWorkingFolder + InputFileName, "CurrentWorkingFolder"}, | ||
{ProgramPath + InputFileName, "ProgramPath"} |
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.
@ajscimone Here are more informative descriptions for each of the strings that describe where files are searched:
- Current working directory
- IDF directory
- "epin" environment variable
- "input_path" environment variable
- <This variable is never used or set, I think it's supposed to be "program_path" environment variable initialized as
cProgramPath
, but that variable overwritesProgramPath
instead> - INI directory (if it exists) <from what I can tell this is always identical to [1] -- maybe we can drop it?>
- "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.
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.
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); |
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.
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; |
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.
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.
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.
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"} | ||
}; |
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.
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); |
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.
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) + "\"."); |
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.
And then no longer needing to report the error details.
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
|
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. |
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 |
Seems right to me. Comparing the diffs, the only real difference in the messages are the clone branch paths. i.e. |
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. |
Got it: NREL/EnergyPlusRegressionTool@d04aae5 Once that PR merged, Decent CI will not show those diffs anymore. |
Pull request overview
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.
Reviewer
This will not be exhaustively relevant to every PR.