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 #262 #263 - Handle Path Arguments (QFileDialog) #761

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Oct 14, 2024

The OS SDK / BCL-gem implementation of the path arguments is incomplete and confusing, and they don't handle the makePathArgument arguments:

  • isRead. what does that even mean? Is this assuming that this is for reading meaning it must be 1) a file (not a directory) and 2) it must exist?)
  • extension

path_arguments

@jmarrec
Copy link
Collaborator Author

jmarrec commented Oct 14, 2024

here is my test measure

example_path_argument.zip

  # define the arguments that the user will input
  def arguments(model)
    args = OpenStudio::Measure::OSArgumentVector.new

    isRead = false
    extension = "CSV (*.csv);;Excel (*.xls *.xlsx);;All Files (*)"
    required = true
    modelDependent = false
    output_path = OpenStudio::Measure::OSArgument.makePathArgument('output_path', isRead, extension, required, modelDependent)
    output_path.setDisplayName('Output Path on Disk')
    args << output_path

    return args
  end

  # define what happens when the measure is run
  def run(model, runner, user_arguments)
    super(model, runner, user_arguments)  # Do **NOT** remove this line

    # use the built-in error checking
    if !runner.validateUserArguments(arguments(model), user_arguments)
      return false
    end

    # assign the user inputs to variables
    output_path = runner.getPathArgumentValue('output_path', user_arguments)

    puts "output_path=#{output_path}"

    File.write(output_path.to_s, "hello")

    # report final condition of model
    runner.registerFinalCondition("The output path is #{output_path}")

    return true
  end

@jmarrec jmarrec changed the title Fix #262 #263 - Handle Path Arguments Fix #262 #263 - Handle Path Arguments (QFileDialog) Oct 14, 2024
@jmarrec
Copy link
Collaborator Author

jmarrec commented Oct 29, 2024

@macumber ping

}

if (!selectedPath.isEmpty()) {
lineEdit->setText(selectedPath); // QFileInfo(selectedPath).absoluteFilePath()
Copy link
Collaborator

@macumber macumber Oct 30, 2024

Choose a reason for hiding this comment

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

Will selectedPath always be absolute? What if the user wants it to be relative? What would it be relative to? Maybe isRelative could be an attribute and would be assumed to be relative to the run directory?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmarrec do you think the guidance should be that file path arguments are always absolute, used for reading/writing files outside of the workflow. If there are files written by the measure, read by other measures, as part of the workflow those would just be found by file name (a string argument) using WorkflowJSON::findFile which searches the workflow paths?

@macumber
Copy link
Collaborator

This is cool @jmarrec, I added some comments, maybe it is worth adding some new attributes if you are already updating the SDK?

@jmarrec
Copy link
Collaborator Author

jmarrec commented Nov 7, 2024

@macumber until #5273 is addressed, I'd say we just merge this. Does that work for you?

@macumber
Copy link
Collaborator

macumber commented Nov 7, 2024

This looks good to me @jmarrec, I'm fine if you want to merge this now before NREL/OpenStudio#5273 is complete

@jmarrec jmarrec merged commit d279ff2 into develop Nov 7, 2024
11 checks passed
@jmarrec jmarrec deleted the 262_263_handle_path_arguments branch November 7, 2024 15:26
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot enter path arguments in apply measure now Add file system browse control for measure path arguments
2 participants