Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion python/pysmurf/client/tune/smurf_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def tune_band_serial(self, band, nsamp=2**19, make_plot=False,
self.log('Done with serial tuning')

@set_action()
def plot_tune_summary(self, band, eta_scan=False, show_plot=False,
def plot_tune_summar(self, band, eta_scan=False, show_plot=False,
save_plot=True, eta_width=.3, channels=None,
plot_summary=True, plotname_append=''):
"""
Expand Down
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.
343 changes: 343 additions & 0 deletions tests/ci/check_so_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,343 @@
import ast
# functions and their arguments to check
# specified here: https://www.overleaf.com/project/5e837cac9659910001e5f71e
interface = {
"python/pysmurf/client/tune/smurf_tune.py": { # file
"SmurfTuneMixin": { # class
"plot_tune_summary": { # function and args
"args": [
'self', 'band', 'eta_scan', 'show_plot', 'save_plot', 'eta_width', 'channels', 'plot_summary', 'plotname_append'
],
"defaults": [
'False', 'False', 'True', '0.3', 'None', 'True', "''"
]
},
"full_band_resp": {
"args": [
'self', 'band', 'n_scan', 'nsamp', 'make_plot', 'save_plot', 'show_plot', 'save_data', 'timestamp', 'save_raw_data', 'correct_att', 'swap', 'hw_trigger', 'write_log', 'return_plot_path', 'check_if_adc_is_saturated'
],
"defaults": [
'1', '2 ** 19', 'False', 'True', 'False', 'False', 'None', 'False', 'True', 'False', 'True', 'False', 'False', 'True'
]
},
"tracking_setup": {
"args": [
'self', 'band', 'channel', 'reset_rate_khz', 'write_log', 'make_plot', 'save_plot', 'show_plot', 'nsamp', 'lms_freq_hz', 'meas_lms_freq', 'meas_flux_ramp_amp', 'n_phi0', 'flux_ramp', 'fraction_full_scale', 'lms_enable1', 'lms_enable2', 'lms_enable3', 'feedback_gain', 'lms_gain', 'return_data', 'new_epics_root', 'feedback_start_frac', 'feedback_end_frac', 'setup_flux_ramp', 'plotname_append'
],
"defaults": [
'None', 'None', 'False', 'False', 'True', 'True', '2 ** 19', 'None', 'False', 'False', '4', 'True', 'None', 'True', 'True', 'True', 'None', 'None', 'True', 'None', 'None', 'None', 'True', "''"
]
},
"flux_ramp_setup": {
"args": [
'self', 'reset_rate_khz', 'fraction_full_scale', 'df_range', 'band', 'write_log', 'new_epics_root'
],
"defaults": [
'0.1', '2', 'False', 'None'
]
},
"find_freq": {
"args": [
'self', 'band', 'start_freq', 'stop_freq', 'subband', 'tone_power', 'n_read', 'make_plot', 'save_plot', 'plotname_append', 'window', 'rolling_med', 'make_subband_plot', 'show_plot', 'grad_cut', 'flip_phase', 'grad_kernel_width', 'amp_cut', 'pad', 'min_gap'
],
"defaults": [
'-250', '250', 'None', 'None', '2', 'False', 'True', "''", '50', 'True', 'False', 'False', '0.05', 'False', '8', '0.25', '2', '2'
]
},
"setup_notches": {
"args": [
'self', 'band', 'resonance', 'tone_power', 'sweep_width', 'df_sweep', 'min_offset', 'delta_freq', 'new_master_assignment', 'lock_max_derivative', 'scan_unassigned'
],
"defaults": [
'None', 'None', '0.3', '0.002', '0.1', 'None', 'False', 'False', 'False'
]
}
}
},
"python/pysmurf/client/command/smurf_command.py": {
"SmurfCommandMixin": {
"run_serial_eta_scan": {
"args": [
'self', 'band', 'sync_group', 'timeout'
],
"defaults": [
'True', '240'
]
},
"run_serial_gradient_descent": {
"args": [
'self', 'band', 'sync_group', 'timeout'
],
"defaults": [
'True', '240'
]
},
"set_amplitude_scale_array": {
"args": [
'self', 'band', 'val'
],
"defaults": [
]
},
"set_stream_enable": {
"args": [
'self', 'val'
],
"defaults": [
]
},
"set_amplifier_bias": {
"args": [
'self', 'bias_hemt', 'bias_50k'
],
"defaults": [
'None', 'None'
]
},
"set_cryo_card_ps_en": {
"args": [
'self', 'enable', 'write_log'
],
"defaults": [
'3', 'False'
]
}
}
},
"python/pysmurf/client/util/smurf_util.py": {
"SmurfUtilMixin": {
"take_stream_data": {
"args": [
'self', 'meas_time', 'downsample_factor', 'write_log', 'update_payload_size', 'reset_unwrapper', 'reset_filter', 'return_data', 'make_freq_mask', 'register_file'
],
"defaults": [
'None', 'True', 'True', 'True', 'True', 'False', 'True', 'False'
]
},
"stream_data_on": {
"args": [
'self', 'write_config', 'data_filename', 'downsample_factor', 'write_log', 'update_payload_size', 'reset_filter', 'reset_unwrapper', 'make_freq_mask', 'channel_mask', 'make_datafile', 'filter_wait_time'
],
"defaults": [
'False', 'None', 'None', 'True', 'True', 'True', 'True', 'True', 'None', 'True', '0.1'
]
},
"stream_data_off": {
"args": [
'self', 'write_log', 'register_file'
],
"defaults": [
'True', 'False'
]
},
"read_stream_data": {
"args": [
'self', 'datafile', 'channel', 'nsamp', 'array_size', 'return_header', 'return_tes_bias', 'write_log', 'n_max', 'make_freq_mask', 'gcp_mode'
],
"defaults": [
'None', 'None', 'None', 'False', 'False', 'True', '2048', 'False', 'False'
]
},
"which_on": {
"args": [
'self', 'band'
],
"defaults": [
]
},
"band_off": {
"args": [
'self', 'band'
],
"defaults": [
]
},
"channel_off": {
"args": [
'self', 'band', 'channel'
],
"defaults": [
]
},
"set_tes_bias_bipolar_array": {
"args": [
'self', 'bias_group_volt_array', 'do_enable'
],
"defaults": [
'False'
]
},
"set_tes_bias_high_current": {
"args": [
'self', 'bias_group', 'write_log'
],
"defaults": [
'False'
]
},
"set_tes_bias_low_current": {
"args": [
'self', 'bias_group', 'write_log'
],
"defaults": [
'False'
]
},
"set_downsample_filter": {
"args": [
'self', 'filter_order', 'cutoff_freq', 'write_log'
],
"defaults": [
'False'
]
}
}
},
"python/pysmurf/client/debug/smurf_iv.py": {
"SmurfIVMixin": {
"run_iv": {
"args": [
'self', 'bias_groups', 'wait_time', 'bias', 'bias_high', 'bias_low', 'bias_step', 'show_plot', 'overbias_wait', 'cool_wait', 'make_plot', 'save_plot', 'plotname_append', 'channels', 'band', 'high_current_mode', 'overbias_voltage', 'grid_on', 'phase_excursion_min', 'bias_line_resistance', 'do_analysis'
],
"defaults": [
'None', '0.1', 'None', '1.5', '0', '0.005', 'False', '2.0', '30', 'True', 'True', "''", 'None', 'None', 'True', '8.0', 'True', '3.0', 'None', 'True'
]
},
"analyze_iv": {
"args": [
'self', 'v_bias', 'resp', 'make_plot', 'show_plot', 'save_plot', 'basename', 'band', 'channel', 'R_sh', 'plot_dir', 'high_current_mode', 'bias_group', 'grid_on', 'R_op_target', 'pA_per_phi0', 'bias_line_resistance', 'plotname_append'
],
"defaults": [
'True', 'False', 'True', 'None', 'None', 'None', 'None', 'None', 'False', 'None', 'False', '0.007', 'None', 'None', "''"
]
}
}
},
"python/pysmurf/client/debug/smurf_noise.py": {
"SmurfNoiseMixin": {
"take_noise_psd": {
"args": [
'self', 'meas_time', 'channel', 'nperseg', 'detrend', 'fs', 'low_freq', 'high_freq', 'make_channel_plot', 'make_summary_plot', 'save_data', 'show_plot', 'grid_on', 'datafile', 'downsample_factor', 'write_log', 'reset_filter', 'reset_unwrapper', 'return_noise_params', 'plotname_append'
],
"defaults": [
'None', '2 ** 12', "'constant'", 'None', 'None', 'None', 'True', 'True', 'False', 'False', 'False', 'None', 'None', 'True', 'True', 'True', 'False', "''"
]
}
},
}
}

"""
Frozen Functions:

SETUP FUNCTIONS
setup
set_amplifier_bias #smurf_command
set_cryo_card_ps_en #smurf_command
which_on #smurf_util
band_off #smurf_util
channel_off #smurf_util

TUNING FUNCTIONS
full_band_resp #smurf_tune.py
find_freq #smurf_tune.py
setup_notches #smurf_tune.py
run_serial_gradient_descent #smurf_command
run_serial_eta_scan #smurf_command
plot_tune_summary #smurf_tune.py
tracking_setup #smurf_tune.py
set_amplitude_scale_array #smurf_command

TES/FLUX RAMP FUNCTIONS
set_tes_bias_bipolar_array #smurf_util
set_tes_bias_high_current #smurf_util
set_tes_bias_low_current #smurf_util
set_mode_dc #smurf_util
set_mode_ac #smurf_util
flux_ramp_setup #smurf_tune.py

DATA ACQUISITION FUNCTIONS
set_stream_enable #smurf_command
take_stream_data #smurf_util
take_noise_psd #smurf_noise
stream_data_on #smurf_util
stream_data_off #surf_util
read_stream_data #smurf_util
set_downsample_filter #smurf_util

IV FUNCTIONS
run_iv #smurf_iv
analyze_iv #smurf_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(node, intdict, name):
#check function
if isinstance(node, ast.FunctionDef):
spec_args = intdict['args']
spec_defaults = intdict["defaults"]

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

has_varargs = any(isinstance(arg, ast.arg) and arg.arg == 'args' for arg in node.args.args) #check for varargs

has_kwargs = any(isinstance(arg, ast.arg) and arg.arg == 'kwargs' for arg in node.args.args) #check for kwargs

if has_varargs == True:
raise NotImplementedError("This code doesn't currently have the functionality to support varargs, " + name + " has vararg")
if has_kwargs == True:
raise NotImplementedError("This code doesn't currently have the functionality to support kwargs, " + name + " has kwarg")

# Compare arguments to specified arguments in interface dict
if found_args != spec_args:
print(f"Mismatch in arguments for function {name}")
print(f"Found: {found_args}")
print(f"Expected: {spec_args}")
return False

# Compare default values to specified defaults in interface dict
if found_defaults != spec_defaults:
print(f"Mismatch in default values for function {name}")
print(f"Found: {found_defaults}")
print(f"Expected: {spec_defaults}")
return False
#Check class
#elif isinstance(node, ast.ClassDef):

return True

if __name__ == "__main__": #if this is the main thing being run
setspecclass = set()
setspecfunc = set()
foundclass = set()
foundfunc = set()
for fname in interface.keys(): #loop over file names "fname" as keys in dictionary called "interface"
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
dump = ast.dump(tree)
for classname in interface[fname].keys():
setspecclass.add(classname)
for node in ast.walk(tree):
if isinstance(node, ast.ClassDef):
if node.name == classname:
intdict = interface[fname][classname]
assert compare_args(node, intdict, classname)
foundclass.add(classname)
for specfunc in interface[fname][classname].keys():
setspecfunc.add(specfunc)
if isinstance(node, ast.FunctionDef) and node.name == specfunc:
intdict = interface[fname][classname][specfunc]
assert compare_args(node, intdict, specfunc)
foundfunc.add(specfunc)
if setspecclass != foundclass:
print(setspecclass-foundclass)
if setspecfunc != foundfunc:
print(setspecfunc-foundfunc)
pass
Loading