GLBs carried the licence's name, URL and notice in asset.extras.license. A pipeline that sorts assets by licence needs what a machine matches on: the id, whether commercial use is allowed, the regions it excludes, the revenue cap and the attribution. The whole licence is written, as /v1/models gives it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
cfc636e328
commit
2eb2a6d8fe
2 files changed
+40
-5
No files matched your search
@@ -401,3 +401,34 @@ func TestAModelAsleepUntilAskedIsListedAndSaidAsleep(t *testing.T) {
|
||||
t.Error("a model serving is not said loaded")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAMeshCarriesItsWholeLicence(t *testing.T) {
|
||||
// The name alone was written: a pipeline that sorts assets by licence
|
||||
// reads the id, whether commercial use is allowed and where it is not.
|
||||
glb, err := objToGLB([]byte("v 0 0 0\nv 1 0 0\nv 1 1 0\nf 1 2 3\n"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
yes := true
|
||||
out, err := glbWithLicense(glb, catalog.License{ID: "stability-community", Name: "Stability AI Community License",
|
||||
Commercial: &yes, RevenueCapUSD: 1000000, Attribution: "Powered by Stability AI", ExcludedRegions: []string{"XX"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n := binary.LittleEndian.Uint32(out[12:])
|
||||
var doc struct {
|
||||
Asset struct {
|
||||
Extras struct {
|
||||
License map[string]any `json:"license"`
|
||||
} `json:"extras"`
|
||||
} `json:"asset"`
|
||||
}
|
||||
if err := json.Unmarshal(out[20:20+n], &doc); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
l := doc.Asset.Extras.License
|
||||
if l["id"] != "stability-community" || l["commercial"] != true || l["revenue_cap_usd"] != 1000000.0 ||
|
||||
l["attribution"] != "Powered by Stability AI" || l["name"] == nil {
|
||||
t.Errorf("licence %v", l)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user