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

Fix the attractors tasks application example #317

Merged
merged 3 commits into from
Oct 21, 2020

Conversation

rahulporuri
Copy link
Contributor

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 and chaco in the envisage devenv and then do python -m attractors.run from the examples/plugins/tasks directory.

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
examples/plugins/tasks/attractors/README.txt Outdated Show resolved Hide resolved
examples/plugins/tasks/attractors/README.txt Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@
from traits.api import Bool, Instance, List, Property

# Local imports.
from attractors_preferences import (
from attractors.attractors_preferences import (
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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
@rahulporuri rahulporuri requested a review from kitchoi October 21, 2020 09:01
Copy link
Contributor

@kitchoi kitchoi left a 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.

@rahulporuri rahulporuri merged commit 7b3a75e into master Oct 21, 2020
@rahulporuri rahulporuri deleted the fix/attractors-example branch October 21, 2020 10:16
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

Successfully merging this pull request may close these issues.

2 participants