4) Deploy code to the network
You can deploy code to a Mariachi device using either the CLI or the Console.
When coding for a Mariachi device, remember two key points:
- Always start by importing the Mariachi modules and calling the _Mariachi() method before calling your main() block.
- Ensure your code is asynchronous by utilizing the asyncio library. This allows the Mariachi infrastructure to operate concurrently with your code.
See a sample of code below:
from _mariachi.loader import _Mariachi
# Your_code_here
async def main():
while True:
print("Doing async things")
await asyncio.sleep(2)
if __name__ == "__main__":
# Call Mariachi before your main method
_Mariachi()
main()
The CLI The Console