mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
import copy
|
|
import pytest
|
|
import yaml
|
|
from harbor_buzz_orchestra import ExperimentManifest, ManifestError
|
|
|
|
|
|
def test_hash_is_independent_of_mapping_and_yaml_key_order(tmp_path, manifest_data):
|
|
first = ExperimentManifest.load(manifest_data)
|
|
path = tmp_path / "manifest.yaml"
|
|
path.write_text(
|
|
yaml.safe_dump(
|
|
dict(reversed(list(copy.deepcopy(manifest_data).items()))), sort_keys=False
|
|
)
|
|
)
|
|
second = ExperimentManifest.load(path)
|
|
assert first.canonical_bytes() == second.canonical_bytes()
|
|
assert first.sha256 == second.sha256
|
|
assert len(first.sha256) == 64
|
|
|
|
|
|
def test_hash_changes_when_staffing_changes(manifest_data):
|
|
first = ExperimentManifest.load(manifest_data)
|
|
changed = copy.deepcopy(manifest_data)
|
|
changed["roster"][1]["count"] = 3
|
|
assert ExperimentManifest.load(changed).sha256 != first.sha256
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("mutation", "match"),
|
|
[
|
|
(lambda data: data.update({"unknown": True}), "Extra inputs"),
|
|
(lambda data: data["roster"].pop(0), "exactly one orchestrator"),
|
|
(lambda data: data["prices"].pop("databricks/qwen"), "prices missing"),
|
|
(lambda data: data["roster"][1].update({"concurrency": 5}), "concurrency"),
|
|
],
|
|
)
|
|
def test_invalid_manifest_is_rejected(manifest_data, mutation, match):
|
|
mutation(manifest_data)
|
|
with pytest.raises(ManifestError, match=match):
|
|
ExperimentManifest.load(manifest_data)
|
|
|
|
|
|
def test_non_mapping_document_is_rejected(tmp_path):
|
|
path = tmp_path / "manifest.yaml"
|
|
path.write_text("- not\n- a\n- mapping\n")
|
|
with pytest.raises(ManifestError, match="root must be a mapping"):
|
|
ExperimentManifest.load(path)
|