[cig-commits] r12047 - cs/portal/trunk

leif at geodynamics.org leif at geodynamics.org
Wed May 28 15:06:42 PDT 2008


Author: leif
Date: 2008-05-28 15:06:42 -0700 (Wed, 28 May 2008)
New Revision: 12047

Modified:
   cs/portal/trunk/daemon.py
Log:
Updated daemon to 'northridge' code base.


Modified: cs/portal/trunk/daemon.py
===================================================================
--- cs/portal/trunk/daemon.py	2008-05-28 22:04:40 UTC (rev 12046)
+++ cs/portal/trunk/daemon.py	2008-05-28 22:06:42 UTC (rev 12047)
@@ -432,7 +432,7 @@
 class Run(object):
     
     # status codes
-    STATUS_NEW        = "new"
+    STATUS_NEW        = "ready"
     STATUS_CONNECTING = "connecting"
     STATUS_PREPARING  = "preparing"  # reported by build & schedule process
     STATUS_PENDING    = "pending"    # reported by build & schedule process
@@ -443,9 +443,8 @@
     STATUS_ERROR      = "error"
     deadCodes = [STATUS_DONE, STATUS_ERROR]
 
-    def __init__(self, id, simulation, urlForInputFile, config, info, jm):
+    def __init__(self, id, urlForInputFile, config, info, jm):
         self.id = id
-        self.simulation = simulation
         self.urlForInputFile = urlForInputFile
         self.specfemPathname = config.specfemPathname
         self.mineosPathname = config.mineosPathname
@@ -504,15 +503,18 @@
         dry = []
         if self.dry:
             dry = ["--scheduler.dry"]
+        parameters = 'par_file.txt'
+        event = 'event.txt'
+        stations = 'stations.txt'
         job = Job(
             self,
             "run",
             jobType = "single",
             count = 1,
             executable = self.specfemPathname,
-            arguments = ['--par-file=' + self.simulation.parameters,
-                         '--cmt-solution=' + self.simulation.event,
-                         '--stations=' + self.simulation.stations,
+            arguments = ['--par-file=' + parameters,
+                         '--cmt-solution=' + event,
+                         '--stations=' + stations,
                          "--scheduler.wait=True",
                          "--job.name=run%05d" % self.id,
                          "--macros.run.id=%05d" % self.id,
@@ -522,8 +524,7 @@
                          ] + dry,
             )
         job.urlForInputFile = self.urlForInputFile
-        sim = self.simulation
-        job.inputFiles = [sim.parameters, sim.event, sim.stations]
+        job.inputFiles = [parameters, event, stations]
         job.outputFiles = ["specfem3dglobe.tar.gz", "output_mesher.txt", "output_solver.txt", "output_build.txt"]
         return job
 
@@ -543,14 +544,6 @@
         return job
 
 
-class Simulation(object):
-    def __init__(self, id):
-        self.id = id
-        self.parameters = 'par_file.txt'
-        self.event = 'event.txt'
-        self.stations = 'stations.txt'
-
-
 class PortalConnection(object):
 
     MULTIPART_BOUNDARY = '----------eArThQuAkE$'
@@ -588,22 +581,19 @@
             for run in runList:
                 id = int(run['id'])
                 status = run['status']
-                simId = run['request']
                 code = run['code']
-                if (status in [Run.STATUS_NEW, ""] and
-                    not runs.has_key(id)):
+                if (status == Run.STATUS_NEW and not runs.has_key(id)):
                     self.info.log("new run %d" % id)
-                    simulation = Simulation(simId)
 
                     def urlForInputFile(inputFile):
                         # Map input filenames to URLs in the context
                         # of this run.
-                        return self.inputFileURL(simulation, inputFile)
+                        return self.inputFileURL(id, inputFile)
 
                     if code == 1:
-                        newRun = SpecfemRun(id, simulation, urlForInputFile, config, self.info, gjm)
+                        newRun = SpecfemRun(id, urlForInputFile, config, self.info, gjm)
                     elif code == 2:
-                        newRun = MineosRun(id, simulation, urlForInputFile, config, self.info, fjm)
+                        newRun = MineosRun(id, urlForInputFile, config, self.info, fjm)
                     else:
                         self.info.log("unknown code %d" % code)
                         continue
@@ -681,8 +671,8 @@
             }
         return fields
 
-    def inputFileURL(self, simulation, inputFile):
-        return self.portal.inputFileUrl % (simulation.id, inputFile)
+    def inputFileURL(self, id, inputFile):
+        return self.portal.inputFileUrl % (id, inputFile)
 
     def postStatusChange(self, url, fields):
         import urllib
@@ -766,7 +756,7 @@
 
     def _configure(self):
         self.urlPrefix           = '%s://%s%s' % (self.scheme, self.host, self.urlRoot)
-        self.inputFileUrl        = self.urlPrefix + 'requests/%d/%s'
+        self.inputFileUrl        = self.urlPrefix + 'runs/%d/%s'
         # runs
         self.runsUrl             = self.urlPrefix + 'runs/list.py'
         self.runStatusUrl        = self.urlRoot + 'runs/%d/status/'



More information about the cig-commits mailing list