Execute a pipeline stage.

        :param index: Stage index.
        :param stage: Stage object.
168195
def _execute_stage(self, index, stage, stop):
        
        if stop.is_set():
            _LOGGER.info("Stopped pipeline on group %s", self._group)
            return
        _LOGGER.info(" -> Running stage '%s' on group %s", stage, self._group)
        if stage.name == 'on':
            self._group.on = True
        elif stage.name == 'off':
            self._group.on = False
        elif stage.name == 'hue':
            self._group.hue = stage.args[0]
        elif stage.name == 'saturation':
            self._group.saturation = stage.args[0]
        elif stage.name == 'color':
            self._group.color = Color(*stage.args)
        elif stage.name == 'brightness':
            self._group.brightness = stage.args[0]
        elif stage.name == 'temperature':
            self._group.temperature = stage.args[0]
        elif stage.name == 'transition':
            self._group.transition(*stage.args, **stage.kwargs)
        elif stage.name == 'white':
            self._group.white()
        elif stage.name == 'white_up':
            self._group.white_up()
        elif stage.name == 'white_down':
            self._group.white_down()
        elif stage.name == 'red_up':
            self._group.red_up()
        elif stage.name == 'red_down':
            self._group.red_down()
        elif stage.name == 'green_up':
            self._group.green_up()
        elif stage.name == 'green_down':
            self._group.green_down()
        elif stage.name == 'blue_up':
            self._group.blue_up()
        elif stage.name == 'blue_down':
            self._group.blue_down()
        elif stage.name == 'night_light':
            self._group.night_light()
        elif stage.name == 'flash':
            self._group.flash(**stage.kwargs)
        elif stage.name == 'repeat':
            self._repeat(index, stage, stop)
        elif stage.name == 'wait':
            time.sleep(*stage.args)
        elif stage.name == 'callback':
            stage.args[0](*stage.args[1:], **stage.kwargs)
230065
private void tryCreateExternalQueue(int index) {
        AuxState aux;
        if ((aux = auxState) != null && index >= 0) {
            WorkQueue q = new WorkQueue(this, null);
            q.config = index;
            q.scanState = ~UNSIGNALLED;
            q.qlock = 1;                   // lock queue
            boolean installed = false;
            aux.lock();
            try {                          // lock pool to install
                WorkQueue[] ws;
                if ((ws = workQueues) != null && index < ws.length &&
                    ws[index] == null) {
                    ws[index] = q;         // else throw away
                    installed = true;
                }
            } finally {
                aux.unlock();
            }
            if (installed) {
                try {
                    q.growArray();
                } finally {
                    q.qlock = 0;
                }
            }
        }
    }
666723
function stage(transformer, opts) {
  var stage = transformer.metadata.stage;
  if (stage != null && stage >= opts.stage) return true;
}
511243
def _add_stage(self, name):
        
        def stage_func(self, *args, **kwargs):
            """ Stage function.

            :param args: Positional arguments.
            :param kwargs: Keyword arguments.
            :return: Pipeline (for method chaining).
            """
            self._pipe.append(Stage(name, args, kwargs))
            return self

        setattr(Pipeline, name, stage_func)
481129
function(index) {
            var step;

            if (!this.steps[index]) {
                if (this.config.loop && this._loops < this.config.maxLoops) {
                    this._loops++;
                    step = this.steps[this._current = 0];
                } else {
                    return false;
                }
            } else {
                step = this.steps[index];
            }

            if (step.preload && !step.preloaded) {
                this._handlePreload(step.preload, function() {
                    step.preloaded = true;
                    this._setNext(step.nextDelay);

                    if(step.fn) {
                        step.fn.call(this, step);
                    }

                }.bind(this));
            } else {
                this._setNext(step.nextDelay);

                if(step.fn) {
                    step.fn.call(this, step);
                }
            }

            if (step.autoDestroy) {
                var i = this.steps.indexOf(step);
                this._current = i;
                this._recentDestroy = true;
                this.steps.splice(i, 1);
            }
        }
28427
public void fadeToLayer(int index) {
    mTransitionState = TRANSITION_STARTING;
    Arrays.fill(mIsLayerOn, false);
    mIsLayerOn[index] = true;
    invalidateSelf();
  }
