Dealing with inputs and variables¶
So far, we have put our inputs directly in the radio file. This is useful to set defaults that users don't need to touch, but not really practical. So let's improve that
The inputs json¶
Internally, all the inputs of a radio are assembled into a giant JSON, with each layer id having it's inputs:
Note: It's a simplification. It's not really how it works but it's pretty closeWhen a user puts arguments when running the radio, they creates own input json, which overide the inputs set in the radio file:
Is added and becomes:
So any input on any step is overridable. This is really powerful for testing stuff
Variables¶
... But not practical for the users. That's where variables comes in. Those are aliases on the inputs json.
Here we create an alias called username. The target is the listen_seeder's user input. This means that if the user input this json:
it will get turned into:
Then added to the radio's defaults
Other variables usages¶
Variables can target multiple layers at once:
{
"username": {
"targets": [
"listen_seeder.user",
"and_filter.radio.username",
"latest_listens.user"
]
},
}
Variables can have a default value:
{
"minimum_listens": {
"description": "The minimum all time listens the tracks need to have before getting suggested",
"targets": [
"listen_filter.minimum"
],
"default": 3
},
}
Special variables¶
Some variables are automatically provided and the user doesn't need to provide them. However you probably want to use them:
username: The name of the default listenbrainz usertimeouts: The recordings in timeout set by the user. To be used in atimeout_filter