def init(self, template='hello-world'): p = Popen([ 'mlt', 'init', '--registry={}'.format( self.registry), '--template-repo={}'.format( basedir()), '--namespace={}'.format(self.namespace), '--template={}'.format(template), self.app_name ], cwd=self.workdir) # keep track of template we created so we can check if it's a TFJob # that terminates pods after completion so we need to check the crd # for status on if job was successful self.template = template assert p.wait() == 0 assert os.path.isfile(self.mlt_json) with open(self.mlt_json) as f: standard_configs = { 'namespace': self.namespace, 'name': self.app_name, 'registry': self.registry } actual_configs = json.loads((f.read())) assert dict(actual_configs, **standard_configs) == actual_configs # verify we created a git repo with our project init assert "On branch master" in run( "git --git-dir={}/.git --work-tree={} status".format( self.project_dir, self.project_dir).split())
def update_template(self, template_repo=basedir()): update_cmd = ['mlt', 'update-template'] if template_repo: update_cmd.append("--template-repo={}".format(template_repo)) output, err = self._launch_popen_call(update_cmd, return_output=True, stderr_is_not_okay=True) # verify that we have some output assert output return output.decode("utf-8")
def init(self, template='hello-world', template_repo=basedir(), enable_sync=False, existing_app_dir=None): self._set_new_mlt_project_vars(template) # If there isn't an existing app, run mlt init to create a new one if not existing_app_dir: init_options = [ 'mlt', 'init', '--registry={}'.format(self.registry), '--template-repo={}'.format(template_repo), '--namespace={}'.format(self.namespace), '--template={}'.format(template), self.app_name ] if enable_sync: init_options.append('--enable-sync') self._launch_popen_call(init_options, cwd=pytest.workdir) else: shutil.copytree(existing_app_dir, self.project_dir) self.config("set", "namespace", self.namespace) self.config("set", "name", self.app_name) self.config("set", "registry", self.registry) # keep track of template we created so we can check if it's a TFJob # that terminates pods after completion so we need to check the crd # for status on if job was successful self.template = template assert os.path.isfile(self.mlt_json) with open(self.mlt_json) as f: standard_configs = { 'namespace': self.namespace, 'name': self.app_name, 'registry': self.registry } actual_configs = json.loads((f.read())) assert dict(actual_configs, **standard_configs) == actual_configs if not existing_app_dir: # verify we created a git repo with our project init assert "On branch master" in run( "git --git-dir={}/.git --work-tree={} status".format( self.project_dir, self.project_dir).split()) # setup additional namespace configs for experiments if template == 'experiments': self._setup_experiments_sa()
def init(self, template='hello-world'): p = Popen( ['mlt', 'init', '--registry={}'.format(self.registry), '--template-repo={}'.format(basedir()), '--namespace={}'.format(self.namespace), '--template={}'.format(template), self.app_name], cwd=self.workdir) assert p.wait() == 0 assert os.path.isfile(self.mlt_json) with open(self.mlt_json) as f: standard_configs = { 'namespace': self.namespace, 'name': self.app_name, 'registry': self.registry } actual_configs = json.loads((f.read())) assert dict(actual_configs, **standard_configs) == actual_configs # verify we created a git repo with our project init assert "On branch master" in run( "git --git-dir={}/.git --work-tree={} status".format( self.project_dir, self.project_dir).split())