Skip to content

Commit

Permalink
Vraymond/bucky fix (#776)
Browse files Browse the repository at this point in the history
## Summary of Changes
- Fixes bug in the Python preprocessor where 2to3 could fail in rare
edge cases
- Reverts Bucky coverage numbers
- Reverts changes to Gromet Object Count

### Related issues

Resolves ???
  • Loading branch information
vincentraymond-ua authored Jan 29, 2024
1 parent 4f8bf6b commit a9e47dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions skema/program_analysis/python_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ def convert_python2_to_python3(source: str):
temp_file.write(source)

# Run 2to3 on the temporary file
subprocess.run(['2to3', '--write', '--nobackups', str(temp_file_path)], check=True)

# Read the converted Python 3 code
python3_code = temp_file_path.read_text()

try:
subprocess.run(['2to3', '--write', '--nobackups', str(temp_file_path)], check=True)
preprocessed_code = temp_file_path.read_text()
except subprocess.CalledProcessError:
preprocessed_code = source

# Clean up the temporary file
temp_file_path.unlink()

return python3_code
return preprocessed_code
2 changes: 1 addition & 1 deletion skema/program_analysis/tests/test_model_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Climlab-v1": [4306, 4306],
"Generated-Halfar": [128, 128],
"SV2AIR3-Waterloo-MATLAB": [0, 1020],
"Bucky": [7503, 7537],
"Bucky": [7537, 7537],
"ABM-REINA": [2622, 7078],
"Cornell-COVID19-sim-Frazier": [7250, 8725],
"ABM-Covasim": [14734, 31042],
Expand Down
6 changes: 3 additions & 3 deletions skema/skema_py/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ def test_gromet_object_count():
assert response.status_code == 200
gromet_object_count = response.json()
assert sum([value for key, value in gromet_object_count.items()]) > 0
assert gromet_object_count["boxes"] == 7
assert gromet_object_count["wires"] == 4
assert gromet_object_count["ports"] == 9
assert gromet_object_count["boxes"] == 16
assert gromet_object_count["wires"] == 6
assert gromet_object_count["ports"] == 14


# TODO: Add more complex test case to test_get_pyacset
Expand Down

0 comments on commit a9e47dc

Please sign in to comment.