{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 実験メタデータを入力する\n", "\n", "実験日や実験者などのメタデータを実験記録に追加します。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. メタデータを入力する" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. 以下のセルを実行して、実験日を入力してください。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipywidgets import Text, Button\n", "from IPython.display import clear_output\n", "import datetime\n", "\n", "d_today = datetime.date.today()\n", "def on_click_callback(clicked_button: Button) -> None:\n", " global experiment_date\n", " experiment_date = text.value\n", " clear_output()\n", " print(\"登録しました:\", experiment_date)\n", "\n", "# テキストボックス\n", "text = Text(\n", " value=str(d_today),\n", " description='実験日:'\n", ")\n", "button = Button(description='入力完了')\n", "button.on_click(on_click_callback)\n", "display(text, button)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. 以下のセルを実行して、実験者を入力してください。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipywidgets import Text, Button\n", "from IPython.display import clear_output\n", "import datetime\n", "\n", "def on_click_callback(clicked_button: Button) -> None:\n", " global experimenter\n", " experimenter = text.value\n", " clear_output()\n", " print(\"登録しました:\", experimenter)\n", "\n", "# テキストボックス\n", "text = Text(\n", " description='実験者:'\n", ")\n", "button = Button(description='入力完了')\n", "button.on_click(on_click_callback)\n", "display(text, button)" ] }, { "cell_type": "markdown", "metadata": { "heading_collapsed": true }, "source": [ "## 2.メタ情報をファイルに保存する" ] }, { "cell_type": "markdown", "metadata": { "hidden": true }, "source": [ "### - 2.1 メタ情報をmeta_data.jsonに書き込む" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hidden": true }, "outputs": [], "source": [ "import json\n", "from collections import OrderedDict\n", "\n", "meta_data = {\n", " \"experiment_date\": experiment_date,\n", " \"experimenter\": experimenter\n", "}\n", "with open('../meta_data.json', 'w') as jf:\n", " json.dump(meta_data, jf, ensure_ascii=False, indent=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. 実行結果をデータガバナンス機能に同期する\n", "\n", "ここまでの内容を保存し、データガバナンス機能に同期します。 \n", "以下のセルを実行してください。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display, Javascript\n", "display(Javascript('IPython.notebook.save_checkpoint();'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hidden": true }, "outputs": [], "source": [ "# FIXME:papermill実装に修正\n", "%cd ~/\n", "!datalad save -m \"メタデータ入力\" SECTIONS/enter_metadata.ipynb\n", "!datalad save -m \"メタデータ入力\" meta_data.json\n", "!datalad unlock .\n", "!datalad push --to gin" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 4 }