Skip to content
Snippets Groups Projects
Commit a9253a23 authored by Adrian Ciu's avatar Adrian Ciu
Browse files

esd-spack-installation: spack install method and additional tests

parent c708d57a
No related branches found
No related tags found
2 merge requests!7Dedal Release,!5Methods for caching; CLI
import os
import re
import subprocess
from abc import ABC, abstractmethod
from pathlib import Path
from tabnanny import check
......@@ -49,10 +50,6 @@ class SpackManager(ABC):
def concretize_spack_env(self, force=True):
pass
@abstractmethod
def install_spack_packages(self, jobs: 3, verbose=False, debug=False):
pass
def create_fetch_spack_environment(self):
if self.env.git_path:
git_clone_repo(self.env.env_name, self.env.path / self.env.env_name, self.env.git_path, logger=self.logger)
......@@ -168,18 +165,24 @@ class SpackManager(ABC):
return None
@check_spack_env
def install_packages(self, jobs: int, signed=True, fresh=False):
def install_packages(self, jobs: int, signed=True, fresh=False, debug=False):
signed = '' if signed else '--no-check-signature'
fresh = '--fresh' if fresh else ''
debug = '--debug' if debug else ''
install_result = run_command("bash", "-c",
f'source {self.spack_setup_script} && spack env activate -p {self.env_path} && spack {debug} install -v {signed} --j {jobs} {fresh}',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
logger=self.logger,
debug_msg=f"Installing spack packages for {self.env.env_name}",
exception_msg=f"Error installing spack packages for {self.env.env_name}",
exception=SpackInstallPackagesException)
with open(str(Path(os.getcwd()).resolve() / ".generate_cache.log"), "w") as log_file:
run_command("bash", "-c",
f'source {self.spack_setup_script} && spack install --env {self.env.env_name} -v {signed} --j {jobs} {fresh}',
stdout=log_file,
capture_output=True, text=True, check=True,
logger=self.logger,
debug_msg=f"Installing spack packages for {self.env.env_name}",
exception_msg=f"Error installing spack packages for {self.env.env_name}",
exception=SpackInstallPackagesException)
log_file.write(install_result.stdout)
log_file.write("\n--- STDERR ---\n")
log_file.write(install_result.stderr)
return install_result
def install_spack(self, spack_version="v0.22.0", spack_repo='https://github.com/spack/spack'):
try:
......
......@@ -14,6 +14,3 @@ class SpackManagerBuildCache(SpackManager):
def concretize_spack_env(self, force=True):
pass
def install_spack_packages(self, jobs: 3, verbose=False, debug=False):
pass
......@@ -23,6 +23,3 @@ class SpackManagerScratch(SpackManager):
else:
self.logger.debug('No spack environment defined')
raise NoSpackEnvironmentException('No spack environment defined')
def install_spack_packages(self, jobs: 3, verbose=False, debug=False):
pass
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment