Introducing Grid3.py and open sourcing Node Status Bot

Hi everyone,

I’m pleased to announce the source code releases of two projects I’ve been working on for a while. I hope some of you can find them interesting or useful :slight_smile:

Grid3.py

The first is called Grid3.py, and it’s a set of modules in the Python programming language for interacting with ThreeFold Grid v3. These grew out of some code I was writing for the Node Status Bot and various scripts I’ve made for doing things like pulling Grid Stats.

The goal so far is to provide a nice interface for grabbing data from the Grid Proxy and TF Chain GraphQL, along with sending and receiving messages with Reliable Message Bus. In the future, I’d also like to add some capabilities for interacting with TF Chain directly and also creating deployments.

Demo

Here’s a quick example of using GraphQL to grab the twin id of node 1 on mainnet:

from grid3.network import GridNetwork
mainnet = GridNetwork()
node = mainnet.graphql.nodes(['nodeID', 'twinID'], nodeID_eq=1)[0]

Then we can use the twin id to send a ping to the node over RMB:

from grid3.rmb import RmbPeer, RmbClient
peer = RmbPeer("mnemonic seed phrase here ...")
client = RmbClient()
client.send("zos.statistics.get", node['twinID'])
print(client.receive())

{'ver': 1, 'ref': None, 'dat': '{"total":{"cru":56,"sru":2000409772032,"hru":144001663500288,"mru":202711719936,"ipv4u":0},"used":{"cru":25,"sru":785953849344,"hru":0,"mru":72884521369,"ipv4u":13},"system":{"cru":0,"sru":16106127360,"hru":0,"mru":20271171993,"ipv4u":0},"users":{"deployments":158,"workloads":178}}', 'src': '7', 'shm': '', 'now': 1698904809, 'err': None}

This shows a bit of the design philosophy for Grid3.py, which is to require minimal input from the user to accomplish common and simple use cases. Overall, the library is aimed at interactive use on the command line and writing scripts, rather than creating large applications. Take it for a spin and have some fun!

Node Status Bot

If you’re a ThreeFold farmer, you have probably at least heard that you can monitor the status of your nodes using the Node Status Bot on Telegram. Thanks to all of you who have tried the bot so far, reported issues, and gave suggestions for improvement!

I’ve kept the source code for the bot under wraps for a while, because, well, it was a bit rough around the edges. While that’s definitely still true, it has matured considerably and I felt it was time to share.

This means that you can run your own copy of the bot, if you feel so inclined.

Questions, issues and PRs welcome

I’ll close by saying that any questions about these projects or how to use them are totally welcome. If you found a bug or have an idea to make them better, please feel free to open an issue on the repos. Finally, if you want to contribute some code, pull requests are certainly welcome.

Cheers and happy hacking,
Scott

3 Likes

Did some testing of both, it is great. Very useful!