:param phase:
        :param stage:
        :param sources: Source names or destination table names.
        :return:
508847
def build(self, sources=None, tables=None, stage=None, force=False):
        

        from operator import attrgetter
        from itertools import groupby
        from .concurrent import build_mp, unify_mp
        from ambry.bundle.events import TAG

        self.log('==== Building ====')
        self.state = self.STATES.BUILDING
        self.commit()

        class SourceSet(object):
            """Container for sources that can reload them after they get expired from the session"""
            def __init__(self, bundle, v):
                self.bundle = bundle
                self.sources = v
                self._s_vids = [s.vid for s in self.sources]

            def reload(self):
                self.sources = [self.bundle.source(vid) for vid in self._s_vids]

            def __iter__(self):
                for s in self.sources:
                    yield s

            def __len__(self):
                return len(self._s_vids)

        self._run_events(TAG.BEFORE_BUILD, 0)

        resolved_sources = SourceSet(self, self._resolve_sources(sources, tables, stage=stage,
                                                                 predicate=lambda s: s.is_processable))
        with self.progress.start('build', stage, item_total=len(resolved_sources)) as ps:

            if len(resolved_sources) == 0:
                ps.update(message='No sources', state='skipped')
                self.log('No processable sources, skipping build stage {}'.format(stage))
                return True

            if not self.pre_build(force):
                ps.update(message='Pre-build failed', state='skipped')
                return False

            if force:
                self._reset_build(resolved_sources)

            resolved_sources.reload()

            e = [
                (stage, SourceSet(self, list(stage_sources)))
                for stage, stage_sources in groupby(sorted(resolved_sources, key=attrgetter('stage')),
                                                    attrgetter('stage'))

                ]

            for stage, stage_sources in e:

                stage_sources.reload()

                for s in stage_sources:
                    s.state = self.STATES.WAITING
                self.commit()

                stage_sources.reload()

                self.log('Processing {} sources, stage {} ; first 10: {}'
                         .format(len(stage_sources), stage, [x.name for x in stage_sources.sources[:10]]))
                self._run_events(TAG.BEFORE_BUILD, stage)

                if self.multi:

                    try:
                        # The '1' for chunksize ensures that the subprocess only gets one
                        # source to build. Combined with maxchildspertask = 1 in the pool,
                        # each process will only handle one source before exiting.

                        args = [(self.identity.vid, stage, source.vid, force) for source in stage_sources]
                        pool = self.library.process_pool(limited_run=self.limited_run)
                        r = pool.map_async(build_mp, args, 1)
                        completed_sources = r.get()

                        ps.add('Finished MP building {} sources. Starting MP coalescing'
                               .format(len(completed_sources)))

                        partition_names = [(self.identity.vid, k) for k, v
                                           in self.collect_segment_partitions().items()]

                        r = pool.map_async(unify_mp, partition_names, 1)

                        completed_partitions = r.get()

                        ps.add('Finished MP coalescing {} partitions'.format(len(completed_partitions)))

                        pool.close()
                        pool.join()

                    except KeyboardInterrupt:
                        self.log('Got keyboard interrrupt; terminating workers')
                        pool.terminate()

                else:

                    for i, source in enumerate(stage_sources):
                        id_ = ps.add(message='Running source {}'.format(source.name),
                                     source=source, item_count=i, state='running')

                        self.build_source(stage, source, ps, force=force)

                        ps.update(message='Finished processing source', state='done')

                        # This bit seems to solve a problem where the records from the ps.add above
                        # never gets closed out.
                        ps.get(id_).state = 'done'
                        self.progress.commit()

                    self.unify_partitions()

                self._run_events(TAG.AFTER_BUILD, stage)

        self.state = self.STATES.BUILT
        self.commit()

        self._run_events(TAG.AFTER_BUILD, 0)

        self.close_session()

        self.log('==== Done Building ====')
        self.buildstate.commit()
        self.state = self.STATES.BUILT
        self.commit()
        return True
1223877
def phase(self, session):
        
        sp_key, _ = self._keygen(session)
        if self.r.sismember(sp_key, session.meepo_unique_id):
            return "prepare"
        else:
            return "commit"
