Skip to content

[WIP] Contributing a few examples to etsdemo#359

Closed
aaronayres35 wants to merge 4 commits into
masterfrom
move-examples-to-package-etsdemo
Closed

[WIP] Contributing a few examples to etsdemo#359
aaronayres35 wants to merge 4 commits into
masterfrom
move-examples-to-package-etsdemo

Conversation

@aaronayres35
Copy link
Copy Markdown
Contributor

closes #320

In this PR I currently attempt to contribute a few examples to etsdemo. To do so, I added the entry point to setup.py, defined a function in the package to return info about the files, and copied the examples over to sit inside the package.
Additionally, I removed the logging related code from the examples that were copied into the package.

I copied not moved the examples because I believe the documentation has links to them currently.

Currently, the examples do not run. As is mentioned on the issue, they assume a specific Python Path when they are run which causes problems. Modules seem to get renamed inside the file tree in the demo (e.g. acme is shown as Acme, underscores turn to spaces). When clicking run with the run.py file selected for the MOTD example, the following traceback occurs:

Traceback (most recent call last):
  File "/Users/aayres/Desktop/traitsui/ets-demo/etsdemo/app.py", line 472, in run_code
    exec(self.source, locals, locals)
  File "<string>", line 5, in <module>
ModuleNotFoundError: No module named 'acme'

I'm unsure how to best resolve this problem. @kitchoi any suggestions would be appreciated. My only idea currently is to define the relevant classes, etc. in just one file (for MOTD this isnt too noisy), but this is not the right solution.

However, the current hello_world.py example seems like it should run fine (no errors occur currently), but no output is printed. It only imports from traits.api and envisage.api. I'm unsure what the problem is here.

….py and define a function in the package that returns information about the data files
@kitchoi
Copy link
Copy Markdown
Contributor

kitchoi commented Nov 30, 2020

I copied not moved the examples because I believe the documentation has links to them currently.

I'd very much prefer not duplicating the examples because of the documentation links. We should try to update the documentation source so that we can move the examples instead of duplicating them.

There are two possible solutions to solving the import issue:
(1) Temporarily modify sys.path when the application runs (see #377)
(2) Since the examples are moved into envisage, we can make use of namespace packages. e.g. we will have to change from acme import ... to from envisage.examples.MOTD.acme import ... instead. But places where package dependencies are evaluated at runtime, e.g. ExtensionPoint(List(Instance("acme.motd.api.IMessage"))), those will need to be changed as well, e.g. to ExtensionPoint(List(Instance("envisage.examples.MOTD.acme.motd.api.IMessage"))). Therefore I prefer option (1).

@kitchoi
Copy link
Copy Markdown
Contributor

kitchoi commented Dec 1, 2020

I'd very much prefer not duplicating the examples because of the documentation links. We should try to update the documentation source so that we can move the examples instead of duplicating them.

See #379

@aaronayres35
Copy link
Copy Markdown
Contributor Author

superseded by #380

@rahulporuri rahulporuri deleted the move-examples-to-package-etsdemo branch May 14, 2021 12:00
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.

Consider contributing a few examples to etsdemo.

2 participants