def get_script_pipeline_fragment(dbm): '''Get a fragment of a pipeline Script -> AnnoTask: A Script connected to an AnnoTask Returns: :class:`lost.db.model.PipeElement`, :class:`lost.db.model.PipeElement`, :class:`lost.db.model.Pipe`: (script_element, annotation_task_element, pipeline) ''' pipe = model.Pipe(name='TestPipe') dbm.add(pipe) dbm.commit() script = model.Script(name='TestScript', path='data/pipes/test/test.py') dbm.add(script) dbm.commit() pe_s = model.PipeElement(pipe_id=pipe.idx, dtype=dtype.PipeElement.SCRIPT) pe_s.script = script dbm.add(pe_s) dbm.commit() script_result = model.Result() dbm.add(script_result) dbm.commit() anno_task = model.AnnoTask(name='TestAnnoTask') dbm.add(anno_task) pe_a = model.PipeElement(pipe_id=pipe.idx, dtype=dtype.PipeElement.ANNO_TASK) pe_a.anno_task = anno_task # pe_a.result_in.append(script_result) # pe_a.result_out.append(script_result) dbm.add(pe_a) dbm.commit() # pe_s.pe_outs.append(pe_a) # dbm.commit() # Link elements res_link_s = model.ResultLink(result_id=script_result.idx, pe_n=pe_s.idx, pe_out=pe_a.idx) res_link_a = model.ResultLink(result_id=script_result.idx, pe_n=pe_a.idx, pe_out=None) dbm.add(res_link_s) dbm.add(res_link_a) dbm.commit() return pe_s, pe_a, pipe
def __init__(self, template, data, manager_id, group_id): self.pipe = model.Pipe() self.data_map = dict() self.pe_map = dict() self.template_map = dict() self.template = template self.data = data self.manager_id = manager_id self.group_id = group_id self.timestamp_now = datetime.now() self.template_content = json.loads(template.json_template) for element in self.template_content['elements']: self.template_map[element['peN']] = element for element in self.data['elements']: self.data_map[element['peN']] = element
def create_pipe(self): try: is_debug_mode = self.data['isDebug'] except KeyError: is_debug_mode = False pipe = model.Pipe(name=self.data['name'], pipe_template_id=self.template.idx, state=state.Pipe.PENDING, is_locked=True, description=self.data['description'], manager_id=self.manager_id, is_debug_mode=is_debug_mode, group_id=self.group_id, timestamp=self.timestamp_now, start_definition=json.dumps(self.data)) self.pipe = pipe return pipe