Skip to content

Commit

Permalink
yaml verification update
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Jul 13, 2024
1 parent 05eada8 commit d452537
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/run-yaml-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
46 changes: 36 additions & 10 deletions run_yaml_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit d452537

Please sign in to comment.