-
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
Fix the attractors tasks application example #317
Conversation
The fixes are mostly trivial - involving updating implicit imports to explicit imports. new file: examples/plugins/tasks/attractors/README.txt modified: examples/plugins/tasks/attractors/attractors_application.py modified: examples/plugins/tasks/attractors/attractors_plugin.py modified: examples/plugins/tasks/attractors/model/henon.py modified: examples/plugins/tasks/attractors/model/i_plottable_2d.py modified: examples/plugins/tasks/attractors/model/lorenz.py modified: examples/plugins/tasks/attractors/model/rossler.py modified: examples/plugins/tasks/attractors/plot_2d_pane.py modified: examples/plugins/tasks/attractors/plot_3d_pane.py modified: examples/plugins/tasks/attractors/run.py modified: examples/plugins/tasks/attractors/visualize_2d_task.py modified: examples/plugins/tasks/attractors/visualize_3d_task.py
@@ -4,7 +4,7 @@ | |||
from traits.api import Bool, Instance, List, Property | |||
|
|||
# Local imports. | |||
from attractors_preferences import ( | |||
from attractors.attractors_preferences import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really does assume where python
is run from, that's okay if this really isn't supposed to be run in any other way. from .attractors_preferences import ...
would be free of that assumption in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was on the fence about using implicit imports. updating them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. that did not work as expected. trying to run python run.py
gives the error
Traceback (most recent call last):
File "run.py", line 7, in <module>
from .attractors_plugin import AttractorsPlugin
ModuleNotFoundError: No module named '__main__.attractors_plugin'; '__main__' is not a package
which makes sense because python does not know about the attractors
package because it is not on path when i cd into the attractors
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK... I am not sure how this is going to work under etsdemo if the examples need to assume certain python paths. Probably a separate issue.
this way, when the attractors example is moved into the envisage package and contributed to etsdemo, it works nicely with the application renamed: attractors/README.txt -> index.rst
Co-authored-by: Kit Choi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, relative imports would have enabled running the plugin from an outer directory, e.g. in examples/plugins
folder:
python -m tasks.attractors.run
Or even from the source root directory:
python -m examples.plugins.tasks.attractors.run
In any case, running run.py
directly from the examples/plugins/tasks/attractors
won't work whichever relative or absolute import we use, unless we change with the python path somehow.
We don't seem to need that flexibility for now, so this is okay.
The fixes are mostly trivial - involving updating implicit imports to explicit imports.
To be able to run this example, you will need to install
numpy
,scipy
,mayavi
andchaco
in the envisage devenv and then dopython -m attractors.run
from theexamples/plugins/tasks
directory.