当前位置: 首页>>代码示例>>Python>>正文


Python runners.AsynchronousJobState类代码示例

本文整理汇总了Python中galaxy.jobs.runners.AsynchronousJobState的典型用法代码示例。如果您正苦于以下问题:Python AsynchronousJobState类的具体用法?Python AsynchronousJobState怎么用?Python AsynchronousJobState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AsynchronousJobState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _job_state

 def _job_state( self, job, job_wrapper ):
     job_state = AsynchronousJobState()
     # TODO: Determine why this is set when using normal message queue updates
     # but not CLI submitted MQ updates...
     raw_job_id = job.get_job_runner_external_id() or job_wrapper.job_id
     job_state.job_id = str( raw_job_id )
     job_state.runner_url = job_wrapper.get_job_runner_url()
     job_state.job_destination = job_wrapper.job_destination
     job_state.job_wrapper = job_wrapper
     return job_state
开发者ID:agrauslys,项目名称:galaxy,代码行数:10,代码来源:pulsar.py

示例2: recover

 def recover(self, job, job_wrapper):
     """Recovers jobs stuck in the queued/running state when Galaxy started"""
     # TODO this needs to be implemented to override unimplemented base method
     job_id = job.get_job_runner_external_id()
     log.debug("k8s trying to recover job: " + job_id)
     if job_id is None:
         self.put(job_wrapper)
         return
     ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper)
     ajs.job_id = str(job_id)
     ajs.command_line = job.command_line
     ajs.job_wrapper = job_wrapper
     ajs.job_destination = job_wrapper.job_destination
     if job.state == model.Job.states.RUNNING:
         log.debug("(%s/%s) is still in running state, adding to the runner monitor queue" % (
             job.id, job.job_runner_external_id))
         ajs.old_state = model.Job.states.RUNNING
         ajs.running = True
         self.monitor_queue.put(ajs)
     elif job.state == model.Job.states.QUEUED:
         log.debug("(%s/%s) is still in queued state, adding to the runner monitor queue" % (
             job.id, job.job_runner_external_id))
         ajs.old_state = model.Job.states.QUEUED
         ajs.running = False
         self.monitor_queue.put(ajs)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:25,代码来源:kubernetes.py

示例3: recover

 def recover(self,job,job_wrapper):
     # Recovers jobs in the queued/running state when Galaxy started
     # What is 'job' an instance of???
     # Could be model.Job?
     # Fetch the job id used by JSE-Drop
     job_name = job.get_job_runner_external_id()
     # Get the job destination
     job_destination = job_wrapper.job_destination
     # Fetch the drop dir
     drop_off_dir = self._get_drop_dir()
     log.debug("recover: drop-off dir = %s" % drop_off_dir)
     jse_drop = JSEDrop(drop_off_dir)
     # Store state information for job
     job_state = AsynchronousJobState()
     job_state.job_wrapper = job_wrapper
     job_state.job_id = job_name
     job_state.job_destination = job_destination
     # Sort out the status
     if job.state == model.Job.states.RUNNING:
         job_state.old_state = True
         job_state.running = True
     elif job.get_state() == model.Job.states.QUEUED:
         job_state.old_state = True
         job_state.running = False
     # Add to the queue of jobs to monitor
     self.monitor_queue.put(job_state)
开发者ID:pjbriggs,项目名称:ansible-palfinder-galaxy,代码行数:26,代码来源:jse_drop_runner.py

示例4: recover

 def recover( self, job, job_wrapper ):
     """Recovers jobs stuck in the queued/running state when Galaxy started"""
     job_id = job.get_job_runner_external_id()
     if job_id is None:
         self.put( job_wrapper )
         return
     ajs = AsynchronousJobState( files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper )
     ajs.job_id = str( job_id )
     ajs.command_line = job.get_command_line()
     ajs.job_wrapper = job_wrapper
     ajs.job_destination = job_wrapper.job_destination
     if job.state == model.Job.states.RUNNING:
         log.debug( "(%s/%s) is still in running state, adding to the DRM queue" % ( job.get_id(), job.get_job_runner_external_id() ) )
         ajs.old_state = drmaa.JobState.RUNNING
         ajs.running = True
         self.monitor_queue.put( ajs )
     elif job.get_state() == model.Job.states.QUEUED:
         log.debug( "(%s/%s) is still in DRM queued state, adding to the DRM queue" % ( job.get_id(), job.get_job_runner_external_id() ) )
         ajs.old_state = drmaa.JobState.QUEUED_ACTIVE
         ajs.running = False
         self.monitor_queue.put( ajs )
