Skip to content

Commit 570cfc8

Browse files
authored
allow for versions to be specified in scripts (#100)
allow for versions to be specified in scripts so that users may use different versions of their given software packages.
1 parent 875e656 commit 570cfc8

File tree

10 files changed

+41
-7
lines changed

10 files changed

+41
-7
lines changed

app/controllers/scripts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def script_params
128128
.require(:script)
129129
.permit(
130130
:name, :frames, :camera, :file, :accounting_id, :cluster, :nodes,
131-
:renderer, :extra, :walltime, :email, :skip_existing
131+
:renderer, :extra, :walltime, :email, :skip_existing, :version
132132
)
133133
end
134134

app/helpers/scripts_helper.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@ module ScriptsHelper
44
def normalize_css_str(str)
55
str.to_s.sub(' ', '-')
66
end
7+
8+
def version_label(project)
9+
if ProjectFactory.maya_project?(project)
10+
'Maya'
11+
elsif ProjectFactory.vray_project?(project)
12+
'VRay'
13+
else
14+
'Maya'
15+
end
16+
end
717
end

app/models/maya_script.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def cluster
2525
Configuration.submit_cluster
2626
end
2727

28+
def available_versions
29+
['2020', '2022']
30+
end
31+
2832
def job_name
2933
'maya-render'
3034
end

app/models/script.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def job_name
7676
raise 'Subclasses need to define `job_name`'
7777
end
7878

79+
def available_versions
80+
raise 'Subclasses need to define `versions_available`'
81+
end
82+
83+
# shell scripts files need to use this method so that we keep backward compatability
84+
# with jobs that never set versions.
85+
def module_version
86+
version.to_s.present? ? version : available_versions.first
87+
end
88+
7989
def task_start_frames
8090
Array.new(tasks).map.with_index(1) do |_, array_id|
8191
task_start_frame(array_id)

app/models/v_ray_script.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def job_name
2727
'vray-render'
2828
end
2929

30+
def available_versions
31+
['5.10.02']
32+
end
33+
3034
def normalized_name
3135
name.parameterize(separator: '_')
3236
end

app/views/scripts/_form.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<div class="panel-body", role="main">
1010
<%= form.text_field :name, required: true %>
1111

12+
<%= form.select :version, @script.available_versions, required: true, label: "#{version_label(@project)} version" %>
13+
1214
<%= form.text_field :frames,
1315
required: true, placeholder: '1-100',
1416
pattern: '\d+-\d+', help: "Must be in the form startframe-endframe" %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddVersionToScripts < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :scripts, :version, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2021_09_07_155035) do
13+
ActiveRecord::Schema.define(version: 2021_09_09_190250) do
1414

1515
create_table "jobs", force: :cascade do |t|
1616
t.string "status"
@@ -58,6 +58,7 @@
5858
t.text "script_attrs", default: ""
5959
t.string "accounting_id"
6060
t.text "type"
61+
t.string "version"
6162
t.index ["project_id"], name: "index_scripts_on_project_id"
6263
end
6364

jobs/video_jobs/maya_submit.sh.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ module load ruby
5959

6060
<% if groups.include?('mayakentst') %>
6161
module load project/kent
62-
module load maya/2020-kent
62+
module load maya/<%= module_version %>-kent
6363
<% else %>
6464
<%# this module blocked by group membership on the file system, so OK to be in else block %>
6565
module load project/accad
66-
module load maya/2022-accad
66+
module load maya/<%= module_version %>-accad
6767
<% end %>
6868

6969
mkdir -p $JOB_TMPDIR/Autodesk

jobs/video_jobs/vray_submit.sh.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
module purge
55
module load project/kent
6-
module load vray
6+
module load vray/<%= module_version %>
77
module load ruby
88

99
UTIL_FILE="$TMPDIR/utils.rb"
10-
export TASK_START_FRAME="<%= start_frame %>"
11-
export TASK_END_FRAME="<%= end_frame %>"
1210

1311
# added 'shift' to this array as the 0th index because SLURM_ARRAY_TASK_ID is always
1412
# greater than or equal to 1.

0 commit comments

Comments
 (0)