From 06472c2b691db748080026373ed597241827da26 Mon Sep 17 00:00:00 2001 From: bonsai Date: Thu, 22 Jan 2026 03:20:08 +0900 Subject: [PATCH] Restore set/colab/setup.ipynb --- set/colab/setup.ipynb | 150 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 set/colab/setup.ipynb diff --git a/set/colab/setup.ipynb b/set/colab/setup.ipynb new file mode 100644 index 0000000..d88b355 --- /dev/null +++ b/set/colab/setup.ipynb @@ -0,0 +1,150 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# MindMutant Colab Setup\n", + "\n", + "Run this notebook to set up the MindMutant environment in Google Colab.\n", + "This script handles:\n", + "1. Google Drive mounting for data persistence\n", + "2. Repository cloning\n", + "3. Swapping to Colab-optimized source code (`src-colab`)\n", + "4. Dependency installation" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 1. Mount Google Drive\n", + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 2. Clone Repository\n", + "import os\n", + "\n", + "if not os.path.exists('MindMutant'):\n", + " !git clone https://github.com/bonsai/MindMutant.git\n", + " %cd MindMutant\n", + "else:\n", + " %cd MindMutant\n", + " !git pull" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 3. Setup Data Persistence\n", + "import os\n", + "\n", + "# Define Drive data path\n", + "drive_data_path = '/content/drive/MyDrive/MindMutant/data'\n", + "\n", + "# Create directory in Drive if it doesn't exist\n", + "if not os.path.exists(drive_data_path):\n", + " os.makedirs(drive_data_path)\n", + " print(f\"Created {drive_data_path}\")\n", + "\n", + "# Link local data directory to Drive\n", + "# We remove the local 'data' folder (from git) and replace it with a symlink to Drive\n", + "if os.path.exists('data'):\n", + " if not os.path.islink('data'):\n", + " !rm -rf data\n", + " print(\"Removed default data folder\")\n", + "\n", + "if not os.path.exists('data'):\n", + " !ln -s \"$drive_data_path\" data\n", + " print(f\"Linked data directory to {drive_data_path}\")\n", + "else:\n", + " print(\"Data directory already linked\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 4. Switch to Colab-Optimized Code\n", + "# We replace the standard 'src' directory with 'src-colab' to use the optimized version\n", + "if os.path.exists('src-colab'):\n", + " if os.path.exists('src'):\n", + " !rm -rf src\n", + " !mv src-colab src\n", + " print(\"Switched to Colab-optimized source code (src-colab -> src)\")\n", + "else:\n", + " print(\"src-colab not found (already switched?)\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 5. Install Dependencies\n", + "!pip install -r set/colab/requirements.txt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 6. Download Spacy Model\n", + "!python -m spacy download ja_core_news_md" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 7. Verify Setup\n", + "import spacy\n", + "from src.deap.evolution import Evolution\n", + "\n", + "nlp = spacy.load(\"ja_core_news_md\")\n", + "print(\"✅ Spacy model loaded successfully!\")\n", + "print(\"✅ MindMutant modules importable!\")" + ] + } + ], + "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.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file