开发者ID:AAFC-MBB,项目名称:galaxy-1,代码行数:21,代码来源:drmaa.py

示例5: recover

 def recover( self, job, job_wrapper ):
     """Recovers jobs stuck in the queued/running state when Galaxy started"""
     job_state = AsynchronousJobState()
     job_state.job_id = str( job.get_job_runner_external_id() )
     job_state.runner_url = job_wrapper.get_job_runner_url()
     job_state.job_destination = job_wrapper.job_destination
     job_wrapper.command_line = job.get_command_line()
     job_state.job_wrapper = job_wrapper
     state = job.get_state()
     if state in [model.Job.states.RUNNING, model.Job.states.QUEUED]:
         log.debug( "(LWR/%s) is still in running state, adding to the LWR queue" % ( job.get_id()) )
         job_state.old_state = True
         job_state.running = state == model.Job.states.RUNNING
         self.monitor_queue.put( job_state )
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:14,代码来源:lwr.py

示例6: recover

 def recover(self, job, job_wrapper):
     msg = ('(name!r/runner!r) is still in {state!s} state, adding to'
            ' the runner monitor queue')
     job_id = job.get_job_runner_external_id()
     ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory,
                                job_wrapper=job_wrapper)
     ajs.job_id = self.JOB_NAME_PREFIX + str(job_id)
     ajs.command_line = job.command_line
     ajs.job_wrapper = job_wrapper
     ajs.job_destination = job_wrapper.job_destination
     if job.state == model.Job.states.RUNNING:
         LOGGER.debug(msg.format(
             name=job.id, runner=job.job_runner_external_id,
             state='running'))
         ajs.old_state = model.Job.states.RUNNING
         ajs.running = True
         self.monitor_queue.put(ajs)
     elif job.state == model.Job.states.QUEUED:
         LOGGER.debug(msg.format(
             name=job.id, runner=job.job_runner_external_id,
             state='queued'))
         ajs.old_state = model.Job.states.QUEUED
         ajs.running = False
         self.monitor_queue.put(ajs)
开发者ID:bwlang,项目名称:galaxy,代码行数:24,代码来源:chronos.py

示例7: recover

    def recover(self, job, job_wrapper):
        """ Recovers jobs stuck in the queued/running state when Galaxy started """
        """ This method is called by galaxy at the time of startup.
            Jobs in Running & Queued status in galaxy are put in the monitor_queue by creating an AsynchronousJobState object
        """
        job_id = job_wrapper.job_id
        ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper)
        ajs.job_id = str(job_id)
        ajs.job_destination = job_wrapper.job_destination
        job_wrapper.command_line = job.command_line
        ajs.job_wrapper = job_wrapper
        if job.state == model.Job.states.RUNNING:
            log.debug("(%s/%s) is still in running state, adding to the god queue" % (job.id, job.get_job_runner_external_id()))
            ajs.old_state = 'R'
            ajs.running = True
            self.monitor_queue.put(ajs)

        elif job.state == model.Job.states.QUEUED:
            log.debug("(%s/%s) is still in god queued state, adding to the god queue" % (job.id, job.get_job_runner_external_id()))
            ajs.old_state = 'Q'
            ajs.running = False
            self.monitor_queue.put(ajs)
开发者ID:bwlang,项目名称:galaxy,代码行数:22,代码来源:godocker.py

