rbbt-util 5.29.1 → 5.29.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b88fc549c1c1dc5cd56f06d933776d56540e3d0f4bacf77f04a449abcda974f
4
- data.tar.gz: caf80ab624418c6c0a744038d98569c3a32d18dc8d9de162b42363e1c281e8c2
3
+ metadata.gz: fa648dbd0465a8c6a9a62820dc08a7f726dcd45cb541e7ef1c5e06b0e8343680
4
+ data.tar.gz: f05f659bfcfe3eef10a1d4ba786d40a7f835a08711ca23af9b5b619ddd61eeda
5
5
  SHA512:
6
- metadata.gz: 8944f1d996afa5610f70046f4e61cf326461050f06f347529cd7e403440e0d9b47d0c33b862bc83e89d4479ce889e773aef0bbabfaf0dae797c3a2164f0e8a8c
7
- data.tar.gz: fa0051835f35e23873bde6a075d81805d2878643e35e96e20c5d7423f0c7c48eaf25b2c5afad48215481b0ddd17b9d251555eae5b5c4a7fa420d9796dba9130b
6
+ metadata.gz: b44a34d7ad19eff67c7f8e6f3bfe0f55372e3d8a255247ff01d1aa858a904d2fcf73d45dd966702adf62bdbc3cb1b0dc3df643aaab747a922bfe3b747f975950
7
+ data.tar.gz: 5e74bcc37585452e22d876211f0c02c8fc431dbbdcc8cc0d3ef537ea794b722e0af9fc4ae743a014a1384c432f8f280761c74e35a1a8aaf25150067675a9f449
@@ -1,23 +1,99 @@
1
1
  require 'rbbt/workflow/util/orchestrator'
2
2
  module HPC
3
3
  module SLURM
4
- def self.orchestrate_job(job, options, seen = {})
4
+
5
+ def self.job_rules(rules, job)
6
+ workflow = job.workflow.to_s
7
+ task_name = job.task_name.to_s
8
+ defaults = rules["defaults"] || {}
9
+
10
+ job_rules = IndiferentHash.setup(defaults.dup)
11
+
12
+ rules["chains"].each do |name,info|
13
+ IndiferentHash.setup(info)
14
+ chain_tasks = info[:tasks].split(/,\s*/)
15
+
16
+ chain_tasks.each do |task|
17
+ task_workflow, chain_task = task.split("#")
18
+ chain_task, task_workflow = task_workflow, info[:workflow] if chain_task.nil? or chain_tasks.empty?
19
+ job_rules["chain_tasks"] ||= {}
20
+ job_rules["chain_tasks"][task_workflow] ||= []
21
+ job_rules["chain_tasks"][task_workflow] << chain_task
22
+ next unless task_name == chain_task.to_s && workflow == task_workflow.to_s
23
+ config_keys = job_rules.delete :config_keys
24
+ job_rules = IndiferentHash.setup(job_rules.merge(info))
25
+ if config_keys
26
+ config_keys.gsub!(/,\s+/,',')
27
+ job_rules[:config_keys] = job_rules[:config_keys] ? config_keys + "," + job_rules[:config_keys] : config_keys
28
+ end
29
+ end
30
+
31
+ if job_rules["chain_tasks"][workflow] && job_rules["chain_tasks"][workflow].include?(task_name)
32
+ break
33
+ else
34
+ job_rules.delete "chain_tasks"
35
+ end
36
+ end if rules["chains"]
37
+
38
+ config_keys = job_rules.delete :config_keys
39
+ job_rules = IndiferentHash.setup(job_rules.merge(rules[workflow][task_name])) if rules[workflow] && rules[workflow][task_name]
40
+
41
+ if config_keys
42
+ config_keys.gsub!(/,\s+/,',')
43
+ job_rules[:config_keys] = job_rules[:config_keys] ? config_keys + "," + job_rules[:config_keys] : config_keys
44
+ end
45
+
46
+ if rules["skip"] && rules["skip"][workflow]
47
+ job_rules["skip"] = true if rules["skip"][workflow].split(/,\s*/).include? task_name
48
+ end
49
+
50
+ job_rules
51
+ end
52
+
53
+ def self.get_job_dependencies(job, job_rules)
54
+ deps = job.dependencies || []
55
+ deps += job.input_dependencies || []
56
+ deps
57
+ end
58
+
59
+ def self.orchestrate_job(job, options, skip = false, seen = {})
5
60
  return if job.done?
6
61
  return unless job.path.split("/")[-4] == "jobs"
62
+ seen[:orchestration_target_job] ||= job
7
63
  options.delete "recursive_clean"
8
64
  options.delete "tail"
9
- rules = YAML.load(Open.read(options[:rules])) if options[:rules]
65
+ options.delete "printfile"
66
+ rules = YAML.load(Open.read(options[:orchestration_rules])) if options[:orchestration_rules]
10
67
  rules ||= {}
68
+ IndiferentHash.setup(rules)
11
69
 
12
- deps = job.dependencies || []
13
- deps += job.input_dependencies || []
70
+ job_rules = self.job_rules(rules, job)
71
+
72
+ deps = get_job_dependencies(job, job_rules)
14
73
 
15
74
  dep_ids = deps.collect do |dep|
16
- seen[dep.path] ||= self.orchestrate_job(dep, options.dup, seen)
17
- end.compact
75
+ skip_dep = job_rules["chain_tasks"] &&
76
+ job_rules["chain_tasks"][job.workflow.to_s] && job_rules["chain_tasks"][job.workflow.to_s].include?(job.task_name.to_s) &&
77
+ job_rules["chain_tasks"][dep.workflow.to_s] && job_rules["chain_tasks"][dep.workflow.to_s].include?(dep.task_name.to_s)
78
+ seen[dep.path] ||= self.orchestrate_job(dep, options, skip_dep, seen)
79
+ end.flatten.compact.uniq
80
+
81
+ skip = true if job_rules[:skip]
82
+ return dep_ids if skip and seen[:orchestration_target_job] != job
83
+
84
+ job_rules.delete :chain_tasks
85
+ job_rules.delete :tasks
86
+ job_rules.delete :workflow
87
+
88
+ config_keys = job_rules.delete(:config_keys)
89
+
90
+ job_options = IndiferentHash.setup(options.merge(job_rules).merge(:slurm_dependencies => dep_ids))
91
+ job_options.delete :orchestration_rules
92
+ if config_keys
93
+ config_keys.gsub!(/,\s+/,',')
94
+ job_options[:config_keys] = job_options[:config_keys] ? config_keys + "," + job_options[:config_keys] : config_keys
95
+ end
18
96
 
19
- job_rules = Workflow::Orchestrator.job_rules(rules, job)
20
- job_options = options.merge(job_rules).merge(:slurm_dependencies => dep_ids)
21
97
  run_job(job, job_options)
22
98
  end
23
99
  end
@@ -361,6 +361,7 @@ EOF
361
361
 
362
362
  slurm_basedir = options[:slurm_basedir]
363
363
  dependencies = options.delete :slurm_dependencies
364
+ dependencies = [] if dependencies.nil?
364
365
  Open.mkdir slurm_basedir
365
366
 
366
367
  dry_run = options.delete :dry_run
@@ -25,7 +25,7 @@ $slurm_options = SOPT.get <<EOF
25
25
  -t--task_cpus* Tasks
26
26
  -W--workflows* Additional workflows
27
27
  -tm--time* Time
28
- -R--rules* Orchestration rules
28
+ -R--orchestration_rules* Orchestration rules
29
29
  -rmb--remove_slurm_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
30
30
  EOF
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.29.1
4
+ version: 5.29.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake