From 7f0051bd23ec28a6949efafa89e04b36e5b86823 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Mon, 19 Aug 2024 17:27:43 +0200 Subject: [PATCH 1/4] Add create_admin.list.py WIP --- scripts/create_admin.list.py | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripts/create_admin.list.py diff --git a/scripts/create_admin.list.py b/scripts/create_admin.list.py new file mode 100644 index 00000000..24490680 --- /dev/null +++ b/scripts/create_admin.list.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# +# Create admin.list file for Lmod. +# This will use information from the known_issues.yaml file to display +# a message to the user when they load a module that is known to have issues. +# +import os +import yaml +from urllib import request + +# Download the known issues YAML file from the EESSI/software-layer GitHub repository + + +# Get known issues file +# TODO: This hardcodes version 2023.06, we should make this dynamic +url = 'https://raw.githubusercontent.com/EESSI/software-layer/2023.06-software.eessi.io/eessi-2023.06-known-issues.yml' +r = request.urlretrieve(url, 'eessi-2023.06-known-issues.yml') + +# Open the YAML file +with open('eessi-2023.06-known-issues.yml', 'r') as file: + # Load the YAML data + known_issues = yaml.safe_load(file) + +# Remove the admin.list file if it exists, we will recreate it +if os.path.exists('admin.list'): + os.remove('admin.list') + + +admin_list_file = open('admin.list', 'a') +path = '/cvmfs/software.eessi.io/versions/2023.06/software/linux/' +for i in range(len(known_issues)): + arch, known_issues_arch = list(known_issues[i].items())[0] + for j in range(len(known_issues_arch)): + # Write known issue per arch and module + known_issues_module, known_issue = list(known_issues_arch[j].items())[0] + known_issues_module = known_issues_module.replace('/', '_') + module_path = os.path.join(path, 'modules/all', arch, known_issues_module) + message = f"{module_path}:" + message += ( + f"\n There is a known issue: {known_issue[1]['info']}" + f"\n See: {known_issue[0]['issue']}\n\n" + ) + admin_list_file.write(message) + +admin_list_file.close() From 9d4e4906139aff7abbe4b521d017932e9f06f7d9 Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 27 Aug 2024 09:43:30 +0200 Subject: [PATCH 2/4] Basic error catching and string constant improvements --- scripts/create_admin.list.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/create_admin.list.py b/scripts/create_admin.list.py index 24490680..a95e2d10 100644 --- a/scripts/create_admin.list.py +++ b/scripts/create_admin.list.py @@ -3,28 +3,31 @@ # Create admin.list file for Lmod. # This will use information from the known_issues.yaml file to display # a message to the user when they load a module that is known to have issues. -# import os import yaml from urllib import request -# Download the known issues YAML file from the EESSI/software-layer GitHub repository - -# Get known issues file +# Download the known issues YAML file from the EESSI/software-layer GitHub repository # TODO: This hardcodes version 2023.06, we should make this dynamic -url = 'https://raw.githubusercontent.com/EESSI/software-layer/2023.06-software.eessi.io/eessi-2023.06-known-issues.yml' -r = request.urlretrieve(url, 'eessi-2023.06-known-issues.yml') +KNOWN_ISSUES_FILE = 'eessi-2023.06-known-issues.yml' +KNOWN_ISSUES_URL = 'https://raw.githubusercontent.com/EESSI/software-layer/2023.06-software.eessi.io/' + KNOWN_ISSUES_FILE +r = request.urlretrieve(KNOWN_ISSUES_URL, KNOWN_ISSUES_FILE) # Open the YAML file -with open('eessi-2023.06-known-issues.yml', 'r') as file: - # Load the YAML data - known_issues = yaml.safe_load(file) +try: + with open(KNOWN_ISSUES_FILE, 'r') as file: + # Load the YAML data + known_issues = yaml.safe_load(file) +except IOError: + raise IOError("Unable to open the known issues file") # Remove the admin.list file if it exists, we will recreate it if os.path.exists('admin.list'): - os.remove('admin.list') - + try: + os.remove('admin.list') + except OSError: + raise OSError("Unable to remove the admin.list file") admin_list_file = open('admin.list', 'a') path = '/cvmfs/software.eessi.io/versions/2023.06/software/linux/' From eb044533ce5cf1b3c0634746c348fdc753cbaa5e Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 27 Aug 2024 09:44:32 +0200 Subject: [PATCH 3/4] Ignore changing files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 39af2bac..5baf4c7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build hosts +*.list +*-known-issues.yml \ No newline at end of file From b362a53e87b57fbc7f94fe493b0fab676c5757bd Mon Sep 17 00:00:00 2001 From: Neves-P Date: Tue, 27 Aug 2024 10:30:36 +0200 Subject: [PATCH 4/4] Split file by arch --- scripts/create_admin.list.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/create_admin.list.py b/scripts/create_admin.list.py index a95e2d10..772352de 100644 --- a/scripts/create_admin.list.py +++ b/scripts/create_admin.list.py @@ -22,17 +22,21 @@ except IOError: raise IOError("Unable to open the known issues file") -# Remove the admin.list file if it exists, we will recreate it -if os.path.exists('admin.list'): - try: - os.remove('admin.list') - except OSError: - raise OSError("Unable to remove the admin.list file") - -admin_list_file = open('admin.list', 'a') +# Create a admin.list file per arch path = '/cvmfs/software.eessi.io/versions/2023.06/software/linux/' for i in range(len(known_issues)): arch, known_issues_arch = list(known_issues[i].items())[0] + admin_list_filename = f"admin.list.{arch}" + + # Remove the admin.list file if it exists, we will recreate it + if os.path.exists(admin_list_filename): + try: + os.remove(admin_list_filename) + except OSError: + raise OSError(f"Unable to remove the {admin_list_filename} file") + + # Open the admin.list file, with no dashes in the filename + admin_list_file = open(admin_list_filename.replace('/', '_'), 'a') for j in range(len(known_issues_arch)): # Write known issue per arch and module known_issues_module, known_issue = list(known_issues_arch[j].items())[0]