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

esd-spack-installation: fixed passing access token to tests; added log file for spack install step

parent 9abbf5f4
No related branches found
No related tags found
2 merge requests!7Dedal Release,!5Methods for caching; CLI
......@@ -39,5 +39,6 @@ testing-pytest:
paths:
- test-results.xml
- .esd.log
- .generate_cache.log
expire_in: 1 week
......@@ -2,12 +2,13 @@ import os
import re
from abc import ABC, abstractmethod
from pathlib import Path
from tabnanny import check
from esd.error_handling.exceptions import BashCommandException, NoSpackEnvironmentException, \
SpackInstallPackagesException
from esd.logger.logger_builder import get_logger
from esd.model.SpackModel import SpackModel
from esd.spack_manager.wrapper.spack_wrapper import no_spack_env
from esd.spack_manager.wrapper.spack_wrapper import check_spack_env
from esd.utils.utils import run_command, git_clone_repo
......@@ -53,7 +54,6 @@ class SpackManager(ABC):
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)
else:
......@@ -127,7 +127,7 @@ class SpackManager(ABC):
return False
return True
@no_spack_env
@check_spack_env
def add_spack_repo(self, repo_path: Path, repo_name: str):
"""Add the Spack repository if it does not exist."""
run_command("bash", "-c",
......@@ -137,7 +137,7 @@ class SpackManager(ABC):
exception_msg=f"Failed to add {repo_name} to spack environment {self.env.env_name}",
exception=BashCommandException)
@no_spack_env
@check_spack_env
def get_compiler_version(self):
result = run_command("bash", "-c",
f'source {self.spack_setup_script} && spack env activate -p {self.env_path} && spack compiler list',
......@@ -167,8 +167,21 @@ class SpackManager(ABC):
return spack_version.stdout.strip().split()[0]
return None
def install_spack(self, spack_version="v0.21.1", spack_repo='https://github.com/spack/spack'):
@check_spack_env
def install_packages(self, jobs: int, signed=True, fresh=False):
signed = '' if signed else '--no-check-signature'
fresh = '--fresh' if fresh else ''
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)
def install_spack(self, spack_version="v0.22.0", spack_repo='https://github.com/spack/spack'):
try:
user = os.getlogin()
except OSError:
......
......@@ -3,7 +3,7 @@ import functools
from esd.error_handling.exceptions import NoSpackEnvironmentException
def no_spack_env(method):
def check_spack_env(method):
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
if self.spack_env_exists():
......
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