Command line tools for working with yaq traits and protocols.
yaq-traits can be installed via PyPI or conda-forge.
$ pip install yaq-traits
$ conda config --add channels conda-forge
$ conda install yaq-traits
yaq-traits is a command line application.
Help: learn more, right from your terminal.
$ yaq-traits --help
Usage: yaq-traits [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
check
compose
Try yaq-traits
to learn more about a particular command.
List: list available traits
$ yaq-traits list
has-limits
has-measure-trigger
has-position
has-turret
is-daemon
is-discrete
is-homeable
is-sensor
uses-i2c
uses-serial
uses-uart
Compose: Convert a simplified TOML file to a fully specified AVPR. This takes a path to a TOML file as an argument, and prints the AVPR to standard out.
$ yaq-traits compose my-daemon.toml > my-daemon.avpr
Get: Retrieve a fully specified AVPR for a trait (similar to compose, but not a full daemon). This takes a name of a trait as an argument, and prints the AVPR to standard out.
$ yaq-traits get has-limits > has-limits.avpr
Check: Verify that an AVPR file matches current trait behavior.
This takes a path to an AVPR file as an argument, and prints a table of traits and whether the trait was found to be accurate.
If it fails, the traits which are not specified are explicitly printed and a nonzero exit status is returned.
The primary intent of check
is to be used by Continuous Integration tests, which consistently get the latest version and will alert you if there is a change to the traits.
$ yaq-traits check fake-continuous-hardware.avpr
+---------------------+----------+----------+
| trait | expected | measured |
+---------------------+----------+----------+
| has-limits | true | true |
| has-position | true | true |
| has-turret | false | false |
| is-daemon | true | false |
| is-discrete | false | false |
| is-homeable | false | false |
| uses-i2c | false | false |
| uses-serial | false | false |
| uses-uart | false | false |
| has-measure-trigger | false | false |
| is-sensor | false | false |
+---------------------+----------+----------+
Error: failed to verify expected trait(s):
is-daemon
What to do when a check fails:
yaq-traits
yaq-traits
to see what has been changed recentlycore
package for your language (e.g. Python). If so, all you need to do is pin the version of core and rerun yaq-traits compose
yaq-traits compose
has-limits
requires has-position
) the required trait need not be specified. is-daemon
must be specified by all daemons.
[links] # all optional, arbitrary keys supported
documentation = "https://yaq.fyi/daemons/example-daemon"
source = "https://git.example.com/example-daemon"
bugtracker = "https://git.example.com/example-daemon/-/issues"
[installation] # all optional, arbitrary keys supported
PyPI = "https://pypi.org/project/yaqd-example"
conda-forge = "https://anaconda.org/conda-forge/yaqd-example"
yaq-tratis
provides a definition for an N-dimensional homogeneous array, which can be used by putting the string "ndarray"
as the type.
"__null__"
is used in place of the null literal.
Note that when referring to the type, "null"
is used, just as "int"
is used to specify the integer type.
[[types]]
name="Greeting"
type="record"
[[types.fields]]
name="message"
type="string"
[[types]]
name="Curse"
type="record"
# You may find inline tables/arrays more readable here
# Note that toml forbids multi-line inline tables (arrays can be multi-line)
fields = [{name="message", "type"="string"}]
[config]
table with the following keys:
"int"
or "ndarray"
, but may be a table representing collection types or a record or an array representing a union of types.
[config]
[config.a_binary_config]
type = "boolean"
default = false
doc = "An example of a boolean config param"
[config.an_optional_array]
type = ["null", {type = "array", items = "int"}]
default = "__null__"
# Overriding a config from a trait
[config.baud_rate]
default = 57600
addendum = "I want to provide more info about why 57600 is the default"
[state]
[state.a_binary_state]
type = "boolean"
default = true
doc = "An example of a boolean state variable"
[]
, i.e. no parameters.
"null"
.
[messages.set_int]
request = [{"name"="int_value", "type"="int"}]
doc = "Set an example int value."
[messages.get_int]
response = "int"
doc = "Get the example int value."
yaq-traits
does add additional information such that the avpr alone can be used to render the documentation.
config
and state
(including those inherited from traits).
The links (including installation links) are also included.
Additional keys specifying which trait provided a method or config/state variable are also added by yaq-traits
CC0: no copyright