A mesh carries its whole licence, not only its name
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
@@ -221,12 +221,16 @@ func glbWithLicense(glb []byte, lic catalog.License) ([]byte, error) {
|
|||||||
if extras == nil {
|
if extras == nil {
|
||||||
extras = map[string]any{}
|
extras = map[string]any{}
|
||||||
}
|
}
|
||||||
l := map[string]any{"name": lic.Name}
|
// The whole licence, as /v1/models gives it: its id, whether it allows
|
||||||
if lic.URL != "" {
|
// commercial use and where it grants nothing are what a pipeline that
|
||||||
l["url"] = lic.URL
|
// sorts assets by licence reads, and the name alone is for people.
|
||||||
|
var l map[string]any
|
||||||
|
b, err := json.Marshal(lic)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
if lic.Notice != "" {
|
if err := json.Unmarshal(b, &l); err != nil {
|
||||||
l["notice"] = lic.Notice
|
return nil, err
|
||||||
}
|
}
|
||||||
extras["license"] = l
|
extras["license"] = l
|
||||||
asset["extras"] = extras
|
asset["extras"] = extras
|
||||||
|
|||||||
@@ -401,3 +401,34 @@ func TestAModelAsleepUntilAskedIsListedAndSaidAsleep(t *testing.T) {
|
|||||||
t.Error("a model serving is not said loaded")
|
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