-
Notifications
You must be signed in to change notification settings - Fork 26
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
ENH: Test calling the scripts #78
base: master
Are you sure you want to change the base?
Conversation
PR #77 should be merged before this one, then I'd rebase on |
1c10bd0
to
62b882c
Compare
62b882c
to
34b8161
Compare
e.g. https://github.com/demianw/tract_querier/actions/runs/12770291868/job/35594799004?pr=78#step:6:52:
Ready to be merged. |
@demianw This is ready to be merged. |
@jhlegarreta I think that if this is good idea. However, the testing file
We should choose one of the two strategies and stick to it and not have two parallel systems performing the same checks. |
Oh, that's true Deminan, sorry. However, that seems not to be running: Even if I must say that I believe I left behind modifying the file names in PR #77: The test has not been running all this time either, e.g. two runs prior to merging PR #77: I do not know why that is, but these are my thoughts:
Let me know what your thoughts are. I may not have the bandwidth to investigate why |
It's a good feedback. So just move all the tests there to the new framework that you started. Does that seem a good solution to you ? |
Sounds good. Will do today/in the coming days. Thanks. |
OK, I have had a look at integrating the tests into the structure proposed in this PR and I believe one of the reasons why this has not been running might be due to:
|
Do you have a preference for the place to drop the files ?
|
x-ref PR #88: test files were added to OSF. OSF works for the immediate purposes of moving forward. Thanks Demian. |
34b8161
to
96883d3
Compare
Doc build failure is unrelated (addressed in PR #89). This is ready to be merged for when PR #88 will be finalized and merged. Tests are passing because actually exercising the scripts is being skipped:
https://github.com/demianw/tract_querier/actions/runs/12833173193/job/35787565543?pr=78#step:6:53 due to the decorator:
It is being removed in PR #88, so we should be good after that. |
9d30828
to
509e5c6
Compare
24d8aaf
to
096f980
Compare
Move test files to OSF and refactor the `datasets.py` module: - Use the new URLs of the test files stored in OSF. - Add the `b` prefix to the MD5 hashes of the files to match the binary string returned by the hash computation method. - Do not try to encode the byte object with the file contents: some of the test files are binary files, and can only be read in binary format; trying to read them in text mode raises a `UnicodeDecodeError` error when calling `encode('utf-8')` on them, and calling `encode('utf-8')` on the bytes read raises a `AttributeError: 'bytes' object has no attribute 'encode'` error. Thus, read them in binary mode and compute the hash on the returned binary data without trying to encode them. Reading the files using chunks is not implemented as the files are not that large. - Remove the unnecessary dependency on `unittest`.
85d6107
to
b31e868
Compare
PR #88 is no longer relevant (x-ref #88 (comment)), and tests are being exercised and are passing now, e.g.:
https://github.com/demianw/tract_querier/actions/runs/12954696522/job/36137183798?pr=78#step:6:52 |
Test the CLI scripts: - Adapt and transfer the contents of the `test_scripts.py` test script to a more modern and compact approach that uses the `pytest` `pytest-console-script` plugin and that does not require fiddling with the location of the files. This allows to test that the CLI scripts are installed appropriately/called using the names defined in the `pyproject.toml` `project.scripts` section. - Split the tests into two different files following the scripts being tested: `tract_math` and `tract_querier`. - Remove the `test_scripts.py` file. Add the `pytest-console-script` dependency so that the scripts can be called when executing `pytest`. Convert the `output.values()` ordered dictionary values to a list prior to slicing in `decorator.py`. Fixes: ``` "/src/tract_querier/scripts/cli_tract_math.py", line 109, in main\n operations[args.operation] (\n File "/src/tract_querier/tract_querier/tract_math/decorator.py", line 148, in wrapper\n process_output(func(*option_and_args))\n File "/src/tract_querier/tract_querier/tract_math/decorator.py", line 199, in process_output\n first_value = output.values()[0]\n TypeError: \'odict_values\' object is not subscriptable\n') ``` raised locally when running the script tests.
Prefer retrieving the next iterator element over slicing.
Use `getfullargspec` instead of deprecated `getargspec` to get the names and default values of function parameters. Fixes: ``` inspect. getargspec() is deprecated since Python 3.0, use inspect. signature() or inspect. getfullargspec() ``` reported by IDE inspection tool.
b31e868
to
42334dc
Compare
Test the CLI scripts:
test_scripts.py
test script to a more modern and compact approach that uses thepytest
pytest-console-script
plugin and that does not require fiddling with the location of the files. This allows to test that the CLI scripts are installed appropriately/called using the names defined in thepyproject.toml
project.scripts
section.tract_math
andtract_querier
.test_scripts.py
file.Add the
pytest-console-script
dependency so that the scripts can be called when executingpytest
.Convert the
output.values()
ordered dictionary values to a list prior to slicing indecorator.py
. Fixes:raised locally when running the script tests.