[cig-commits] r11785 - in cs/portal/trunk: . seismo/SeismoWebPortal seismo/SeismoWebPortal/templates/SeismoWebPortal
leif at geodynamics.org
leif at geodynamics.org
Wed Apr 9 09:59:10 PDT 2008
Author: leif
Date: 2008-04-09 09:59:09 -0700 (Wed, 09 Apr 2008)
New Revision: 11785
Modified:
cs/portal/trunk/daemon.py
cs/portal/trunk/mineos.py
cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/mineos_parameters.pml
cs/portal/trunk/seismo/SeismoWebPortal/views.py
Log:
Dusted-off the daemon. Updated 'mineos.py' run script: it now
downloads the earth model from the portal.
Modified: cs/portal/trunk/daemon.py
===================================================================
--- cs/portal/trunk/daemon.py 2008-04-09 16:21:30 UTC (rev 11784)
+++ cs/portal/trunk/daemon.py 2008-04-09 16:59:09 UTC (rev 11785)
@@ -25,25 +25,40 @@
class GassServer(object):
# @classmethod
- def startUp(cls, directory):
+ def startUp(cls, directory, info):
argv = ["globus-gass-server", "-r", "-w", "-c"]
savedWd = os.getcwd()
os.chdir(directory)
child = Popen4(argv)
os.chdir(savedWd)
child.tochild.close()
- url = child.fromchild.readline().strip()
- return GassServer(child, url, directory)
+ while True:
+ url = child.fromchild.readline().strip()
+ if url.startswith("https:"):
+ break
+ child.fromchild.close()
+ return GassServer(child, url, directory, info)
startUp = classmethod(startUp)
- def __init__(self, child, url, directory):
+ def __init__(self, child, url, directory, info):
self.child = child
self.url = url
self.directory = directory
+ self.info = info
def shutDown(self):
+ # This doesn't work reliably...
argv = ["globus-gass-server-shutdown", self.url]
- os.spawnvp(os.P_NOWAIT, argv[0], argv)
+ command = ' '.join(argv)
+ self.info.log("spawning: %s" % command)
+ status = os.spawnvp(os.P_WAIT, argv[0], argv)
+ statusMsg = "%s: exit %d" % (argv[0], status)
+ self.info.log(statusMsg)
+ if status != 0:
+ # ...so sometimes we kill it!
+ self.info.log("kill -INT %d" % self.child.pid)
+ os.kill(self.child.pid, signal.SIGINT)
+ self.info.log("waitpid(%d)" % self.child.pid)
status = self.child.wait()
return
@@ -138,9 +153,9 @@
def jobRunner(self, job):
- self.downloadInputFilesForJob(job)
+ try:
+ self.downloadInputFilesForJob(job)
- try:
argv = [job.resSpec['executable']] + job.resSpec['arguments']
command = ' '.join(argv)
self.info.log("spawning: %s" % command)
@@ -187,7 +202,7 @@
def jobRunner(self, job):
self.downloadInputFilesForJob(job)
- gassServer = GassServer.startUp(job.directory)
+ gassServer = GassServer.startUp(job.directory, self.info)
try:
resSpec = self.resSpec(job, gassServer)
@@ -365,53 +380,44 @@
STATUS_ERROR = "error"
deadCodes = [STATUS_DONE, STATUS_ERROR]
- def __init__(self, id, simulation, urlForInputFile, config, info):
+ def __init__(self, id, simulation, urlForInputFile, config, info, jm):
self.id = id
self.simulation = simulation
self.urlForInputFile = urlForInputFile
self.mineosPathname = config.mineosPathname
self.dry = config.dry
self.info = info
+ self.jm = jm
self.jobChannel = stackless.channel()
self.status = self.STATUS_NEW
self.statusChanged = Event()
- def go(self, gjm, fjm):
- stackless.tasklet(self)(gjm, fjm)
+ def go(self):
+ stackless.tasklet(self)()
- def __call__(self, gjm, fjm):
+ def __call__(self):
try:
self.setStatus(self.STATUS_CONNECTING)
# run
- mineos = self.newMineosJob()
- specfem = self.newSpecfemJob()
- fjm.runJob(mineos)
- gjm.runJob(specfem)
+ job = self.newJob()
+ self.jm.runJob(job)
# send jobs to jobSink()
- self.jobChannel.send(mineos)
- self.jobChannel.send(specfem)
+ self.jobChannel.send(job)
self.jobChannel.send(None) # no more jobs
self.setStatus(self.STATUS_PREPARING)
- while specfem.isAlive():
- specfem.statusChanged.wait()
+ while job.isAlive():
+ job.statusChanged.wait()
# while
- if specfem.status == specfem.STATUS_FAILED:
+ if job.status == job.STATUS_FAILED:
self.setStatus(self.STATUS_ERROR)
raise RuntimeError("run failed")
- # The Mineos job should have finished long ago.
- while mineos.isAlive():
- mineos.statusChanged.wait()
- if mineos.status == mineos.STATUS_FAILED:
- self.setStatus(self.STATUS_ERROR)
- raise RuntimeError("Mineos run failed")
-
self.setStatus(self.STATUS_DONE)
except Exception, e:
@@ -427,7 +433,10 @@
def isAlive(self):
return not self.status in self.deadCodes
- def newSpecfemJob(self):
+
+class SpecfemRun(Run):
+
+ def newJob(self):
dry = []
if self.dry:
dry = ["--scheduler.dry"]
@@ -454,24 +463,26 @@
job.outputFiles = ["seismograms.tar.gz", "output_mesher.txt", "output_solver.txt"]
return job
- def newMineosJob(self):
+
+class MineosRun(Run):
+
+ def newJob(self):
job = Job(
"run",
executable = self.mineosPathname,
arguments = ["parameters.pml"],
)
job.urlForInputFile = self.urlForInputFile
- job.inputFiles = ["mineos/parameters.pml", "mineos/event.txt", "mineos/stations.site", "mineos/stations.sitechan"]
+ job.inputFiles = ["parameters.pml", "event.txt", "stations.site", "stations.sitechan", "model.txt"]
job.outputFiles = ["output_mineos.txt", "mineos.tar.gz"]
return job
class Simulation(object):
- def __init__(self, id, nodes):
+ def __init__(self, id):
self.id = id
- self.nodes = nodes
- self.parameters = 'parameters.pml'
- self.events = 'events.txt'
+ self.parameters = 'par_file.txt'
+ self.events = 'event.txt'
self.stations = 'stations.txt'
@@ -512,23 +523,29 @@
for run in runList:
id = int(run['id'])
status = run['status']
- simId = run['simulation']
- nodes = int(run['nodes'])
+ simId = run['request']
+ code = run['code']
if (status in [Run.STATUS_NEW, ""] and
not runs.has_key(id)):
self.info.log("new run %d" % id)
- simulation = Simulation(simId, nodes)
+ simulation = Simulation(simId)
def urlForInputFile(inputFile):
# Map input filenames to URLs in the context
# of this run.
return self.inputFileURL(simulation, inputFile)
+
+ if code == 1:
+ newRun = SpecfemRun(id, simulation, urlForInputFile, config, self.info, gjm)
+ elif code == 2:
+ newRun = MineosRun(id, simulation, urlForInputFile, config, self.info, fjm)
+ else:
+ self.info.log("unknown code %d" % code)
+ continue
- newRun = Run(id, simulation, urlForInputFile, config, self.info)
-
self.watchRun(newRun)
runs[id] = newRun
- newRun.go(gjm, fjm)
+ newRun.go()
return
@@ -679,11 +696,11 @@
import pyre.inventory as pyre
scheme = pyre.str("scheme", validator=pyre.choice(["http", "https"]), default="http")
host = pyre.str("host", default="localhost:8000")
- urlRoot = pyre.str("url-root", default="/specfem3dglobe/")
+ urlRoot = pyre.str("url-root", default="/portals/seismo/")
def _configure(self):
self.urlPrefix = '%s://%s%s' % (self.scheme, self.host, self.urlRoot)
- self.inputFileUrl = self.urlPrefix + 'simulations/%d/%s'
+ self.inputFileUrl = self.urlPrefix + 'requests/%d/%s'
# runs
self.runsUrl = self.urlPrefix + 'runs/list.py'
self.runStatusUrl = self.urlRoot + 'runs/%d/status/'
Modified: cs/portal/trunk/mineos.py
===================================================================
--- cs/portal/trunk/mineos.py 2008-04-09 16:21:30 UTC (rev 11784)
+++ cs/portal/trunk/mineos.py 2008-04-09 16:59:09 UTC (rev 11785)
@@ -9,13 +9,8 @@
mHz = milli*hertz
-# Assume this script is installed alongside the mineos binaries. Note
-# that "DEMO.tar.gz" -- which contains these models -- must be
-# unpacked after installing Mineos.
+# Assume this script is installed alongside the mineos binaries.
prefix = dirname(dirname(__file__))
-modelsDir = prefix + "/share/mineos/models/"
-models = [modelsDir + filename for filename in ["prem_noocean.txt", "prem_ocean.txt"]]
-del filename
mode = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
@@ -176,7 +171,7 @@
#------------------------------------------------------------------------
# common
- #model = pyre.str("model")
+ model = pyre.str("model")
# jcom
radial = pyre.bool("radial")
@@ -244,24 +239,14 @@
archiveDirName = "mineos"
os.mkdir(archiveDirName)
- inputFiles = [self.event] + [self.stations + suffix for suffix in [".site", ".sitechan"]]
+ inputFiles = [self.model, self.event] + [self.stations + suffix for suffix in [".site", ".sitechan"]]
for inputFile in inputFiles:
os.rename(inputFile, os.path.join(archiveDirName, inputFile))
os.chdir(archiveDirName)
- archiveDirPath = os.getcwd()
- for model in models:
- self._info.log("running Mineos program suite for model '%s'" % model)
+ self._info.log("running Mineos program suite for model '%s'" % self.model)
+ self.runMineos(self.model, enabledModes)
- # create a subdirectory for each model
- subdir = splitext(basename(model))[0]
- os.mkdir(subdir)
- os.chdir(subdir)
-
- self.runMineos(model, enabledModes)
-
- os.chdir(archiveDirPath)
-
# archive the output
os.chdir(jobdir)
self.spawn("/bin/tar", "cvzf", archiveDirName + ".tar.gz", archiveDirName)
@@ -273,7 +258,7 @@
def runMineos(self, model, enabledModes):
- mineos = Mineos(model, "../" + self.event, "../" + self.stations)
+ mineos = Mineos(model, self.event, self.stations)
# minos_bran
for mode in enabledModes:
Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/mineos_parameters.pml
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/mineos_parameters.pml 2008-04-09 16:21:30 UTC (rev 11784)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/mineos_parameters.pml 2008-04-09 16:59:09 UTC (rev 11785)
@@ -7,6 +7,7 @@
<component name="mineos">
<!-- input files (fixed) -->
+ <property name="model">model.txt</property>
<property name="event">event.txt</property>
<property name="stations">stations</property>
Modified: cs/portal/trunk/seismo/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/views.py 2008-04-09 16:21:30 UTC (rev 11784)
+++ cs/portal/trunk/seismo/SeismoWebPortal/views.py 2008-04-09 16:59:09 UTC (rev 11785)
@@ -96,6 +96,7 @@
"runs": runs, # accessed by daemon
"jobs": jobs, # accessed by daemon
"output": output, # accessed by daemon
+ "requests": requests, # accessed by daemon
"beachballs": beachballs,
"designs": designs,
"doc": static,
@@ -123,7 +124,6 @@
"trash": trashFolder,
"config": configFactory,
"events": event_search,
- "requests": requests,
"profile": profile,
"logout": logout,
"help": help,
@@ -1366,6 +1366,9 @@
return index[name](request)
+ if request.user.is_anonymous():
+ return HttpResponseRedirect(config.root + '/login/')
+
if path or request.method != 'POST': raise Http404
workspace = EventWorkspace.objects.get(id = int(request.POST['workspace']))
@@ -1530,7 +1533,7 @@
mapsFolder.appendNode(gui.File("antipode", "Antipode", url = url + "antipode/"))
appWindow.path.append(mapsFolder.index[name])
child = gui.ChildWindow(url, title)
- child.content = gui.StaticContent(img(url + "%s/%s.jpg" % (name, name)))
+ child.content = gui.StaticContent(img(url + "%s/%s.jpg" % (name, name), width=506, height=506))
desktop.activeWindow.selectWindow(child)
return desktop
More information about the cig-commits
mailing list