示例8: queue_job

    def queue_job(self, job_wrapper):
        job_destination = job_wrapper.job_destination
        self._populate_parameter_defaults(job_destination)

        command_line, client, remote_job_config, compute_environment = self.__prepare_job(job_wrapper, job_destination)

        if not command_line:
            return

        try:
            dependencies_description = PulsarJobRunner.__dependencies_description(client, job_wrapper)
            rewrite_paths = not PulsarJobRunner.__rewrite_parameters(client)
            unstructured_path_rewrites = {}
            output_names = []
            if compute_environment:
                unstructured_path_rewrites = compute_environment.unstructured_path_rewrites
                output_names = compute_environment.output_names()

            client_job_description = ClientJobDescription(
                command_line=command_line,
                input_files=self.get_input_files(job_wrapper),
                client_outputs=self.__client_outputs(client, job_wrapper),
                working_directory=job_wrapper.tool_working_directory,
                metadata_directory=job_wrapper.working_directory,
                tool=job_wrapper.tool,
                config_files=job_wrapper.extra_filenames,
                dependencies_description=dependencies_description,
                env=client.env,
                rewrite_paths=rewrite_paths,
                arbitrary_files=unstructured_path_rewrites,
                touch_outputs=output_names,
            )
            job_id = pulsar_submit_job(client, client_job_description, remote_job_config)
            log.info("Pulsar job submitted with job_id %s" % job_id)
            job_wrapper.set_job_destination(job_destination, job_id)
            job_wrapper.change_state(model.Job.states.QUEUED)
        except Exception:
            job_wrapper.fail("failure running job", exception=True)
            log.exception("failure running job %d", job_wrapper.job_id)
            return

        pulsar_job_state = AsynchronousJobState()
        pulsar_job_state.job_wrapper = job_wrapper
        pulsar_job_state.job_id = job_id
        pulsar_job_state.old_state = True
        pulsar_job_state.running = False
        pulsar_job_state.job_destination = job_destination
        self.monitor_job(pulsar_job_state)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:48,代码来源:pulsar.py

示例9: queue_job

    def queue_job(self, job_wrapper):
        command_line = ''
        job_destination = job_wrapper.job_destination

        try:
            job_wrapper.prepare()
            if hasattr(job_wrapper, 'prepare_input_files_cmds') and job_wrapper.prepare_input_files_cmds is not None:
                for cmd in job_wrapper.prepare_input_files_cmds:  # run the commands to stage the input files
                    #log.debug( 'executing: %s' % cmd )
                    if 0 != os.system(cmd):
                        raise Exception('Error running file staging command: %s' % cmd)
                job_wrapper.prepare_input_files_cmds = None  # prevent them from being used in-line
            command_line = self.build_command_line( job_wrapper, include_metadata=False, include_work_dir_outputs=False )
        except:
            job_wrapper.fail( "failure preparing job", exception=True )
            log.exception("failure running job %d" % job_wrapper.job_id)
            return

        # If we were able to get a command line, run the job
        if not command_line:
            job_wrapper.finish( '', '' )
            return

        try:
            client = self.get_client_from_wrapper(job_wrapper)
            output_files = self.get_output_files(job_wrapper)
            input_files = job_wrapper.get_input_fnames()
            working_directory = job_wrapper.working_directory
            tool = job_wrapper.tool
            file_stager = FileStager(client, tool, command_line, job_wrapper.extra_filenames, input_files, output_files, working_directory)
            rebuilt_command_line = file_stager.get_rewritten_command_line()
            job_id = file_stager.job_id
            client.launch( rebuilt_command_line )
            job_wrapper.set_job_destination( job_destination, job_id )
            job_wrapper.change_state( model.Job.states.QUEUED )
        except:
            job_wrapper.fail( "failure running job", exception=True )
            log.exception("failure running job %d" % job_wrapper.job_id)
            return

        lwr_job_state = AsynchronousJobState()
        lwr_job_state.job_wrapper = job_wrapper
        lwr_job_state.job_id = job_id
        lwr_job_state.old_state = True
        lwr_job_state.running = False
        lwr_job_state.job_destination = job_destination
        self.monitor_job(lwr_job_state)
开发者ID:knowingchaos,项目名称:galaxy,代码行数:47,代码来源:lwr.py

示例10: queue_job

    def queue_job(self, job_wrapper):
        job_destination = job_wrapper.job_destination

        command_line, client, remote_job_config = self.__prepare_job( job_wrapper, job_destination )

        if not command_line:
            return

        try:
            dependency_resolution = LwrJobRunner.__dependency_resolution( client )
            remote_dependency_resolution = dependency_resolution == "remote"
            requirements = job_wrapper.tool.requirements if remote_dependency_resolution else []
            client_job_description = ClientJobDescription(
                command_line=command_line,
                output_files=self.get_output_files(job_wrapper),
                input_files=job_wrapper.get_input_fnames(),
                working_directory=job_wrapper.working_directory,
                tool=job_wrapper.tool,
                config_files=job_wrapper.extra_filenames,
                requirements=requirements,
                version_file=job_wrapper.get_version_string_path(),
            )
            job_id = lwr_submit_job(client, client_job_description, remote_job_config)
            log.info("lwr job submitted with job_id %s" % job_id)
            job_wrapper.set_job_destination( job_destination, job_id )
            job_wrapper.change_state( model.Job.states.QUEUED )
        except Exception:
            job_wrapper.fail( "failure running job", exception=True )
            log.exception("failure running job %d" % job_wrapper.job_id)
            return

        lwr_job_state = AsynchronousJobState()
        lwr_job_state.job_wrapper = job_wrapper
        lwr_job_state.job_id = job_id
        lwr_job_state.old_state = True
        lwr_job_state.running = False
        lwr_job_state.job_destination = job_destination
        self.monitor_job(lwr_job_state)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:38,代码来源:lwr.py

