OSC / ondemand

Supercomputing. Seamlessly. Open, Interactive HPC Via the Web
https://openondemand.org/
MIT License
293 stars 107 forks source link

Dynamic form JS data-show #3346

Open robinkar opened 9 months ago

robinkar commented 9 months ago

The data-hide option in forms is quite inconvenient if you have some widget that only is available for a small number of options. Something that would work the opposite of data-hide would be nice to have, e.g. data-show or maybe data-hide: false.

So rather than having forms like this:

slurm_partition:
  widget: "select"
  options:
    - ["interactive", "interactive", data-hide-gpu-type: true]
    - ["small", "small", data-hide-gpu-type: true]
    - ["largemem", "largemem", data-hide-gpu-type: true]
    - ["test", "test", data-hide-gpu-type: true]
    - ["medium", "medium", data-hide-gpu-type: true]
    - ["longrun", "longrun", data-hide-gpu-type: true]
    - ["gpu", "gpu"]

I would want to have this:

slurm_partition:
  widget: "select"
  options:
    - ["interactive", "interactive"]
    - ["small", "small"]
    - ["largemem", "largemem"]
    - ["test", "test"]
    - ["medium", "medium"]
    - ["longrun", "longrun"]
    - ["gpu", "gpu", data-show-gpu-type: true]

Where the gpu_type select widget would be hidden by default, and shown only for the gpu partition.

johrstrom commented 9 months ago

I'd have to look into the hidden_field widget type. This may be doable if gpu-type is hidden by default. I think data-show could only work on hidden fields given everything's shown by default.

That said - #2924 covers your example for GPUs specifically which I'm trying to build underlying support for in https://github.com/OSC/ood_core/pull/825

robinkar commented 9 months ago

The GPU type field here would be a dropdown, while I think the hidden_field is always a textbox (unless there is a way to make it a dropdown I have missed).

This would also be useful beyond this case with GPUs, for example with reservations where some reservation might not be available for all (most) accounts (i.e. show reservation field for some account).

johrstrom commented 9 months ago

OK I made #3348 for auto reservations.

I'm not really sure how to implement this given everything is shown by default. I'd guess we'd need to collect all the data attributes and determine if there's only 1 state it can be shown in and react off of that.

But auto_gpus and auto_reservations may make the whole thing moot.

robinkar commented 9 months ago

I think it could be fine to have some attribute be set for the GPU type field to toggle the behaviour, although some automatic detection would of course be better. So something like:

gpu_type:
  widget: "select"
  hide_by_default: true
  options:
    - a100
    - mi250

I'm not sure how useful an auto_reservation or autogpus field would be for us, as right now as we are not using the auto attributes (mostly due to some missing features).

johrstrom commented 8 months ago

I'm not sure how useful an auto_reservation or autogpus field would be for us, as right now as we are not using the auto attributes (mostly due to some missing features).

Well I would say that the intent is to be feature complete. Please let me know through tickets what's missing and I'll try to complete it. A test case for the expected behavior of you'd want would be best with perhaps some test fixtures we can test against.

We don't expose reservations or queues to customers, so it's a bit tough for me to test against our own sacctmgr or sinfo output.