|
@@ -0,0 +1,200 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "# 実験を開始する\n",
|
|
|
+ "\n",
|
|
|
+ "これは、実験パッケージを用意して実験を行うためのノートブックです。 "
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 1. 実験用の空リポジトリを作成する\n",
|
|
|
+ "実験リポジトリを作成する準備として、[リポジトリの作成方法](https://gin.g-node.org/G-Node/Info/wiki/Web+Interface#creating-a-repository)を参考にデータガバナンス機能で実験用の空リポジトリを作成してください。"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "1. [データガバナンス機能に遷移する](http://dg02.dg.rcos.nii.ac.jp/)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 2. ステップ1で作成した空リポジトリに実験パッケージをコピーする"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "1. 以下のセルを実行すると入力フォームが現れます。ステップ1で作成した空リポジトリの名前を入力してください。"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "repository_title = input()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "%cd ~/\n",
|
|
|
+ "tmp = !git remote -v\n",
|
|
|
+ "tmp = tmp[0]\n",
|
|
|
+ "tmp = tmp[tmp.find(\"http\"):]\n",
|
|
|
+ "tmp = tmp.split(\"/\")\n",
|
|
|
+ "tmp = tmp[0] + \"//\" + tmp[2] + \"/\" + tmp[3]\n",
|
|
|
+ "\n",
|
|
|
+ "ssh_url = tmp + \"/\" + repository_title + \".git\"\n",
|
|
|
+ "print(ssh_url)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "2. 空リポジトリ名のフォルダを作成し、実験パッケージをコピーします。"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "!mkdir ~/.tmp/\n",
|
|
|
+ "!git init ~/.tmp/$repository_title\n",
|
|
|
+ "# !datalad create ~/.tmp/$repository_title\n",
|
|
|
+ "!cp -r ~/WORKFLOW/PACKAGE/. ~/.tmp/$repository_title/\n",
|
|
|
+ "\n",
|
|
|
+ "%cd ~/.tmp/$repository_title\n",
|
|
|
+ "!git add ~/.tmp/$repository_title\n",
|
|
|
+ "!git commit -m '1st commit'\n",
|
|
|
+ "!git remote add $repository_title $ssh_url\n",
|
|
|
+ "!git push $repository_title master\n",
|
|
|
+ "# !datalad save --to-git -m \"1st commit\"\n",
|
|
|
+ "# !datalad push"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 3. 上記リポジトリをサブデータセットとして設定する"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "%cd ~/\n",
|
|
|
+ "!git submodule add $ssh_url ./experiments/$repository_title"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 4. pipeline.jsonに実験名を追記する"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import json\n",
|
|
|
+ "\n",
|
|
|
+ "with open('/home/jovyan/experiments/pipeline.json', 'r') as f:\n",
|
|
|
+ " pipeline = json.load(f)\n",
|
|
|
+ "\n",
|
|
|
+ "pipeline.append(repository_title)\n",
|
|
|
+ "\n",
|
|
|
+ "with open('/home/jovyan/experiments/pipeline.json', 'w') as f:\n",
|
|
|
+ " json.dump(pipeline, f, indent = 4)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 5. 変更内容を書き戻す"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "%cd ~/\n",
|
|
|
+ "!git add ~/\n",
|
|
|
+ "!git commit -m '実験の作成'\n",
|
|
|
+ "!git push origin master\n",
|
|
|
+ "# !datalad save --to-git -m \"実験の作成\"\n",
|
|
|
+ "# !datalad push"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## 6. 複製したパッケージのコンテナを立ち上げて、ソースコードのJupyterNotebookに遷移する\n",
|
|
|
+ "\n",
|
|
|
+ "以下のセルを実行して表示されるリンクを押下してください。"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import urllib\n",
|
|
|
+ "\n",
|
|
|
+ "print(\n",
|
|
|
+ " \"https://binder.cs.rcos.nii.ac.jp/v2/git/\" + urllib.parse.quote(ssh_url, safe='') + \"/HEAD?filepath=experiment.ipynb\"\n",
|
|
|
+ ")"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": "Python 3",
|
|
|
+ "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.8.12"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 4
|
|
|
+}
|