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

run_tool default arguments #2174

Closed
nbiederbeck opened this issue Dec 21, 2022 · 3 comments · Fixed by #2175
Closed

run_tool default arguments #2174

nbiederbeck opened this issue Dec 21, 2022 · 3 comments · Fixed by #2175

Comments

@nbiederbeck
Copy link
Contributor

def run_tool(tool: Tool, argv=None, cwd=None, raises=False):

We only use run_tool in test files:

$ rg run_tool -l
ctapipe/conftest.py
ctapipe/core/__init__.py
ctapipe/core/tool.py
ctapipe/instrument/conftest.py
ctapipe/tools/tests/test_process_ml.py
ctapipe/tools/tests/test_process.py
ctapipe/tools/tests/test_merge.py
ctapipe/tools/tests/test_train.py
ctapipe/tools/tests/test_tools.py
ctapipe/tools/tests/test_apply_models.py
ctapipe/core/tests/test_tool.py
ctapipe/core/tests/test_traits.py

I assume it is not used externally.

I have two points to discuss:

  1. It happens that cwd is not set properly and tests clutter the working directory with (prov-)log-files etc. Maybe it should have no default argument, so it gets set correctly by the developers implementing the tests?
  2. raises is by default False, which I think is the wrong choice. One can either check correctly for raised errors when writing the tests, or if assert run_tool([...]) != 0 is really needed, set raises=False. I think this is mainly a quality of life change for developers debugging while implementing tests.

What do you think?

@maxnoe
Copy link
Member

maxnoe commented Dec 21, 2022

Maybe it should have no default argument, so it gets set correctly by the developers implementing the tests?

Or the default should be a tmpdir

@maxnoe
Copy link
Member

maxnoe commented Dec 21, 2022

What do you think?

Agreed.

@nbiederbeck
Copy link
Contributor Author

Or the default should be a tmpdir

We are using at least dl1_tmp_path and dl2_tmp_path so I would say one should set it accordingly to whatever gets tested.

Not sure though if different temporary paths are needed at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants