replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
8.08k stars 561 forks source link

Add ordering to output objects #623

Open bfirsh opened 2 years ago

bfirsh commented 2 years ago

Inputs are ordered, but outputs are not.

zeke commented 2 years ago

https://github.com/zeke/cog-haiku/pull/12

zeke commented 2 years ago

The order is still intact in Cog's OpenAPI schema:

Screen Shot 2022-05-27 at 3 18 40 PM

But not in the schema (nor the prediction object) in replicate-web, which looks to be alphabetical:

Screen Shot 2022-05-27 at 3 14 50 PM
zeke commented 2 years ago

In replicate-web, the order of the outputs in the properties is reversed:

postgres=# select openapi_schema->'components'->'schemas'->'Output'->'properties' from models_version where docker_image_id='9d45ce800c36226fa0190021cc70ce6bbb64dce6ff71c70eb2acf11c45fd2635';
                                                                          ?column?                                                                           
-------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"seed": {"type": "integer", "title": "Seed"}, "text": {"type": "string", "title": "Text"}, "image": {"type": "string", "title": "Image", "format": "uri"}}
(1 row)

I think we need to solve this by adding x-order properties to each output object, like we do for Input in Cog.

zeke commented 2 years ago

Related: https://github.com/go-openapi/spec/issues/24

zeke commented 2 years ago

@chenxwh ran into this again today.