Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/maxtext/examples/sft_llama3_demo_tpu.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@
" notebook_login()\n",
"else:\n",
" from huggingface_hub import login\n",
" login()"
" hf_token = os.environ.get(\"HF_TOKEN\", \"\")\n",
" if hf_token:\n",
" login(token=hf_token)\n",
" else:\n",
" login()"
Comment on lines +158 to +162

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Importing os directly within this block ensures that the cell is self-contained and robust against out-of-order execution (e.g., if a user restarts the kernel and runs this cell first).

    "    import os\n",
    "    hf_token = os.environ.get(\"HF_TOKEN\", \"\")\n",
    "    if hf_token:\n",
    "        login(token=hf_token)\n",
    "    else:\n",
    "        login()"

]
},
{
Expand Down
Loading