Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Docker publish: sync the Hub page with DOCKER_API_KEY on the namespace route (#10343)
Daniel Han7deb244ac3c0
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymlindex c0acab2c82a..bbd1bcea3a7 100644--- a/.github/workflows/docker-publish.yml+++ b/.github/workflows/docker-publish.yml@@ -530,6 +530,12 @@ jobs:# hand. Synced from docker/DOCKERHUB.md whenever :latest moved, i.e. the same# condition as the stable tags above. Verified by reading it back, and a token# that cannot edit the description fails the job rather than warning.+ #+ # Uses DOCKER_API_KEY on the namespace-scoped route. The legacy+ # /v2/repositories/{owner}/{repo}/ path answers every organization access token+ # with 403 "token issued from organization access token is not allowed" (run+ # 33943728004), which is what failed this job on each publish before; the token+ # also needs the repository edit permission.hub-readme:needs: merge-studioif: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.event.inputs.unsloth_ref == '' && (github.event.inputs.unsloth_zoo_ref == '' || github.event.inputs.unsloth_zoo_ref == 'main') && (github.event.inputs.notebooks_ref == '' || github.event.inputs.notebooks_ref == 'main') && github.event.inputs.llama_prebuilt_tag == '' }}@@ -544,27 +550,30 @@ jobs:run: |README=docker/DOCKERHUB.mdtest -s "$README"- # Organization access tokens are exchanged at /v2/auth/token, not- # /v2/users/login/, which rejects organization accounts.+ # The organization token is only accepted on the namespace-scoped routes.+ # The legacy /v2/repositories/{owner}/{repo}/ path answers every+ # organization token with 403 "token issued from organization access token+ # is not allowed", whatever its scopes. The token needs the repository+ # edit permission on ${IMAGE_NAME}.+ HUB="https://hub.docker.com/v2/namespaces/${IMAGE_NAME%%/*}/repositories/${IMAGE_NAME#*/}"TOKEN="$(curl -sS -X POST https://hub.docker.com/v2/auth/token \-H 'Content-Type: application/json' \- -d "{\"identifier\": \"${REGISTRY_USERNAME}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \+ -d "{\"identifier\": \"${{ env.REGISTRY_USERNAME }}\", \"secret\": \"${{ secrets.DOCKER_API_KEY }}\"}" \| python3 -c 'import json,sys; print(json.load(sys.stdin).get("access_token",""))')"if [ -z "$TOKEN" ]; thenecho "::error::Could not exchange DOCKER_API_KEY for a Hub API token; the Hub page was not updated."exit 1fiBODY="$(python3 -c 'import json,sys; print(json.dumps({"full_description": open(sys.argv[1], encoding="utf-8").read()}))' "$README")"- CODE="$(curl -sS -o /tmp/hub_patch.json -w '%{http_code}' -X PATCH \- "https://hub.docker.com/v2/repositories/${IMAGE_NAME}/" \+ CODE="$(curl -sS -o /tmp/hub_patch.json -w '%{http_code}' -X PATCH "$HUB" \-H "Authorization: Bearer ${TOKEN}" -H 'Content-Type: application/json' \--data-binary "$BODY")"echo "PATCH returned HTTP ${CODE}"# Read it back rather than trusting the status code.- LIVE="$(curl -sS "https://hub.docker.com/v2/repositories/${IMAGE_NAME}/" \+ LIVE="$(curl -sS -H "Authorization: Bearer ${TOKEN}" "$HUB" \| python3 -c 'import json,sys; print(json.load(sys.stdin).get("full_description",""))')"if [ "$LIVE" != "$(cat "$README")" ]; then- echo "::error::The Hub page does not match ${README} after PATCH ${CODE}. The token most likely lacks permission to edit the repository description."+ echo "::error::The Hub page does not match ${README} after PATCH ${CODE}. DOCKER_API_KEY most likely lacks the repository edit permission on ${IMAGE_NAME}."head -c 400 /tmp/hub_patch.json; echoexit 1fidiff --git a/tests/python/test_docker_hub_readme.py b/tests/python/test_docker_hub_readme.pyindex a0f256693f2..20bd5a23cc7 100644--- a/tests/python/test_docker_hub_readme.py+++ b/tests/python/test_docker_hub_readme.py@@ -80,6 +80,7 @@ def _run_sync(*,live_after_patch: str,token: str = "tok",+ secret: str = "not-a-secret",):bin_dir = tmp_path / "bin"bin_dir.mkdir()@@ -101,7 +102,9 @@ def _run_sync((bin_dir / "curl").chmod(0o755)(tmp_path / "docker").mkdir()shutil.copy(HUB_README, tmp_path / "docker" / "DOCKERHUB.md")- script = step.replace("${{ secrets.DOCKER_API_KEY }}", "not-a-secret")+ script = step.replace("${{ secrets.DOCKER_API_KEY }}", secret).replace(+ "${{ env.REGISTRY_USERNAME }}", "unsloth"+ )assert "${{" not in script, "unexpanded expression in the sync step"env = dict(os.environ)env["PATH"] = f"{bin_dir}{os.pathsep}" + env["PATH"]@@ -122,8 +125,20 @@ def test_the_sync_patches_the_readme_and_confirms_it(sync_job: dict, tmp_path: Pstep = sync_job["steps"][-1]["run"]res, log = _run_sync(step, tmp_path, live_after_patch = HUB_README.read_text(encoding = "utf-8"))assert res.returncode == 0, res.stdout + res.stderr- assert "-X PATCH https://hub.docker.com/v2/repositories/unsloth/unsloth/" in log+ assert "-X PATCH https://hub.docker.com/v2/namespaces/unsloth/repositories/unsloth" in logassert "Authorization: Bearer tok" in log+ assert '"identifier": "unsloth"' in log, "the organization token authenticates as the org"+++def test_the_sync_never_touches_the_legacy_repository_route(sync_job: dict, tmp_path: Path):+ """Docker Hub rejects every organization access token on+ /v2/repositories/{owner}/{repo}/ with 403 "token issued from organization access+ token is not allowed", whatever its scopes; only the namespace-scoped route+ accepts it. That 403 failed the sync on every publish before this test existed."""+ step = sync_job["steps"][-1]["run"]+ _, log = _run_sync(step, tmp_path, live_after_patch = HUB_README.read_text(encoding = "utf-8"))+ assert "/v2/repositories/" not in log+ assert "/v2/namespaces/unsloth/repositories/unsloth" in logdef test_the_sync_fails_when_the_page_did_not_change(sync_job: dict, tmp_path: Path):