ANTsX/ANTsPy

File errors in `ants` folder under home directory crashes ANTsPyx

dipterix opened this issue · 4 comments

I copied some home-brewed scripts using ants into my home directory, under folder name ants.

It seems that whenever I load ants, the package will run whatever is in the ~/ants folder, and errors out when the folder script contains bugs.

I wonder if it's possible to

  1. add try-catch to wrap loading ~/ants so ants loads even there is an error in the script
  2. add a special file (e.g. .ANTSIGNORE), which list files that should be excluded from startup.

I sort of get what you mean but would need a bit more explanation. Would just renaming your folder to something else fix it? It is never really advisable to have a folder with the same name as a package... but I'm assuming you actually have the repo cloned? If you're willing to submit a PR the it sounds like something we can definitely use.

I was able to fix it by myself. I understand the solution is easy once found out. However, that requires me to read into the python error trace back messages. I was helping a physician with his computer but they don't know too much about programming. What's even worse is that they have pipeline SOP that includes creating this folder.

Though I told them not to do this. It's pretty straightforward and common for lots of people to create folders with the same name under home directory, just to store their daily functions. For programs, I believe there are better places to store the package add-ons. For example $XDG_DATA_HOME, $XDG_CONFIG_HOME, and $XDG_CACHE_HOME.

However, I guess changing to $XDG_CONFIG_HOME or $XDG_DATA_HOME may be hard for ANTs as you probably created this "add-on" loader because someone wants to use this feature. That's why files like .ANTS_IGNORE or .ANTS_ADD_ON could help resolving the current issues without putting too much efforts: it simply allows ANTs to either ignore or include some starting up files. Or even simpler, putting try-catch with warnings.

If you could point me to where the loading is happening, I'm happy to write a PR.

It seems that whenever I load ants, the package will run whatever is in the ~/ants folder, and errors out when the folder script contains bugs.

Can you show an exact set of commands you're doing, and the output you're getting?

Going to close for now because I think this is kind of an unusual case. I can't reproduce unless I use an environment where antspyx is not installed. But when using Jupyter or some other setup where the search path is different, I guess it could happen.

I'm not sure ANTsPy is doing anything special. I can put bad code under ~/ants and still import ants normally.