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 order of interactive app submission handling #451

Closed
ericfranz opened this issue Feb 21, 2019 · 0 comments

Comments

@ericfranz
Copy link
Contributor

commented Feb 21, 2019

This code handles the form submission for an interactive app in this order:

  1. stages the app template, providing the context for rendering the template files
  2. renders the submit.yml.erb file providing the context to get a submit hash
  3. calls submit with the with the hash to submit a job

def save(app:, context:, format: nil)
self.id = SecureRandom.uuid
self.cluster_id = app.cluster_id
self.token = app.token
self.title = app.title
self.view = app.session_view
self.created_at = Time.now.to_i
stage(app.root.join("template"), context: context) &&
submit(app.submit_opts(context, fmt: format))
end

The rendering of the submit.yml.erb should occur first. That way, if there are any errors, the submit.yml.erb can raise an exception and the error will be presented to the user. Currently the user receives the error but after the template is copied to the user's home directory.

So the order would instead be

  1. renders the submit.yml.erb file providing the context to get a submit hash
  2. stages the app template, providing the context for rendering the template files
  3. calls submit with the with the hash to submit a job
def save(app:, context:, format: nil)
  # ...
  submit_script = app.submit_opts(context, fmt: format) # raises an exception
  stage(app.root.join("template"), context: context) && submit(submit_script)

rescue => e   # rescue from all standard exceptions (app never crashes)
  errors.add(:stage, e.message)
  Rails.logger.error("ERROR: #{e.class} - #{e.message}")
  false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.