From 53d00cb72f08df99dd45068b23c2e076596f24e8 Mon Sep 17 00:00:00 2001 From: Douglas Jacobsen Date: Sat, 7 Sep 2024 08:41:31 -0600 Subject: [PATCH] Update repos used in deployments This commit updates how repositories are used within deployments. Previously, when creating a deployment, Ramble would create configuration files to add the deployment into the resulting workspace. This commit changes this behavior so that the repository is created, but it is added at deployment pull time instead of deployment push time. This allows the path of the deployment respository to be absolute on the remote machine rather than a relative path that hopefully will work on the remote machine. --- lib/ramble/ramble/cmd/deployment.py | 8 ++++++++ lib/ramble/ramble/pipeline.py | 29 +---------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/lib/ramble/ramble/cmd/deployment.py b/lib/ramble/ramble/cmd/deployment.py index 378e212f9..8427f9631 100644 --- a/lib/ramble/ramble/cmd/deployment.py +++ b/lib/ramble/ramble/cmd/deployment.py @@ -24,6 +24,7 @@ import ramble.workspace.shell import ramble.pipeline import ramble.filters +from ramble.main import RambleCommand description = "(experimental) manage workspace deployments" @@ -135,6 +136,13 @@ def pull_file(src, dest): pull_file(src, dest) + obj_repo_path = os.path.join( + ws.root, ramble.pipeline.PushDeploymentPipeline.object_repo_name + ) + if os.path.exists(obj_repo_path): + repo_cmd = RambleCommand("repo") + repo_cmd("add", obj_repo_path, global_args=["-D", ws.root]) + def deployment_run_pipeline(args, pipeline): include_phase_dependencies = getattr(args, "include_phase_dependencies", None) diff --git a/lib/ramble/ramble/pipeline.py b/lib/ramble/ramble/pipeline.py index dd36df44c..bc43414a5 100644 --- a/lib/ramble/ramble/pipeline.py +++ b/lib/ramble/ramble/pipeline.py @@ -564,6 +564,7 @@ class PushDeploymentPipeline(Pipeline): index_filename = "index.json" index_namespace = "deployment_files" tar_extension = ".tar.gz" + object_repo_name = "object_repo" def __init__( self, workspace, filters, create_tar=False, upload_url=None, deployment_name=None @@ -573,7 +574,6 @@ def __init__( self.require_inventory = True self.create_tar = create_tar self.upload_url = upload_url - self.object_repo_name = "object_repo" if deployment_name: workspace.deployment_name = deployment_name @@ -582,8 +582,6 @@ def __init__( self.deployment_name = workspace.name def _execute(self): - from spack.util import spack_yaml as syaml - configs_dir = os.path.join( self.workspace.named_deployment, ramble.workspace.workspace_config_path ) @@ -593,31 +591,6 @@ def _execute(self): aux_software_dir = os.path.join(configs_dir, ramble.workspace.auxiliary_software_dir_name) fs.mkdirp(aux_software_dir) - aux_repo_conf = os.path.join(aux_software_dir, "repos.yaml") - - repo_conf_defs = [ - (conf_def["config_section"], f'{conf_def["config_section"]}.yaml') - for conf_def in ramble.repository.type_definitions.values() - ] - - for repo_conf in repo_conf_defs: - aux_repo_conf = os.path.join(aux_software_dir, repo_conf[1]) - repo_data = syaml.syaml_dict() - if os.path.exists(aux_repo_conf): - with open(aux_repo_conf) as f: - repo_data = syaml.load_config(f.read()) - else: - repo_data[repo_conf[0]] = [] - - add_repo = True - for repo in repo_data[repo_conf[0]]: - if repo == f"../../{self.object_repo_name}": - add_repo = False - if add_repo: - repo_data[repo_conf[0]].append(f"../../{self.object_repo_name}") - - with open(aux_repo_conf, "w+") as f: - f.write(syaml.dump_config(repo_data)) repo_path = os.path.join(self.workspace.named_deployment, self.object_repo_name) for object_type_def in ramble.repository.type_definitions.values():