From df21c9a136275a44f58e7eb926f538066e9c206f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Tue, 28 Oct 2025 08:54:51 +0000 Subject: [PATCH] Add `build-and-upload` command This does what it says on the tin. The upload location can be configured in `build.toml`: ``` [general.hub] repo-id = "kernels-community/relu-upload-test" branch = "upload-test" ``` If `repo_id` is absent, then `kernels-commumity/` is used. If `branch` is absent, then `main` is used. --- build2cmake/src/config/v2.rs | 10 ++++++++++ lib/gen-flake-outputs.nix | 16 ++++++++++++++++ overlay.nix | 11 +++++++++++ 3 files changed, 37 insertions(+) diff --git a/build2cmake/src/config/v2.rs b/build2cmake/src/config/v2.rs index 606f3177..b4dfa075 100644 --- a/build2cmake/src/config/v2.rs +++ b/build2cmake/src/config/v2.rs @@ -51,6 +51,15 @@ pub struct General { pub cuda_maxver: Option, pub cuda_minver: Option, + + pub hub: Option, +} + +#[derive(Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields, rename_all = "kebab-case")] +pub struct Hub { + pub repo_id: Option, + pub branch: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] @@ -249,6 +258,7 @@ impl General { universal, cuda_maxver: None, cuda_minver: None, + hub: None, } } } diff --git a/lib/gen-flake-outputs.nix b/lib/gen-flake-outputs.nix index d7c1a82b..15418879 100644 --- a/lib/gen-flake-outputs.nix +++ b/lib/gen-flake-outputs.nix @@ -158,6 +158,22 @@ in chmod -R +w build ''; + build-and-upload = + let + buildToml = build.readBuildConfig path; + repo_id = lib.attrByPath [ + "general" + "hub" + "repo-id" + ] "kernels-community/${buildToml.general.name}" buildToml; + branch = lib.attrByPath [ "general" "hub" "branch" ] "main" buildToml; + in + writeScriptBin "build-and-upload" '' + #!/usr/bin/env bash + set -euo pipefail + ${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle} + ''; + ci = let setsWithFramework = diff --git a/overlay.nix b/overlay.nix index 4b40f978..427895a2 100644 --- a/overlay.nix +++ b/overlay.nix @@ -18,6 +18,17 @@ final: prev: { ( python-self: python-super: with python-self; { kernel-abi-check = callPackage ./pkgs/python-modules/kernel-abi-check { }; + + kernels = python-super.kernels.overrideAttrs (oldAttrs: { + version = "unstable"; + + src = final.fetchFromGitHub { + owner = "huggingface"; + repo = "kernels"; + rev = "5d21b86a5d611100c10c10b79ffa7965edf567fd"; + sha256 = "sha256-lKQUVbjhpeXKj1SeZRxgPSsOtBUZ7zQeO6pRoA1h+W8="; + }; + }); } ) ];