Loads a workflow identified by id_code
        id_code - unique identifier, previously must have called save with same id_code
557324
def load(self, id_code):
        
        filestream = open('{0}/{1}'.format(self.data_path, id_code), 'rb')
        workflow = pickle.load(filestream)
        return workflow
963080
def save(self, fname, mode=None, validate=True, wd=False, inline=False,
             relative=True, pack=False, encoding='utf-8'):
        
        super(WorkflowGenerator, self).save(fname,
                                            mode=mode,
                                            validate=validate,
                                            wd=wd,
                                            inline=inline,
                                            relative=relative,
                                            pack=pack,
                                            encoding=encoding)
325215
def transaction_commit(self, transaction_id, **kwargs):
        
        if transaction_id not in self.__transactions:
            raise workflows.Error("Attempting to commit unknown transaction")
        self.log.debug("Committing transaction %s", transaction_id)
        self.__transactions.remove(transaction_id)
        self._transaction_commit(transaction_id, **kwargs)
782596
def save(self, typ, data):
        
        if 'id' in data:
            return self._load(self._request(typ, id=data['id'], method='PUT', data=data))

        return self.create(typ, data)
860810
def find_workflow(workflow_name, custom_id)
      params = { ATTR_ID => custom_id, ATTR_NAME => workflow_name }
      params[ATTR_PROG] = PROG
      data = @http.get(instance_website_url(params))['data']
      data && @properties.object_from(
        data['name'],
        @serializer.decode(data['properties'])
      )
    rescue Zenaton::InternalError => exception
      return nil if exception.message =~ /No workflow instance found/
      raise exception
    end
514049
def register(workflow_id, workflow_version):
    """"""
    name = "workflow_definitions:{}:{}".format(workflow_id, workflow_version)
    workflow_definition = dict(id=workflow_id, version=workflow_version,
                               stages=[])
    # DB.set_hash_values(name, workflow_definition)
    DB.save_dict(name, workflow_definition, hierarchical=False)
967115
public Workflow getWorkflow(String workflowId, boolean includeTasks) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        WorkflowPb.Workflow workflow = stub.getWorkflowStatus(
                WorkflowServicePb.GetWorkflowStatusRequest.newBuilder()
                        .setWorkflowId(workflowId)
                        .setIncludeTasks(includeTasks)
                        .build()
        );
        return protoMapper.fromProto(workflow);
    }
1305381
def execute(workflow_service = nil)
      # If we're not given an explicit workflow service for this execution
      # request, use the one defined when we were created.
      workflow_service = @service if workflow_service.nil?
      # If we still have a nil workflow_service, go home.
      fail(IOError, ERR[:no_workflow_service_defined]) if workflow_service.nil?
      # Make sure we didn't forget any required parameters
      verify_parameters
      # Let's get this thing running!
      @execution_id = workflow_service.execute_workflow(@id, input_parameter_json)
    end
1213773
public String updateWorkflow(Workflow workflow) {
        executionDAO.updateWorkflow(workflow);
        indexDAO.indexWorkflow(workflow);
        return workflow.getWorkflowId();
    }