161284
def update_pipeline_stage(self, stage):
		'''
		'''
		#req sanity check
		payload = None
		if  type(stage) is not StreakStage:
			return requests.codes.bad_request, None

		payload = stage.to_dict(rw = True)
	
		#print(new_pl.attributes)
		#print(new_pl.to_dict())
		#raw_input()
		try:
			uri = '/'.join([self.api_uri,
							self.pipelines_suffix,
							stage.attributes['pipelineKey'],
							self.stages_suffix,
							stage.attributes['key']
							])
		except KeyError:
			return requests.codes.bad_request, None
	
		code, data = self._req('post', uri , json.dumps(payload))
		
		return code, data
767
def set_vars_to_stage(stage, variables)
      # convert to array using VAR=value
      vars_array = variables.map{|k,v| "#{k}=#{v}" }
      Capistrano::Application.invoke(stage)
      Capistrano::Application.invoke("rbenv:vars:set", *vars_array)
    end
1025575
def _get_stage_variables(stage_variables):
    '''
    
    '''
    ret = dict()
    if stage_variables is None:
        return ret

    if isinstance(stage_variables, six.string_types):
        if stage_variables in __opts__:
            ret = __opts__[stage_variables]
        master_opts = __pillar__.get('master', {})
        if stage_variables in master_opts:
            ret = master_opts[stage_variables]
        if stage_variables in __pillar__:
            ret = __pillar__[stage_variables]
    elif isinstance(stage_variables, dict):
        ret = stage_variables

    if not isinstance(ret, dict):
        ret = dict()

    return ret
1191758
def on_each_source(self):
        
        return (self.info.applytosources and
                self.info.applytosources == self.source_ids)
923428
def stages(self):
        
        if self._stage_manager is None:
            self._stage_manager = StageManager(session=self._session)
        return self._stage_manager
1196259
def _stage_output_files(self, file_mapping, dry_run=True):
        """"""
        # print ("Staging output ", file_mapping)
        if self._file_stage is None:
            return
        self._file_stage.copy_from_scratch(file_mapping, dry_run)
730814
def set_phases(self, literals=[]):
        

        if self.maplesat:
            pysolvers.maplecm_setphases(self.maplesat, literals)
750307
def stage_tc_batch(self, owner, staging_data):
        
        batch = self.tcex.batch(owner)
        for group in staging_data.get('group') or []:
            # add to redis
            variable = group.pop('variable', None)
            path = group.pop('path', None)
            data = self.path_data(group, path)
            # update group data
            if group.get('xid') is None:
                # add xid if one doesn't exist
                group['xid'] = self.stage_tc_batch_xid(group.get('type'), group.get('name'), owner)
            # add owner name
            group['ownerName'] = owner
            # add to batch
            batch.add_group(group)
            # create tcentity
            if variable is not None and data is not None:
                self.stage_redis(variable, self.stage_tc_group_entity(data))
        for indicator in staging_data.get('indicator') or []:
            # add to redis
            variable = indicator.pop('variable', None)
            path = indicator.pop('path', None)
            if indicator.get('xid') is None:
                indicator['xid'] = self.stage_tc_batch_xid(
                    indicator.get('type'), indicator.get('summary'), owner
                )
            indicator['ownerName'] = owner
            # add to batch after extra data has been popped
            batch.add_indicator(indicator)
            data = self.path_data(dict(indicator), path)
            if variable is not None and data is not None:
                # if isinstance(data, (dict)):
                # tcentity uses value as the name
                #     data['value'] = data.pop('summary')
                self.stage_redis(variable, self.stage_tc_indicator_entity(data))
        # submit batch
        batch_results = batch.submit()
        self.log.debug('[stage] Batch Results: {}'.format(batch_results))
        for error in batch_results.get('errors') or []:
            self.log.error('[stage] {}'.format(error))
