-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
draft: sketched out SO interface CI workflow. #798
Draft
tristpinsm
wants to merge
5
commits into
main
Choose a base branch
from
so-interface-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df86024
draft: sketched out SO interface CI workflow.
tristpinsm 2bdc678
Initial draft of check_so_interface.py code(in so-interface-ci)
d9718b5
Initial draft of check_so_interface.py code(in so-interface-ci)
a094bfe
Second draft of check_so_interface.py code, still adjusting compare_a…
cde2320
Functional version of code, changes necessary for neatness
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,38 @@ | |
# 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 | ||
|
||
#Files that need to be checked: smurf_tune, smurf_command, smurf_util, smurf_noise, smurf_iv | ||
#python/pysmurf/client/util/smurf_util.py | ||
#python/pysmurf/client/command/smurf_command.py | ||
#python/pysmurf/client/debug/smurf_noise.py | ||
#python/pysmurf/client/debug/smurf_iv.py | ||
interface = { | ||
"python/pysmurf/client/tune/smurf_tune.py": { # file | ||
"SmurfTuneMixin": { # class | ||
"find_freq": [], # function and args | ||
} | ||
}, | ||
"python/pysmurf/client/command/smurf_command.py": { | ||
"SmurfCommandMixin": { | ||
"set_stream_enable": [] | ||
} | ||
}, | ||
"python/pysmurf/client/util/smurf_util.py": { | ||
"SmurfUtilMixin": { | ||
"which_on": [] | ||
} | ||
}, | ||
"python/pysmurf/client/debug/smurf_iv.py": { | ||
"SmurfIVMixin": { | ||
"run_iv": [] | ||
} | ||
}, | ||
"python/pysmurf/client/debug/smurf_noise.py": { | ||
"SmurfNoiseMixin": { | ||
"take_noise_psd" : [] | ||
} | ||
} | ||
} | ||
|
||
spec_args = { | ||
|
@@ -104,49 +130,50 @@ | |
for node in ast.walk(frozen): | ||
if isinstance(node, ast.FunctionDef) and node.name in spec_args.keys(): | ||
freeze.update({node.name: node}) | ||
print("FROZEN") | ||
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 | ||
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 *** | ||
find_freq *** | ||
setup_notches *** | ||
run_serial_gradient_descent | ||
run_serial_eta_scan | ||
run_serial_gradient_descent #smurf_command | ||
run_serial_eta_scan #smurf_command | ||
plot_tune_summary *** | ||
tracking_setup *** | ||
set_amplitude_scale_array | ||
set_amplitude_scale_array #smurf_command | ||
|
||
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 | ||
set_tes_bias_bipolar_array #smurf_util | ||
set_tes_bias_high_current #smurf_util | ||
set_tes_bias_low_current #smurft_util | ||
set_mode_dc #smurf_util | ||
set_mode_ac #smurf_util | ||
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 | ||
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 | ||
analyze_iv | ||
run_iv #smurf_iv | ||
analyze_iv #smurf_iv | ||
|
||
DATA OUTPUTS TO DISK | ||
tune files generated when new resonators are found | ||
|
@@ -155,14 +182,18 @@ | |
iv_files - generated by run_iv" | ||
|
||
""" | ||
def compare_args(found, spec_args): | ||
def compare_args(found, freeze): | ||
#print(freeze.values()) | ||
for func_name, func_node in found.items(): | ||
if func_name not in spec_args: | ||
if func_name not in freeze: | ||
print(func_name + " not in specified functions") | ||
continue | ||
|
||
spec_func = spec_args[func_name] | ||
|
||
|
||
spec_func = freeze[func_name] | ||
#print(freeze[func_name]) | ||
if spec_func == []: | ||
print("waht") | ||
|
||
# Handle the case where spec_func is a list | ||
if isinstance(spec_func, list): | ||
if len(spec_func) == 0: | ||
|
@@ -172,12 +203,13 @@ def compare_args(found, spec_args): | |
|
||
# Extract arguments from the AST node | ||
found_args = [arg.arg for arg in func_node.args.args] | ||
#print(found_args) | ||
found_defaults = [ast.unparse(d) if d else None for d in func_node.args.defaults] | ||
#print(found_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] | ||
spec_args_list = [arg.arg for arg in spec_func.args.args] | ||
spec_defaults = [ast.unparse(d) if d else None for d in spec_func.args.defaults] | ||
|
||
# Compare arguments | ||
if found_args != spec_args_list: | ||
|
@@ -197,7 +229,6 @@ def compare_args(found, spec_args): | |
|
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently |
||
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 = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these two lines don't need to be in the context manager |
||
|
@@ -209,11 +240,11 @@ def compare_args(found, spec_args): | |
for key in spec_args: | ||
if key not in found: | ||
notfound.append(key) | ||
print("FOUND:") | ||
print(found.keys()) | ||
print("NOT FOUND:") | ||
print(notfound) | ||
#print("FOUND:") | ||
#print(found.items()) | ||
#print("NOT FOUND:") | ||
#print(notfound) | ||
#compare arguments | ||
assert compare_args(found, spec_args) | ||
assert compare_args(found, freeze) | ||
#print(ast.dump(found.get('find_freq'))) | ||
pass |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of these print checks I put along the way to debug, and visualize the flow of my code. I haven't deleted them yet because I wanted to keep them in here to remember good places/dictionaries and lists to check in my code for future debugging. A final version of this code will definitely have these removed.