-
Notifications
You must be signed in to change notification settings - Fork 196
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
Schedule:File relative paths #4879
Conversation
76c8024
to
bdddd1f
Compare
@joseph-robertson this is still marked as draft, is more work needed? |
Yes, more work is needed. I need to circle back to this. |
resources/model/OpenStudio.idd
Outdated
A8; \field Translate File Name | ||
\type choice | ||
\default No | ||
\key Yes | ||
\key No |
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 don't think the name is clear. Should have a \note
probably as well.
Not a huge fan of having a default rather than hard-coded required param. I know this saves on needing to do VT, and the above has a default, so I guess it's up to you to make it required or not.
Maybe one of these two?
A8; \field Translate File Name | |
\type choice | |
\default No | |
\key Yes | |
\key No | |
A8; \field Translate File With Absolute Path | |
\note "Yes" means the absolute path of the ExternalFile is resolved and translated to IDF. | |
\note "No" means only the filename (relative) is translated | |
\type choice | |
\default Yes | |
\key Yes | |
\key No |
A8; \field Translate File Name | |
\type choice | |
\default No | |
\key Yes | |
\key No | |
A8; \field Translate File With Relative Path | |
\note "No" means the absolute path of the ExternalFile is resolved and translated to IDF. | |
\note "Yes" means only the filename (relative) is translated | |
\type choice | |
\default No | |
\key Yes | |
\key No |
path fileName; | ||
if (modelObject.translateFileName()) { | ||
fileName = toPath(modelObject.externalFile().fileName()); | ||
} else { | ||
// make the path correct for this system | ||
filePath = system_complete(filePath); | ||
fileName = modelObject.externalFile().filePath(); | ||
if (!exists(fileName)) { | ||
LOG(Warn, "Cannot find file \"" << fileName << "\""); | ||
} else { | ||
// make the path correct for this system | ||
fileName = system_complete(fileName); | ||
} |
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.
Consider putting this logic in ScheduleFile directly, that'd be much easier to debug if something goes awry. And much easier to add a model test for it too.
openstudio::path ScheduleFile::translatedFilePath() const {
if (translatedFileName()) {
return toPath(modelObject.externalFile().fileName());
}
openstudio::path filePath = modelObject.externalFile().filePath();
if (!exists(filePath)) {
LOG(Warn, "Cannot find file \"" << filePath << "\"");
} else {
// make the path correct for this system
filePath = system_complete(filePath);
}
return filePath;
}
(If externalFile.filePath doesn't exist, maybe it should throw?)
Proposed some changes in #5010 @joseph-robertson |
…leFile::translatedFilePath() const`
[internal] Schedule:File relative paths mod
CI Results for 28a3f30:
|
Pull request overview
Schedule:File
objects #4865Currently,
translates to
We want (optionally) "File Name" to be translated to
workflow/sample_files/run/in.schedules.csv
.I think we can just useexternalFile.filePath()
being relative/absolute as the switch in ScheduleFile FT. It's absolute when using either (1)ScheduleFile.new(external_file)
, or (2)ScheduleFile.new(model, /abs/path)
. It's relative when usingScheduleFile.new(model, /rel/path)
.Looks like
externalFile.filePath
is always FT'd to "File Name" as an absolute path. So, this PR introduces a new bool field "Translate File Name" on theOS:Schedule:File
object (defaults to false). When false, the old behavior is preserved (the FT translatesexternalFile.filePath
. When true, the FT translatesexternalFile.fileName
into "File Name".Add FT tests for checking "File Name" with
scheduleFile.setTranslateFileName(true)
:ScheduleFile.new(externalFile(model, /abs/path))
-> rel pathScheduleFile.new(externalFile(model, /rel/path))
-> rel pathScheduleFile.new(model, /abs/path)
-> abs pathScheduleFile.new(model, /rel/path)
-> rel pathPull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.