Skip to content
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

Revised structure for writing example tests #848

Open
jpn-- opened this issue Apr 16, 2024 · 0 comments
Open

Revised structure for writing example tests #848

jpn-- opened this issue Apr 16, 2024 · 0 comments
Labels
Feature New feature or request

Comments

@jpn--
Copy link
Member

jpn-- commented Apr 16, 2024

I am proposing a new structure for writing example tests.

Currently, we write most examples using layered config directories. For example, here we look for settings in three different directories:

"-c",
test_path("configs_mp"),
"-c",
example_path("configs_mp"),
"-c",
example_path("configs"),

As we have more complicated testing permutations, these can get messy and hard to maintain:

shadowprice_configs = (
[] if shadow_pricing else ["-c", test_path("no-shadow-pricing")]
)
if shadow_pricing:
kwargs["configs_dir"].append(test_path("no-shadow-pricing"))
if sharrow:
sh_configs = ["-c", example_path("configs_sharrow")]
kwargs["configs_dir"].append(example_path("configs_sharrow"))
else:
sh_configs = []
if multiprocess:
mp_configs = [
"-c",
test_path("configs_mp"),
"-c",
example_path("configs_mp"),
]
kwargs["configs_dir"].append(test_path("configs_mp"))
kwargs["configs_dir"].append(example_path("configs_mp"))
elif sharrow:
mp_configs = [
"-c",
test_path("configs"),
]
kwargs["configs_dir"].append(test_path("configs"))
else:
mp_configs = [
"-c",
test_path("configs"),
]
kwargs["configs_dir"].append(test_path("configs"))
run_args = (
shadowprice_configs
+ sh_configs
+ mp_configs
+ [
"-c",
example_path("configs"),
"-c",
example_mtc_path("configs"),
"-d",
example_mtc_path("data"),
"-o",
test_path(f"output_{int(sharrow)}{int(shadow_pricing)}"),
"--data_model",
example_path("data_model"),
]
)
kwargs["configs_dir"].append(example_path("configs"))
kwargs["configs_dir"].append(example_mtc_path("configs"))
kwargs["data_dir"] = [example_mtc_path("data")]
kwargs["output_dir"] = test_path("output")

I propose a more direct structure for testing, where there are only a very limited number of "main" config directories, and various permutations for testing are not written out in more config directories, but instead manipulated directly in the Python of the test.

https://github.com/camsys/sandag-abm3-example/blob/6092354290a45aa4b771a8c18910b8bb4cd952de/test/test_sandag_abm3.py#L217-L239

cc @i-am-sijia @dhensle

@jpn-- jpn-- added the Feature New feature or request label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant