Closed rajavishah closed 1 month ago
After discussing with @gnodar01 , we’ve agreed on the following approach to handle various cli_tag/cli_flag
and value
in the current code base.
The backend logic requires updates to handle cases based on parameter
types.
type == Boolean
There could be 3 cases/patterns how cli_tag
and value
could be appended with someexecutable
|------------------|
| cli_tag | value |
|------------------|
| Yes | Yes |
| Yes | No |
| No | Yes |
|------------------|
type != Boolean
There could be 2 cases/patterns how cli_tag
and value
could be appended with someexecutable
|------------------|
| cli_tag | value |
|------------------|
| Yes | Yes |
| No | Yes |
|------------------|
Since, we can't foresee any cases where the cli_tag
would only be appended without it's value
value
without cli_tag
config.yaml
fileparameters
(formerly inputs
) : Helps appending either cli_tag
or value
or both to someexecutable
display_only
(New Section): Doesn't append anything to someexecutable
results
(formerly outputs
): It's the right-side section of gradio
(like the output section)cli_tag
or value
will be categorized under the display_only
section. This includes information intended solely for user display in the interface
, such as default output paths, which users cannot use through the cli_command
. For example, if an algorithm's output directory path is hardcoded with it's natural behavior to save output-files and unchangeable, this path will be shown in the display_only section to help users understand where their files are saved. Hence, they could look into docker-desktop ---> Files ---> /path/for/output/files
On top of it, we will have cli_order
for appending flags and values to the cli_command
. We plan to implement this using a jagged/ragged array, as the insertion and search operations will have constant time complexity. The idea is to store all unordered cli_tags
in the 0th column, while ordered cli_tags
and values
will be appended in columns 1 to n
Since, we can't foresee any cases where the cli_tag would only be appended without it's value Hence, the backend logic needs to be resilient to handle such Cases. Currently, it isn't able to handle the case where we only append the value without cli_tag
I think this can just be handled by the fact that cli_tag
will be ""
, yes?
The harder case to handle in my opinion is the booleans; we might need to think more through the nuances there.
(But great summary!)
Since, we can't foresee any cases where the cli_tag would only be appended without it's value Hence, the backend logic needs to be resilient to handle such Cases. Currently, it isn't able to handle the case where we only append the value without cli_tag
I think this can just be handled by the fact that
cli_tag
will be""
, yes?The harder case to handle in my opinion is the booleans; we might need to think more through the nuances there.
Yeah, but in the scenario where Algorithm's Documentation is having cli_tag
for some of the parameter
, and the algorithm's executable
structure expects us to only append value
. Would there be a case like that?
Or it would be the case where cli_tag
won't be present at all if the executable's
structure is to just take value
?
Or it would be the case where cli_tag won't be present at all if the executable's structure is to just take value
Yes, if there is no preceding flag, the person filling out the config shouldn't add one
The harder case to handle in my opinion is the booleans; we might need to think more through the nuances there.
For type == Boolean, I feel there are 6 cases
cli_tag
is present and value is True|Yes --> someexecutable cli_tag True|Yes
cli_tag
is present and value is False|No --> someexecutable cli_tag False|No
cli_tag
is present and value is True|Yes --> someexecutable cli_tag
cli_tag
is present and value is False|No --> someexecutable
cli_tag
is "" and value is True|Yes --> someexecutable True|Yes
cli_tag
is "" and value is False|No --> someexecutable False|No
I've confusion with case 6 - Would the logic should behave like append False
or if it's False
don't append anything with someexecutable
?
Although I could imagine them as possible, the last two cases are incredibly rare (for booleans), to the point that I've happily never encountered it in the wild.
We might consider taking 5. and 6. out as possibilities for the boolean type.
What is still rare, but common enough that I have encountered once or twice, is a positional value that is single choice / select (i.e. a dropdown of a finite, predefined set of values).
So you might have algo_name [flags] [choice A | choice B | choice C ]
, where you can optionally have only one of Choice A
or Choice B
or Choice C
, or none of them.
Or you might have algo_name [flags] (choice A | choice B | choice C)
, where you must have one and only one of Choice A
or Choice B
or Choice C
.
We could use the above type for the very rare, if not nonexistent cases of 5. and 6.
In the case of 5. and your first interpretation of 6., we would have:
algo_name [flags] [True | False]
In the case of 5. and your second interpretation of 6., we would have:
algo_name [flags] (True | False)
Or Yes | No
, Doit | Dontdoit
, please | nothanks
, etc.
So the type
would be Select
(or Dropdown
or Choice
or whatever we name it), and the value would be an array which just so happens to have exactly two values, True
and False
, and there would be a required
field which if false
or not set, would allow none
as an option, and if true
or set would not allow none
as an option.
Although I could imagine them as possible, the last two cases are incredibly rare (for booleans), to the point that I've happily never encountered it in the wild.
We might consider taking 5. and 6. out as possibilities for the boolean type.
What is still rare, but common enough that I have encountered once or twice, is a positional value that is single choice / select (i.e. a dropdown of a finite, predefined set of values).
So you might have
algo_name [flags] [choice A | choice B | choice C ]
, where you can optionally have only one ofChoice A
orChoice B
orChoice C
, or none of them.Or you might have
algo_name [flags] (choice A | choice B | choice C)
, where you must have one and only one ofChoice A
orChoice B
orChoice C
.We could use the above type for the very rare, if not nonexistent cases of 5. and 6.
In the case of 5. and your first interpretation of 6., we would have:
algo_name [flags] [True | False]
In the case of 5. and your second interpretation of 6., we would have:
algo_name [flags] (True | False)
Or
Yes | No
,Doit | Dontdoit
,please | nothanks
, etc.So the
type
would beSelect
(orDropdown
orChoice
or whatever we name it), and the value would be an array which just so happens to have exactly two values,True
andFalse
, and there would be arequired
field which iffalse
or not set, would allownone
as an option, and iftrue
or set would not allownone
as an option.
Got it, Thankyou!
@gnodar01 and I, were discussing about what else we should support at making the cli_command.
cli_order with negative values
cli_order
as negative
value. The cli_command
construction behavior should be someexecutable positive_cli_ordered_flags unordered_flags(i.e. cli_order=0) negative_cli_ordered_flags
Some of the many patterns of generating cli_command would be
someexecuatble --flag=value -flag2 -value2 ...
=
rather than {white-space-between-flag-and-value}
?someexecutable --flag1 value1_for_flag1 value2_for_falg1 value3_for_flag3
someexecutable --flag1 value1 --flag1 value2 --flag1 value3
How common are those patterns and for which-n-all we want to provide support for?
Implemented
A nuance - cli_tag and cli_order aren't necessarily mutually exclusive, though in my experience, often if something has to be positioned at the beginning, it may not have a cli flag. But any of the following patterns are possible
someexecutable --unordered_flag_1 unordered_value_1 --unordered_flag_2 unordered_value_2
someexecutable unordered_value_1 unordered_value_2
someexecutable ordered_value_1 unordered_value_2
someexecutable --ordered_flag_1 ordered_value_1 unordered_value_2
someexecutable ordered_value_1 --unordered_flag_2 unordered_value_2
Originally posted by @bethac07 in https://github.com/bilayer-containers/bilayers/issues/36#issuecomment-2297501273