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

[IPython] Support IDLE and Blender scripting module as interactive shell #1308

Closed
wants to merge 2 commits into from

Conversation

archibate
Copy link
Collaborator

@archibate archibate commented Jun 23, 2020

@archibate archibate added waiting for reply wontfix We won't fix this issue or merge this PR and removed waiting for reply labels Jun 27, 2020
@archibate archibate closed this Jul 1, 2020
@archibate archibate reopened this Jul 13, 2020
@archibate archibate changed the title [IPython] Support IDLE as interactive shell (experimental) [IPython] Support IDLE and Blender scripting module as interactive shell Jul 13, 2020
@codecov
Copy link

codecov bot commented Jul 13, 2020

Codecov Report

Merging #1308 into master will decrease coverage by 0.57%.
The diff coverage is 61.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1308      +/-   ##
==========================================
- Coverage   66.84%   66.26%   -0.58%     
==========================================
  Files          38       41       +3     
  Lines        5450     5775     +325     
  Branches      956      998      +42     
==========================================
+ Hits         3643     3827     +184     
- Misses       1644     1777     +133     
- Partials      163      171       +8     
Impacted Files Coverage Δ
python/taichi/idle_hacker.py 0.00% <0.00%> (ø)
python/taichi/lang/kernel.py 82.77% <ø> (+1.20%) ⬆️
python/taichi/tools/np2ply.py 13.37% <ø> (ø)
python/taichi/misc/gui.py 25.36% <16.12%> (-1.15%) ⬇️
python/taichi/main.py 42.18% <17.64%> (+0.10%) ⬆️
python/taichi/lang/shell.py 42.51% <39.47%> (+3.81%) ⬆️
python/taichi/core/util.py 21.30% <42.85%> (-0.43%) ⬇️
python/taichi/core/settings.py 48.14% <45.45%> (ø)
python/taichi/lang/impl.py 89.41% <63.15%> (-1.14%) ⬇️
python/taichi/__init__.py 75.00% <75.00%> (-17.00%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f4ce50...d04fbf7. Read the comment docs.

@archibate archibate marked this pull request as ready for review July 13, 2020 05:30
@archibate archibate requested review from rexwangcc, yuanming-hu, k-ye and taichi-gardener and removed request for rexwangcc and yuanming-hu July 13, 2020 05:30
@archibate archibate added large changeset The PR contains a large changeset and reviewing may take times and removed wontfix We won't fix this issue or merge this PR labels Jul 13, 2020
@archibate archibate force-pushed the dillidle branch 2 times, most recently from d4aa3a2 to 73bff6c Compare July 14, 2020 01:22
taichi_dir = os.path.dirname(os.path.abspath(ti.__file__))
filename = os.path.join(taichi_dir, '.tidle_' + str(os.getpid()))
with open(filename, 'a') as f:
f.write('\n===\n' + source)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to use this dirty method since idle and taichi is running in separate process... any idea?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUIC you want to inject part of the process info of taichi into IDLE so they could work together? I'm not so sure but would ZeroMQ work in this scenario without the dirty hack? Its binding with Python is really easy to work with and is pretty fast at IPC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we can directly wrap sockets and pass arbitrary python objects using multiprocessing? Correct me if I'm wrong, I feel like I'm missing sth here lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sockets

In fact, the IDLE already using socket as IPC, and that could be an ultimate solution, however:

  1. Not sure if it's invarient over different versions.
  2. I'm not super familiar about sockets :(

So I'd rather write a portable file IPC instead, WDYT?

ZeroMQ

No, Taichi is already a highly dedicated package, having too heavy dependencies could easily ban it from everyday people, sorry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see. Then I think this solution's good enough. The one that works is always the best one.

@archibate archibate force-pushed the dillidle branch 2 times, most recently from 1121ab3 to 7847dc3 Compare July 14, 2020 04:24
@archibate
Copy link
Collaborator Author

I don't have a Blender, could you confirm this PR works for the Blender scripting module too?

@Eydcao
Copy link
Contributor

Eydcao commented Jul 16, 2020

I don't have a Blender, could you confirm this PR works for the Blender scripting module too?

Hi Yubin,

My first time hearing taichi script in Blender. Does Blender have sth like IDLE for running interactive python? I could help confirm when free later.

Thx


I read that in the #1483 that there is a Blender Python environment. :>

@archibate archibate added the enhancement Make existing things or codebases better label Jul 16, 2020
@archibate archibate added the python Python engineering related label Jul 16, 2020
@archibate archibate requested a review from PavelBlend July 22, 2020 01:50
@archibate
Copy link
Collaborator Author

Why nobody review this.. Here're tons of ad-hoc engineering effort to make the stupid IDLE happy :(

@archibate
Copy link
Collaborator Author

Is this going to be closed?

@EaryChow
Copy link

Please don't close this (╯︵╰)

@archibate
Copy link
Collaborator Author

Please don't close this (╯︵╰)

Of course I won't! ❤️ But given that people never review our PR (why??), I think we can merge on our own if they don't hit the Request Changes button after next release.

@yuanming-hu
Copy link
Member

Thanks for all the contributions here! This is a useful feature and the PR should stay open. I just need more time to review given the large change (and my packed daily schedule...) Sorry about that.

@archibate archibate changed the base branch from master to archibate-idle July 25, 2020 06:05
archibate added a commit that referenced this pull request Jul 26, 2020
* [Misc] Use 'dill.source' of 'inspect' to run codes in interactive shell

* [skip ci] Add dill to CI

* _ShellInspectorWrapper

* Hack IDLE to make it happy

* Fix IDLE

* [skip ci] cache: we do care user experience!!

* improve stability

* [skip ci] fix example exit

* [skip ci] fix exit in IPython

* [skip ci] improve comment

* fix exec risk in ti debug (@rexwangcc)

* [skip ci] Fix ti debug too verbose

* Better line

* fix test_cli

* [skip ci] idle_hacker.py

* fix typo and improve hacker

* [skip ci] reimprov

* improve idle inspector

* [skip ci] add tag [IPython]

* revert idle

* [skip ci] Revert "revert idle"

This reverts commit 794bf05.

* tmp save

* well

* clean

* [skip ci] re

* [skip ci] al

* t

* improve hack

* nice message

* [skip ci] enforce code format

* ti idle_hacker -r

* [skip ci] enforce code format

* fix ipython

* revert

Co-authored-by: Taichi Gardener <taichigardener@gmail.com>
@archibate archibate changed the base branch from archibate-idle to master July 26, 2020 09:08
This reverts commit 202c235.
Copy link
Contributor

@isdanni isdanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The injector LGTM so far! If the other solutions wouldn't work I think this is a good choice

taichi_dir = os.path.dirname(os.path.abspath(ti.__file__))
filename = os.path.join(taichi_dir, '.tidle_' + str(os.getpid()))
with open(filename, 'a') as f:
f.write('\n===\n' + source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUIC you want to inject part of the process info of taichi into IDLE so they could work together? I'm not so sure but would ZeroMQ work in this scenario without the dirty hack? Its binding with Python is really easy to work with and is pretty fast at IPC.

python/taichi/idle_hacker.py Outdated Show resolved Hide resolved
taichi_dir = os.path.dirname(os.path.abspath(ti.__file__))
filename = os.path.join(taichi_dir, '.tidle_' + str(os.getpid()))
with open(filename, 'a') as f:
f.write('\n===\n' + source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we can directly wrap sockets and pass arbitrary python objects using multiprocessing? Correct me if I'm wrong, I feel like I'm missing sth here lol

Co-authored-by: Danni <38550500+isdanni@users.noreply.github.com>
@archibate
Copy link
Collaborator Author

archibate commented Aug 8, 2020

Hi! I searched for the Internet and realized that there are no such package capable of inspecting these various shells yet.
Instead of waiting for somebody to create it, let me create it for serving taichi, and other people suffered from the same issue.
How about this:

  1. Let me create a separate package sourceinspect, and deploy it to PyPI.
  2. The package is able to deal with IDLE, IPython, Jupyter, Blender, etc.
  3. Move all current mocks in taichi, including this PR, to that external package.
  4. No maintaining cost in taichi, we maintain the mocks in sourceinspect separately.
  5. Include sourceinspect as a hard dependency of taichi.

WDYT about this solution? @yuanming-hu @EaryChow @isdanni Inputs are welcome!

@archibate archibate added the wontfix We won't fix this issue or merge this PR label Aug 8, 2020
@archibate archibate closed this Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make existing things or codebases better large changeset The PR contains a large changeset and reviewing may take times python Python engineering related wontfix We won't fix this issue or merge this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants