Skip to content

Commit

Permalink
use OrderedDict for protojob patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
kpedro88 committed Sep 26, 2017
1 parent 2661d8f commit 34403bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Internally, `jobSubmitter` stores job information in a list `protoJobs`, where e
* `njobs`: total number of jobs (used in [count mode](#count-mode))
* `jdl`: JDL filename for this set of jobs
* `queue`: queue command for this set of jobs
* `patterns`: list of find/replace pairs to create the JDL from template
* `patterns`: `OrderedDict` of find/replace pairs to create the JDL from template
* `appends`: list of strings to append to the JDL

#### Count mode
Expand Down
20 changes: 10 additions & 10 deletions python/jobSubmitter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, subprocess, sys, stat
from optparse import OptionParser
from collections import defaultdict
from collections import defaultdict, OrderedDict
from parseConfig import list_callback, parser_dict

# minimal sed-like function
Expand All @@ -10,13 +10,13 @@ def pysed(lines,out,patterns):
with open(out,'w') as outfile:
for line in lines:
linetmp = line
for pattern in patterns:
linetmp = linetmp.replace(str(pattern[0]),str(pattern[1]))
for pattern,replace in patterns.iteritems():
linetmp = linetmp.replace(str(pattern),str(replace))
outfile.write(linetmp)

class protoJob(object):
def __init__(self):
self.patterns = []
self.patterns = OrderedDict()
self.appends = []
self.queue = ""
self.njobs = 0
Expand Down Expand Up @@ -167,7 +167,7 @@ def initStep1(self):
sp.wait()

def generateDefault(self,job):
job.patterns.append(("SCRIPTARGS",",".join(self.scripts)))
job.patterns["SCRIPTARGS"] = ",".join(self.scripts)

def generateStep1(self,job):
# command line args for step1
Expand All @@ -176,16 +176,16 @@ def generateStep1(self,job):
if self.cmsswMethod != "transfer":
# xrdcp needs input dir, cmsrel needs scram arch
step1args += " -L "+(self.input if self.cmsswMethod=="xrdcp" else os.getenv("SCRAM_ARCH"))
job.patterns.append(("STEP1ARGS",step1args))
job.patterns["STEP1ARGS"] = step1args
if self.cmsswMethod=="transfer":
job.patterns.append(("CMSSWVER",cmsswver))
job.patterns["CMSSWVER"] = cmsswver
else:
job.patterns.append(("CMSSWVER.tar.gz, ",""))
job.patterns["CMSSWVER.tar.gz, "] = ""
if self.novoms:
job.patterns.append(("x509userproxy = $ENV(X509_USER_PROXY)\n",""))
job.patterns["x509userproxy = $ENV(X509_USER_PROXY)\n"] = ""

def generateExtra(self,job):
job.patterns.extend([
job.patterns.update([
("MYDISK",self.disk),
("MYMEMORY",self.memory),
("MYCPUS",self.cpus),
Expand Down

0 comments on commit 34403bb

Please sign in to comment.