From d4525377bc62a50d18eeee51902ecff4a4448df2 Mon Sep 17 00:00:00 2001 From: Lukas Chrostowski Date: Fri, 12 Jul 2024 22:11:23 -0700 Subject: [PATCH] yaml verification update --- .github/workflows/run-yaml-verification.yml | 7 +++- run_yaml_verification.py | 46 ++++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-yaml-verification.yml b/.github/workflows/run-yaml-verification.yml index 5ee45fa..a4ce832 100644 --- a/.github/workflows/run-yaml-verification.yml +++ b/.github/workflows/run-yaml-verification.yml @@ -61,6 +61,8 @@ jobs: echo "Running verification on $file" output=$(python run_yaml_verification.py "submissions/$file") + + echo $output >> $GITHUB_STEP_SUMMARY # get number of errors #errors_from_output=$(echo "$output" | tail -n 1) @@ -81,8 +83,11 @@ jobs: run: | if [ -z "$files_with_errors" ]; then echo "No errors detected." + echo "No errors detected." >> $GITHUB_STEP_SUMMARY else - echo "Errors detected: $files_with_errors" + echo "Errors detected: $files_with_errors" + echo "Errors detected: $files_with_errors" >> $GITHUB_STEP_SUMMARY + exit 1 fi diff --git a/run_yaml_verification.py b/run_yaml_verification.py index f1fc30f..c9f67a9 100644 --- a/run_yaml_verification.py +++ b/run_yaml_verification.py @@ -5,16 +5,42 @@ """ -# gds file to run verification on -yaml_file = sys.argv[1] -print(yaml_file) +num_errors = 0 -with open(yaml_file, 'r') as file: - yaml_data = yaml.safe_load(file) +print('Checking YAML file:') -print(yaml_data) +# YAML file to run verification on +if len(sys.argv)>1: + yaml_file = sys.argv[1] +else: + # debugging: + import os + yaml_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'submissions/Example.yaml') + +try: + with open(yaml_file, 'r') as file: + yaml_data = yaml.safe_load(file) +except: + print(' - Error loading layout: %s' % yaml_file) + num_errors += 1 + +try: + print(' - number of Devices: %s' % len(yaml_data['Devices'])) + for r in yaml_data['Devices']: + print(' - Device: %s' % r) +except: + print(" - No 'Devices' found.") + num_errors += 1 + +try: + print(' - number of Sequences: %s' % len(yaml_data['Sequences'])) + for r in yaml_data['Sequences']: + print(' - Sequence: %s' % r) +except: + print(" - No 'Sequence' found.") + num_errors += 1 + + +# Print the result value to standard output +print(num_errors) -print(' - number of devices: %s' % len(yaml_data['Devices'])) -print(' - number of routines: %s' % len(yaml_data['Routines'])) -for r in yaml_data['Routines']: - print(' - routine: %s' % r)