示例11: queue_job

    def queue_job( self, job_wrapper ):
        """Create job script and submit it to the DRM"""
        # prepare the job
        if not self.prepare_job( job_wrapper, include_metadata=True ):
            return

        # command line has been added to the wrapper by prepare_job()
        command_line = job_wrapper.runner_command_line
        
        # get configured job destination
        job_destination = job_wrapper.job_destination

        # wrapper.get_id_tag() instead of job_id for compatibility with TaskWrappers.
        galaxy_id_tag = job_wrapper.get_id_tag()

        # define job attributes
        job_name = 'g%s' % galaxy_id_tag
        if job_wrapper.tool.old_id:
            job_name += '_%s' % job_wrapper.tool.old_id
        if self.external_runJob_script is None:
            job_name += '_%s' % job_wrapper.user
        job_name = ''.join( map( lambda x: x if x in ( string.letters + string.digits + '_' ) else '_', job_name ) )
        ajs = AsynchronousJobState( files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper, job_name=job_name )

        # set up the drmaa job template
        jt = self.ds.createJobTemplate()
        jt.remoteCommand = ajs.job_file
        jt.jobName = ajs.job_name
        jt.outputPath = ":%s" % ajs.output_file
        jt.errorPath = ":%s" % ajs.error_file

        # Avoid a jt.exitCodePath for now - it's only used when finishing.
        native_spec = job_destination.params.get('nativeSpecification', None)
        if native_spec is not None:
            jt.nativeSpecification = native_spec

        # fill in the DRM's job run template
        script = drm_template % ( job_wrapper.galaxy_lib_dir,
                                  job_wrapper.get_env_setup_clause(),
                                  os.path.abspath( job_wrapper.working_directory ),
                                  command_line,
                                  ajs.exit_code_file )

        try:
            fh = file( ajs.job_file, "w" )
            fh.write( script )
            fh.close()
            os.chmod( ajs.job_file, 0755 )
        except:
            job_wrapper.fail( "failure preparing job script", exception=True )
            log.exception( "(%s) failure writing job script" % galaxy_id_tag )
            return

        # job was deleted while we were preparing it
        if job_wrapper.get_state() == model.Job.states.DELETED:
            log.debug( "(%s) Job deleted by user before it entered the queue" % galaxy_id_tag )
            if self.app.config.cleanup_job in ( "always", "onsuccess" ):
                job_wrapper.cleanup()
            return

        log.debug( "(%s) submitting file %s" % ( galaxy_id_tag, ajs.job_file ) )
        log.debug( "(%s) command is: %s" % ( galaxy_id_tag, command_line ) )

        # runJob will raise if there's a submit problem
        if self.external_runJob_script is None:
            external_job_id = self.ds.runJob(jt)
        else:
            job_wrapper.change_ownership_for_run()
            log.debug( '(%s) submitting with credentials: %s [uid: %s]' % ( galaxy_id_tag, job_wrapper.user_system_pwent[0], job_wrapper.user_system_pwent[2] ) )
            filename = self.store_jobtemplate(job_wrapper, jt)
            self.userid =  job_wrapper.user_system_pwent[2]
            external_job_id = self.external_runjob(filename, job_wrapper.user_system_pwent[2]).strip()
        log.info( "(%s) queued as %s" % ( galaxy_id_tag, external_job_id ) )

        # store runner information for tracking if Galaxy restarts
        job_wrapper.set_job_destination( job_destination, external_job_id )

        # Store DRM related state information for job
        ajs.job_id = external_job_id
        ajs.old_state = 'new'
        ajs.job_destination = job_destination
        
        # delete the job template
        self.ds.deleteJobTemplate( jt )

        # Add to our 'queue' of jobs to monitor
        self.monitor_queue.put( ajs )
