Skip to content

feat(endpoints): Values by option and optional extended value metadata#293

Open
ketiltrout wants to merge 1 commit into
chime-upgradefrom
value_params
Open

feat(endpoints): Values by option and optional extended value metadata#293
ketiltrout wants to merge 1 commit into
chime-upgradefrom
value_params

Conversation

@ketiltrout

Copy link
Copy Markdown
Member

There are two related changes here, which I though were low-priority, but I've realised the ordering of endpoint values in the client isn't fixed anymore, so this should sort that out:

Endpoint values specified by option, not argument

This changes the default way of specifying endpoint data to use (required) --options, instead of positional arguments on the command line.

In the past, endpoint values in the client were read directly from endpoint files on the local system, so ensuring they kept a fixed order was easy. But now the values dict is forced through both YAML and JSON codecs and we can't guarantee that the dict keys retain their order. The side-effect of that, is there's no guarantee of which order the corresponding arguments ended up on the command line.

So, to get around that, required --options are used to make the ordering on the command-line unimportant.

Extended "values" metadata format in endpoint definitions ---------------------------------------------------------

To allow more flexibility on how the coco CLI is built for an endpoint, the endpoint definition is extended to allow additional optional metadata for endpoint "values". This adds an alternate format for defining "values". Instead of the dict-of-types specification, a list-of-dicts can be used for "values" instead.

In the list-of-dicts, each dict represents a single value. Each of these dicts is required to contain a "name" and a "type" (which recover the data in the old dict-of-types specification). There are additional, optional keys allowed in the dict which can be used to specify additional metadata, which is used by the client when building the CLI for this endpoint:

  • "params": string or list of strings. can be used to set the --option names used for the value. (For bools, this can be called "on-flags" instead, to match the next key.)
  • "off-flags": string or list of strings. For bool-types only, sets the names of the false-valued option flags.
  • "help": string. The help string to display
  • "option": boolean. Whether or not to use an --option or an argument for this parameter. Defaults to True
  • "meta": string. The metavar to use in help strings.

The original dict-of-types specification is still supported.

Additionally, for lists, the element type can also be specified: "list[int]".

None of this extra data is used in the daemon. It's all extra metadata for the client. For backwards compatibility, this includes the item type specified for lists: the daemon does not validate the type of list items passed to it via JSON.

There are two related changes here:

Endpoint values specified by option, not argument
-------------------------------------------------

This changes the default way of specifying endpoint data to
use (required) --options, instead of positional arguments on the
command line.

In the past, endpoint values in the client were read directly from
endpoint files on the local system, so ensuring they kept a fixed order
was easy.  But now the values dict is forced through both YAML and JSON
codecs and we can't guarantee that the dict keys retain their order.
The side-effect of that, is there's no guarantee of which order the
corresponding arguments ended up on the command line.

So, to get around that, required --options are used to make the ordering
on the command-line unimportant.

Extended "values" metadata format in endpoint definitions
---------------------------------------------------------

To allow more flexibility on how the coco CLI is built for an endpoint,
the endpoint definition is extended to allow additional optional
metadata for endpoint "values".  This adds an alternate format
for defining "values".  Instead of the dict-of-types specification,
a list-of-dicts can be used for "values" instead.

In the list-of-dicts, each dict represents a single value.  Each
of these dicts is required to contain a "name" and a "type" (which
recover the data in the old dict-of-types specification).  There
are additional, optional keys allowed in the dict which can be used
to specify additional metadata, which is used by the client when
building the CLI for this endpoint:

* "params": string or list of strings.  can be used to set the --option names
  used for the value.  (For bools, this can be called "on-flags" instead, to
  match the next key.)
* "off-flags": string or list of strings.  For bool-types only, sets the
  names of the false-valued option flags.
* "help": string.  The help string to display
* "option": boolean.  Whether or not to use an --option or an argument for
  this parameter.  Defaults to True
* "meta": string.  The metavar to use in help strings.

The original dict-of-types specification is still supported.

Additionally, for lists, the element type can also be specified: "list[int]".

None of this extra data is used in the daemon.  It's all extra metadata
for the client.  For backwards compatibility, this includes the item type
specified for lists: the daemon does not validate the type of list items
passed to it via JSON.
This was referenced Jul 9, 2026
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

Successfully merging this pull request may close these issues.

1 participant