216618
def render(self, ctx=None):
        '''
        
        '''
        self._initialize()
        times = self._min_times
        if self._mutating() and self._in_repeat_stage():
            times += (self._current_index) * self._step
        rendered = super(Repeat, self).render(ctx)
        self.set_current_value(rendered * times)
        return self._current_rendered
950921
async def execute(self, *, return_exceptions=False):
        
        assert not self._done, "Pipeline already executed. Create new one."
        self._done = True

        if self._pipeline:
            if isinstance(self._pool_or_conn, AbcPool):
                async with self._pool_or_conn.get() as conn:
                    return await self._do_execute(
                        conn, return_exceptions=return_exceptions)
            else:
                return await self._do_execute(
                    self._pool_or_conn,
                    return_exceptions=return_exceptions)
        else:
            return await self._gather_result(return_exceptions)
650096
def _pass_uid(self):
        

        for stage in self._stages:
            stage.parent_pipeline['uid'] = self._uid
            stage.parent_pipeline['name'] = self._name
            stage._pass_uid()
1132262
public function onAfterWrite() {
        if (\Config::inst()->get('ElasticSearch', 'disabled') || !$this->owner->autoIndex()) {
            return;
        }
        $stage = \Versioned::current_stage();
        
		$this->service->index($this->owner, $stage);
	}
318230
def set_stage_index(self):
        """"""
        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')
        stage = self.annot.get_stage_for_epoch(window_start, window_length)
        #lg.info('winstart: ' + str(window_start) + ', stage: ' + str(stage))

        if stage is None:
            self.idx_stage.setCurrentIndex(-1)
        else:
            self.idx_stage.setCurrentIndex(STAGE_NAME.index(stage))
462546
def start(self):
        
        # top - > bottom of pipeline
        pipers = self.postorder()
        # 
        for piper in pipers:
            piper.start(stages=(0, 1))
        for piper in pipers:
            piper.start(stages=(2,))
988792
function insertQueueStep(step, index) {
  if (index && index < currentSteps.length) {
    return currentSteps.splice(index, 0, step);
  }

  return currentSteps.push(step);
}
1294847
def run(self):
        """"""
        last_status = ''
        # lambda is used to avoid http://bugs.python.org/issue30473 in py36
        start_times = defaultdict(lambda: datetime.datetime.now())
        max_stage_id = -1

        status = self.sc.statusTracker()
        while True:
            with self.condition:
                if self.sc._jsc is None or not self.alive:
                    # End the thread
                    self.paused = True
                    break
                elif self.paused:
                    # Pause the thread
                    self.condition.wait()
            stage_ids = status.getActiveStageIds()
            progressbar_list = []
            # Only show first 3
            stage_counter = 0
            current_max_stage = max_stage_id
            for stage_id in stage_ids:
                stage_info = status.getStageInfo(stage_id)
                if stage_info and stage_info.numTasks > 0:
                    # Set state variables used for flushing later
                    current_max_stage = stage_id
                    stage_counter += 1
                    td = datetime.datetime.now() - start_times[stage_id]
                    s = _format_stage_info(self.bar_width, stage_info, td, self.timedelta_formatter)
                    progressbar_list.append(s)
                if stage_counter == 3:
                    break

            # Ensure that when we get a new maximum stage id we print a \n
            # to make the progress bar go on to the next line.
            if current_max_stage > max_stage_id:
                if last_status != '':
                    sys.stderr.write("\n")
                sys.stderr.flush()
                max_stage_id = current_max_stage

            new_status = ' '.join(progressbar_list)
            if new_status != last_status:
                sys.stderr.write("\r" + new_status)
                sys.stderr.flush()
                last_status = new_status
            time.sleep(self.sleep_time)
869651
def workflow_move_stage(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/moveStage' % object_id, input_params, always_retry=always_retry, **kwargs)
394420
def workflow_update_stage_executable(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/updateStageExecutable' % object_id, input_params, always_retry=always_retry, **kwargs)
1144003
def _repeat(self, index, stage, stop):
        
        times = None
        if 'iterations' in stage.kwargs:
            times = stage.kwargs['iterations'] - 1
        stages_back = 1
        if 'stages' in stage.kwargs:
            stages_back = stage.kwargs['stages']
        i = 0
        while i != times:
            if stop.is_set():
                break
            for forward in range(stages_back):
                if stop.is_set():
                    break
                stage_index = index - stages_back + forward
                self._execute_stage(stage_index, self._pipe[stage_index], stop)
            i += 1