ubii.node package¶
The ubii.node package imports the classes from the ubii.framework.client module typically
needed to implement a client node. The ubii.node.protocol submodule implements concrete
AbstractClientProtocols, e.g. the
DefaultProtocol used by the connect
callable implemented in the ubii.node.connect submodule (imported as
connect_client)
Note
You can start a async python REPL by using python -m asyncio to use Await expression directly
instead of writing everything in a main() function and using asyncio.run() (whenever you
see python interpreter syntax that simply uses await assume it’s running in an async REPL)
Example
Make sure the master node is running, note the URL for the service endpoint for json data e.g.
http://*:8102/services/json(the output of the running master node should show the URL)Either set the appropriate environment variable (see
UBII_URL_ENV) to the url of your service endpoint, or pass it toconnect_cliente.g.>>> from ubii.node import * >>> client = await connect_client('http://localhost:8102/services/json') >>> print(client.protocol.state) <States.CONNECTED: 8>
Make sure the client implements the behaviours that you expect or want to try
>>> ... >>> assert client.implements(Services) >>> print(client[Services].service_map) {'client_deregistration': <ServiceCall object [topic=/services/client/deregistration]>, [...] 'server_config': <ServiceCall object [topic=/services/server_configuration]>, [...] 'topic_subscription': <ServiceCall object [topic=/services/topic_subscription]>} >>> await client[Services].service_map.server_config() server { id: "c2741cca-c75a-41d4-820a-80ac6407d791" name: "master-node" [...] } >>> await client[Services].service_map.client_get_list() client_list { elements { id: "dc3a2252-7501-4b8d-a3dc-cc09be8e98e0" name: "Python-Client-UbiiClient" [...] } } >>> client.id 'dc3a2252-7501-4b8d-a3dc-cc09be8e98e0'
You could also inspect which behaviours the client implements and look into their documentation.
help()should also give hints about usage of the client behaviours>>> client.behaviours [<class 'ubii.framework.client.Services'>, <class 'ubii.framework.client.Subscriptions'>, <class 'ubii.framework.client.Publish'>, ...]
See also
ubii.framework.client – more information how the Ubi Interact python client works
- ubii.node.connect_client¶
alias for
ubii.node.connect.connect
- ubii.node.UbiiClient¶
alias for
ubii.framework.client.UbiiClient
- ubii.node.Services¶
alias for
ubii.framework.client.Services
- ubii.node.Subscriptions¶
alias for
ubii.framework.client.Subscriptions
- ubii.node.Publish¶
alias for
ubii.framework.client.Publish
- ubii.node.Devices¶
alias for
ubii.framework.client.Devices
- ubii.node.Register¶
alias for
ubii.framework.client.Register
- ubii.node.RunProcessingModules¶
- ubii.node.InitProcessingModules¶
- ubii.node.DiscoverProcessingModules¶
- ubii.node.Sessions¶
alias for
ubii.framework.client.Sessions