rig.wizard
: Stock SpiNNaker-board info gathering wizards¶
Many applications require end-users to supply the details of a SpiNNaker system they wish to connect to. This module hopes to provide a more-friendly user interaction than just asking for an IP address in the general case.
This module contains a number of wizards which extract various pieces of
information from a user by asking simple questions. A wizard is a generator
function which generates sequences of questions to which the answers are fed
back into the generator. For command-line applications, a wrapper script
cli_wrapper()
will do all the heavy-lifting:
>> from rig.wizard import (
.. ip_address_wizard, cli_wrapper)
>> resp = cli_wrapper(ip_address_wizard())
Would you like to auto-detect the SpiNNaker system's IP address?
0: Auto-detect
1: Manually Enter IP address or hostname
Select an option 0-1 (default: 0):
Make sure the SpiNNaker system is switched on and is not booted.
<Press enter to continue>
Discovering attached SpiNNaker systems...
>> resp
{'ip_address': '192.168.240.253'}
Third-parties whose needs are not met by the supplied CLI wizard interface are encouraged to build their own front-ends which support the wizard protocol. The wizard generator functions generate the following objects:
MultipleChoice
This tuple includes a question to be presented to the user along with a list of valid options to choose from and a default value to select (or None if no default exists). The generator should be sent the index of the user’s selection.Text
This tuple includes a question to be presented to the user. The generator should be sent the user’s free-form text response as a string.Prompt
This tuple indicates the user should be shown a message which they should read and acknowledge. No response is expected.Info
This tuple indicates the user should be shown a message to which no response is required.
When the information has been collected successfully,
Success
is raised by the wizard with a data attribute
containing a dictionary with the information gathered by the wizard. If the
wizard fails, a Failure
exception is thrown with a
human-readable message.
-
class
rig.wizard.
MultipleChoice
[source]¶ -
default
¶ Alias for field number 2
-
options
¶ Alias for field number 1
-
question
¶ Alias for field number 0
-
-
exception
rig.wizard.
Failure
[source]¶ Indicates that the wizard couldn’t determine the information requested. The message indicates the reason.
-
exception
rig.wizard.
Success
(data)[source]¶ The wizard successfully gathered the information requested.
Attributes: - data : dict
A dictionary containing the information requested.
-
rig.wizard.
dimensions_wizard
()[source]¶ A wizard which attempts to determine the dimensions of a SpiNNaker system.
Warning
Since SC&MP v2.0.0 it is not necessary to know the dimensions of a SpiNNaker machine in order to boot it. As a result, most applications will no longer require this wizard step.
Returns
{"dimensions": (x, y)}
via theSuccess
exception.
-
rig.wizard.
ip_address_wizard
()[source]¶ A wizard which attempts to determine the IP of a SpiNNaker system.
Returns
{"ip_address": "..."}
via theSuccess
exception.
-
rig.wizard.
cat
(*wizards)[source]¶ A higher-order wizard which is the concatenation of a number of other wizards.
The resulting data is the union of all wizard outputs.
-
rig.wizard.
cli_wrapper
(generator)[source]¶ Given a wizard, implements an interactive command-line human-friendly interface for it.
Parameters: - generator
A generator such as one created by calling
rig.wizard.wizard_generator()
.
Returns: - dict or None
Returns a dictionary containing the results of the wizard or None if the wizard failed.