1060934
def commit_workflow(self, workflow_id):
        
        # TODO: We should also be committing the Stream definitions if there are new ones

        workflow = self.workflows[workflow_id]

        with switch_db(WorkflowDefinitionModel, "hyperstream"):
            workflows = WorkflowDefinitionModel.objects(workflow_id=workflow_id)
            if len(workflows) > 0:
                logging.warn("Workflow with id {} already exists in database".format(workflow_id))
                return

            factors = []
            for f in workflow.factors:
                tool = f.tool.get_model()

                if isinstance(f, Factor):
                    sources = [s.node_id for s in f.sources] if f.sources else []
                    sinks = [f.sink.node_id]
                    alignment_node = f.alignment_node.node_id if f.alignment_node else None
                    splitting_node = None
                    output_plate = None

                elif isinstance(f, MultiOutputFactor):
                    sources = [f.source.node_id] if f.source else []
                    sinks = [f.sink.node_id]
                    alignment_node = None
                    splitting_node = f.splitting_node.node_id if f.splitting_node else None
                    output_plate = None

                elif isinstance(f, NodeCreationFactor):
                    sources = [f.source.node_id] if f.source else []
                    sinks = []
                    alignment_node = None
                    splitting_node = None
                    output_plate = f.output_plate

                else:
                    raise NotImplementedError("Unsupported factor type")

                if output_plate:
                    output_plate_copy = deepcopy(output_plate)
                    if 'parent_plate' in output_plate_copy:
                        del output_plate_copy['parent_plate']
                else:
                    output_plate_copy = None

                factor = FactorDefinitionModel(
                    tool=tool,
                    factor_type=f.__class__.__name__,
                    sources=sources,
                    sinks=sinks,
                    alignment_node=alignment_node,
                    splitting_node=splitting_node,
                    output_plate=output_plate_copy
                )

                factors.append(factor)

            nodes = []
            for n in workflow.nodes.values():
                nodes.append(NodeDefinitionModel(
                    stream_name=n.node_id,
                    plate_ids=n.plate_ids,
                    channel_id=n._channel.channel_id
                ))

            workflow_definition = WorkflowDefinitionModel(
                workflow_id=workflow.workflow_id,
                name=workflow.name,
                description=workflow.description,
                nodes=nodes,
                factors=factors,
                owner=workflow.owner,
                online=workflow.online,
                monitor=workflow.monitor
            )

            workflow_definition.save()

        with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
            workflow_status = WorkflowStatusModel(
                workflow_id=workflow.workflow_id,
                last_updated=utcnow(),
                last_accessed=utcnow(),
                requested_intervals=[]
            )

            workflow_status.save()

        self.uncommitted_workflows.remove(workflow_id)
        logging.info("Committed workflow {} to database".format(workflow_id))
161707
def _extract_from_subworkflow(vs, step):
    
    substep_ids = set([x.name for x in step.workflow])
    out = []
    for var in vs:
        internal = False
        parts = var["id"].split("/")
        if len(parts) > 1:
            if parts[0] in substep_ids:
                internal = True
        if not internal:
            var.pop("source", None)
            out.append(var)
    return out
936010
def save(self, obj, run_id):
        
        id_code = self.generate_save_identifier(obj, run_id)
        self.store.save(obj, id_code)
822267
def load(uid=None):
    
    app.logger.info("GET /sync route with id: %s" % uid)

    try:
        user = Participant.query.\
            filter(Participant.uniqueid == uid).\
            one()
    except exc.SQLAlchemyError:
        app.logger.error("DB error: Unique user not found.")

    try:
        resp = json.loads(user.datastring)
    except:
        resp = {
            "condition": user.cond,
            "counterbalance": user.counterbalance,
            "assignmentId": user.assignmentid,
            "workerId": user.workerid,
            "hitId": user.hitid,
            "bonus": user.bonus
        }

    return jsonify(**resp)
627977
def execute_workflow(id, parameter_json)
      path = "/workflows/#{id}/executions/"
      response = @session.post(path, parameter_json)
      # Execution ID is the final component in the Location header URL, so
      # chop off the front, then pull off any trailing /
      response.headers[:location].gsub(%r{^.*/executions/}, '').gsub(%r{\/$}, '')
    end
1136314
def reload
      old_id = @id
      @id = nil

      if @data_dir
        # Read the id file from the data directory if it exists as the
        # ID for the pre-existing physical representation of this machine.
        id_file = @data_dir.join("id")
        id_content = id_file.read.strip if id_file.file?
        if !id_content.to_s.empty?
          @id = id_content
        end
      end

      if @id != old_id && @provider
        # It changed, notify the provider
        @provider.machine_id_changed
      end

      @id
    end
746313
def create_unique_disk_operation_id(dd, offsets):
        # type: (blobxfer.models.download.Descriptor,
        #        blobxfer.models.download.Offsets) -> str
        
        return ';'.join(
            (str(dd.final_path), dd.entity._client.primary_endpoint,
             dd.entity.path, str(offsets.range_start))
        )
356184
public void retryLastFailedTask(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        postForEntityWithUriVariablesOnly("workflow/{workflowId}/retry", workflowId);
    }