jupyter notebook を用いた文芸的インフラ運用のススメ

25
Y Masatani, National Institute of Informatics Jupyter Notebook を⽤いた⽂芸的インフラ運⽤のススメ Toward Literate Computing for Reproducible Infrastructure Y Masatani NII

Upload: no-bu

Post on 15-Apr-2017

1.002 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Jupyter Notebook を⽤いた⽂芸的インフラ運⽤のススメToward Literate Computing for Reproducible Infrastructure

Y Masatani

NII

Page 2: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

現実の問題として..

⽇々の運⽤作業の証跡を記録

そこから⼿順を整理して再利⽤する

マニュアルや教材を整備する

これら複数局⾯での計算機利⽤を、同じような粒度、シームレスな⽅法で「適切に分節化したものを同様に紡いで」記述・蓄積したい

様相の異なる局⾯でも,, 対象が異なっても,,

属⼈化, サイロ化を回避する,,

1

Traceability

Reusability

Reproducibility

Page 3: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Automation ではなく.. Communication

Infrastructure “as Code” = Coding Style を適⽤する–  Validation, Auditing, cross OS …

–  CI (Continuous Integration), Automation …

–  Code vs. Config (Hiera,

現場的には Communication が⼤切…•  スキルセットが異なる当事者間においても.. 個々の作業の再現性を担保したい..

•  インフラの状態やそこに⾄るまでの経緯を理解し易くする..

•  その上で作業をカスタマイズ・再利⽤すると⾔ったプロセス⾃体も(Code として)⾒える化

•  伝達可能にすること,蓄積・発展させること

2

それだけで充分だっけ??

Page 4: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

実現したいこと

•  作業の信頼性向上

•  ⼿順の再利⽤

•  ポータブルな⼿順–  環境に依存しない…

–  環境の変更に追従できる…

–  Systems System への適応

Infrastructure でも Social Coding / Design Review のような… 集合知の形成 / 綺麗な建付を愛でる美意識を形成… できるように

à architecture (operation込) における rationality / cardinality of design を 対象化

Page 5: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

“Literate Computing for Reproducible Infrastructure”⽂芸的機械化 - “機械的に再現できる、⼈が読み解ける⼿順”

⾃動化 ≠ 機械化 ⼈が介在しつつも機械的に再現できる ⇒ Reproducibility

asCode は共通認識の形成に寄与してこそ! .. 現場でのコミュニケーションを促すもの

“Open Communication about Design and Process through Notebook”

計算機 = computation も ⼈間どうし も = communication 役割分担-  実際の実⾏結果が⼿順とともに,dataが live-code に埋め込まれていて再現できる-  ⼿順や経緯 が具体的に,再現可能な形で表現・伝達-  Technical と Non-Technical で 理解を共有

4

Page 6: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Individual 個々⼈による探索・試⾏錯誤

Collaborative 複数⼈でアイデアを共有・レビューして発展

Production 複数のグループによる展開,実⽤化

Publication & Communication

Education

Lifecycle of a Scientific Idea ≒ Engineering Practices5

Page 7: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

構造 - Ansible と Notebook の使い分けと それぞれの分節

Ansible 

⽂脈に依存しない⼿順はAnsibleで構造化•  作業単位に冪等性がある,ないしは作業後の状態が(運⽤観点で)⼀意に確定するなど再利⽤性が⾼い作業単位

•  複数の⽂脈で顕れる類似する作業群をパラメタ化によってひとつに集約して記述できる作業単位

•  複数の対象,サーバ群などに対する作業単位

•  インフラの環境構成とシステムのあるべき姿としてのソフトウェア構成を記述するが、それらの「構成」を決定した経緯はNotebookで記述

Notebook

副作⽤を把握しなければならない⼿順,⽂脈を伴う⼿順はNotebookで構造化•  依存関係のある⼀連の⽂脈を伴う作業の記述.例えば,事前・事後処理のあるひとまとまり作業単位-  リソースの配置設計、リソースに対するアプリケーションの収容設計 をそれぞれ “コードとして” 記述する

•  作業結果に基づいて⼀定の判断,確認が必要な作業単位

•  systems system としての運⽤観点で、⼀括りに制御したい作業単位

•  ⼀部,機械化できない状態,⼈での作業を伴う作業単位

分節点分節点

Page 8: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

経緯 - retrospective & prospective narrativesインフラ運⽤において伝達・共有したいこと…過去に起こった経緯(いきさつ)これから起こるであろう経緯(なりゆき)

トレーサビリティの把握

-  “Who” (誰が) - “When did” (いつ) - “in What operation” (何をどうして) with “intention; Why” (どういうつもりが), then “Consequences happened” (どうなった)

-  作業対象としてのインフラが,現在どうなっているか理解したい

複数作業間の依存関係,⽂脈の把握

-  When(どういう時に)Why(なんのために)What Operation(何をどうして)Consequence(どうなって欲しいのか)

-  やり直しの効く範囲はどこまでか,戻せるのか

-  (状況が変わったら,失敗したら)どこまで戻ればよいのか

-  回復できないポイントとその回避可能性

-  依存関係が恒常的なのか⼀時的なのか

-  事前,事後の依存する作業

-  分離できる条件と範囲, 作業の構造を⾒通したい

7

Page 9: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

どのような構造を把握すべきか

記述・ドキュメントの..「形」は何にしたがう..

ソフトウェアのアーキテクチャ

収容構成

運⽤の体制

当事者たる⼈間の関係性

蓄積と発展

機能に従う

失敗に従う

Social な “Literacy”

Page 10: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics2016/6/30 NII Cloud Operation

9Literate Computing

TOC

Documents

Codes

Results

Jupyter Notebook

Page 11: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

運⽤作業者のための「追随可能な⼿順書」

機械化できない⼿動作業も指⽰書き

⼿順のレビュー

前回作業時の記録と差分を⽐較、検討

作業証跡、報告として記録

10

Page 12: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

利⽤者のための「追随可能な指⽰書・作業確認書」

予め雛形を⽰し要件を摺り合わせる

提供した環境内容の確認

カスタマイズに必要な情報の提供

セルフ・アドミニストレーション

11

Page 13: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

⽇常の作業記録・証跡 12

Page 14: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Literate Computing for Reproducible Infrastructure 13

Bare Metal Cloud

< Live Codes >

< Outputs >

refactor operations

run notebooks as live codeswrite reproducible

operations as notebooks

keep outputs for tractability and reproducibility

communicate via notebookcommunicate via notebook

share and elaborate narrative stories

share and elaborate narrative stories

self administrationreproducible workflowsaccelerated experiments

Ansible Playbook & Jupyter NotebookReference Patterns

Expert EngineerApprentice Engineer Expert UserParticipant User

Page 15: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

参考Jupyter is ascending

14

Page 16: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

IPython Notebook

•  Python の Rich Web client な対話インターフェース

•  実⾏Code,実⾏結果(計算の結果や,結果を埋め込んだ図表),⾃然⾔語による⼿順や経緯の説明を ひとつにまとめて記述

•  “The purpose of Computing is insight, not numbers” – Hamming [Numerical Methods for Scientists and Engineers (1962) Preface]

•  数理系研究者のツールとして発展

http: //ipython.org

1991: Python1995: Numeric → NumPy (~2006)2001: SciPy2001: IPython2003: Matplotlib …2011: IPython Notebook2015: Jupyter

15

アイデアの探索課程の記録,共同開発,再現可能な成果の公開,教育

Page 17: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Jupyter – Language Agnostic Notebook

http: //jupyter.org

- Interactive Python shell - Network protocol and Rich Web clients- Kernel for Python - Notebook file format and tools- Tools for Interactive Parallel - Nbviewer Computing

Jupyter = Julia, Python & R†

Github でもサポート

16

- Language Agnostic

† https://github.com/jupyter/design/wiki/Jupyter-Logo

Page 18: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

http://try.jupyter.org 17

Page 19: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

jupyter.org 18

Page 20: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

GitHub 19

http://blog.jupyter.org/2015/05/07/rendering-notebooks-on-github/

http://nb.bianp.net/sort/views/

https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-

IPython-Notebooks

Page 21: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Courseware 20

"Aerodynamics-Hydrodynamics" (MAE 6226) using the AeroPython series of lessons is taught at the George Washington University by Prof. Lorena A.

Barba. The first version of the course ran in Spring 2014…

https://github.com/barbagroup/AeroPython

Page 22: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Publication 21

https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/

Chapter1.ipynb

Page 23: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Publication 22

https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/

Chapter1.ipynbhttp://enakai00.hatenablog.com/entry/

2016/04/01/170802

Page 24: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics

Open Science 23

This notebook reproduces their results, and demonstrates why their claims are unsupported by

their analysis.…

https://github.com/benlaken/Comment_BadruddinAslam2014/blob/master/

Monsoon_analysis.ipynb

Page 25: Jupyter notebook を用いた文芸的インフラ運用のススメ

Y Masatani, National Institute of Informatics