Skip to content

Commit

Permalink
feat(abr-testing): Automated ABR data collection Make command
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNASC20 committed Oct 21, 2024
1 parent 2633162 commit 24c5174
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
10 changes: 9 additions & 1 deletion abr-testing/abr_testing/automation/google_sheets_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ def update_cell(
self, sheet_title: str, row: int, column: int, single_data: Any
) -> Tuple[int, int, Any]:
"""Update ONE individual cell according to a row and column."""
self.spread_sheet.worksheet(sheet_title).update_cell(row, column, single_data)
try:
self.spread_sheet.worksheet(sheet_title).update_cell(
row, column, single_data
)
except gspread.exceptions.APIError:
t.sleep(30)
self.spread_sheet.worksheet(sheet_title).update_cell(
row, column, single_data
)
return row, column, single_data

def get_all_data(
Expand Down
33 changes: 33 additions & 0 deletions abr-testing/protocol_simulation/abr_sim_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from protocol_simulation import simulation_metrics
import os
import traceback
from pathlib import Path

def run(file_to_simulate: Path):
protocol_name = file_to_simulate.stem
try:
simulation_metrics.main(file_to_simulate, False)
except Exception as e:
print(f"Error in protocol: {protocol_name}")
traceback.print_exc()




if __name__ == "__main__":
# Directory to search
root_dir = 'abr_testing/protocols'

exclude = [
'__init__.py',
'shared_vars_and_funcs.py',
]
# Walk through the root directory and its subdirectories
for root, dirs, files in os.walk(root_dir):
for file in files:
if file.endswith(".py"): # If it's a Python file
if file in exclude:
continue
file_path = os.path.join(root, file)
print(f"Simulating protocol: {file_path}")
run(Path(file_path))
21 changes: 20 additions & 1 deletion abr-testing/protocol_simulation/simulation_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@



def set_api_level(protocol_file_path) -> None:
with open(protocol_file_path, "r") as file:
file_contents = file.readlines()
# Look for current'apiLevel:'
for i, line in enumerate(file_contents):
print(line)
if 'apiLevel' in line:
print(f"The current API level of this protocol is: {line}")
change = input("Would you like to simulate with a different API level? (Y/N) ").strip().upper()

if change == "Y":
api_level = input("Protocol API Level to Simulate with: ")
# Update new API level
file_contents[i] = f'apiLevel: {api_level}\n'
print(f"Updated line: {file_contents[i]}")
break
with open(protocol_file_path, "w") as file:
file.writelines(file_contents)
print("File updated successfully.")

def look_for_air_gaps(protocol_file_path: str) -> int:
"""Search Protocol for Air Gaps"""
Expand Down Expand Up @@ -351,7 +370,7 @@ def main(protocol_file_path: Path, save: bool, storage_directory: str = os.curdi

# set_api_level()
if CLEAN_PROTOCOL:
# set_api_level(Path(protocol_file_path))
set_api_level(Path(protocol_file_path))
main(
protocol_file_path,
True,
Expand Down

0 comments on commit 24c5174

Please sign in to comment.