harrrshall/BarunAction-35M main
PYTHON
Verdict: BENIGN
Local reference
Suspicious dependency
Inferred
test_barunaction_hub.py
python
| 1 |
from __future__ import annotations |
|
| 2 |
|
|
| 3 |
import hashlib |
|
| 4 |
import json |
|
| 5 |
from pathlib import Path |
|
| 6 |
from types import MappingProxyType |
|
| 7 |
from typing import Any |
|
| 8 |
|
|
| 9 |
import pytest |
Imports the pytest module |
| 10 |
|
|
| 11 |
import barunaction |
|
| 12 |
from barunaction import hub |
|
| 13 |
from barunaction.cli import main as cli_main |
|
| 14 |
|
|
| 15 |
|
|
| 16 |
def _sha256(payload: bytes) -> str: |
|
| 17 |
return hashlib.sha256(payload).hexdigest() |
Performs Python SHA-256 operation |
| 18 |
|
|
| 19 |
|
|
| 20 |
def _fake_release(monkeypatch: pytest.MonkeyPatch) -> tuple[dict[str, bytes], bytes]: |
|
| 21 |
files = { |
|
| 22 |
"barun_config.json": b'{"vocab_size":4}\n', |
|
| 23 |
"model.safetensors": b"tiny-test-weights", |
|
| 24 |
"tokenizer.json": b'{"version":"… |
|
| 24:46 |
…\n', |
|
| 25 |
} |
|
| 26 |
hashes = {name: _sha256(payload) for name, payload in files.items()} |
|
| 27 |
manifest = ( |
|
| 28 |
json.dumps( |
|
| 29 |
{ |
|
| 30 |
"file_sha256": hashes, |
|
| 31 |
"schema_version": "barun-… |
|
| 75:22 |
…download_candidate_checkpoint(destination) |
|
| 76 |
|
|
| 77 |
assert downloaded.path == destination.resolve() |
Checks condition using Python assert |
| 78 |
assert downloaded.candidate_id == "candidate-v2" |
|
| 79 |
assert downloaded.repo_id == "harrrshall/BarunAction-35M" |
|
| 80 |
assert downloaded.revision == "candidate-v2" |
|
| 81 |
assert dict(downloaded.checkpoint_sha256) == { |
|
| 82 |
name: _sha256(payload) for name, payload in files.items() |
|
| 83 |
} |
|
| 84 |
assert downloaded.manifest_sha256 == _sha256(manifest) |
|
| 85 |
assert calls == [ |
|
| 86 |
{ |
|
| 87 |
"allow_patterns": [*files, "checkpoint_manifest.json"], |
|
| 88 |
"local_dir": str(destination.resolve()), |
|
| 89 |
"repo_id": "harrrshall/BarunAction-35M… |
|
| 91:22 |
…": "candidate-v2", |
|
| 92 |
"token": False, |
|
| 93 |
} |
|
| 94 |
] |
|
| 95 |
assert barunaction.download_candidate_checkpoint is hub.download_candidate_checkpoint |
Checks condition using Python assert |
| 96 |
|
|
| 97 |
|
|
| 98 |
def test_download_fails_closed_on_content_mismatch( |
|
| 99 |
tmp_path: Path, |
|
| 100 |
monkeypatch: pytest.MonkeyPatch, |
|
| 101 |
) -> None: |
|
| 102 |
files, manifest = … |
|
| 128:33 |
…ndidate" |
|
| 129 |
|
|
| 130 |
code = cli_main(["download", "--output", str(destination)]) |
|
| 131 |
payload = json.loads(capsys.readouterr().out) |
Parses JSON data with Python |
| 132 |
|
|
| 133 |
assert code == 0 |
|
| 134 |
assert payload["ok"] is True |
|
| 135 |
assert payload["download"]["checkpoint"] ==… |
|
Micro-behaviors
| 1 |
from __future__ import annotations |
|
| 2 |
|
|
| 3 |
import hashlib |
|
| 4 |
import json |
|
| 5 |
from pathlib import Path |
|
| 6 |
from types import MappingProxyType |
|
| 7 |
from typing import Any |
|
| 8 |
|
|
| 9 |
import pytest |
|
| 10 |
|
|
| 11 |
import barunaction |
|
| 12 |
from barunaction import hub |
|
| 13 |
from barunaction.cli import main as cli_main |
|
| 14 |
|
|
| 15 |
|
|
| 16 |
def _sha256(payload: bytes) -> str: |
|
| 17 |
return hashlib.sha256(payload).hexdigest() |
|
| 18 |
|
|
| 19 |
|
|
| 20 |
def _fake_release(monkeypatch: pytest.MonkeyPatch) -> tuple[dict[str, bytes], bytes]: |
|
| 21 |
files = { |
|
| 22 |
"barun_config.json": b'{"vocab_size":4}\n', |
|
| 23 |
"model.safetensors": b"tiny-test-weights", |
|
| 24 |
"tokenizer.json": b'{"version":"… |
|
| 128:33 |
…ndidate" |
|
| 129 |
|
|
| 130 |
code = cli_main(["download", "--output", str(destination)]) |
|
| 131 |
payload = json.loads(capsys.readouterr().out) |
|
| 132 |
|
|
| 133 |
assert code == 0 |
|
| 134 |
assert payload["ok"] is True |
|
| 135 |
assert payload["download"]["checkpoint"] ==… |
|
| 75:22 |
…download_candidate_checkpoint(destination) |
|
| 76 |
|
|
| 77 |
assert downloaded.path == destination.resolve() |
|
| 78 |
assert downloaded.candidate_id == "candidate-v2" |
|
| 79 |
assert downloaded.repo_id == "harrrshall/BarunAction-35M" |
|
| 80 |
assert downloaded.revision == "candidate-v2" |
|
| 81 |
assert dict(downloaded.checkpoint_sha256) == { |
|
| 82 |
name: _sha256(payload) for name, payload in files.items() |
|
| 83 |
} |
|
| 84 |
assert downloaded.manifest_sha256 == _sha256(manifest) |
|
| 85 |
assert calls == [ |
|
| 86 |
{ |
|
| 87 |
"allow_patterns": [*files, "checkpoint_manifest.json"], |
|
| 88 |
"local_dir": str(destination.resolve()), |
|
| 89 |
"repo_id": "harrrshall/BarunAction-35M… |
|
| 91:22 |
…": "candidate-v2", |
|
| 92 |
"token": False, |
|
| 93 |
} |
|
| 94 |
] |
|
| 95 |
assert barunaction.download_candidate_checkpoint is hub.download_candidate_checkpoint |
|
| 96 |
|
|
| 97 |
|
|
| 98 |
def test_download_fails_closed_on_content_mismatch( |
|
| 99 |
tmp_path: Path, |
|
| 100 |
monkeypatch: pytest.MonkeyPatch, |
|
| 101 |
) -> None: |
|
| 102 |
files, manifest = … |
|
Metadata
| 104:19 |
…snapshot(monkeypatch, files, manifest, []) |
|
| 105 |
|
|
| 106 |
with pytest.raises(hub.HubDownloadError, match="model.safetensors"): |
|
| 107 |
hub.download_candidate_checkpoint(tmp_path / "candidate") |
|
| 108 |
|
|
| 109 |
|
|
| 110 |
def test_download_fails_closed_on_manifest_mismatch( |
|
| 111 |
tmp_path: Path, |
|
| 112 |
monkeypatch: pytest.MonkeyPatch, |
|
| 113 |
) -> None: |
|
| 114 |
files, manifest = … |
|
| 24:46 |
…\n', |
|
| 25 |
} |
|
| 26 |
hashes = {name: _sha256(payload) for name, payload in files.items()} |
|
| 27 |
manifest = ( |
|
| 28 |
json.dumps( |
|
| 29 |
{ |
|
| 30 |
"file_sha256": hashes, |
|
| 31 |
"schema_version": "barun-… |
|
| 1 |
from __future__ import annotations |
|
| 2 |
|
|
| 3 |
import hashlib |
|
| 4 |
import json |
|
| 5 |
from pathlib import Path |
|
| 6 |
from types import MappingProxyType |
|
| 7 |
from typing import Any |
|
| 8 |
|
|
| 9 |
import pytest |
|
| 10 |
|
|
| 11 |
import barunaction |
|
| 12 |
from barunaction import hub |
|
| 13 |
from barunaction.cli import main as cli_main |
|
| 14 |
|
|
| 15 |
|
|
| 16 |
def _sha256(payload: bytes) -> str: |
|
| 17 |
return hashlib.sha256(payload).hexdigest() |
|
| 18 |
|
|
| 19 |
|
|
| 20 |
def _fake_release(monkeypatch: pytest.MonkeyPatch) -> tuple[dict[str, bytes], bytes]: |
|
| 21 |
files = { |
|
| 22 |
"barun_config.json": b'{"vocab_size":4}\n', |
|
| 23 |
"model.safetensors": b"tiny-test-weights", |
|
| 24 |
"tokenizer.json": b'{"version":"… |
|
-
0
from __future__ import annotations
import hashlib
import json
from pathlib import Path
from types import MappingProxyType
from typing import Any
import pytest
import barunaction
from barunaction import hub
from barunaction.cli import main as cli_main
def _sha256(payload: bytes) -> str:
return hashlib.sha256(payload).hexdigest()
def _fake_release(monkeypatch: pytest.MonkeyPatch) -> tuple[dict[str, bytes], bytes]:
files = {
"barun_config.json": b'{"vocab_size":4}\n',
"model.safetensors": b"tiny-test-weights",
"tokenizer.json": b'{"version":"
| 1 |
from __future__ import annotations |
|
| 2 |
|
|
| 3 |
import hashlib |
|
| 4 |
import json |
|
| 5 |
from pathlib import Path |
|
| 6 |
from types import MappingProxyType |
|
| 7 |
from typing import Any |
|
| 8 |
|
|
| 9 |
import pytest |
|
| 10 |
|
|
| 11 |
import barunaction |
|
| 12 |
from barunaction import hub |
|
| 13 |
from barunaction.cli import main as cli_main |
|
| 14 |
|
|
| 15 |
|
|
| 16 |
def _sha256(payload: bytes) -> str: |
|
| 17 |
return hashlib.sha256(payload).hexdigest() |
|
| 18 |
|
|
| 19 |
|
|
| 20 |
def _fake_release(monkeypatch: pytest.MonkeyPatch) -> tuple[dict[str, bytes], bytes]: |
|
| 21 |
files = { |
|
| 22 |
"barun_config.json": b'{"vocab_size":4}\n', |
|
| 23 |
"model.safetensors": b"tiny-test-weights", |
|
| 24 |
"tokenizer.json": b'{"version":"… |
|
Identity
| SHA-256 |
3f53becda27b910dbe37bd5d29be032295edee64fb677a608d3180bc9a3f9281 |
| Filename |
test_barunaction_hub.py |
| Package |
harrrshall/BarunAction-35M |
| Version |
main |
| PURL |
pkg:huggingface/harrrshall/BarunAction-35M@main |
Timeline
| First seen |
5 Aug 2026 10:58 UTC |
| First analyzed |
19 Aug 2026 19:59 UTC |
| Last analyzed |
19 Aug 2026 19:59 UTC |
| Last updated |
19 Aug 2026 19:59 UTC |
Labeling
| Label |
unknown |
| Label source |
forager |
| Traits version |
73b94 |