You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, many of the module imports in scripts in this repository use sys.path.insert() which is bad form. To close this PR, update all of the needed files to import the modules directly without using the sys.path.insert() method.
The text was updated successfully, but these errors were encountered:
There is a feature called importlib.util that is slightly different?
I'm not totally clear on the reasons you have for why sys.path.insert() is bad form, but I've used importlib.util on a couple projects. Basically:
import importlib.util
# Specify the path relative to the current notebook's directory
<name> = importlib.util.spec_from_file_location('<package name>', 'relative/path/to/script.py')
In this repo, from scenarios, you could import analysis.py with:
import importlib.util
# Specify the path relative to the current notebook's directory
analysis = importlib.util.spec_from_file_location('analysis', '../scripts/analysis.py')
I'm sure there are other ways to do this, but this is one method I know of. Would something like this address your issue @abachma2?
If the directory is set up correctly, then you should be able to use import package_name instead of having to add the path to the system. That's what I'm saying is bad form. It's a relatively small thing, but if there is a way to easily clean it all up then it might be worth it.
Right now, many of the module imports in scripts in this repository use
sys.path.insert()
which is bad form. To close this PR, update all of the needed files to import the modules directly without using thesys.path.insert()
method.The text was updated successfully, but these errors were encountered: