Upgrade to Pro — share decks privately, control downloads, hide ads and more …

주피터(Jupyter) - IRuby Notebook

nacyot
September 01, 2015

주피터(Jupyter) - IRuby Notebook

주피터(Jupyter) - IRuby Notebook
RORLAB #84 (2015-04-14)

http://blog.nacyot.com/articles/2015-04-15-rorlab-jupyter-iruby-notebook/

IPython은 파이썬의 REPL을 확장하기 위한 도구입니다. IPython과 더불어 웹기반 IPython Notebook은 모든 REPL에 관심있는 사람들에게 사랑받고 있는 도구입니다. 이는 IPython의 웹기반 인터페이스와 언어 실행을 위한 REPL(커널)이 분리되어 있어, 파이썬 뿐만 아니라 다양한 언어의 커널을 지원하고 있기 때문입니다. 또한 IPython 역시 얼마 전 이러한 흐름을 받아들여 Python이라는 흔적을 지우고 Jupyter라고 이름을 바꾸었습니다.

이 발표에서는 Jupyter가 어떻게 다언어 커널을 지원하는 지에 대한 원리를 설명하고, IRuby Notebook을 실제로 사용하는 방법에 대해서 다룹니다. 또한 이러한 웹 기반 REPL 도구가 단순한 프로그래밍 언어를 보조하기 위한 REPL을 넘어 글쓰기 도구로서 어떻게 확장될 수 있는지에 대해서 이야기합니다.

nacyot

September 01, 2015
Tweet

More Decks by nacyot

Other Decks in Programming

Transcript

  1. REPL of Ruby irb(ܖ࠺ ղ੢ REPL) PRY (ഛ੢ REPL) RORLAB

    / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 4
  2. PRY an IRB alternative and runtime developer console RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 5
  3. Demo #1 • Executing IRuby Notebook server • IRuby Notebook

    interface • Evaluating simple Ruby expressions RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 7
  4. Python੄ REPL ҳഅ • ӝࠄ REPL • python • ഛ੢

    REPL • ipython • bpython RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 13
  5. ৵ Python REPL੄ ഛ੢ਸ ٜ݅঻ਸө? I started using Python in

    2001 and liked the language, but its interactive prompt felt like a crippled toy compared to the systems mentioned(maple, mathematica, etc) above or to a Unix shell. — Fernando Perez RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 15
  6. IPython 0.12 The major new feature with this release is

    the IPython Notebook, an interactive Python interface running in the browser. Download it now, or read more about what’s new. — IPython 0.12 Release Note RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 19
  7. IPython 0.11 - qtconsole Rich GUI IPython client RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 22
  8. IPython 0.11 - ZeroMQ • ZeroMQ ӝ߈ ݫद૑ दझమ بੑ

    • ࢿמ ޙઁ ೧Ѿ ߂ qtconsole ߔূ٘ • ipython notebook RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 23
  9. ӝઓ੄ REPL • ೧׼ೞח प೯ӝ ঱য۽ ҳഅ • lisp ->

    lisp, irb -> ruby • python -> python • ௿ۄ੉঱౟(ࣕ)৬ ߔূ٘(प೯ӝ)੄ ъೠ Ѿ೤ • ܻ࠙ೞӝ য۰਑ • REPL੉ о૑ח Ӕࠄ੸ੋ ઁড RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 24
  10. ZeroMQо بੑػ ੉ਬ ZeroMQ provides us with much tighter control

    over memory, higher performance, and its communications are impervious to the Python Global Interpreter Lock because they take place in a system-level C++ thread." — IPython 0.11 Release Note RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 26
  11. ׮নೠ ௿ۄ੉঱౟ ૑ਗ • Notebook(client) - IPython Server • qtconsole

    • IPython Notebook • IPython • BIPython RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 30
  12. Message Protocol • Messaging in IPython • 0.11ীࢲ ҕѐ •

    ੗୓ ߡ੹ਸ о૑Ҋ ੓ਵݴ അ੤ 5.0 • ZeroMQ ӝ߈ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 33
  13. प೯ӝ(ழօ)੄ ܻ࠙ • Message Protocolী ٮܰח Kernel ѐ֛ بੑ •

    Python प೯ӝо Python Kernel۽ ܻ࠙ؽ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 34
  14. IPython਷ ঱যী ࠺ઙࣘ੸ੋ REPL • ழօ੉ ܻ࠙غݶࢲ ׮নೠ ழօ੉ ѐߊؽ

    • ӝઓ੄ بҳ/ࢤక҅ܳ Ӓ؀۽ ੉ਊ оמ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 38
  15. IPython Kernels • IPython kernels for other languages • Julia,

    Haskell, FSharp, Ruby, Go • Scala, Mathics, Aldor, Calico, Erlang • Lua, R, OCaml, Forth, Perl, Perl6 • Octave, Scilab, MathLab, Bash, CSahrp • Clojure, Hy, Redis, Javascript, Calysto, ... RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 39
  16. IPython 3.0 = Jupyter • Project Jupyter • ؊ ੉࢚

    Python݅ਸ ਤೠ بҳо ইשਸ ੋ੿ • ౵੉ॆী ҙ۲ػ ೐۽ં౟ -> IPython • ׮঱য ૑ਗਸ ਤೠ ೐۽ં౟ -> Jupyter • Jupyter Protocol • Jupyter Notebook(HTML+Javascript ܻ࠙) RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 40
  17. Jupiter тܾۨয় тܾۨ੉ - য়ېػ ഴܯೠ दпച ࢎ۹ link RORLAB

    / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 41
  18. Jupyter = Julia + Python + R RORLAB / ઱ೖఠ(Jupyter)

    ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 42
  19. Jupyter = Julia + Python + R RORLAB / ઱ೖఠ(Jupyter)

    ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 43
  20. Jupyter ੉੹ - ఋ঱য ழօ ࢎਊߨ IPython਷ ழօী ੄ઓ੸ਵ۽ प೯

    $ ipython notebook --kernel <language> RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 44
  21. Jupyter ੉റ - Kernelspec ౠ੿ ழօী ࠺੄ઓ੸ਵ۽ प೯ RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 45
  22. ࢸ੿ ٣۩ఠܻ ҳઑ $ tree -d -L 1 ~/.ipython ~/.ipython

    ├── db ├── extensions ├── kernels # <- ৈӝ ├── log ├── nbextensions ├── pid ├── profile_default ├── security ├── startup └── static RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 46
  23. ఋ঱য ழօ ࢎਊ -> ׮঱য ழօ ࢎਊ IRuby, IBash ࢸ஖

    ੉റ $ tree -d -L 1 ~/.ipython/kernels ~/.ipython/kernels ├── ruby └── bash RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 47
  24. Jupyter Interface ೞա੄ Jupyter Instanceীࢲ ׮঱য ழօ प೯оמ RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 48
  25. Demo 2 • Ruby • Haskell • Bash RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 49
  26. What is the big deal about IPython Notebooks? RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 51
  27. ਢ গ೒ܻா੉࣌ • ߧਊ੸ੋ ਬ੷ ੋఠಕ੉झ • ࠺ࢶഋ੸ ௏٘ प೯

    • CodeMirror ী٣ఠ • Javascript ജ҃ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 52
  28. ߧਊ੸ੋ ਬ੷ ੋఠಕ੉झ • ਢীࢲ оמೠ ݽٚ Ѫ • HTML,

    CSS, Image, Canvas, SVG, ... RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 53
  29. ࠺ࢶഋ੸ ௏٘ प೯ (1) ࢶഋ੸ੋ प೯ - REPL੄ ࠄ૕੸ੋ ೠ҅

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 54
  30. ࠺ࢶഋ੸ ௏٘ प೯ (2) ௏٘ח ࣄ ױਤ۽ ಞ૘ೞҊ, प೯غҊ, ੤प೯

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 55
  31. Demo 3 • Javascript Magic • D3 Notebook ৘ઁ(दпച झఠ٣)

    • Interactive Widget • InlineAttachment ৘ઁ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 58
  32. REPL • ࣗݽࢿ ೐۽Ӓې߁ ജ҃ • ࠁా ૣ਷ ௏٘ పझ౟ਊ

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 62
  33. REPL੄ ೠ҅ܳ ֈযࢲ • ӝ۾ਸ ਤೠ ೐۽Ӓې߁ ജ҃ • ׮নೠ

    ಴അ ૑ਗ • ࣄ ױਤ੄ ௏٘ ಞ૘ ૑ਗ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 63
  34. োणҗ ӝ۾ Examples are reusable ideas in the form of

    customizable code snippets; examples can serve as an alternative to fixed, monolithic typologies; examples are a shared extension of memory. — Eyeo 2013 - For example by Mike Bostock RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 64
  35. ௏٘ IPython code ઺ ੌࠗ - BSD License RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 67
  36. Ӗ Discourse on Floating Bodies, by Galileo Galilei RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 68
  37. ௏٘৬ Ӗ ≒ ޛҗ ӝܴ • п੗ Ҋਬೠ ݓۅਸ о૗

    • ੹ഃ ׮ܲ ߑधਵ۽ ॳৈ૗ • بҳ۽ ୊ܻೡ ࣻ ੓ח ࠗ࠙੉ ׮ܴ • ޙߨ ࠙ࢳҗ ݏ୺ߨ/য়ఋ • Syntax ೞ੉ۄ੉౴ • 80੗ ઁೠҗ ޙױ ѐ֛ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 69
  38. Ӗ উী ನೣػ "લয੓ח" ௏٘ ଼ী पܽ ௏٘ RORLAB /

    ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 70
  39. ௏٘৬ Ӗ੄ Ҋਬೠ ݓۅী ؀ೠ Ҋ޹ٜ • Donal E. Knuth

    - Literate Programming • Alan Kay - Active Essays • Fernando Perez - Data-driven Journalism RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 71
  40. Literate Programming(ޙ೟੸ ೐۽Ӓې߁) Let us change our traditional attitude to

    the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. — Donald E. Knuth RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 72
  41. knitr (1) from future import dream knitrܳ ੉ਊೠ ਕ٘೐ۨझ ನझ౴ೞӝ

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 80
  42. knitr (2) from future import dream knitrܳ ੉ਊೠ ਕ٘೐ۨझ ನझ౴ೞӝ

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 81
  43. Active Essays An “Active Essay” is a new kind of

    literacy, combining a written essay, live simulations, and the programs that make them work in order to provide a deep explanation of a dynamic system. The reader works directly with multiple ways of representing the concepts under discussion. By “playing with” the simulations and code, the reader gets some hands-on experience with the topic. — Alan Kay RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 83
  44. Steven Wittens' Presentation • Making WebGL Dance • Source Code

    RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 84
  45. Jiongster • ..., Why React is Awesome • Presenting The

    Most Over-Engineered Blog Ever RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 86
  46. Awesome! • ಴അ بҳ۽ࢲ੄ ੗߄झ௼݀౟ • ೞ૑݅, ೞա੄ ਢࢎ੉౟ۄҊ ࠊঠ...

    • ੷੘ ജ҃ = Ӓր ೐۽Ӓې߁ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 87
  47. "௏٘"৬ "োҳ"੄ ݅թ അઓೞח о੢ ߧਊ੸ੋ Scientific Research ജ҃. RORLAB

    / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 89
  48. "Ӗ"җ "௏٘"੄ Ҋਬೠ ݓۅ അઓೞח о੢ ߧਊ੸ੋ Active Essays ੷੘

    ജ҃. RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 90
  49. Data-driven Journalism Our job with IPython is to think deeply

    about questions regarding the intersection of computing, data and science, but it's clear to me at this point that we can contribute in contexts beyond pure scientific research. I hope we'll be able to provide folks who have a direct intersection with the public, such as journalists, with tools that help a more informed and productive debate. — Fernando Perez RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 92
  50. Reproducible Notebook • ௏٘ܳ प೯೧ࠁח Ѫী Ӓ஖૑ ঋ਺ • ੷੢ೞҊ,

    ѱदೞҊ, ҕਬೞب۾ ب৬ષ • ipython ജ҃੉ ੓׮ݶ प೯೧ࠁח Ѫب оמ • HTML ١ ׮ܲ ನݘਵ۽ ୹۱ ӝמ ઁҕ • nbviewer • ipynb ࠭য ࢲߡ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 93
  51. IPython Notebookਵ۽ ࠶۽Ӓೞӝ • Fernando Perez Blogging with the IPython

    notebook • Pythonic Perambulations • Box and Whisker IPython Notebookਵ۽ ࠶۽Ӧೞӝ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 94
  52. ࢎ۹ ܖ࠺੄ Ԣ, ৌѢ੗ Enumerable ݽٕ ܖ࠺(Ruby) పझ౟ ೐ۨ੐ਕ௼ RSpec

    2.14 ݒ୛ RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 95
  53. .ipynb ࠽٘ helper/markdown_helper.rb def render_ipynb(filename) source = "./source/iruby/#{filename}.ipynb" output =

    "./source/iruby/#{filename}" cmd = "ipython nbconvert --to html --template basic #{source} --output #{output}" system(cmd) end RORLAB / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 96
  54. Demo 5 • ܖ࠺੄ Ԣ, ৌѢ੗ Enumerable ݽٕ प೯ೞӝ RORLAB

    / ઱ೖఠ(Jupyter) ೐۽ં౟ - IRuby Notebook © nacyot 2015 - 97