def clone_job(self, job_key, units=None, extra_tags=None):
    extra_tags = (extra_tags or [])
    job = self.client.get_job(job_key)
    spider = job.metadata.get('spider')
    job_params = dict()
    for (key, (target_key, _)) in _COPIED_FROM_META.items():
        if (target_key is None):
            target_key = key
        job_params[target_key] = job.metadata.get(key)
        add_tag = job_params.setdefault('add_tag', [])
        add_tag = list(filter((lambda x: (not x.startswith('ClonedFrom='))), add_tag))
        add_tag.append(f'ClonedFrom={job_key}')
        add_tag.extend(extra_tags)
        job_params['add_tag'] = add_tag
        if (units is not None):
            job_params['units'] = units
    self.job_params_hook(job_params)
    for (key, (target_key, transform)) in _COPIED_FROM_META.items():
        target_key = (target_key or key)
        if (transform is None):

            def transform(x):
                return x
        job_params[target_key] = transform(job_params[target_key])
    (project_id, _, _) = job_key.split('/')
    project = self.get_project((self.project_id or project_id))
    new_job = self.schedule_generic(project, spider, **job_params)
    _LOG.info('Cloned %s to %s', job_key, new_job.key)
    jobtags = job.metadata.get('tags')
    jobtags.append(f'ClonedTo={new_job.key}')
    job.metadata.update({'tags': jobtags})
    return (job, new_job)
def clone_job(self, job_key, units=None, extra_tags=None):
    extra_tags = (extra_tags or [])
    job = self.client.get_job(job_key)
    spider = job.metadata.get('spider')
    job_params = dict()
    for (key, (target_key, _)) in _COPIED_FROM_META.items():
        if (target_key is None):
            target_key = key
        job_params[target_key] = job.metadata.get(key)
        add_tag = job_params.setdefault('add_tag', [])
        add_tag = list(filter((lambda x: (not x.startswith('ClonedFrom='))), add_tag))
        add_tag.append(f'ClonedFrom={job_key}')
        add_tag.extend(extra_tags)
        job_params['add_tag'] = add_tag
        if (units is not None):
            job_params['units'] = units
    self.job_params_hook(job_params)
    for (key, (target_key, transform)) in _COPIED_FROM_META.items():
        target_key = (target_key or key)
        if (transform is None):

            def transform(x):
                return x
        job_params[target_key] = transform(job_params[target_key])
    (project_id, _, _) = job_key.split('/')
    project = self.get_project((self.project_id or project_id))
    new_job = self.schedule_generic(project, spider, **job_params)
    _LOG.info('Cloned %s to %s', job_key, new_job.key)
    jobtags = job.metadata.get('tags')
    jobtags.append(f'ClonedTo={new_job.key}')
    job.metadata.update({'tags': jobtags})
    return (job, new_job)