Skip to content

Commit 2897889

Browse files
authored
Add build-and-upload command (#278)
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/<kernel-name>` is used. If `branch` is absent, then `main` is used. Fixes #204.
1 parent 1b6fe71 commit 2897889

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

build2cmake/src/config/v2.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ pub struct General {
5151
pub cuda_maxver: Option<Version>,
5252

5353
pub cuda_minver: Option<Version>,
54+
55+
pub hub: Option<Hub>,
56+
}
57+
58+
#[derive(Debug, Deserialize, Serialize)]
59+
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
60+
pub struct Hub {
61+
pub repo_id: Option<String>,
62+
pub branch: Option<String>,
5463
}
5564

5665
#[derive(Debug, Deserialize, Clone, Serialize)]
@@ -249,6 +258,7 @@ impl General {
249258
universal,
250259
cuda_maxver: None,
251260
cuda_minver: None,
261+
hub: None,
252262
}
253263
}
254264
}

lib/gen-flake-outputs.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ in
158158
chmod -R +w build
159159
'';
160160

161+
build-and-upload =
162+
let
163+
buildToml = build.readBuildConfig path;
164+
repo_id = lib.attrByPath [
165+
"general"
166+
"hub"
167+
"repo-id"
168+
] "kernels-community/${buildToml.general.name}" buildToml;
169+
branch = lib.attrByPath [ "general" "hub" "branch" ] "main" buildToml;
170+
in
171+
writeScriptBin "build-and-upload" ''
172+
#!/usr/bin/env bash
173+
set -euo pipefail
174+
${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle}
175+
'';
176+
161177
ci =
162178
let
163179
setsWithFramework =

overlay.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ final: prev: {
1818
(
1919
python-self: python-super: with python-self; {
2020
kernel-abi-check = callPackage ./pkgs/python-modules/kernel-abi-check { };
21+
22+
kernels = python-super.kernels.overrideAttrs (oldAttrs: {
23+
version = "unstable";
24+
25+
src = final.fetchFromGitHub {
26+
owner = "huggingface";
27+
repo = "kernels";
28+
rev = "5d21b86a5d611100c10c10b79ffa7965edf567fd";
29+
sha256 = "sha256-lKQUVbjhpeXKj1SeZRxgPSsOtBUZ7zQeO6pRoA1h+W8=";
30+
};
31+
});
2132
}
2233
)
2334
];

0 commit comments

Comments
 (0)