def handles(self): ''' Handles files are assumed to reside in a subfolder called "handles" and have the suffix ".handles.yml". Returns ------- List[dict] name and description for each handles file ''' handles = list() for module_file in self.module_files: name = self._get_module_name_from_file(module_file) try: with YamlReader(self._get_handles_file(module_file)) as y: handles.append({ # FIXME: why not a NamedTuple?? 'name': name, 'description': y.read(), }) except Exception as err: logging.warning("Cannot read handles file for module `%s`: %s", name, err) continue return handles
def _create_pipe(self): with YamlReader(self.pipe_file) as f: content = f.read() try: description = PipelineDescription(**content) except TypeError as err: raise PipelineDescription('Incorrect pipeline description: %s' % str(err)) return Pipe(description)
def _create_handles(self): handles = list() for name in self._module_names: h_file = self._get_handles_file(name) try: with YamlReader(h_file) as f: content = f.read() description = HandleDescriptions(**content) h = Handles(name, description) handles.append(h) except Exception as err: logger.error("Cannot instanciate module `%s`: %s: %s", name, err.__class__.__name__, err) return handles
def _create_handles(self): handles = list() for name in self._module_names: h_file = self._get_handles_file(name) with YamlReader(h_file) as f: content = f.read() try: description = HandleDescriptions(**content) except TypeError as err: raise PipelineDescription( 'Incorrect handles description of module "%s": %s' % (name, str(err))) h = Handles(name, description) handles.append(h) return handles
def handles(self): ''' Handles files are assumed to reside in a subfolder called "handles" and have the suffix ".handles.yml". Returns ------- List[dict] name and description for each handles file ''' handles = list() for name in self.module_names: try: with YamlReader(self._get_handles_file(name)) as f: handles.append({'name': name, 'description': f.read()}) except: continue return handles
def workflow_description(self): '''tmlib.workflow.tmaps.description.WorkflowDescription: description of the workflow Note ---- When no description is available from file, a default description is provided. The type of the workflow will be determined based on :attr:`workflow_type <tmlib.models.experiment.Experiment.workflow_type>`. ''' if not os.path.exists(self._workflow_descriptor_file): logger.warn('no persistent workflow description found') with ExperimentSession(self.id) as session: exp = session.query(Experiment).get(self.id) workflow_type = exp.workflow_type logger.info('create workflow of type "%s"', workflow_type) workflow_description = WorkflowDescription(workflow_type) self.persist_workflow_description(workflow_description) with YamlReader(self._workflow_descriptor_file) as f: description = f.read() if not isinstance(description, dict): raise TypeError('Description must be a mapping.') if 'type' not in description: raise KeyError('Workflow description must have key "type".') if 'stages' not in description: raise KeyError('Workflow description must have key "stages".') workflow_description = WorkflowDescription(**description) def update_choices(arguments): for arg in arguments.iterargs(): if getattr(arg, 'get_choices', None): arg.choices = arg.get_choices(self) for stage in workflow_description.stages: for step in stage.steps: update_choices(step.batch_args) update_choices(step.submission_args) return workflow_description