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

Unit tests for Examples #605

Merged
merged 21 commits into from
Sep 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
parse only known args in examples
  • Loading branch information
RasmusOrsoe committed Sep 26, 2023
commit d3e34fd96a78ddf3be9f36868361cf532179aeb9
2 changes: 1 addition & 1 deletion examples/01_icetray/01_convert_i3_files.py
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ def main_icecube_upgrade(backend: str) -> None:
"detector", choices=["icecube-86", "icecube-upgrade"]
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you've changed to use parse_known_args instead of parse_args?


# Run example script
if args.detector == "icecube-86":
2 changes: 1 addition & 1 deletion examples/01_icetray/02_compare_sqlite_and_parquet.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ def load_data() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.


# Run example script(s)
convert_data()
2 changes: 1 addition & 1 deletion examples/01_icetray/03_i3_deployer_example.py
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ def main() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.


# Run example script
main()
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ def main() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.


# Run example script
main()
2 changes: 1 addition & 1 deletion examples/02_data/01_read_dataset.py
Original file line number Diff line number Diff line change
@@ -121,6 +121,6 @@ def main(backend: str) -> None:
nargs="?",
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(args.backend)
2 changes: 1 addition & 1 deletion examples/02_data/02_plot_feature_distributions.py
Original file line number Diff line number Diff line change
@@ -66,6 +66,6 @@ def main() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main()
2 changes: 1 addition & 1 deletion examples/02_data/03_convert_parquet_to_sqlite.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,6 @@ def main(parquet_path: str, mc_truth_table: str) -> None:
default="truth",
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(args.parquet_path, args.mc_truth_table)
1 change: 1 addition & 0 deletions examples/02_data/04_ensemble_dataset.py
Original file line number Diff line number Diff line change
@@ -88,4 +88,5 @@ def main() -> None:
Combine multiple Datasets using EnsembleDataset.
"""
)
args, unknown = parser.parse_known_args()
main()
2 changes: 1 addition & 1 deletion examples/03_weights/01_fit_uniform_weights.py
Original file line number Diff line number Diff line change
@@ -37,6 +37,6 @@ def main() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main()
2 changes: 1 addition & 1 deletion examples/03_weights/02_fit_bjoern_low_weights.py
Original file line number Diff line number Diff line change
@@ -45,6 +45,6 @@ def main() -> None:
"""
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main()
2 changes: 1 addition & 1 deletion examples/04_training/01_train_dynedge.py
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ def main(
help="If True, Weights & Biases are used to track the experiment.",
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(
args.path,
2 changes: 1 addition & 1 deletion examples/04_training/02_train_tito_model.py
Original file line number Diff line number Diff line change
@@ -235,7 +235,7 @@ def main(
help="If True, Weights & Biases are used to track the experiment.",
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(
args.path,
2 changes: 1 addition & 1 deletion examples/04_training/03_train_dynedge_from_config.py
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ def main(
help="If True, Weights & Biases are used to track the experiment.",
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(
args.dataset_config,
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ def main(
default=None,
)

args = parser.parse_args()
args, unknown = parser.parse_known_args()

main(
args.dataset_config,
2 changes: 1 addition & 1 deletion tests/examples/04_training/test_training_examples.py
Original file line number Diff line number Diff line change
@@ -15,4 +15,4 @@
@pytest.mark.parametrize("example", examples)
def test_script_execution(example: str) -> None:
"""Test function that executes example."""
runpy.run_path(os.path.join(EXAMPLE_PATH, example))
runpy.run_path(os.path.join(EXAMPLE_PATH, example), run_name="__main__")
Loading