Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service launcher configuration tabs are ordered depending on the values.schema.json #786

Open
Eldrile opened this issue Apr 4, 2024 · 3 comments
Assignees
Milestone

Comments

@Eldrile
Copy link

Eldrile commented Apr 4, 2024

Hi,
At the time I can't understand the order of the configuration tabs present in a service.
It would be great if these tabs could be ordered following the order present in the values.schema.json.

I tried looking into it from the front-end side but while I did find the function getting these values they are already in a different order, any ideas?
Thanks !

@olevitt
Copy link
Contributor

olevitt commented Apr 4, 2024

Hi !

The spec for values.schema.json defines the "tabs" as JSON objects and not JSON array (see https://github.com/InseeFrLab/helm-charts-interactive-services/blob/main/charts/jupyter-pytorch/values.schema.json for example) so there is no ordering built-in the spec (json objects are key-indexed, not position-indexed).
Additionally, in the case of Onyxia, the values.schema.json is read and parsed server-side (onyxia-api) before being sent to the UI (see catalogs endpoints) so if we wanted to preserve the order (which I don't think we should as it's contrary to JSON spec and ideology) we would have to ensure it's done multiple times : at API unmarshalling, at API endpoint marshalling in addition to UI side.
I think if we wanted to implement any sort of fine control over the ordering then we would have to add an additional attribute to the values.schema.json structure. Not sure if that's worth it but it may be up for debate

@garronej
Copy link
Contributor

garronej commented Apr 4, 2024

@olevitt You are correct in principle, but I think it's important to give the author of the charts the ability to enforce an order in the tabs. We could, of course, add a new x-onyxia parameter, but in my opinion, it would be worth it to see why the tabs are getting shuffled on the Java side. Because even if it's not in the spec, every implementation of JSON and JavaScript runtime respects the ordering of keys in object declarations.

Object.keys({ a: "foo", b: "bar" }) // Will always return [ "a", "b" ], never [ "b", "a" ]

Also:

const obj = { a: "foo", b: "bar" };
// and
const obj2 = JSON.parse(`{ "a": "foo", "b": "bar" }`)

are equivalent.

@fcomte fcomte added this to the Helm Launcher milestone May 31, 2024
@fcomte
Copy link
Contributor

fcomte commented May 31, 2024

I guess we should try to respect the order in the schema. Onyxia does not need to parse it. In my mind , in the near futur we will have a specific endpoint to request many json schema.. The one from the catalog could be override by a region. #798

So Onyxia-web should try to respect the order and Onyxia-api also.
For Onyxia-api we should create specific endpoint to provide json schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants