Beispiel #1
0
 def _create_op(self, opName, req, **kwargs):
     #TODO(robnagler) kind should be set earlier in the queuing process.
     req.kind = job.PARALLEL if self.db.isParallel and opName != job.OP_ANALYSIS \
         else job.SEQUENTIAL
     req.simulationType = self.db.simulationType
     # run mode can change between runs so use req.content.jobRunMode
     # not self.db.jobRunMode
     r = req.content.get('jobRunMode', self.db.jobRunMode)
     if r not in sirepo.simulation_db.JOB_RUN_MODE_MAP:
         # happens only when config changes, and only when sbatch is missing
         sirepo.util.raise_not_found('invalid jobRunMode={} req={}', r, req)
     o = _Op(
         #TODO(robnagler) don't like the camelcase. It doesn't actually work right because
         # these values are never sent directly, only msg which can be camelcase
         computeJob=self,
         kind=req.kind,
         msg=PKDict(req.copy_content()).pksetdefault(jobRunMode=r),
         opName=opName,
         task=asyncio.current_task(),
     )
     if 'dataFileKey' in kwargs:
         kwargs['dataFileUri'] = job.supervisor_file_uri(
             o.driver.cfg.supervisor_uri,
             job.DATA_FILE_URI,
             kwargs.pop('dataFileKey'),
         )
     o.msg.pkupdate(**kwargs)
     self.ops.append(o)
     return o
Beispiel #2
0
 def make_lib_dir_symlink(self, op):
     m = op.msg
     with sirepo.auth.set_user(m.uid):
         d = sirepo.simulation_db.simulation_lib_dir(m.simulationType)
         op.lib_dir_symlink = job.LIB_FILE_ROOT.join(job.unique_key())
         op.lib_dir_symlink.mksymlinkto(d, absolute=True)
         m.pkupdate(
             libFileUri=job.supervisor_file_uri(
                 self.cfg.supervisor_uri,
                 job.LIB_FILE_URI,
                 op.lib_dir_symlink.basename,
             ),
             libFileList=[f.basename for f in d.listdir()],
         )
Beispiel #3
0
 def make_lib_dir_symlink(self, op):
     if not self._has_remote_agent():
         return
     m = op.msg
     d = pykern.pkio.py_path(m.simulation_lib_dir)
     op.lib_dir_symlink = job.LIB_FILE_ROOT.join(
         job.unique_key()
     )
     op.lib_dir_symlink.mksymlinkto(d, absolute=True)
     m.pkupdate(
         libFileUri=job.supervisor_file_uri(
             self.cfg.supervisor_uri,
             job.LIB_FILE_URI,
             op.lib_dir_symlink.basename,
         ),
         libFileList=[f.basename for f in d.listdir()],
     )
Beispiel #4
0
 async def _create_op(self, opName, req, **kwargs):
     #TODO(robnagler) kind should be set earlier in the queuing process.
     req.kind = job.PARALLEL if self.db.isParallel and opName != job.OP_ANALYSIS \
         else job.SEQUENTIAL
     req.simulationType = self.db.simulationType
     # TODO(e-carlin): We need to be able to cancel requests waiting in this
     # state. Currently we assume that all requests get a driver and the
     # code does not block.
     d = await job_driver.get_instance(req, self.db.jobRunMode)
     if 'dataFileKey' in kwargs:
         kwargs['dataFileUri'] = job.supervisor_file_uri(
             d.get_supervisor_uri(), job.DATA_FILE_URI,
             kwargs.pop('dataFileKey'))
     o = _Op(
         driver=d,
         kind=req.kind,
         maxRunSecs=0
         if opName in _UNTIMED_OPS else _MAX_RUN_SECS[req.kind],
         msg=PKDict(req.content).pkupdate(**kwargs, ).pksetdefault(
             jobRunMode=self.db.jobRunMode),
         opName=opName,
     )
     self._ops.append(o)
     return o