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

Many examples won't work if config file is not specified in Python 3.9+ #374

Open
shixnya opened this issue Jun 25, 2024 · 2 comments
Open

Comments

@shixnya
Copy link
Collaborator

shixnya commented Jun 25, 2024

Many examples under examples/ use the following line to set the 'default' config file.

if __file__ != sys.argv[-1]:

However, in Python 3.9+, this won't work because __file__ is an absolute path.

An easy way to fix it will be using something like:

if sys.argv[-1] in __file__:

Or, alternatively, we can change __file__ to os.path.basename(__file__).

There might be a better idea, so making an issue to discuss.

@shixnya
Copy link
Collaborator Author

shixnya commented Jun 25, 2024

This change of behavior in Python 3.9+ is documented here.
https://docs.python.org/3/whatsnew/3.9.html#other-language-changes

Python now gets the absolute path of the script filename specified on the command line (ex: python3 script.py): the file attribute of the main module became an absolute path, rather than a relative path.

@kaeldai
Copy link
Collaborator

kaeldai commented Jun 26, 2024

We should replace the if statement with using argparse library. It's relatively easy to implement but we'll have to change most of the run_[bionet|pointnet|filternet].py examples

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

No branches or pull requests

2 participants