-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-binary-executable-mode-change
- Loading branch information
Showing
8 changed files
with
256 additions
and
72 deletions.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Define the Python interpreter and MATLAB command | ||
PYTHON = python | ||
MATLAB = matlab | ||
|
||
# Define the directories and files | ||
EXAMPLES_DIR = examples | ||
TESTS_DIR = tests | ||
MATLAB_SCRIPT = tests/matlab_test_data_collectors/run_all_collectors.m | ||
KWAVE_MATLAB_PATH = $(abspath ../k-wave) # Get absolute path of k-wave directory | ||
|
||
# Define the artifact directory | ||
COLLECTED_VALUES_DIR = $(abspath tests/matlab_test_data_collectors/python_testers/collectedValues) | ||
|
||
# Default target | ||
all: run-examples test | ||
|
||
# Target to run all examples | ||
run-examples: | ||
@echo "Running all examples..." | ||
@MPLBACKEND=Agg $(PYTHON) run_examples.py | ||
|
||
# Target to run pytest, which depends on running the MATLAB script first | ||
test: $(COLLECTED_VALUES_DIR) | ||
@echo "Running pytest..." | ||
@pytest $(TESTS_DIR) | ||
|
||
# Target to run the MATLAB script and create the artifact directory | ||
$(COLLECTED_VALUES_DIR): | ||
@echo "Running MATLAB script to collect values..."; \ | ||
$(MATLAB) -batch "run('$(MATLAB_SCRIPT)');"; \ | ||
# Clean target (optional) - cleans Python caches and collected values | ||
clean: clean-python clean-collected_values | ||
|
||
clean-python: | ||
@echo "Cleaning Python cache files..." | ||
@find . -name '*.pyc' -delete | ||
@find . -name '__pycache__' -delete | ||
|
||
# Clean collected values directory | ||
clean-collected_values: | ||
@echo "Cleaning collected values directory..." | ||
@rm -rf $(COLLECTED_VALUES_DIR) | ||
|
||
.PHONY: all run-examples run-tests clean-python clean-collected_values clean |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
|
||
|
||
def run_python_files(directory): | ||
# Recursively walk through the directory | ||
for root, _, files in os.walk(directory): | ||
for file in files: | ||
# Check if it's a Python file | ||
if file.endswith(".py"): | ||
file_path = os.path.join(root, file) | ||
print(f"Running: {file_path}") | ||
try: | ||
# Use subprocess to run the Python file | ||
result = subprocess.run(["python", file_path], capture_output=True, text=True) | ||
print(f"Output:\n{result.stdout}") | ||
if result.stderr: | ||
print(f"Errors:\n{result.stderr}") | ||
except Exception as e: | ||
print(f"Failed to run {file_path}: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
directory = Path("examples/") | ||
run_python_files(directory) |
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
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
Oops, something went wrong.