Exemplo n.º 1
0
def initialize_external_job(job_id, *args, **kwargs):
    """
        Create external jobs when job has been initialized.
    """
    job = Job.objects.get(id=job_id)
    handler = get_job_handler(job)
    handler.init_job(**kwargs)
Exemplo n.º 2
0
    def run(self, *args, **kwargs):
        """ Main task function.
        """
        try:
            unmapped_samples = self.get_unmapped_samples()
            jobs = self.get_jobs(unmapped_samples)
            tc = make_tagapi_client()

            log.info('SampleVotingManager: Gathered samples and jobs.')
            for job, new_samples, initialized in jobs:
                try:
                    handler = get_job_handler(job)
                    if initialized:
                        handler.update_voting(tc=tc, samples=new_samples)
                    else:
                        handler.init_voting(tc=tc, samples=new_samples)
                except Exception, e:
                    log.exception(
                        'SampleVotingManager: Error in job %d: %s.' % (job.id, e)
                    )
                    continue
        except Exception, e:
            log.exception(
                'SampleVotingManager: exception while all jobs: %s.' % e
            )
Exemplo n.º 3
0
def btm_send_to_human(sample_id, **kwargs):
    '''
        Updates appropriate BTM job with new sample.
    '''
    btm = BeatTheMachineSample.objects.get(id=sample_id)
    job = btm.job
    handler = get_job_handler(job)
    handler.update_btm(btm_samples=[btm])
Exemplo n.º 4
0
def initialize_btm_job(job_id, topic, description, no_of_urls, **kwargs):
    """
        Initializes BTM task for given job.
    """
    job = Job.objects.get(id=job_id)
    handler = get_job_handler(job)
    handler.init_btm_gather(topic=topic, description=description,
        no_of_urls=no_of_urls)
Exemplo n.º 5
0
def voting_hit_change(job_id, old_hit, new_hit, **kwargs):
    job = Job.objects.get(id=job_id)
    handler = get_job_handler(job)
    handler.voting_hit_changed(old=old_hit, new=new_hit)
Exemplo n.º 6
0
def btm_voting_hit_change(job_id, old_hit, new_hit, **kwargs):
    job = Job.objects.get(id=job_id)
    handler = get_job_handler(job)
    handler.btm_voting_hit_changed(old=old_hit, new=new_hit)
Exemplo n.º 7
0
def sample_gathering_hit_change(job_id, old_hit, new_hit, **kwargs):
    job = Job.objects.get(id=job_id)
    handler = get_job_handler(job)
    handler.sample_gathering_hit_changed(old=old_hit, new=new_hit)