Creates a new job instance. Takes the arguments that will be
 passed to the perform method.
 Returns a hash with the job data that can safely be passed to the
 queuing adapter.
498839
def serialize
      {
        "job_class"  => self.class.name,
        "job_id"     => job_id,
        "provider_job_id" => provider_job_id,
        "queue_name" => queue_name,
        "priority"   => priority,
        "arguments"  => serialize_arguments_if_needed(arguments),
        "executions" => executions,
        "exception_executions" => exception_executions,
        "locale"     => I18n.locale.to_s,
        "timezone"   => Time.zone.try(:name),
        "enqueued_at" => Time.now.utc.iso8601
      }
    end
398004
def create_job(self, phases, name=None, input=None):
        
        log.debug('CreateJob')
        path = '/%s/jobs' % self.account
        body = {"phases": phases}
        if name:
            body["name"] = name
        if input:
            body["input"] = input
        headers = {"Content-Type": "application/json"}
        res, content = self._request(path,
                                     "POST",
                                     body=json.dumps(body),
                                     headers=headers)
        if res["status"] != '201':
            raise errors.MantaAPIError(res, content)
        location = res["location"]
        assert res["location"]
        job_id = res["location"].rsplit('/', 1)[-1]
        return job_id
309607
def create_job(db, datadir):
    
    calc_id = get_calc_id(db, datadir) + 1
    job = dict(id=calc_id, is_running=1, description='just created',
               user_name='openquake', calculation_mode='to be set',
               ds_calc_dir=os.path.join('%s/calc_%s' % (datadir, calc_id)))
    return db('INSERT INTO job (?S) VALUES (?X)',
              job.keys(), job.values()).lastrowid
845013
def create
			@instance = get_model.new(instance_params)

			respond_to do |format|
				if @instance.save
					flash[:notice] = "#{get_model.name} was successfully created."
					format.html { render 'quick_dry/show' }
					format.json { render json:@instance, status: :created, location: get_url }
				else
					format.html { render 'quick_dry/new' }
					format.json { render json:@instance.errors, status: :unprocessable_entity }
				end
			end
		end
270961
def copy_job_order(job, job_order_object):
    # type: (Any, Any) -> Any
    """"""
    if not hasattr(job, "tool"):
        # direct command line tool execution
        return job_order_object
    customised_job = {}  # new job object for RO
    for each, i in enumerate(job.tool["inputs"]):
        with SourceLine(job.tool["inputs"], each, WorkflowException,
                        _logger.isEnabledFor(logging.DEBUG)):
            iid = shortname(i["id"])
            if iid in job_order_object:
                customised_job[iid] = copy.deepcopy(job_order_object[iid])
                # add the input element in dictionary for provenance
            elif "default" in i:
                customised_job[iid] = copy.deepcopy(i["default"])
                # add the default elements in the dictionary for provenance
            else:
                pass
    return customised_job
74941
def create(self, name, data):
        
        return self._update('/job-binary-internals/%s' %
                            urlparse.quote(name.encode('utf-8')), data,
                            'job_binary_internal', dump_json=False)
745112
def create_new_upgrade_job_from_an_existing_job(user):
    """"""
    values = schemas.job_upgrade.post(flask.request.json)

    values.update({
        'id': utils.gen_uuid(),
        'created_at': datetime.datetime.utcnow().isoformat(),
        'updated_at': datetime.datetime.utcnow().isoformat(),
        'etag': utils.gen_etag(),
        'status': 'new'
    })

    original_job_id = values.pop('job_id')
    original_job = v1_utils.verify_existence_and_get(original_job_id,
                                                     models.JOBS)
    if not user.is_in_team(original_job['team_id']):
        raise dci_exc.Unauthorized()

    # get the remoteci
    remoteci_id = str(original_job['remoteci_id'])
    remoteci = v1_utils.verify_existence_and_get(remoteci_id,
                                                 models.REMOTECIS)
    values.update({'remoteci_id': remoteci_id})

    # get the associated topic
    topic_id = str(original_job['topic_id'])
    topic = v1_utils.verify_existence_and_get(topic_id, models.TOPICS)

    values.update({
        'user_agent': flask.request.environ.get('HTTP_USER_AGENT'),
        'client_version': flask.request.environ.get(
            'HTTP_CLIENT_VERSION'
        ),
    })

    next_topic_id = topic['next_topic_id']

    if not next_topic_id:
        raise dci_exc.DCIException(
            "topic %s does not contains a next topic" % topic_id)

    # instantiate a new job in the next_topic_id
    # todo(yassine): make possible the upgrade to choose specific components
    values = _build_job(next_topic_id, remoteci, [], values,
                        previous_job_id=original_job_id)

    return flask.Response(json.dumps({'job': values}), 201,
                          headers={'ETag': values['etag']},
                          content_type='application/json')
