Skip to content

Conversation

@danieldk
Copy link
Member

This change adds the version option to the general section in build.toml. The version will be written to the build metadata and will be used by kernels upload to upload builds to a versioned branch.

drbh
drbh previously approved these changes Jan 13, 2026
Copy link
Collaborator

@drbh drbh left a comment

Choose a reason for hiding this comment

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

lgtm, just left a question about the version type


pub struct General {
pub name: String,
pub version: Option<usize>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

likely overly pedantic, but maybe we want to be more strict on the version and disallow negative numbers or 0? additionally maybe we want to use a less ambiguous type like u32.

conversely maybe we want a more open ended type like a string? just thinking out loud here..

curious to hear your thoughts on the type?

Copy link
Member Author

@danieldk danieldk Jan 14, 2026

Choose a reason for hiding this comment

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

Certainly not overly pedantic, I changed it a few times while working on this.

but maybe we want to be more strict on the version and disallow negative numbers or 0?

Negative numbers are already disallowed, >= 0 I feel adds the unnecessary complication of having to use NonZero. I think it's also a nice number to show that the kernel is still in the initial stages.

conversely maybe we want a more open ended type like a string?

I find this a hard one. Initially I had a string and some additional validation to check that the string can be parsed as usize. When it was still called a channel, my idea was that you could also make testing and development channels and you would put something like "foo-test" here, it would get uploaded to the channel channel-foo-test.

The primary objections I can think of are: making it a string could confuse people into thinking they could put a full dotted version there and it makes you have to do more parsing and validation. But the objections are not particularly strong.

That said, I think we could easily transition to a string in the future by either changing the type to an enum or by upgrading to version v4 of the configuration. Using an enum could even be semantically clearer: either it is a version or it is something else (that we haven't thought of yet).

Copy link
Collaborator

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Thank you! I just have few questions

Comment on lines +190 to +201
branch = lib.attrByPath [ "general" "hub" "branch" ] null buildToml;
branchOpt = lib.optionalString (branch != null) "--branch ${branch}";
Copy link
Collaborator

Choose a reason for hiding this comment

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

qq since lib.attrByPath [ "general" "hub" "branch" ] is an integer, for example 1, i'm not sure why this gets uploaded to v1, instead of just 1 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

general.hub.branch is still a stringly-typed branch. If it is not set (the normal case), then the --branch option is not passed, so it will be a regular kernels upload repo_id. In that case, the version upload code in kernels upload will be used:

https://github.com/huggingface/kernels/blob/ff4de4eafdfe5c2346b252cf09c6c412e13f3135/src/kernels/upload.py#L48

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah makes sense! thanks for pointing that out

#!/usr/bin/env bash
set -euo pipefail
${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle}
${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} ${branchOpt} ${bundle}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the version isn’t set, I’m assuming we’re uploading to main.
I’m not sure whether it’s better to automatically infer the version when the user doesn’t specify it, or to simply raise a warning reminding them to set a version explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, in that case we are uploading in main. I am not sure about setting it for the user automatically, I think it should be opt-in, because initially a user will want to upload both to a version branch and to main (for backwards compatibility) up till when the first version bump happens.

We should indeed emit a warning in build2toml when the version is not set. But I think we should only add it once versions are supported everywhere (once we have a versions-enabled kernels release).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes I agree! let's do that

This change adds the `version` option to the `general` section in
`build.toml`. The version will be written to the build metadata and will
be used by `kernels upload` to upload builds to a versioned branch.
This allows version-based uploading to kick in when no branch is
specified.
@danieldk danieldk merged commit 2997c77 into main Jan 15, 2026
28 of 30 checks passed
@danieldk danieldk deleted the version-option branch January 15, 2026 11:31
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.

4 participants