Skip to content
Snippets Groups Projects
Commit 8c8589f7 authored by Jithu Murugan's avatar Jithu Murugan
Browse files

Merge remote-tracking branch 'origin/esd-spack-installation' into...

Merge remote-tracking branch 'origin/esd-spack-installation' into VT-70-function-Migrate-Spack-env-setup-into-ESD-repo-with-buildcache

# Conflicts:
#	.gitlab-ci.yml
#	dedal/build_cache/BuildCacheManager.py
#	dedal/cli/SpackManager.py
#	esd/tests/utils_test.py
#	esd/utils/utils.py
#	pyproject.toml
parents 7cc4f758 ccf28f62
No related branches found
No related tags found
1 merge request!4feat(spack_operation): implement setup_spack_env functionality
Showing
with 143 additions and 18 deletions
......@@ -28,18 +28,16 @@ testing-pytest:
- docker-runner
image: ubuntu:22.04
script:
- chmod +x esd/utils/bootstrap.sh
- ./esd/utils/bootstrap.sh
- echo "$SPACK_ENV_ACCESS_TOKEN"
- pip install -e .[tests,dev]
- pytest ./esd/tests/ -s --junitxml=test-results.xml
- chmod +x dedal/utils/bootstrap.sh
- ./dedal/utils/bootstrap.sh
- pip install e .[tests,dev]
- pytest ./dedal/tests/ -s --junitxml=test-results.xml
artifacts:
when: always
reports:
junit: test-results.xml
paths:
- test-results.xml
- .esd.log
- .generate_cache.log
- .dedal.log
expire_in: 1 week
File moved
......@@ -3,10 +3,9 @@ import os
from os.path import join
from pathlib import Path
import oras.client
from esd.build_cache.BuildCacheManagerInterface import BuildCacheManagerInterface
from esd.logger.logger_builder import get_logger
from dedal.build_cache.BuildCacheManagerInterface import BuildCacheManagerInterface
from dedal.logger.logger_builder import get_logger
from dedal.utils.utils import clean_up
class BuildCacheManager(BuildCacheManagerInterface):
......@@ -113,7 +112,7 @@ class BuildCacheManager(BuildCacheManagerInterface):
if tags is not None:
try:
self._client.delete_tags(self._oci_registry_path, tags)
self._logger.info("Successfully deleted all artifacts form OCI registry.")
self._logger.info(f"Successfully deleted all artifacts form OCI registry.")
except RuntimeError as e:
self._logger.error(
f"Failed to delete artifacts: {e}")
......
File moved
File moved
File moved
class GpgConfig:
"""
Configuration for gpg key used by spack
"""
def __init__(self, gpg_name='example', gpg_mail='example@example.com'):
self.name = gpg_name
self.mail = gpg_mail
import os
from pathlib import Path
from dedal.configuration.GpgConfig import GpgConfig
from dedal.model import SpackDescriptor
class SpackConfig:
def __init__(self, env: SpackDescriptor = None, repos: list[SpackDescriptor] = None,
install_dir=Path(os.getcwd()).resolve(), upstream_instance=None, system_name=None,
concretization_dir: Path = None, buildcache_dir: Path = None, gpg: GpgConfig = None):
self.env = env
if repos is None:
self.repos = []
else:
self.repos = repos
self.install_dir = install_dir
if self.install_dir:
os.makedirs(self.install_dir, exist_ok=True)
self.upstream_instance = upstream_instance
self.system_name = system_name
self.concretization_dir = concretization_dir
if self.concretization_dir:
os.makedirs(self.concretization_dir, exist_ok=True)
self.buildcache_dir = buildcache_dir
if self.buildcache_dir:
os.makedirs(self.buildcache_dir, exist_ok=True)
self.gpg = gpg
def add_repo(self, repo: SpackDescriptor):
if self.repos is None:
self.repos = []
else:
self.repos.append(repo)
File moved
File moved
class SpackException(Exception):
def __init__(self, message):
super().__init__(message)
self.message = str(message)
def __str__(self):
return self.message
class BashCommandException(SpackException):
"""
To be thrown when a bash command has failed
"""
class NoSpackEnvironmentException(BashCommandException):
"""
To be thrown when an operation on a spack environment is executed without the environment being activated or existent
"""
class SpackConcertizeException(BashCommandException):
"""
To be thrown when the spack concretization step fails
"""
class SpackInstallPackagesException(BashCommandException):
"""
To be thrown when the spack fails to install spack packages
"""
class SpackMirrorException(BashCommandException):
"""
To be thrown when the spack add mirror command fails
"""
class SpackGpgException(BashCommandException):
"""
To be thrown when the spack fails to create gpg keys
"""
File moved
File moved
File moved
import logging
class LoggerConfig:
"""
This class sets up logging with a file handler
and a stream handler, ensuring consistent
and formatted log messages.
"""
def __init__(self, log_file):
self.log_file = log_file
self._configure_logger()
def _configure_logger(self):
formatter = logging.Formatter(
fmt='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
file_handler = logging.FileHandler(self.log_file)
file_handler.setFormatter(formatter)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
self.logger.addHandler(file_handler)
self.logger.addHandler(stream_handler)
def get_logger(self):
return self.logger
############################################
## ESD - logging configuration. ##
## Dedal - logging configuration. ##
############################################
[loggers]
keys=root, esd, oras
keys=root, dedal, oras
[handlers]
keys=consoleHandler, fileHandler
......@@ -16,12 +16,12 @@ handlers=consoleHandler, fileHandler
propagate=0
############################################
## esd specific logging ##
## dedal specific logging ##
############################################
[logger_esd]
[logger_dedal]
level=DEBUG
handlers=consoleHandler, fileHandler
qualname=esd
qualname=dedal
propagate=0
[logger_oras]
......@@ -44,7 +44,7 @@ args=(sys.stdout,)
class=handlers.TimedRotatingFileHandler
level=INFO
formatter=simpleFormatter
args=('.esd.log', 'midnight', 1, 30, None, False, False)
args=('.dedal.log', 'midnight', 1, 30, None, False, False)
############################################
## Formatters ##
......
import os
from pathlib import Path
class SpackDescriptor:
""""
Provides details about the spack environment
"""
def __init__(self, env_name: str, path: Path = Path(os.getcwd()).resolve(), git_path: str = None):
self.env_name = env_name
self.path = path
self.git_path = git_path
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