Associate Jobs with respective cluster ids.
507961
def update_node_ids(self, sub_job_num=None):
        
        # Build condor_q and condor_history commands
        dag_id = '%s.%s' % (self.cluster_id, sub_job_num) if sub_job_num else str(self.cluster_id)
        job_delimiter = '+++'
        attr_delimiter = ';;;'

        format = [
            '-format', '"%d' + attr_delimiter + '"', 'ClusterId',
            '-format', '"%v' + attr_delimiter + '"', 'Cmd',
            '-format', '"%v' + attr_delimiter + '"', 'Args',     # Old way
            '-format', '"%v' + job_delimiter + '"', 'Arguments'  # New way
        ]
        # Get ID, Executable, and Arguments for each job that is either started to be processed or finished in the workflow
        cmd = 'condor_q -constraint DAGManJobID=={0} {1} && condor_history -constraint DAGManJobID=={0} {1}'.format(dag_id, ' '.join(format))

        # 'condor_q -constraint DAGManJobID==1018 -format "%d\n" ClusterId -format "%s\n" CMD -format "%s\n" ARGS && condor_history -constraint DAGManJobID==1018 -format "%d\n" ClusterId -format "%s\n" CMD -format "%s\n" ARGS'
        _args = [cmd]
        out, err = self._execute(_args, shell=True, run_in_job_dir=False)

        if err:
            log.error('Error while associating ids for jobs dag %s: %s', dag_id, err)
            raise HTCondorError(err)
        if not out:
            log.warning('Error while associating ids for jobs in dag %s: No jobs found for dag.', dag_id)

        try:
            # Split into one line per job
            jobs_out = out.split(job_delimiter)

            # Match node to cluster id using combination of cmd and arguments
            for node in self._node_set:
                job = node.job

                # Skip jobs that already have cluster id defined
                if job.cluster_id != job.NULL_CLUSTER_ID:
                    continue

                for job_out in jobs_out:
                    if not job_out or attr_delimiter not in job_out:
                        continue

                    # Split line by attributes
                    cluster_id, cmd, _args, _arguments = job_out.split(attr_delimiter)

                    # If new form of arguments is used, _args will be 'undefined' and _arguments will not
                    if _args == 'undefined' and _arguments != 'undefined':
                        args = _arguments.strip()

                    # If both are undefined, then there are no arguments
                    elif _args == 'undefined' and _arguments == 'undefined':
                        args = None

                    # Otherwise, using old form and _arguments will be 'undefined' and _args will not.
                    else:
                        args = _args.strip()

                    job_cmd = job.executable
                    job_args = job.arguments.strip() if job.arguments else None

                    if job_cmd in cmd and job_args == args:
                        log.info('Linking cluster_id %s to job with command and arguments: %s %s', cluster_id,
                                  job_cmd, job_args)
                        job._cluster_id = int(cluster_id)
                        break

        except ValueError as e:
            log.warning(str(e))
427295
def insert(cls, jobs_data, queue=None, statuses_no_storage=None, return_jobs=True, w=None, j=None):
        

        now = datetime.datetime.utcnow()
        for data in jobs_data:
            if data["status"] == "started":
                data["datestarted"] = now

        no_storage = (statuses_no_storage is not None) and ("started" in statuses_no_storage)
        if no_storage and return_jobs:
            for data in jobs_data:
                data["_id"] = ObjectId()  # Give the job a temporary ID
        else:
            inserted = context.connections.mongodb_jobs.mrq_jobs.insert(
                jobs_data,
                manipulate=True,
                w=w,
                j=j
            )

        if return_jobs:
            jobs = []
            for data in jobs_data:
                job = cls(data["_id"], queue=queue)
                job.set_data(data)
                job.statuses_no_storage = statuses_no_storage
                job.stored = (not no_storage)
                if data["status"] == "started":
                    job.datestarted = data["datestarted"]
                jobs.append(job)

            return jobs
        else:
            return inserted
994713
def jobs_hash
      hash = {}
      jobs.each_with_index { |job, idx| hash[idx.to_s] = job }
      hash
    end
15929
def insert_jobs(jobs, verify_jobs=True, conn=None):
    
    assert isinstance(jobs, list)
    if verify_jobs \
            and not verify({Jobs.DESCRIPTOR.name: jobs}, Jobs()):
        raise ValueError("Invalid Jobs")
    inserted = RBJ.insert(jobs).run(conn)
    return inserted
