예제 #1
0
 def execute(self, taskSpec: Sequence[str]) -> Response:
     clientId = self.elem(taskSpec, 0)
     runargs = self.getRunArgs(taskSpec)
     jobId = runargs.get("jobId", self.elem(taskSpec, 2, Job.randomStr(8)))
     proj = runargs.get("proj", "proj-" + Job.randomStr(4))
     exp = runargs.get("exp", "exp-" + Job.randomStr(4))
     process_name = self.elem(taskSpec, 2)
     runargs["ncores"] = self.processManager.ncores.items()[0][1]
     dataInputsSpec = self.elem(taskSpec, 3)
     self.setExeStatus(clientId, jobId,
                       "executing " + process_name + "-> " + dataInputsSpec)
     self.logger.info(" @@E: Executing " + process_name + "-> " +
                      dataInputsSpec + ", jobId = " + jobId +
                      ", runargs = " + str(runargs))
     try:
         job = Job.new(jobId, proj, exp, process_name, dataInputsSpec,
                       runargs, 1.0)
         execHandler: ExecHandler = self.addHandler(
             clientId, jobId,
             ExecHandler(clientId, job, self, workers=job.workers))
         execHandler.start()
         return Message(clientId, jobId, execHandler.filePath)
     except Exception as err:
         self.logger.error("Caught execution error: " + str(err))
         traceback.print_exc()
         return Message(clientId, jobId, str(err))
예제 #2
0
 def runJob(self, job: Job, clientId: str = "local") -> Response:
     try:
         resultHandler = ExecHandler("local",
                                     job.process,
                                     workers=job.workers)
         self.processManager.submitProcess(job.process, job, resultHandler)
         return Message(clientId, job.process, resultHandler.filePath)
     except Exception as err:
         self.logger.error("Caught execution error: " + str(err))
         traceback.print_exc()
         return Message(clientId, job.process, str(err))
예제 #3
0
 def capabilities(self, type: str, **kwargs  ) -> Dict:
     if type == "epas":
         return dict( epas = self._epas )
     elif type == "capabilities" or type == "" or type is None:
         if type == None: type = "kernels"
         capabilities = edasOpManager.getCapabilitiesXml(type)
         return Message( type, "capabilities", capabilities ).dict()
     elif type == "processes":
         capabilities = edasOpManager.getCapabilitiesJson(type)
         return Message( type, "capabilities", capabilities ).dict()
     elif type == "util":
         utilSpec = kwargs.get( "spec" )
         (module, op) = WpsCwtParser.split([":", "."], utilSpec[1])
         description = json.dumps( edasOpManager.describeProcess(module, op) )
         return Message(utilSpec[0], "capabilities", description).dict()
     else: raise Exception( f"Unknown capabilities type: {type}" )
예제 #4
0
 def execUtility( self, utilSpec: Sequence[str] ) -> Dict:
     uType = utilSpec[0].lower()
     for capType in [ 'col', 'ker' ]:
         if uType.startswith( capType ):
             return self.capabilities( uType )
     if uType.startswith( "var" ):
         if len( utilSpec ) <= 2: raise Exception( "Missing parameter(s) to getVariableSpec" )
         return self.getVariableSpec( utilSpec[1], utilSpec[2]  )
     return Message("","","").dict()
예제 #5
0
 def execUtility(self, utilSpec: Sequence[str]) -> Message:
     uType = utilSpec[0].lower()
     for capType in ['col', 'ker']:
         if uType.startswith(capType):
             return self.getCapabilities(uType)
     if uType.startswith("var"):
         if len(utilSpec) <= 2:
             raise Exception("Missing parameter(s) to getVariableSpec")
         return self.getVariableSpec(utilSpec[1], utilSpec[2])
     if uType.startswith("metrics"):
         mtype = utilSpec[1].lower()
         metrics = self.getCWTMetrics(
         ) if mtype == "cwt" else self.processManager.getProfileData(mtype)
         return Message("metrics", mtype, json.dumps(metrics))
     if uType.startswith("health"):
         mtype = utilSpec[1].lower()
         health = self.processManager.getHealth(mtype)
         return Message("health", mtype, health)
     return Message("", "", "")
예제 #6
0
 def getVariableSpec(self, collId: str, varId: str) -> Dict:
     from edas.collection.agg import Collection
     col = Collection.new(collId)
     varSpec = col.getVariableSpec(varId)
     return Message("var", "VariableSpec", varSpec).dict()
예제 #7
0
 def describeProcess(self, utilSpec: Sequence[str]) -> Message:
     (module, op) = WpsCwtParser.split([":", "."], utilSpec[1])
     description = edasOpManager.describeProcess(module, op)
     return Message(utilSpec[0], "capabilities", json.dumps(description))
예제 #8
0
 def getCapabilities(self, type: str) -> Message:
     capabilities: Dict = edasOpManager.getCapabilitiesJson(type)
     return Message(type, "capabilities", json.dumps(capabilities))