开发者ID:knowingchaos,项目名称:galaxy,代码行数:87,代码来源:drmaa.py

示例12: recover

 def recover( self, job, job_wrapper ):
     """Recovers jobs stuck in the queued/running state when Galaxy started"""
     job_id = job.get_job_runner_external_id()
     pbs_job_state = AsynchronousJobState()
     pbs_job_state.output_file = "%s/%s.o" % (self.app.config.cluster_files_directory, job.id)
     pbs_job_state.error_file = "%s/%s.e" % (self.app.config.cluster_files_directory, job.id)
     pbs_job_state.exit_code_file = "%s/%s.ec" % (self.app.config.cluster_files_directory, job.id)
     pbs_job_state.job_file = "%s/%s.sh" % (self.app.config.cluster_files_directory, job.id)
     pbs_job_state.job_id = str( job_id )
     pbs_job_state.runner_url = job_wrapper.get_job_runner_url()
     pbs_job_state.job_destination = job_wrapper.job_destination
     job_wrapper.command_line = job.command_line
     pbs_job_state.job_wrapper = job_wrapper
     if job.state == model.Job.states.RUNNING:
         log.debug( "(%s/%s) is still in running state, adding to the PBS queue" % ( job.id, job.get_job_runner_external_id() ) )
         pbs_job_state.old_state = 'R'
         pbs_job_state.running = True
         self.monitor_queue.put( pbs_job_state )
     elif job.state == model.Job.states.QUEUED:
         log.debug( "(%s/%s) is still in PBS queued state, adding to the PBS queue" % ( job.id, job.get_job_runner_external_id() ) )
         pbs_job_state.old_state = 'Q'
         pbs_job_state.running = False
         self.monitor_queue.put( pbs_job_state )
开发者ID:AAFC-MBB,项目名称:galaxy-1,代码行数:23,代码来源:pbs.py

示例13: queue_job

    def queue_job( self, job_wrapper ):
        """Create job script and submit it to the DRM"""
        # prepare the job
        if not self.prepare_job( job_wrapper, include_metadata=True ):
            return

        # Get shell and job execution interface
        job_destination = job_wrapper.job_destination
        shell_params, job_params = self.parse_destination_params(job_destination.params)
        shell, job_interface = self.get_cli_plugins(shell_params, job_params)

        # wrapper.get_id_tag() instead of job_id for compatibility with TaskWrappers.
        galaxy_id_tag = job_wrapper.get_id_tag()

        # define job attributes
        ajs = AsynchronousJobState( files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper )

        job_file_kwargs = job_interface.job_script_kwargs(ajs.output_file, ajs.error_file, ajs.job_name)
        script = self.get_job_file(
            job_wrapper,
            exit_code_path=ajs.exit_code_file,
            **job_file_kwargs
        )

        try:
            fh = file(ajs.job_file, "w")
            fh.write(script)
            fh.close()
        except:
            log.exception("(%s) failure writing job script" % galaxy_id_tag )
            job_wrapper.fail("failure preparing job script", exception=True)
            return

        # job was deleted while we were preparing it
        if job_wrapper.get_state() == model.Job.states.DELETED:
            log.info("(%s) Job deleted by user before it entered the queue" % galaxy_id_tag )
            if self.app.config.cleanup_job in ("always", "onsuccess"):
                job_wrapper.cleanup()
            return

        log.debug( "(%s) submitting file: %s" % ( galaxy_id_tag, ajs.job_file ) )

        cmd_out = shell.execute(job_interface.submit(ajs.job_file))
        if cmd_out.returncode != 0:
            log.error('(%s) submission failed (stdout): %s' % (galaxy_id_tag, cmd_out.stdout))
            log.error('(%s) submission failed (stderr): %s' % (galaxy_id_tag, cmd_out.stderr))
            job_wrapper.fail("failure submitting job")
            return
        # Some job runners return something like 'Submitted batch job XXXX'
        # Strip and split to get job ID.
        external_job_id = cmd_out.stdout.strip().split()[-1]
        if not external_job_id:
            log.error('(%s) submission did not return a job identifier, failing job' % galaxy_id_tag)
            job_wrapper.fail("failure submitting job")
            return

        log.info("(%s) queued with identifier: %s" % ( galaxy_id_tag, external_job_id ) )

        # store runner information for tracking if Galaxy restarts
        job_wrapper.set_job_destination( job_destination, external_job_id )

        # Store state information for job
        ajs.job_id = external_job_id
        ajs.old_state = 'new'
        ajs.job_destination = job_destination

        # Add to our 'queue' of jobs to monitor
        self.monitor_queue.put( ajs )
