-
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
BUG: Fix miscellaneous errors in scripts #77
Conversation
CI failure is unrelated: X-ref issue #69. |
8b32231
to
31715ac
Compare
I know 8b32231 is probably not a popular decision, but I see no other way to solve the script and package name clash issue. Not sure why this did not happen before. Also, I do not know whether this implies changes to the
|
31715ac
to
3969469
Compare
If the current renaming is not good/descriptive enough for the package, other possibilities may be: |
3969469
to
c0ad2a1
Compare
I'm really not keen on renaming the tools. Can we avoid it? there was never an issue before. I can check if we can avoid renaming it. But having a script with the same name of the package is common practice |
I have not found a way to rename them, unfortunately. TBH, I believe that keeping naming a script with the same name as the package is something that will continue causing issues and prevent using the tool for those of us that likely need to develop on top of it (i.e. not only call the scripts). The alternative is to rename the package, which involves more work and looks less appropriate as a fix here. From the point of view of a SW, a script name should take the form of an action verb. As long as all this is clear in the documentation, I do not think this will be misleading, and I do not think users of If you find a solution that avoids renaming the scripts that is not likely to cause issues such as the ones described above, I would be happy to try them. I will rebase on |
I don't share the opinion that this will cause problems. There are several examples on packages with the same name as their scripts, for example: https://sshuttle.readthedocs.io/en/stable/ |
Sorry, Demian, re-checked my statements and went through the example you provided me with:
Are we OK with this? Please try the above recipe (cloning the repository, checking out the branch, installing the package and calling the help on the script) on your end if you want to be sure. |
c0ad2a1
to
a468e16
Compare
Sounds great, good job! Would it be possible to be more uniform in the renaming of the scripts ? For instance |
Rename scripts so that their `main` method can be effectively imported when installing them as Python scripts that can be effectively called from the command line: add the `py` extension to the script filenames. Fixes: ``` Traceback (most recent call last): File ".virtualenvs/tract_querier/bin/tract_querier", line 5, in <module> from scripts.tract_querier import main ModuleNotFoundError: No module named 'scripts.tract_querier' Traceback (most recent call last): File ".virtualenvs/tract_querier/bin/tract_querier", line 5, in <module> from scripts.tract_querier import main ModuleNotFoundError: No module named 'scripts.tract_querier' ``` raised locally when executing: ``` tract_querier -t "${tractogram_fname}" -a "${wmparc_fname}" -q "${query_fname}" -o "${out_fname}" ``` using some local data.
Fix `Mapping` and `Iterables` classes import modules: import them from `collections.abc` instead of from `collections` as they have been moved to the former since Python 3.3. Fixes: ``` Traceback (most recent call last): File ".virtualenvs/tract_querier/bin/tract_math", line 8, in <module> sys.exit(main()) File ".virtualenvs/tract_querier/lib/python3.10/site-packages/scripts/tract_math.py", line 33, in main from tract_querier.tract_math import operations File ".virtualenvs/tract_querier/lib/python3.10/site-packages/tract_querier/tract_math/__init__.py", line 3, in <module> from .decorator import tract_math_operation, TractMathWrongArgumentsError File ".virtualenvs/tract_querier/lib/python3.10/site-packages/tract_querier/tract_math/decorator.py", line 3, in <module> from collections import Mapping, Iterable ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py) ``` Documentation: https://docs.python.org/3.3/library/collections.abc.html
Rename scripts: do not use package names to name scripts to avoid clashes. If a script has the same name as the package, importing the package or its submodules within the script may result in Python trying to import the script itself. Fixes: ``` Traceback (most recent call last): File "/snap/pycharm-professional/443/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/snap/pycharm-professional/443/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/jhlegarreta/src/tract_querier/scripts/tract_querier.py", line 286, in <module> main() File "/home/jhlegarreta/src/tract_querier/scripts/tract_querier.py", line 94, in main if os.path.exists(tract_querier.default_queries_folder): AttributeError: module 'tract_querier' has no attribute 'default_queries_folder' ``` raised locally when debugging `tract_querier.py`.
a468e16
to
14a85f8
Compare
Done in 14a85f8. Force pushed. |
Good job @jhlegarreta ! |
There's no script name changes, after the installation, the installed scripts that you can run from the commandline have the correct names @tashrifbillah . It's the intermediate scripts to be installed that have been renamed. |
Okay, we shall test the current master shortly. |
Let us know how it goes ! |
It went fine, thank you. |
So we can close the corresponding issue and PR you had opened on this matter @tashrifbillah ? |
Yes. |
py
extension to the script filenamesMapping
andIterables
names import modules