跳到正文
Skillpedia
智能体48k · #4838

hugging-face-jobs

它能做什么

这个工具可以让你在强大的云端计算机上运行编程任务(Python 脚本),不需要在自己的电脑上做任何配置。它还可以使用 GPU 等硬件资源来加快运算速度。

适用场景

  • ✓需要运行计算量很大的 Python 脚本时。
  • ✓需要处理大量数据,又不想让自己的电脑过载时。
  • ✓需要在云端运行重复性或定时任务时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hugging-face-jobs/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/hugging-face-jobs/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“运行我的 Python 脚本,使用 GPU 训练这个机器学习模型。”

每周 5 个新技能,1 分钟读完。

工作原理

你把 Python 代码发送出去,工具会在远程服务器上执行它。所有的环境配置都由工具自动完成,还可以使用 GPU 等专用硬件来加快速度。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Running Workloads on Hugging Face Jobs

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use This Skill

Use this skill when users want to:

  • Run Python workloads on cloud infrastructure
  • Execute jobs without local GPU/TPU setup
  • Process data at scale
  • Run batch inference or experiments
  • Schedule recurring tasks
  • Use GPUs/TPUs for any workload
  • Persist results to the Hugging Face Hub

Prerequisites Checklist

Before starting any job, verify:

✅ Account & Authentication

  • Hugging Face Account with Pro, Team, or Enterprise plan (Jobs require paid plan)
  • Authenticated login: Check with hf_whoami()
  • HF_TOKEN for Hub Access ⚠️ CRITICAL - Required for any Hub operations (push models/datasets, download private repos, etc.)
  • Token must have appropriate permissions (read for downloads, write for uploads)

✅ Token Usage (See Token Usage section for details)

When tokens are required:

  • Pushing models/datasets to Hub
  • Accessing private repositories
  • Using Hub APIs in scripts
  • Any authenticated Hub operations

How to provide tokens:

# hf_jobs MCP tool — $HF_TOKEN is auto-replaced with real token:
{"secrets": {"HF_TOKEN": "$HF_TOKEN"}}

# HfApi().run_uv_job() — MUST pass actual token:
from huggingface_hub import get_token
secrets={"HF_TOKEN": get_token()}

⚠️ CRITICAL: The $HF_TOKEN placeholder is ONLY auto-replaced by the hf_jobs MCP tool. When using HfApi().run_uv_job(), you MUST pass the real token via get_token(). Passing the literal string "$HF_TOKEN" results in a 9-character invalid token and 401 errors.

Token Usage Guide

Understanding Tokens

What are HF Tokens?

  • Authentication credentials for Hugging Face Hub
  • Required for authenticated operations (push, private repos, API access)
  • Stored securely on your machine after hf auth login

Token Types:

  • Read Token - Can download models/datasets, read private repos
  • Write Token - Can push models/datasets, create repos, modify content
  • Organization Token - Can act on behalf of an organization

When Tokens Are Required

Always Required:

  • Pushing models/datasets to Hub
  • Accessing private repositories
  • Creating new repositories
  • Modifying existing repositories
  • Using Hub APIs programmatically

Not Required:

  • Downloading public models/datasets
  • Running jobs that don't interact with Hub
  • Reading public repository information

How to Provide Tokens to Jobs

Method 1: Automatic Token (Recommended)

hf_jobs("uv", {
    "script": "your_script.py",
    "secrets": {"HF_TOKEN": "$HF_TOKEN"}  # ✅ Automatic replacement
})

How it works:

  • $HF_TOKEN is a placeholder that gets replaced with your actual token
  • Uses the token from your logged-in session (hf auth login)
  • Most secure and convenient method
  • Token is encrypted server-side when passed as a secret

Benefits:

  • No token exposure in code
  • Uses your current login session
  • Automatically updated if you re-login
  • Works seamlessly with MCP tools

Method 2: Explicit Token (Not Recommended)

hf_jobs("uv", {
    "script": "your_script.py",
    "secrets": {"HF_TOKEN": "hf_abc123..."}  # ⚠️ Hardcoded token
})

When to use:

  • Only if automatic token doesn't work
  • Testing with a specific token
  • Organization tokens (use with caution)

Security concerns:

  • Token visible in code/logs
  • Must manually update if token rotates
  • Risk of token exposure

Method 3: Environment Variable (Less Secure)

hf_jobs("uv", {
    "script": "your_script.py",
    "env": {"HF_TOKEN": "hf_abc123..."}  # ⚠️ Less secure than secrets
})

Difference from secrets:

  • env variables are visible in job logs
  • secrets are encrypted server-side
  • Always prefer secrets for tokens

Using Tokens in Scripts

In your Python script, tokens are available as environment variables:

# /// script
# dependencies = ["huggingface-hub"]
# ///

import os
from huggingface_hub import HfApi

# Token is automatically available if passed via secrets
token = os.environ.get("HF_TOKEN")


…
常见问题

使用它需要付费吗?

需要。这个工具要求你拥有付费的 Hugging Face 套餐(Pro、Team 或 Enterprise)才能使用。

什么是“令牌”(token),为什么需要它?

令牌就像一把秘密钥匙,用来向 Hugging Face 证明你的身份。访问你的数据或把结果发送回平台时都需要用到它。

脚本如何知道该使用哪个令牌?

最安全的方式是使用特殊代码,自动从你已登录的账户中获取令牌。尽量不要把令牌直接写进代码里。

详情

作者的原始描述

Run workloads on Hugging Face Jobs with managed CPUs, GPUs, TPUs, secrets, and Hub persistence.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4838
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能