Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ kernels to-wheel drbh/img2grey 1.1.2
### kernels upload

Use `kernels upload <dir_containing_build> --repo_id="hub-username/kernel"` to upload
your kernel builds to the Hub.
your kernel builds to the Hub. To know the supported arguments run: `kernels upload -h`.

**Notes**:

Expand Down
11 changes: 6 additions & 5 deletions src/kernels/check.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from pathlib import Path
import sys
from pathlib import Path
Copy link
Member Author

Choose a reason for hiding this comment

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

Result of make style.


from huggingface_hub import snapshot_download
from kernels.utils import CACHE_DIR
from kernel_abi_check import (
BinaryFormat,
IncompatibleMacOSVersion,
ObjectFile,
IncompatibleAbi3Symbol,
NonAbi3Symbol,
IncompatibleMacOSVersion,
IncompatibleManylinuxSymbol,
MissingMacOSVersion,
NonAbi3Symbol,
ObjectFile,
)

from kernels.utils import CACHE_DIR


def check_kernel(
*, macos: str, manylinux: str, python_abi: str, repo_id: str, revision: str
Expand Down
6 changes: 6 additions & 0 deletions src/kernels/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def main():
type=str,
help="Repository ID to use to upload to the Hugging Face Hub",
)
upload_parser.add_argument(
"--branch",
type=None,
help="If set, the upload will be made to a particular branch of the provided `repo_id`.",
)
upload_parser.add_argument(
"--private",
action="store_true",
Expand Down Expand Up @@ -218,6 +223,7 @@ def upload_kernels(args):
upload_folder(
repo_id=repo_id,
folder_path=build_dir,
revision=args.branch,
path_in_repo="build",
delete_patterns=list(delete_patterns),
commit_message="Build uploaded using `kernels`.",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_kernel_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class UploadArgs:
kernel_dir: None
repo_id: None
private: False
branch: None


def next_filename(path: Path) -> Path:
Expand Down Expand Up @@ -70,14 +71,15 @@ def get_filenames_from_a_repo(repo_id: str) -> List[str]:

@pytest.mark.token
@pytest.mark.is_staging_test
def test_kernel_upload_works_as_expected():
@pytest.mark.parametrize("branch", (None, "foo"))
def test_kernel_upload_works_as_expected(branch):
with tempfile.TemporaryDirectory() as tmpdir:
path = f"{tmpdir}/build/torch-universal/upload_test"
build_dir = Path(path)
build_dir.mkdir(parents=True, exist_ok=True)
script_path = build_dir / "foo.py"
script_path.write_text(PY_CONTENT)
upload_kernels(UploadArgs(tmpdir, REPO_ID, False))
upload_kernels(UploadArgs(tmpdir, REPO_ID, False, branch))

repo_filenames = get_filenames_from_a_repo(REPO_ID)
assert any(str(script_path.name) for f in repo_filenames)
Expand Down
Loading