def init(self): self.clear() ExpandableWorkflow.activate() self.find_config() self.load_config() self.config_expander = ConfigExpander(self) ExpandableWorkflow.default_params(mem=self.mem())
def unload(cls): log.debug("Unloading ConfigMgr") ExpandableWorkflow.clear() if cls.__instance: cls.__instance.cache.close() cls.__instance = None from ymp.stage import Stage, StageStack StageStack.stacks = {} Stage.active = None
def __init__(self, root, conffiles): log.debug("Inizializing ConfigMgr") self._root = root self._conffiles = conffiles self._config = ymp.yaml.load(self._conffiles) # lazy filled by accessors self._snakefiles = None prj_cfg = self._config.get(self.KEY_PROJECTS) or {} self._datasets = { project: DatasetConfig(self, project, cfg) for project, cfg in prj_cfg.items() } ref_cfg = self._config.get(self.KEY_REFERENCES) or {} self._references = load_references(self, ref_cfg) self._workflow = ExpandableWorkflow.register_expanders( SnakemakeExpander(), RecursiveExpander(), ConfigExpander(self), CondaPathExpander(self), OverrideExpander(self), DefaultExpander(params=([], { 'mem': self.mem(), 'walltime': self.limits.default_walltime })), InheritanceExpander(), StageExpander() )
def __init__(self, root, conffiles): log.debug("Inizializing ConfigMgr") self.root = root self.conffiles = conffiles if os.path.dirname(conffiles[-1]) == root: self.cachedir = os.path.join(self.root, ".ymp") else: self.cachedir = os.path.join(XDG_CACHE_HOME, "ymp") self._config = ymp.yaml.load(conffiles, root) self.cache = cache = Cache(self.cachedir) # lazy filled by accessors self._snakefiles = None self.projects = cache.get_cache( "projects", itemloadfunc=Project, itemdata=self._config.get(self.KEY_PROJECTS) or {}, dependfiles=conffiles) self.references = cache.get_cache( "references", itemloadfunc=Reference, itemdata=self._config.get(self.KEY_REFERENCES) or {}, dependfiles=conffiles) self.pipelines = cache.get_cache( "pipelines", itemloadfunc=Pipeline, itemdata=self._config.get(self.KEY_PIPELINES) or {}, dependfiles=conffiles) ExpandableWorkflow.register_expanders( SnakemakeExpander(), RecursiveExpander(), CondaPathExpander(self), StageExpander(), ConfigExpander(self), ResourceLimitsExpander(self._config.get(self.KEY_LIMITS)), OverrideExpander(self), InheritanceExpander(), )
def activate(cls): ExpandableWorkflow.activate()
def load_workflow(self, file_path: str) -> ExpandableWorkflow: """Load the Snakefile""" workflow = ExpandableWorkflow(snakefile=file_path) workflow.include(file_path) return workflow
def reload(self): log.debug("Reloading ConfigMgr") ExpandableWorkflow.clear() self.__init__(*self.find_config())