Customizing Interactive App Cards using erb

I am writing an interactive app which will generate a slurm accounting report from a bash script I wrote. I want to add a link to downloads the resulting file which is named dynamically based on date range.

  1. Is there a way to query the status of the job to add logic to the info.html.erb file based on whether the job is complete or not?

  2. I am not having success with accessing the session objects (ie. session.staged_root) using erb in the info.html.erb.

  3. Is there a way to update the context objects while running the script or even add to the user_defined_context.json during the script? or are these objects defined on initialization and remain static through the process?

Ultimately I want a button which will download the file which is created by my script in the run dir. I assume it will look something like this in the end:

<h5>Once this job is completed you can download the csv file</h5>

<form action="https://portal.corvidhpc.com/pun/sys/dashboard/files/fs/...............?download=1">
   <button class="btn btn-primary" type="submit">
    <i class="fa fa-download"></i> Download csv file
  </button>
</form>

I figured out I can call from models/batch_connect/session.rb and get these values. Things are starting to make sense now.

I’m not sure, I don’t think so or at least not super easily. In any case, the card itself updates when the job completes so I’m not sure what you’re going for.

Yea there’s not that much that’s available in this view from the session. There appears to be very little available directly here. Though you could just read read user_defined_context.json here though.

https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/view.html#bc-info-html-md-erb

Yes they’re static.

You can use conn_params to pass information from the script back to the view.

If you had something like this in a script.

export the_link_dir = <%= session.staged_root %>/some_file

You could then read the_link_dir back in the view.html.erb.

Here’s an example of that in our production jupyter app.

image

Thanks for the replies Jeff. I gotta say, what you guys have put together is an excellent sandbox, and it’s more powerful than I realized.

I’ve been able to figure it out using ruby logic which takes me from this:

To this:


<h5>Once this job is completed you can download the csv file by clicking the link: </h5>


<%- 
      filesapp = "https://portal.corvidhpc.com/pun/sys/dashboard/files/fs/"
      
      filename = Dir.glob("#{staged_root}/*.csv").first
      logfilename = Dir.glob("#{staged_root}/*.log").first

      if Dir.glob("#{staged_root}/*.csv").length()==0
          link=''
      else
          link="#{filesapp}#{filename}?download=1" 
%>
<h3> <a href=<%=link%>>Download Accounting CSV File</a> </h3>


<details class="abstract">
<summary>Script Log (Debug)</summary>
<div class="highlight"><pre><span></span><iframe src=<%= "#{filesapp}#{logfilename}" %> width="600" height="300" frameBorder="0"></pre></div>
</details>

<%
       end
%>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.