Nbdev:ソフトウェア工学のベストプラクティスを民主化するリテラートプログラミング環境
GitHub は教育者や学生向けのソフトウェア開発の参入障壁を下げ、ベストプラクティスを民主化するために、Jupyter を基盤としたリテラプログラミング環境「nbdev」の開発を支援し、ドキュメント生成や CI 統合などの機能を提供している。
キーポイント
GitHub と fastai の協業による開発支援
GitHub はソフトウェア開発の民主化の一環として、fastai が開発するリテラプログラミング環境「nbdev」を支援しており、Jupyter ノートブックの拡張機能を GitHub Pages や Actions と統合している。
ドキュメントと CI の自動化機能
GitHub Pages 上のノートブックから自動的に検索可能でリンク付きのドキュメントを生成し、GitHub Actions を用いて手動設定なしでユニットテストを実行する CI 環境を標準装備している。
コードとノートの双方向同期
IDE でのコードナビゲーションや編集が可能になるよう、ノートブックとソースコードの間で堅牢な双方向同期を実現し、競合解決も人間が読みやすい形式で行える。
パッケージ公開の自動化
PyPI や Conda パッケージの公開プロセスを自動化するユーティリティを提供しており、開発ライフサイクル全体を効率化するツールセットを備えている。
開発の摩擦低減による高品質化
ソースコード内でテストとドキュメントを記述できるため、特別な API の学習やウェブ開発の知識が不要となり、ソフトウェアの質向上と包括性が促進されます。
nbdev を基盤とした多様なツールの拡張
Jupyter ノートブックから直接ブログ記事を作成する「fastpages」や、自動更新されるインタラクティブダッシュボード「covid19-dashboards」など、新たなツール構築にも活用されています。
ソフトウェア工学の包括性と次世代への期待
開発をより親しみやすく堅牢なものにし、リテラシープログラミングの新しい潮流を生み出すことを目指しており、コミュニティでの議論も歓迎されています。
影響分析・編集コメントを表示
影響分析
この発表は、データサイエンティストや教育現場における開発ワークフローの標準化に大きな影響を与える可能性があり、ドキュメント作成やテスト管理といった非本質的な作業の負担を大幅に軽減します。特に GitHub と fastai の連携により、オープンソースコミュニティ全体で「ベストプラクティス」が容易に採用される土壌が整い、ソフトウェア開発の民主化が加速すると予想されます。
編集コメント
教育現場や初学者にとって、ドキュメント作成や CI 設定の壁を取り除く画期的なツールであり、開発プロセス全体の品質向上に寄与する。
タイトル: Nbdev: ソフトウェア工学のベストプラクティスを民主化するリテラートプログラミング環境
GitHubでは、ソフトウェア開発の民主化に深く取り組んでいます。その一環として、オープンソースの拠点としての役割を果たし、教育者や学生にツールを提供しています。また、Codespacesのような、ソフトウェア開発への参入障壁を下げる機能も開発しています。しかし、ソフトウェア開発をもっと取り組みやすくし、継続的インテグレーション(CI)、配布、ドキュメンテーションといったベストプラクティスをより簡単に適用できるようにするためには、まだ多くの課題が残されています。
これが、私たちがfastaiによる新しいPython用リテラートプログラミング環境「nbdev」の開発を支援することを決めた理由です。nbdevの背景にある動機と、リテラートプログラミングの歴史に関する解説は、このブログ記事でご覧いただけます。初めての方のために説明すると、ドナルド・クヌースが提唱したリテラートプログラミングとは、次のようなものです:
…コンピュータによって課せられる形式や順序でプログラムを書くことから離れ、プログラマが自身の思考の論理と流れに沿った順序でプログラムを開発できるようにする手法です。
リテラートプログラミングの概念の一部は、Swift Playgrounds、Jupyter、Mathematicaなどのツールに既に導入されていますが、ソフトウェア開発ライフサイクル全体をカバーするツールはこれまで不足していました。nbdevはJupyterノートブックを基盤とし、このギャップを埋めるために以下の機能を提供します。その多くはGitHubと統合されています:
- GitHub PagesでホストされているJupyterノートブックからのドキュメント自動生成。生成されたドキュメントは検索可能で、バッククォートで囲んだキーワードをイントロスペクションすることで、適切なドキュメントページに自動的にハイパーリンクされます。公式のfastaiドキュメントがその一例です。
- GitHub Actionsを用いた継続的インテグレーション(CI) の事前設定。これにより、ユニットテストが自動的に実行されます。GitHub Actionsに不慣れでも、手動での設定なしにすぐに機能します。
- ドキュメントサイトをプレビューするWebサーバー、コード記述用のJupyterサーバー、一連のCLIツールで構成されるnbdev環境は、GitHub Codespacesで動作するよう設定されており、開始がさらに容易になります。Codespacesがnbdevとどのように統合されるかについては、このブログ記事で詳しく説明されています。
予告として、以下はCodespaces内でのこのリテラートプログラミング環境のプレビューです。ノートブック、ドキュメントサイト、IDEが含まれています:
このGitHub統合に加えて、nbdevは以下の機能も提供します:
- ノートブックとソースコード間の堅牢な双方向同期。これにより、必要に応じてIDEをコードナビゲーションや簡単な編集に使用できます。
- 特別なAPIを学ぶ必要なく、ノートブック内で直接テストを記述する機能。これらのテストは、単一のCLIコマンドおよびGitHub Actionsで並列実行されます。
- 人間が読める形式でノートブックのマージ/競合解決を行うツール。
- pypiおよびcondaパッケージの公開を自動化するユーティリティ。
nbdevは、開発者が特別なAPIを学んだりWeb開発を気にしたりすることなく、ソースコードと同じコンテキストでユニットテストとドキュメントを記述できるようにすることで、ソフトウェア工学のベストプラクティスを推進します。同様に、GitHub Actionsはデフォルトでユニットテストを自動実行し、これらのツールに関する事前知識を必要としません。ドキュメントとテストの作成における障壁を取り除くことが、より高品質なソフトウェアを生み出し、ソフトウェア開発をより包括的なものにすると私たちは信じています。
Pythonソフトウェアの作成にnbdevを利用できるだけでなく、nbdevを拡張して新たな種類のツールを構築することもできます。例えば私たちは最近、開発者がJupyterノートブックで直接ブログ投稿を作成できる、使いやすいブログプラットフォーム「fastpages」を構築するためにnbdevを活用しました。fastpagesはGitHub ActionsとGitHub Pagesを使用してノートブックのブログ投稿への変換を自動化し、知識共有の民主化に役立つ様々な機能をPython開発者に提供します。また、nbdevとfastpagesを使ってcovid19-dashboardsも作成し、Jupyterノートブックで自動更新されるインタラクティブなダッシュボードの構築方法を示しました。
私たちは、nbdevがソフトウェア工学をより包括的で、親しみやすく、堅牢なものにする可能性に期待を寄せています。また、nbdevのようなツールが次世代のリテラートプログラミングツールを生み出すきっかけとなることも願っています。nbdevについてさらに詳しく知りたい方は、以下のリソースをご覧ください:
- 公式nbdevドキュメント
- エンドツーエンドでnbdevを使用する最小限の例
- 創設者ジェレミー・ハワードによる、nbdevの背景と動機についてのブログ記事
- 今年のJupyterCon基調講演におけるnbdevのプレゼンテーション
最後に、nbdevでプロジェクトを構築されている方、またはさらなる議論をご希望の方は、nbdevフォーラムまたはGitHubでお気軽にご連絡ください。
原文を表示
At GitHub, we are deeply invested in democratizing software development. Part of this is accomplished by serving as the home of open source and providing tools to educators and students. We are also building features that lower the barrier to entry for software development, such as Codespaces. However, there is much work left to be done in order to make software development more approachable and to make it easier to employ best practices, such as continuous integration, distribution, and documentation of software.
This is why we decided to assist fastai in their development of a new, literate programming environment for Python, called nbdev. A discussion of the motivations behind nbdev as well as a primer on the history of literate programming can be found in this blog post. For the uninitiated, literate programming, as described by Donald Knuth, it is:
…a move away from writing computer programs in the manner and order imposed by the computer, and instead enables programmers to develop programs in the order demanded by the logic and flow of their thoughts.
While a subset of ideas from literate programming have shown up in tools, such as Swift Playgrounds, Jupyter, and Mathematica, there has been a lack of tools that encompass the entire software development life cycle. nbdev builds on top of Jupyter notebooks to fill these gaps and provides the following features, many of which are integrated with GitHub:
Automated generation of docs from Jupyter notebooks hosted on GitHub Pages. These docs are searchable and automatically hyperlinked to appropriate documentation pages by introspecting keywords you surround in backticks. An example of this documentation is the official fastai docs.
Continuous integration (CI) comes setup for you with GitHub Actions, which will run unit tests automatically for you. Even if you are not familiar with GitHub Actions, this starts working right away without any manual intervention.
The nbdev environment, which consists of a web server for previewing a docs site, a Jupyter server for writing code, and a series of CLI tools are set up to work with GitHub Codespaces, which makes getting started even easier. A detailed discussion of how CodeSpaces integrates with nbdev is discussed in this blog post.
As a teaser, this is a preview of this literate programming environment in Codespaces, which includes a notebook, a docs site and an IDE:
In addition to this GitHub integration, nbdev also offers the following features:
A robust, two-way sync between notebooks and source code, which allow you to use your IDE for code navigation or quick edits if desired.
The ability to write tests directly in notebooks without having to learn special APIs. These tests get executed in parallel with a single CLI command and also with GitHub Actions.
Tools for merge/conflict resolution with notebooks in a human readable format.
Utilities to automate the publishing of pypi and conda packages.
nbdev promotes software engineering best practices by allowing developers to write unit tests and documentation in the same context as source code, without having to learn special APIs or worry about web development. Similarly, GitHub Actions run unit tests automatically by default without requiring any prior experience with these tools. We believe removing friction from writing documentation and tests promotes higher quality software and makes software more inclusive.
Aside from using nbdev to create Python software, you can extend nbdev to build new types of tools. For example, we recently used nbdev to build fastpages, an easy to use blogging platform that allows developers to create blog posts directly with Jupyter notebooks. fastpages uses GitHub Actions and GitHub Pages to automate the conversion of notebooks to blog posts and offers a variety of other features to Python developers that democratize the sharing of knowledge. We have also used nbdev and fastpages to create covid19-dashboards, which demonstrates how to create interactive dashboards that automatically update with Jupyter notebooks.
We are excited about the potential of nbdev to make software engineering more inclusive, friendly, and robust. We are also hopeful that tools like nbdev can inspire the next generation of literate programming tools. To learn more about nbdev, please see the following resources:
The official nbdev docs
A minimal example of using nbdev end-to-end
The blog post discussing the background and motivations behind nbdev, by its creator, Jeremy Howard
A presentation discussing nbdev from a keynote at this year’s JupyterCon
Finally, If you are building any projects with nbdev or would like to have further discussions, please feel free to reach out on the nbdev forums or on GitHub.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み