开发者ID:mb12985,项目名称:Galaxy,代码行数:68,代码来源:cli.py

示例14: queue_job

 def queue_job(self, job_wrapper):
     """Write JSE-Drop file to drop location
     """
     # Get the configured job destination
     job_destination = job_wrapper.job_destination
     # Get the parameters defined for this destination
     # i.e. location of the drop-off directory etc
     drop_off_dir = self._get_drop_dir()
     virtual_env = self._get_virtual_env()
     qsub_options = self._get_qsub_options(job_destination)
     galaxy_slots = self._get_galaxy_slots(job_destination)
     galaxy_id = self._get_galaxy_id()
     log.debug("queue_job: drop-off dir = %s" % drop_off_dir)
     log.debug("queue_job: virtual_env  = %s" % virtual_env)
     log.debug("queue_job: qsub options = %s" % qsub_options)
     log.debug("queue_job: galaxy_slots = %s" % galaxy_slots)
     log.debug("queue_job: galaxy_id    = %s" % galaxy_id)
     if drop_off_dir is None:
         # Can't locate drop-off dir
         job_wrapper.fail("failure preparing job script (no JSE-drop "
                          "directory defined)",exception=True )
         log.exception("(%s/%s) failure writing job script (no "
                       "JSE-drop directory defined)" %
                       (galaxy_id_tag,job_name))
         return
     # Initialise JSE-drop wrapper
     jse_drop = JSEDrop(drop_off_dir)
     # ID and name for job
     galaxy_id_tag = job_wrapper.get_id_tag()
     log.debug("ID tag: %s" % galaxy_id_tag)
     job_name = self._get_job_name(galaxy_id_tag,
                                   job_wrapper.tool.old_id,
                                   galaxy_id)
     log.debug("Job name: %s" % job_name)
     # Prepare the job wrapper (or abort)
     if not self.prepare_job(job_wrapper):
         return
     # Sort out the slots (see e.g. condor.py for example)
     if galaxy_slots:
         galaxy_slots_statement = 'GALAXY_SLOTS="%s"; export GALAXY_SLOTS_CONFIGURED="1"' % galaxy_slots
     else:
         galaxy_slots_statement = 'GALAXY_SLOTS="1"'
     # Create script contents
     script = self.get_job_file(job_wrapper,
                                galaxy_virtual_env=virtual_env,
                                slots_statement=galaxy_slots_statement,
                                exit_code_path=None)
     # Separate leading shell specification from generated script
     shell = '\n'.join(filter(lambda x: x.startswith('#!'),
                              script.split('\n')))
     script = '\n'.join(filter(lambda x: not x.startswith('#!'),
                               script.split('\n')))
     # Create header with embedded qsub flags
     qsub_header = ["-V",
                    "-wd %s" % job_wrapper.working_directory]
     if qsub_options:
         qsub_header.append(qsub_options)
     qsub_header = '\n'.join(["#$ %s" % opt for opt in qsub_header])
     log.debug("qsub_header: %s" % qsub_header)
     # Reassemble the script components
     script = "\n".join((shell,qsub_header,script))
     # Create the drop file to submit the job
     try:
         drop_file = jse_drop.run(job_name,script)
         log.debug("created drop file %s" % drop_file)
         log.info("(%s) submitted as %s" % (galaxy_id_tag,job_name))
     except:
         # Some problem writing the qsub file
         job_wrapper.fail("failure preparing job script",
                          exception=True )
         log.exception("(%s/%s) failure writing job script" %
                       (galaxy_id_tag,job_name))
         return
     # External job id (i.e. id used by JSE-Drop as a handle to
     # identify the job) is the same as the job name here
     external_job_id = job_name
     # Store runner information for tracking if Galaxy restarts
     job_wrapper.set_job_destination(job_destination,
                                     external_job_id)
     # Store state information for job
     job_state = AsynchronousJobState()
     job_state.job_wrapper = job_wrapper
     job_state.job_id = job_name
     job_state.old_state = True
     job_state.running = False
     job_state.job_destination = job_destination
     # Add to the queue of jobs to monitor
     self.monitor_job(job_state)
     log.info("%s: queued" % job_name)
