From 77f515e77e9c901d259120b0548db312d1925326 Mon Sep 17 00:00:00 2001 From: laraPPr Date: Tue, 24 Jun 2025 16:57:47 +0200 Subject: [PATCH 1/2] add workflow scripts for filtering and checking the missing installation in easystacks Signed-off-by: laraPPr --- .github/workflows/scripts/filter_git_diff.py | 37 +++++++++++++++++++ .../parse_missing-installations-output.py | 23 ++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/scripts/filter_git_diff.py create mode 100644 .github/workflows/scripts/parse_missing-installations-output.py diff --git a/.github/workflows/scripts/filter_git_diff.py b/.github/workflows/scripts/filter_git_diff.py new file mode 100644 index 00000000..8ea1ce4b --- /dev/null +++ b/.github/workflows/scripts/filter_git_diff.py @@ -0,0 +1,37 @@ +# At the moment this script will only filter out the easystack files +# Next step could be to filter out other subpaths +# by using the GITHUB action envitonment variables and argsparse. + +# Can also distiguish between modified, added, ... files +# That information is in the string that is generated by git diff +# For filtering easystacks this was however not necessary +# since we want to check both added and modified files + +import os + +diff = os.getenv('CHANGED') +env_file = os.getenv('GITHUB_ENV') + +diff_list = diff.split('\n') + +diff_filter_path = 'easystacks' + +diff_filtered = '' + +for line in diff_list: + status = line.split('\t')[0] + file = line.split('\t')[1] + if file.startswith(diff_filter_path): + # Ignoring the status assigned to the file + diff_filtered += file + ' ' + +if diff_filtered != '': + # If we will at some point add paths to in diff_filter_path + # we'll have to remove '/' + # Name of the env_var can than also change based on the file or path + env_var = 'CHANGED_' + diff_filter_path.upper() + set_var = env_var + "=" + diff_filtered + + # This adds the environment variable to the github action environment + with open(env_file, 'a') as file: + file.write(set_var) diff --git a/.github/workflows/scripts/parse_missing-installations-output.py b/.github/workflows/scripts/parse_missing-installations-output.py new file mode 100644 index 00000000..a5d42ca1 --- /dev/null +++ b/.github/workflows/scripts/parse_missing-installations-output.py @@ -0,0 +1,23 @@ +import os +import re + +missing = os.environ['missing'] +missing = missing.split('\n') +missing_cuda = [] +missing_cpu = [] +for ec in missing: + if re.search('CUDA', ec): + missing_cuda.append(ec) + else: + missing_cpu.append(ec) +if len(missing_cpu) != 0 and len(missing_cuda) != 0: + print(f'Please open a seperate pr for these dependencies: {missing_cpu}') + os.write(2, b'Error: CPU dependencies for CUDA build must be build in a seperate pr') + exit(1) +elif len(missing_cuda) != 0: + # TODO: Make this set the accelorator label? + print(f'Have fun installing the following gpu builds: {missing_cuda}') +elif len(missing_cpu) != 0: + print(f'Have fun installing the following gpu builds: {missing_cpu}') +else: + print('no missing modules') From 6b598ed1265a483c601aae5111098e16dee306e0 Mon Sep 17 00:00:00 2001 From: laraPPr Date: Fri, 27 Jun 2025 12:24:23 +0200 Subject: [PATCH 2/2] clean-up filter script Signed-off-by: laraPPr --- .github/workflows/scripts/filter_git_diff.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/filter_git_diff.py b/.github/workflows/scripts/filter_git_diff.py index 8ea1ce4b..f85eeab2 100644 --- a/.github/workflows/scripts/filter_git_diff.py +++ b/.github/workflows/scripts/filter_git_diff.py @@ -1,6 +1,6 @@ # At the moment this script will only filter out the easystack files # Next step could be to filter out other subpaths -# by using the GITHUB action envitonment variables and argsparse. +# by using the GITHUB action environment variables and argsparse. # Can also distiguish between modified, added, ... files # That information is in the string that is generated by git diff @@ -26,9 +26,9 @@ diff_filtered += file + ' ' if diff_filtered != '': - # If we will at some point add paths to in diff_filter_path - # we'll have to remove '/' - # Name of the env_var can than also change based on the file or path + # Todo: Can only handle 1 level paths now + # I we want to pass multi-level paths this will need to be updated + # Name of the env_var can change based on the file or path env_var = 'CHANGED_' + diff_filter_path.upper() set_var = env_var + "=" + diff_filtered