VSCode による開発を推奨する.
- 必ず手動で更新すること
- 直接依存しているパッケージのみを書くこと
- PyPIで利用可能なパッケージのみを書くこと
例) flake8 の バージョンを 1.2.X にしたい場合: flake8~=1.2.3
参考: https://www.python.org/dev/peps/pep-0440/#version-specifiers
以下のコマンドによる更新は禁止
pip freeze > requirements.in
pip freeze >> requirements.in
以下のコマンドを実行
./scripts/generate_lockfile.sh
作業ディレクトリをきれいにした状態で以下のコマンドを実行
./scripts/apply_template_updates.sh
requirements.in
などに適用された変更が意図したものかを確認してからコミットする.
以下の手順を実行することで開発環境を構築できる.
VSCode を起動し,拡張機能のVisual Studio Code Remote Containers をインストールする.
コマンドパレットを開き,
Remote-Containers: Reopen in Container
を選択する.
VSCode の Remote Container のターミナルで
functions-framework --target=example --debug
http://localhost:8080 に対してリクエストを送ることができるようになる.
JSON
curl -X POST -H "Content-Type: application/json" localhost:8080 -d '{"api_name": "Solver", "name": "Taro"}'
JSON Lines
DATA='
{"api_name": "Solver", "name": "Taro"}
{"api_name": "Solver", "name": "Jiro"}
{"api_name": "Solver", "name": "Siro"}
'
curl -X POST -H "Content-Type: application/jsonl" localhost:8080 -d "$DATA"
VSCode の Remote Container のターミナルで
python -m unittest
OpenAPI を用いて定義する. schema.yaml に OpenAPI を置く.
以下を実行することで Python の dataclass を利用した表現に変換したものを src/models/ に置く.
./scripts/convert_open_api_to_dataclass.sh
ここで自動生成したコードを直接編集するのは避ける. また,scripts/convert_open_api_to_dataclass.sh は Docker コンテナ内で実行する想定であることに注意!