refine: notebook - tolerant import verify, keep last err in tunnel check
Reviewer feedback: wrap the install-cell import verification in try/except so a walk-up failure cannot crash the cell (previously always-succeeding), and keep the last exception detail in the tunnel external-verification failure message.
This commit is contained in:
@@ -142,8 +142,12 @@ def cells() -> list[dict]:
|
||||
"while not _os.path.isdir(_os.path.join(_root, 'src', 'luke_scribe')) and _root != _os.path.dirname(_root):\n"
|
||||
" _root = _os.path.dirname(_root)\n"
|
||||
"sys.path.insert(0, _os.path.join(_root, 'src'))\n"
|
||||
"import luke_scribe.config as _cfg\n"
|
||||
"print('패키지 임포트 OK →', _cfg.__file__)\n"
|
||||
"try:\n"
|
||||
" import luke_scribe.config as _cfg\n"
|
||||
" print('패키지 임포트 OK →', _cfg.__file__)\n"
|
||||
"except ImportError as _e:\n"
|
||||
" print('경고: luke_scribe import 실패 —', _e)\n"
|
||||
" print(' 셀 1(클론)이 실행됐는지, 저장소가 src/luke_scribe 구조인지 확인하세요')\n"
|
||||
"\n"
|
||||
"# Cloudflare 터널용 cloudflared 바이너리 (실패해도 진행 — 터널 없이 로컬 사용 가능)\n"
|
||||
"!wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /usr/local/bin/cloudflared || echo 'cloudflared 다운로드 실패 — 터널 없이 계속합니다'\n"
|
||||
@@ -285,16 +289,18 @@ def cells() -> list[dict]:
|
||||
" print(' 상태 (health):', TUNNEL_URL + '/health')\n"
|
||||
" # DNS 전파 지연 대비 재시도 (새 trycloudflare 호스트는 초반에 못 풀릴 수 있음)\n"
|
||||
" ext_ok = False\n"
|
||||
" _last_err = None\n"
|
||||
" for _ in range(6):\n"
|
||||
" try:\n"
|
||||
" ext = urllib.request.urlopen(TUNNEL_URL + '/health', timeout=15)\n"
|
||||
" print(' 외부 접속 검증 OK (HTTP', ext.status, ')')\n"
|
||||
" ext_ok = True\n"
|
||||
" break\n"
|
||||
" except Exception:\n"
|
||||
" except Exception as _e:\n"
|
||||
" _last_err = _e\n"
|
||||
" time.sleep(2)\n"
|
||||
" if not ext_ok:\n"
|
||||
" print(' 외부 접속 검증 실패 (DNS 전파 지연이거나 Cloudflare 브라우저 체크 — 브라우저에서 직접 확인하세요)')\n"
|
||||
" print(' 외부 접속 검증 실패 (DNS 전파 지연이거나 Cloudflare 브라우저 체크 — 브라우저에서 직접 확인하세요):', _last_err)\n"
|
||||
" print(' ※ 임시 링크 — Colab 세션 종료 시 닫힘. API 호출에는 RAW_KEY(X-API-Key) 필요.')\n"
|
||||
"else:\n"
|
||||
" print('터널 URL 미감지 — 서버 로그:')\n"
|
||||
|
||||
Reference in New Issue
Block a user