开发者ID:pjbriggs,项目名称:ansible-palfinder-galaxy,代码行数:89,代码来源:jse_drop_runner.py

示例15: queue_job

    def queue_job( self, job_wrapper ):
        """Create job script and submit it to the DRM"""
        # prepare the job
        if not self.prepare_job( job_wrapper, include_metadata=True ):
            return

        # command line has been added to the wrapper by prepare_job()
        command_line = job_wrapper.runner_command_line

        # Get shell and job execution interface
        job_destination = job_wrapper.job_destination
        shell_params, job_params = self.parse_destination_params(job_destination.params)
        shell, job_interface = self.get_cli_plugins(shell_params, job_params)

        # Updated by jinchao
        print "\nQueue job shell/job interface"
        print "shell: %s  |  job: %s" % (shell_params['plugin'], job_params['plugin'])

        # wrapper.get_id_tag() instead of job_id for compatibility with TaskWrappers.
        galaxy_id_tag = job_wrapper.get_id_tag()

        # define job attributes
        ajs = AsynchronousJobState( files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper )

        # fill in the DRM's job run template
        script = job_interface.get_job_template(ajs.output_file, ajs.error_file, ajs.job_name, job_wrapper, command_line, ajs.exit_code_file)

        # Updated by jinchao
        print "\nQueue job script"
        print script

        try:
            fh = file(ajs.job_file, "w")
            fh.write(script)
            fh.close()
        except:
            log.exception("(%s) failure writing job script" % galaxy_id_tag )
            job_wrapper.fail("failure preparing job script", exception=True)
            return

        # job was deleted while we were preparing it
        if job_wrapper.get_state() == model.Job.states.DELETED:
            log.info("(%s) Job deleted by user before it entered the queue" % galaxy_id_tag )
            if self.app.config.cleanup_job in ("always", "onsuccess"):
                job_wrapper.cleanup()
            return

        log.debug( "(%s) submitting file: %s" % ( galaxy_id_tag, ajs.job_file ) )
        log.debug( "(%s) command is: %s" % ( galaxy_id_tag, command_line ) )

        cmd_out = shell.execute(job_interface.submit(ajs.job_file, job_wrapper))

        # Updated by jinchao
        print "\nQueue job cmd_out"
        print cmd_out

        if cmd_out.returncode != 0:
            log.error('(%s) submission failed (stdout): %s' % (galaxy_id_tag, cmd_out.stdout))
            log.error('(%s) submission failed (stderr): %s' % (galaxy_id_tag, cmd_out.stderr))
            job_wrapper.fail("failure submitting job")
            return

        # Updated by jinchao
        print "\nQueue job cmd_out returncode:"
        print cmd_out.returncode
        print "\nQueue job cmd_out stdout:"
        print cmd_out.stdout
        print "\nQueue job cmd_out stderr:"
        print cmd_out.stderr
        print "\nQueue job cmd_out job params"
        print job_params

        #external_job_id = cmd_out.stdout.strip()

        # Updated by jinchao: handle job info to get job id
        if job_params['plugin'] == 'Hadoop':
            # The stdout was sent to stderr under hadoop job plugin
            external_job_id = job_interface.parse_job_info(cmd_out.stderr)
        else:
            external_job_id = job_interface.parse_job_info(cmd_out.stdout)
        print "\Queue job JOB ID:"
        print external_job_id

        if not external_job_id:
            log.error('(%s) submission did not return a job identifier, failing job' % galaxy_id_tag)
            job_wrapper.fail("failure submitting job")
            return

        log.info("(%s) queued with identifier: %s" % ( galaxy_id_tag, external_job_id ) )

        # store runner information for tracking if Galaxy restarts
        job_wrapper.set_job_destination( job_destination, external_job_id )

        # Store state information for job
        ajs.job_id = external_job_id
        ajs.old_state = 'new'
        ajs.job_destination = job_destination

        # Add to our 'queue' of jobs to monitor
        self.monitor_queue.put( ajs )
开发者ID:bluesky8640,项目名称:galaxy-hadoop-plugin,代码行数:100,代码来源:cli.py


注:本文中的galaxy.jobs.runners.AsynchronousJobState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。