{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 書き戻しの準備をする\n", "\n", "このノートブックでは、ワークフロー実行結果をginリポジトリに書き戻すための準備を行います。 \n", "上から順番にセルを実行してください。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 0. SSH秘密鍵を.ssh/id_rsaに配置する\n", "\n", "プロトタイプではSSH秘密鍵をjupyterhubの.ssh/id_rsa、公開鍵をginリポジトリに登録することでSSH接続するため、初めにSSH秘密鍵を.ssh/id_rsaに配置してください。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. バージョン管理システムdataladを使用するために、このリポジトリをdatalad datasetとして認識させる" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%sh\n", "cd\n", "datalad create --force" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. dataladでワークフロー実行結果をginリポジトリに反映させるために、ginリポジトリをリモートリポジトリとして登録する" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%sh\n", "mkdir ./tmp\n", "git remote show origin > ./tmp/remote.txt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with open('./tmp/remote.txt', 'r') as f:\n", " lines = [s.strip() for s in f.readlines()]\n", " ssh_push_url = lines[2].replace('Push URL: http://dg02.dg.rcos.nii.ac.jp/', 'ssh://root@dg02.dg.rcos.nii.ac.jp:3001/') " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from datalad import api\n", "\n", "try:\n", " api.siblings(action='add', name='gin', url=ssh_push_url)\n", "except:\n", " pass" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. SSH接続で書き戻しを行うためにssh鍵に権限を与える(ssh鍵は.sshディレクトリの中にid_rsaとして保存する)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%sh\n", "cd\n", "chmod 600 /home/jovyan/.ssh/id_rsa" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. .gitconfigにユーザー名とメールアドレスを登録する" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1. 以下のセルでgitアカウントのユーザー名とメールアドレスを入力してください。" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ivis-mizuguchi\n" ] } ], "source": [ "name = input()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rino.mizuguchi@ivis.co.jp\n" ] } ], "source": [ "email = input()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2. 入力されたユーザー名とメールアドレスを.gitconfigに登録する" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "os.system(\"git config --global user.name \" + name)\n", "os.system(\"git config --global user.email \" + email)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. .gitignoreで.local配下をgit管理しない設定にする" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%sh\n", "cd\n", "echo \".local/*\" >> .gitignore" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 6. SSH鍵の利用確認をオフにする" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%sh\n", "cd\n", "echo \"host *\\n\\tStrictHostKeyChecking no\\n\\tUserKnownHostsFile /dev/null\" >> .ssh/config" ] } ], "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.7.8" } }, "nbformat": 4, "nbformat_minor": 4 }