195417
def describe_api_stages(restApiId, deploymentId, region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        stages = conn.get_stages(restApiId=restApiId, deploymentId=deploymentId)
        return {'stages': [_convert_datetime_str(stage) for stage in stages['item']]}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
14977
def input_stages(self):
        """"""
        if self._properties.get("inputStages") is None:
            return []
        return [
            _helpers._int_or_none(entry)
            for entry in self._properties.get("inputStages")
        ]
758099
def get_segments(self):
        """"""
        # Chunking
        chunk = {k: v.isChecked() for k, v in self.chunk.items()}
        lock_to_staging = self.lock_to_staging.get_value()
        epoch_dur = self.epoch_param['dur'].get_value()
        epoch_overlap = self.epoch_param['overlap_val'].value()
        epoch_step = None
        epoch = None

        if chunk['epoch']:
            if lock_to_staging:
                epoch = 'locked'
            else:
                epoch = 'unlocked'

                if self.epoch_param['step'].isChecked():
                    epoch_step = self.epoch_param['step_val'].get_value()

                    if epoch_step <= 0:
                        epoch_step = 0.1

        # Which channel(s)
        self.chan = self.get_channels() # chan name without group
        if not self.chan:
            return

        # Which event type(s)
        chan_full = None
        evt_type = None

        if chunk['event']:

            if self.evt_chan_only.get_value():
                chan_full = [i + ' (' + self.idx_group.currentText() + ''
                           ')' for i in self.chan]

            evt_type = self.idx_evt_type.selectedItems()
            if not evt_type:
                return
            else:
                evt_type = [x.text() for x in evt_type]

        # Which cycle(s)
        cycle = self.cycle = self.get_cycles()

        # Which stage(s)
        stage = self.idx_stage.selectedItems()
        if not stage:
            stage = self.stage = None
        else:
            stage = self.stage = [
                    x.text() for x in self.idx_stage.selectedItems()]

        # Concatenation
        cat = {k: v.get_value() for k, v in self.cat.items()}
        cat = (int(cat['cycle']), int(cat['stage']),
               int(cat['discontinuous']), int(cat['evt_type']))

        # Artefact event rejection
        reject_event = self.reject_event.get_value()
        if reject_event == 'channel-specific':
            chan_full = [i + ' (' + self.idx_group.currentText() + ''
                           ')' for i in self.chan]
            reject_artf = True
        elif reject_event == 'from any channel':
            reject_artf = True
        else:
            reject_artf = False

        # Other options
        min_dur = self.min_dur.get_value()
        reject_epoch = self.reject_epoch.get_value()

        # Generate title for summary plot
        self.title = self.make_title(chan_full, cycle, stage, evt_type)

        segments = fetch(self.parent.info.dataset,
                         self.parent.notes.annot, cat=cat,
                         evt_type=evt_type, stage=stage, cycle=cycle,
                         chan_full=chan_full, epoch=epoch,
                         epoch_dur=epoch_dur, epoch_overlap=epoch_overlap,
                         epoch_step=epoch_step, reject_epoch=reject_epoch,
                         reject_artf=reject_artf, min_dur=min_dur)

        return segments
641781
def _get_validated_stages(stages):
    
    if not isinstance(stages, list):
        raise WorkflowBuilderException("Stages must be specified as a list of dictionaries")
    validated_stages = []
    for index, stage in enumerate(stages):
        validated_stages.append(_get_validated_stage(stage, index))
    return validated_stages
783462
private function assertThereIsAtMostOneConnectorPerStage($stageName, $stageConnectors)
    {
        if (count($stageConnectors) > 1) {
            $connectorClasses = [];
            foreach ($stageConnectors as $connector) {
                $connectorClasses[] = $connector->getStepFqcn();
            }
            $connectors = implode(',', $connectorClasses);

            throw new PipelineBuildingException(
                "Multiple stage connectors found for stage '$stageName'. Please remove one of: $connectors."
            );
        }
    }
742615
def get_stages(self):
        '''
        
        '''
        sequence = self.get_sequence()
        return {
            'current': [e.dst.get_name() for e in sequence],
            'stages': {e.src.get_name(): [e.dst.get_name()] for e in sequence}
        }
465875
protected void beginStage(final String header, final String stage,
            final String numStages) {
        boolean print = getPhaseConfiguration().isVerbose();
        if (print) {
            StringBuilder bldr = new StringBuilder();
            bldr.append(INDENT);
            bldr.append("Stage ");
            bldr.append(stage);
            bldr.append(" of ");
            bldr.append(numStages);
            bldr.append(": ");
            bldr.append(header);
            reportable.output(bldr.toString());
        }
    }