Skip to content

Add minimal hfjobs uv run command#8

Merged
lhoestq merged 7 commits intolhoestq:mainfrom
davanstrien:feat/uv-run-mvp
Jul 11, 2025
Merged

Add minimal hfjobs uv run command#8
lhoestq merged 7 commits intolhoestq:mainfrom
davanstrien:feat/uv-run-mvp

Conversation

@davanstrien
Copy link
Copy Markdown
Contributor

@davanstrien davanstrien commented Jul 9, 2025

WIP adds a super minimal MVP version of the UV run (will keep #7 for further UX experiments with different workflows, etc.).

Usage

hfjobs uv --help
usage: hfjobs <command> [<args>] uv [-h] {run} ...

positional arguments:
  {run}       UV commands
    run       Run a UV script (local file or URL) on HF infrastructure

options:
  -h, --help  show this help message and exit
hfjobs uv run --help
usage: hfjobs <command> [<args>] uv run [-h] [--repo REPO] [--flavor FLAVOR] [-e ENV] [-s SECRET] [--timeout TIMEOUT] [-d] [--token TOKEN] script [script_args ...]

positional arguments:
  script                UV script to run (local file or URL)
  script_args           Arguments for the script

options:
  -h, --help            show this help message and exit
  --repo REPO           Repository name for the script (creates ephemeral if not specified)
  --flavor FLAVOR       Hardware flavor (default: cpu-basic)
  -e ENV, --env ENV     Environment variables
  -s SECRET, --secret SECRET
                        Secret environment variables
  --timeout TIMEOUT     Max duration (e.g., 30s, 5m, 1h)
  -d, --detach          Run in background
  --token TOKEN         HF token

What are UV scripts?

UV scripts are Python scripts with inline dependencies. Here's a simple example:

# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "requests",
#     "rich",
# ]
# ///

import requests
from rich import print

response = requests.get("https://api.github.com")
print(f"[green]GitHub API status:[/green] {response.status_code}")

Examples

Supports running from a local Python file:

Screenshot 2025-07-10 at 09 56 42

And from a public URL:

Screenshot 2025-07-10 at 09 57 19

Note on private repositories

Currently, it only supports using a public repository for the ephemeral storage of scripts. I would suggest we start with that for the launch and add a --private flag post-launch. @lhoestq WDYT?

davanstrien and others added 5 commits July 9, 2025 16:36
- Support running UV scripts directly from URLs
- Add HfApi token parameter for proper authentication
- Update README with URL usage example
@davanstrien davanstrien marked this pull request as ready for review July 10, 2025 09:05
Copy link
Copy Markdown
Owner

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

LGTM ! Let me know if you'd like to do more changes but IMO this can be integrated as is :)

Comment thread hfjobs/commands/uv.py
@davanstrien
Copy link
Copy Markdown
Contributor Author

davanstrien commented Jul 10, 2025 via email

@davanstrien
Copy link
Copy Markdown
Contributor Author

@lhoestq think this is ready now! I did add a warning Note: hfjobs uv run is experimental and subject to change. at the top of the logs for now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants