Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
df86024
draft: sketched out SO interface CI workflow.
tristpinsm Sep 24, 2024
2bdc678
Initial draft of check_so_interface.py code(in so-interface-ci)
Nov 15, 2024
d9718b5
Initial draft of check_so_interface.py code(in so-interface-ci)
Nov 15, 2024
a094bfe
Second draft of check_so_interface.py code, still adjusting compare_a…
Nov 28, 2024
cde2320
Functional version of code, changes necessary for neatness
Dec 5, 2024
506e39e
Check so-interface functions, classes
Jan 16, 2025
0a49fca
Temporary changes
Feb 21, 2025
ca1f2e0
Better dictionary loops and improved functionality
Feb 25, 2025
7d44401
Cleaned, no class checking
Feb 27, 2025
e4a8775
Finalizing changes
Mar 8, 2025
ac8085c
Checking workflows yaml syntax
Mar 25, 2025
1c2b712
Checking workflows 2
Mar 25, 2025
3c695a0
Checking workflows 3
Mar 25, 2025
a98000d
Checking workflows 4
Mar 25, 2025
4559aec
Checking workflows 5
Mar 26, 2025
0db56b2
Updating errors, returns
Mar 26, 2025
139738b
Intentionally breaking: altering run_iv args
Apr 3, 2025
3b8e865
Exceptions, Docstrings, and only one ast.walk
Apr 3, 2025
75f6415
Exceptions, comments, minor error fixes
Apr 17, 2025
a5405f9
Ubuntu version deprecated fix
Apr 17, 2025
be49e5b
Ubuntu version deprecated fix 2
Apr 17, 2025
b61ca5d
Fixing ubuntu python 3.8.10 error
Apr 18, 2025
0d2f788
Python version change to work ubuntu
Apr 18, 2025
df9d979
Python fix, Ubuntu 24.04 not working with Python 3.8.10
Apr 18, 2025
6e67d89
fix(workflow): Add quotes to python version string.
tristpinsm Apr 18, 2025
448ebfd
fix(workflow): Bump version of setup-python.
tristpinsm Apr 18, 2025
f15c04b
fix(workflow): Use ubuntu-latest.
tristpinsm Apr 18, 2025
ef85bd4
fix(workflow): Bump to python 3.9.
tristpinsm Apr 18, 2025
911851e
fix(workflow): Try single quotes...
tristpinsm Apr 18, 2025
7454b55
fix(workflow): python 3.8.12
tristpinsm Apr 18, 2025
869f894
Remove .DS_Store from repository
Apr 25, 2025
8476b48
updating my branch
Apr 25, 2025
d168701
Fixing exceptions with f-strings
Apr 28, 2025
57162fd
Nodes in body check dict index fix
Apr 28, 2025
109e306
remove remaining .DS_Store
tristpinsm Apr 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/interface_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

name: interface-ci
on: [pull_request]

jobs:
check-so-interface:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tests/ci
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Check SO interface spec
run: python ./check_so_interface.py
Binary file added tests/.DS_Store
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this before we merge

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is still here...

Binary file not shown.
219 changes: 219 additions & 0 deletions tests/ci/check_so_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
import ast
# functions and their arguments to check
# specified here: https://www.overleaf.com/project/5e837cac9659910001e5f71e
# could move this to a file
#to complete: work on functions and arguments to check file and spec_args dictionary
interface = {
"python/pysmurf/client/tune/smurf_tune.py": { # file
"SmurfTuneMixin": { # class
"find_freq": [], # function and args
}
},
}

