fix: colab notebook — use system pip instead of venv

Colab 'python3 -m venv' fails with ensurepip error (no .venv created,
so every subsequent cell hit 'command not found'). Switch to system pip
(Colab standard) and run the API server via nohup background with log
fallback diagnostics.
This commit is contained in:
2026-08-12 16:55:21 +09:00
parent 0d90845ac6
commit f385734630
2 changed files with 19 additions and 27 deletions
+3 -3
View File
@@ -59,7 +59,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "# 3) venv + 설치 (GPU 추론은 engine+api만으로 충분 — Colab T4에 CUDA 런타임 내장)\n!python3 -m venv .venv\n!source .venv/bin/activate && pip install -q --upgrade pip\n!source .venv/bin/activate && pip install -q -e '.[engine,api]'\n!source .venv/bin/activate && pip install -q edge-tts # 샘플 음성 생성용\n\n# 이후 셀에서 activate 없이 CLI 사용 가능하게 PATH 등록\nimport os\nos.environ['PATH'] = '/content/luke_scribe/.venv/bin:' + os.environ['PATH']\nprint('설치 완료')\n!luke-scribe --help 2>&1 | head -12\n"
"source": "# 3) 설치 — Colab은 시스템 pip가 표준 (venv는 Colab에서 ensurepip 오류로 실패할 수 있음)\n!pip install -q --upgrade pip\n!pip install -q -e '.[engine,api]'\n!pip install -q edge-tts # 샘플 음성 생성용\nprint('설치 완료')\n!which luke-scribe && luke-scribe --help 2>&1 | head -8\n"
},
{
"cell_type": "markdown",
@@ -83,7 +83,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "# 5) 테스트 스위트\n!source .venv/bin/activate && python -m pytest tests/ -q 2>&1 | tail -5\n"
"source": "# 5) 테스트 스위트\n!python -m pytest tests/ -q 2>&1 | tail -5\n"
},
{
"cell_type": "markdown",
@@ -133,7 +133,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "# 10) 서버 기동 (in-proc 큐, 백그라운드)\nimport subprocess, time, os, json\nenv = dict(os.environ)\nenv['LUKESCRIBE_API_KEY_FILE'] = '/content/api_keys.json'\nenv['LUKESCRIBE_QUEUE_BACKEND'] = 'inproc'\nproc = subprocess.Popen(\n ['luke-scribe', 'serve', '--port', '8000'],\n env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,\n)\n# 기동 대기\nimport urllib.request\nfor _ in range(30):\n try:\n urllib.request.urlopen('http://localhost:8000/health', timeout=1)\n break\n except Exception:\n time.sleep(1)\nprint('서버 기동 OK')\n"
"source": "# 10) 서버 기동 (in-proc 큐, 백그라운드 — Colab에서는 %%bash --bg 또는 nohup 사용)\n!mkdir -p /content/logs\n!nohup luke-scribe serve --port 8000 > /content/logs/server.log 2>&1 &\nimport time, urllib.request\nok = False\nfor _ in range(40):\n try:\n urllib.request.urlopen('http://localhost:8000/health', timeout=1)\n ok = True\n break\n except Exception:\n time.sleep(1)\nprint('서버 기동 OK' if ok else '서버 기동 실패 — 로그:')\nif not ok:\n print(open('/content/logs/server.log').read()[-1500:])\n"
},
{
"cell_type": "code",