[docs]classTemplateRebaser(ErsiliaBase):""" Class for rebasing model repositories with a template repository. Parameters ---------- model_id : str The ID of the model to be rebased. template_repo : str, optional The name of the template repository. Default is 'eos-template'. config_json : str, optional Path to the configuration JSON file. credentials_json : str, optional Path to the credentials JSON file. """def__init__(self,model_id:str,template_repo="eos-template",config_json=None,credentials_json=None,):ErsiliaBase.__init__(self,config_json=config_json,credentials_json=credentials_json)self.model_id=model_idself.template_repo=template_repoself.root=os.path.abspath(self._tmp_dir)self.cwd=os.getcwd()self.model_path=os.path.join(self.root,self.model_id)self.template_path=os.path.join(self.root,self.template_repo)self.clean()self.file_folder_rebaser=_FileFolderRebaser(self.model_path,self.template_path)
[docs]defclone_template(self):""" Clone the template repository. """os.chdir(self.root)run_command("gh repo clone {0}/{1}".format(GITHUB_ORG,self.template_repo))os.chdir(self.cwd)
[docs]defclone_current_model(self):""" Clone the current model repository. """os.chdir(self.root)run_command("gh repo clone {0}/{1}".format(GITHUB_ORG,self.model_id))os.chdir(self.cwd)
[docs]defdvc_part(self):""" Set up DVC (Data Version Control) for the model repository. """self.file_folder_rebaser.do_file("data.h5",overwrite=False)self.file_folder_rebaser.do_file(".dvcignore",overwrite=False)self.file_folder_rebaser.do_folder(".dvc",overwrite=False)