spec_args = {
"setup": [

],
"set_amplifier_bias": [

],
"set_cryo_card_ps_en": [

],
"which_on": [

],
"band_off": [

],
"channel_off": [

],
"full_band_resp": [

],
"find_freq": [

],
"setup_notches": [

],
"run_serial_gradient_descent": [

],
"run_serial_eta_scan": [

],
"plot_tune_summary": [

],
"tracking_setup": [

],
"set_amplitude_scale_array": [

],
"set_tes_bias_bipolar_array": [

],
"set_tes_bias_high_current": [

],
"set_tes_bias_low_current": [

],
"set_mode_dc" "set_mode_ac": [

],
"flux_ramp_setup": [

],
"set_stream_enable": [

],
"take_stream_data": [

],
"take_noise_psd": [

],
"stream_data_on": [

],
"stream_data_off": [

],
"read_stream_data": [

],
"set_downsample_filter": [

],
"run_iv": [

],
"analyze_iv": [

]
}
freeze = {}

with open('tests/ci/frozen_functions.py', 'r') as fh: #opens file "fname", in read mode 'r', to be used in code as "fh"
frozen = ast.parse(fh.read())
for node in ast.walk(frozen):
if isinstance(node, ast.FunctionDef) and node.name in spec_args.keys():
freeze.update({node.name: node})
print(freeze.items())
"""
*** ==> I found this function in smurf_tune.py
frozen functions list:

SETUP FUNCTIONS
setup
set_amplifier_bias
set_cryo_card_ps_en
which_on
band_off
channel_off

TUNING FUNCTIONS
full_band_resp ***
find_freq ***
setup_notches ***
run_serial_gradient_descent
run_serial_eta_scan
plot_tune_summary ***
tracking_setup ***
set_amplitude_scale_array

TES/FLUX RAMP FUNCTIONS
set_tes_bias_bipolar_array
set_tes_bias_high_current
set_tes_bias_low_current
set_mode_dc
set_mode_ac
flux_ramp_setup ***

DATA ACQUISITION FUNCTIONS
set_stream_enable
take_stream_data
take_noise_psd
stream_data_on
stream_data_off
read_stream_data
set_downsample_filter

IV FUNCTIONS
run_iv
analyze_iv

DATA OUTPUTS TO DISK
tune files generated when new resonators are found
channel mapping file format
.dat noise files - generated by take_stream_data
iv_files - generated by run_iv"

"""
def compare_args(found, spec_args):
for func_name, func_node in found.items():
if func_name not in spec_args:
print(func_name + " not in specified functions")
continue

spec_func = spec_args[func_name]

# Handle the case where spec_func is a list
if isinstance(spec_func, list):
if len(spec_func) == 0:
print(f"No specification for {func_name}")
continue
spec_func = spec_func[0] # Assume the function is the first item in the list

# Extract arguments from the AST node
found_args = [arg.arg for arg in func_node.args.args]
found_defaults = [ast.unparse(d) if d else None for d in func_node.args.defaults]

# Extract arguments from the spec function
spec_sig = ast.parse(f"def {func_name}{ast.get_source_segment(spec_func, spec_func.args)}:pass").body[0]
spec_args_list = [arg.arg for arg in spec_sig.args.args]
spec_defaults = [ast.unparse(d) if d else None for d in spec_sig.args.defaults]

# Compare arguments
if found_args != spec_args_list:
print(f"Mismatch in arguments for function {func_name}")
print(f"Found: {found_args}")
print(f"Expected: {spec_args_list}")
return False

# Compare default values
if found_defaults != spec_defaults:
print(f"Mismatch in default values for function {func_name}")
print(f"Found: {found_defaults}")
print(f"Expected: {spec_defaults}")
return False

return True

if __name__ == "__main__": #if this is the main thing being run
for fname, spec in interface.items(): #loop over file names "fname" as keys and "spec" as values in dictionary called "interface"
print(interface.items())
with open(fname, 'r') as fh: #opens file "fname", in read mode 'r', to be used in code as "fh"
tree = ast.parse(fh.read()) #parsing contents of file into abstract syntax tree
notfound = []
found = {}
dump = ast.dump(tree)
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef) and node.name in spec_args.keys():
found.update({node.name: node})
for key in spec_args:
if key not in found:
notfound.append(key)
print("FOUND:")
print(found.keys())
print("NOT FOUND:")
print(notfound)
#compare arguments
assert compare_args(found, spec_args)
#print(ast.dump(found.get('find_freq')))
pass