1234426
public void setAssociatedClusters(java.util.Collection<ClusterAssociatedToSchedule> associatedClusters) {
        if (associatedClusters == null) {
            this.associatedClusters = null;
            return;
        }

        this.associatedClusters = new com.amazonaws.internal.SdkInternalList<ClusterAssociatedToSchedule>(associatedClusters);
    }
1165550
def get_cluster_assignment(self):
        """"""
        plan = self.get_cluster_plan()
        assignment = {}
        for elem in plan['partitions']:
            assignment[
                (elem['topic'], elem['partition'])
            ] = elem['replicas']

        return assignment
38686
def _assign_clusters(self):
        
        self.clusters = np.array([self._closest_centroid(x) for x in self._X])
717102
protected void matchPointsToClusters(List<double[]> points) {
		sumDistance = 0;
		for (int i = 0; i < points.size(); i++) {
			double[]p = points.get(i);

			// find the cluster which is closest to the point
			int bestCluster = findBestMatch(p);

			// sum up all the points which are members of this cluster
			double[] c = workClusters.get(bestCluster);
			for (int j = 0; j < c.length; j++) {
				c[j] += p[j];
			}
			memberCount.data[bestCluster]++;
			labels.data[i] = bestCluster;
			sumDistance += bestDistance;
		}
	}
661057
def check_jobs(jobs):
    """"""
    if jobs == 0:
        raise click.UsageError("Jobs must be >= 1 or == -1")
    elif jobs < 0:
        import multiprocessing

        jobs = multiprocessing.cpu_count()
    return jobs
302010
public void setJobs(java.util.Collection<String> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<String>(jobs);
    }
263632
public void setJobRunIds(java.util.Collection<String> jobRunIds) {
        if (jobRunIds == null) {
            this.jobRunIds = null;
            return;
        }

        this.jobRunIds = new java.util.ArrayList<String>(jobRunIds);
    }
827397
def stop_jobs(self, job_ids):
    """"""
    self.lock()

    jobs = self.get_jobs(job_ids)
    for job in jobs:
      if job.status in ('executing', 'queued', 'waiting'):
        qdel(job.id, context=self.context)
        logger.info("Stopped job '%s' in the SGE grid." % job)
        job.submit()

      self.session.commit()
    self.unlock()
1170519
def _update_cluster_view(self):
        """"""
        logger.log(5, "Update the cluster view.")
        cluster_ids = [int(c) for c in self.clustering.cluster_ids]
        self.cluster_view.set_rows(cluster_ids)
848429
def create_or_update(cluster_config_file, min_workers, max_workers, no_restart,
                     restart_only, yes, cluster_name):
    """"""
    if restart_only or no_restart:
        assert restart_only != no_restart, "Cannot set both 'restart_only' " \
            "and 'no_restart' at the same time!"
    create_or_update_cluster(cluster_config_file, min_workers, max_workers,
                             no_restart, restart_only, yes, cluster_name)
380178
private <T> void deployJob(ExecutionContext<T> context, JobGraph jobGraph, Result<T> result) {
		// create or retrieve cluster and deploy job
		try (final ClusterDescriptor<T> clusterDescriptor = context.createClusterDescriptor()) {
			try {
				// new cluster
				if (context.getClusterId() == null) {
					deployJobOnNewCluster(clusterDescriptor, jobGraph, result, context.getClassLoader());
				}
				// reuse existing cluster
				else {
					deployJobOnExistingCluster(context.getClusterId(), clusterDescriptor, jobGraph, result);
				}
			} catch (Exception e) {
				throw new SqlExecutionException("Could not retrieve or create a cluster.", e);
			}
		} catch (SqlExecutionException e) {
			throw e;
		} catch (Exception e) {
			throw new SqlExecutionException("Could not locate a cluster.", e);
		}
	}
1341567
def kick_jobs(self, num_jobs):
        """"""
        with self._sock_ctx() as socket:
            self._send_message('kick {0}'.format(num_jobs), socket)
            return self._receive_id(socket)
622318
def rm(ctx, cluster_id):
    """"""
    session = create_session(ctx.obj['AWS_PROFILE_NAME'])

    client = session.client('emr')
    try:
        result = client.describe_cluster(ClusterId=cluster_id)
        target_dns = result['Cluster']['MasterPublicDnsName']
        flag = click.prompt(
            "Are you sure you want to terminate {0}: {1}? [y/Y]".format(
                cluster_id, target_dns), type=str, default='n')
        if flag.lower() == 'y':
            result = client.terminate_job_flows(JobFlowIds=[cluster_id])
    except ClientError as e:
        click.echo(e, err=True)