108443
def perform(id, method, *args)
      if id
        begin
          self.class.find(id).send(method, *args)
        rescue ActiveRecord::RecordNotFound
          # If the record was deleted after the job was created, swallow it
        end
      else
        self.class.send(method, *args)
      end
    end
465671
function queue (job, value, put) {
      var ts = timestamp()
      var key = toKey(job, ts)

      var id = hash(job+':'+value)
      if(pending[id]) return null //this job is already queued.
      pending[id] = Date.now()

      if(put === false) {
        //return the job to be queued, to include it in a batch insert.
          return {
          type: 'put', 
          key: Buffer.isBuffer(key) ? key : new Buffer(key), 
          value: Buffer.isBuffer(key) ? value : new Buffer(value)
        }
      } else {
        db.put(key, value)
      }
    }
362630
def create(attributes_hash)
      #the tap method allows preconfigured methods and values to
      #be associated with the instance during instantiation while also automatically returning
      #the object after its creation is concluded.
      self.new.tap do |card|
        attributes_hash.each do |key, value|
          #sending the new instance the key name as a setter with the value
          card.send("#{key}=", value)
          #string interpolation is used as the method doesn't know the key name yet
          #but an = sign is implemented into the string in order to asssociate it as a setter
        end
        #saves the new instance into the database
        card.save
      end
    end
72948
protected function createPayload($job, $data = '', $queue = null)
	{
		if ($job instanceof Closure)
		{
			return json_encode($this->createClosurePayload($job, $data));
		}
		elseif (is_object($job))
		{
			return json_encode([
				'job' => 'Illuminate\Queue\CallQueuedHandler@call',
				'data' => ['command' => serialize(clone $job)],
			]);
		}

		return json_encode($this->createPlainPayload($job, $data));
	}
1366541
def _create_job_info(self, job_dir):
        
        meta = self._build_job_meta(job_dir)

        self.logger.debug("Create job: %s" % meta)

        job_record = JobRecord.from_json(meta)
        job_record.save()
417882
def create_new_update_job_from_an_existing_job(user, job_id):
    """"""

    values = {
        'id': utils.gen_uuid(),
        'created_at': datetime.datetime.utcnow().isoformat(),
        'updated_at': datetime.datetime.utcnow().isoformat(),
        'etag': utils.gen_etag(),
        'status': 'new'
    }

    original_job_id = job_id
    original_job = v1_utils.verify_existence_and_get(original_job_id,
                                                     models.JOBS)

    if not user.is_in_team(original_job['team_id']):
        raise dci_exc.Unauthorized()

    # get the remoteci
    remoteci_id = str(original_job['remoteci_id'])
    remoteci = v1_utils.verify_existence_and_get(remoteci_id,
                                                 models.REMOTECIS)
    values.update({'remoteci_id': remoteci_id})

    # get the associated topic
    topic_id = str(original_job['topic_id'])
    v1_utils.verify_existence_and_get(topic_id, models.TOPICS)

    values.update({
        'user_agent': flask.request.environ.get('HTTP_USER_AGENT'),
        'client_version': flask.request.environ.get(
            'HTTP_CLIENT_VERSION'
        ),
    })

    values = _build_job(topic_id, remoteci, [], values,
                        update_previous_job_id=original_job_id)

    return flask.Response(json.dumps({'job': values}), 201,
                          headers={'ETag': values['etag']},
                          content_type='application/json')
325003
def perform_job(*args)
      @task_logger.info('Creating job')

      job = @job_class.new(*args)
      Config.current_job = job

      job.task_id = @task_id
      job.task_checkpoint # cancelled in the queue?

      run_checkpointing

      @task_logger.info("Performing task: #{@task.inspect}")

      @task.timestamp = Time.now
      @task.started_at = Time.now
      @task.checkpoint_time = Time.now
      @task.save

      result = job.perform

      @task_logger.info('Done')
      finish_task(:done, result)

    rescue Bosh::Director::TaskCancelled => e
      log_exception(e)
      @task_logger.info("Task #{@task.id} cancelled")
      finish_task(:cancelled, 'task cancelled')
    rescue Exception => e
      log_exception(e)
      @task_logger.error("#{e}\n#{e.backtrace.join("\n")}")
      finish_task(:error, e)
    end
144187
def enqueue(self, job):
    
    if job.queue_name():
      raise EnqueueError("job %s already queued!" % job.job_id)
    new_len = self.redis.lpush(self.queue_name, job.serialize())
    job.notify_queued(self)
    return new_len
1166627
def create_hash(response)
      begin
        JSON.parse response
      rescue JSON::ParserError
        response
      rescue StandardError
        response
      end
    end
199015
def getnjobs(self, key, **kwargs):
        

        return self.get(key, cast_func=parse_n_jobs, **kwargs)