-
Notifications
You must be signed in to change notification settings - Fork 195
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
A bug related to OS:Schedule:File and OS:External:File with OpenStudio App #4046
Comments
I can also take a look at this unless someone else is |
DId you end up looking at it @macumber? |
On my list for this week |
@macumber Should I look into it? |
It's hard to tell where things are going south: measure itself, OpenStudio SDK, openstudio-workflow gem, or OpenStudioApplication. There may be more than one bug (and there probably is) BUT that being said, this measure itself appears faulty. It should be modified to start with. The measure tries way too hard to provide an absolute path to write the CSV/XML files to. It shouldn't do that. Also, if you run the measure by adding it to your workflow.osm (Or on the Measures tab of the app), the measure says it worked, but if you inspect your resulting files you actually end up with zero So I'm going to exclude the measure for the testing, and instead focus on a Minimum Complete Verifiable Example with a dummy measure that uses paths correctly to test this with. measure.rb class TestCreateAScheduleFile < OpenStudio::Measure::ModelMeasure
# human readable name
def name
# Measure name should be the title case of the class name.
return 'Test Create a ScheduleFile'
end
# human readable description
def description
return 'Test creating a ScheduleFile on the fly'
end
# human readable description of modeling approach
def modeler_description
return 'Test creating a ScheduleFile on the fly. To test whether we can successfully run that via workflow.osw AND apply Now in the App'
end
# define the arguments that the user will input
def arguments(model)
args = OpenStudio::Measure::OSArgumentVector.new
return args
end
# define what happens when the measure is run
def run(model, runner, user_arguments)
super(model, runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments(model), user_arguments)
return false
end
# assign the user inputs to variables
# report initial condition of model
runner.registerInitialCondition("The model started with #{model.getScheduleFiles.size} ScheduleFiles.")
csv_in_path = "#{File.dirname(__FILE__)}/resources/schedulefile.csv"
runner.registerWarning("File.dirname(__FILE__)=#{File.dirname(__FILE__)}")
runner.registerWarning("csv_in_path=#{csv_in_path}")
runner.registerWarning("File.realpath('./')=#{File.realpath('./')}")
runner.registerWarning("File.absolute_path('.')=#{File.absolute_path('.')}")
# Note: copying is pointless. ExternalFile Ctor does that for you.
# But I'm trying stuff, so I'm going to make an arbitrary copy with another name.
# This replicates what the openstudio_results.html will do for eg to create the openstudio_results.html
FileUtils.cp(csv_in_path, './somethingelse.csv')
externalFile_ = OpenStudio::Model::ExternalFile::getExternalFile(model, csv_in_path)
if (!externalFile_)
runner.registerError("Failed to instantiate an External File")
return false
end
scheduleFile = OpenStudio::Model::ScheduleFile.new(externalFile_.get())
puts "===== scheduleFile ===="
puts scheduleFile
# report final condition of model
runner.registerFinalCondition("The model finished with #{model.getScheduleFiles.size} ScheduleFiles.")
return true
end
end
# register the measure to be used by the application
TestCreateAScheduleFile.new.registerWithApplication |
Not sure if this is the right place for this but I think it would be useful to document the supported workflows for generating files in the workflow and then finding them downstream. I just ran across this in the honeybee to openstudio translator when I had to copy a schedule CSV to a generated files directory because that is where the workflow gem is looking for them: https://github.com/ladybug-tools/honeybee-openstudio-gem/pull/204/files Documenting the correct use would allow everyone to standardize on one approach |
Yeah I agree some documentation is needed. If i recall correctly the workflow gem does append it first in line. Then the SDK does various things with workflowPaths[0], eg ExternalFile ctor copies the file it is passed to that path (so it does end up in generated_files/ if added from a workflow measure, or in files/ otherwise...) OSrunner scans added files and does something too, but in my brief testing it didn't behave like I expected |
…e Template In conjunction with NREL/OpenStudio-user-documentation#25
#4046 - Clarify the situation with output file in the ReportingMeasure Template
Issue overview
When exporting an OpenStudio model with OS:External:File objects to IDF with OpenStudio App, related schedule objects are not translated properly. EnergyPlus simulation with the exported IDF fails due to blank "File Name" field in the Schedule:File.
Current Behavior
The OS:Schedule:File and OS:External:File objects are not handled correctly. Two unexpected behaviors:
Expected Behavior
Corresponding to the two behaviors above, the expected behaviors are:
Steps to Reproduce
Steps to reproduce the first unexpected behavior:
Steps to reproduce the second unexpected behavior:
Possible Solution
Improve the generated files storing mechanism.
Details
Environment
Some additional details about your environment for this issue (if relevant):
Context
This issue may affect users that uses schedules associated with external files.
The text was updated successfully, but these errors were encountered: