Che237 commited on
Commit
3e18f98
·
verified ·
1 Parent(s): 0242071

Fix: Force HF upload with explicit token authentication

Browse files
notebooks/07_deployment_artifacts.ipynb CHANGED
@@ -38,7 +38,9 @@
38
  "warnings.filterwarnings('ignore')\n",
39
  "\n",
40
  "# Configuration\n",
41
- "config_path = Path(\"notebook_config.json\")\nif not config_path.exists():\n config_path = Path(\"/home/user/app/notebooks/notebook_config.json\")\n",
 
 
42
  "with open(config_path) as f:\n",
43
  " CONFIG = json.load(f)\n",
44
  "\n",
@@ -292,15 +294,16 @@
292
  "joblib>=1.3.0\n",
293
  "python-multipart>=0.0.6\n",
294
  "huggingface-hub>=0.19.0\n",
295
- "google-generativeai>=0.3.0\n",
296
  "requests>=2.31.0\n",
 
297
  "'''\n",
298
  "\n",
299
  "requirements_path = DEPLOY_DIR / \"requirements.txt\"\n",
300
  "with open(requirements_path, 'w') as f:\n",
301
  " f.write(requirements_content)\n",
302
  "\n",
303
- "print(f\"✓ requirements.txt saved\")"
304
  ]
305
  },
306
  {
@@ -693,24 +696,22 @@
693
  "metadata": {},
694
  "outputs": [],
695
  "source": [
696
- "# Uncomment to upload to Hugging Face\n",
697
- "# \n",
698
- "# if hf_deployer.is_authenticated():\n",
699
- "# print(\"Uploading to Hugging Face Hub...\")\n",
700
- "# try:\n",
701
- "# hf_deployer.api.upload_folder(\n",
702
- "# folder_path=str(hf_package_dir),\n",
703
- "# repo_id=hf_deployer.repo_id,\n",
704
- "# repo_type=\"model\",\n",
705
- "# commit_message=\"Update CyberForge ML models\"\n",
706
- "# )\n",
707
- "# print(f\"✓ Uploaded to: https://huggingface.co/{hf_deployer.repo_id}\")\n",
708
- "# except Exception as e:\n",
709
- "# print(f\"Upload error: {e}\")\n",
710
- "# else:\n",
711
- "# print(\"Not authenticated. Set HF_TOKEN to upload.\")\n",
712
- "\n",
713
- "print(\"To upload, set HF_TOKEN and run: python deployment/upload_to_hf.py\")"
714
  ]
715
  }
716
  ],
 
38
  "warnings.filterwarnings('ignore')\n",
39
  "\n",
40
  "# Configuration\n",
41
+ "config_path = Path(\"notebook_config.json\")\n",
42
+ "if not config_path.exists():\n",
43
+ " config_path = Path(\"/home/user/app/notebooks/notebook_config.json\")\n",
44
  "with open(config_path) as f:\n",
45
  " CONFIG = json.load(f)\n",
46
  "\n",
 
294
  "joblib>=1.3.0\n",
295
  "python-multipart>=0.0.6\n",
296
  "huggingface-hub>=0.19.0\n",
297
+ "google-genai>=1.0.0\n",
298
  "requests>=2.31.0\n",
299
+ "pyarrow>=14.0.0\n",
300
  "'''\n",
301
  "\n",
302
  "requirements_path = DEPLOY_DIR / \"requirements.txt\"\n",
303
  "with open(requirements_path, 'w') as f:\n",
304
  " f.write(requirements_content)\n",
305
  "\n",
306
+ "print(f\"✓ requirements.txt saved\")\n"
307
  ]
308
  },
309
  {
 
696
  "metadata": {},
697
  "outputs": [],
698
  "source": [
699
+ "# Upload trained models and artifacts to Hugging Face Hub\n",
700
+ "if hf_deployer.is_authenticated():\n",
701
+ " print(\"Uploading to Hugging Face Hub...\")\n",
702
+ " try:\n",
703
+ " hf_deployer.api.upload_folder(\n",
704
+ " folder_path=str(hf_package_dir),\n",
705
+ " repo_id=hf_deployer.repo_id,\n",
706
+ " repo_type=\"model\",\n",
707
+ " commit_message=\"Update CyberForge ML models and deployment artifacts\"\n",
708
+ " )\n",
709
+ " print(f\"✓ Uploaded to: https://huggingface.co/{hf_deployer.repo_id}\")\n",
710
+ " except Exception as e:\n",
711
+ " print(f\"⚠ Upload error: {e}\")\n",
712
+ "else:\n",
713
+ " print(\"⚠ Not authenticated to HuggingFace. Models saved locally only.\")\n",
714
+ " print(\" Set HF_TOKEN environment variable or hf_token in notebook_config.json to upload.\")"
 
 
715
  ]
716
  }
717
  ],