agicommies / communex

alternative commune cli/sdk
MIT No Attribution
25 stars 16 forks source link

Environment variable to set node URL #34

Closed steinerkelvin closed 4 months ago

steinerkelvin commented 5 months ago

Setting the environment variable COMMUNE_NODE_URLS like this

export COMMUNE_NODE_URLS="wss://testnet-commune-api-node-0.communeai.net"

should make comx connect to one of the specified nodes.

The value is a list, with the purpose of load balancing / failover (which doesn't need to be implemented right now). Probably comma separated, but could be something else if more convenient to implement.

steinerkelvin commented 5 months ago

Implemented in 5d6e933 / c597787.

I chose the name COMX_NODE_URLS for the env var instead. Other env vars will be prefixed with COMX_.

pydantic-settings defaults to loading lists and other composite types as JSON, so to set the variable one would do in sh:

export COMX_NODE_URLS='["wss://testnet-commune-api-node-0.communeai.net"]'

@PsicoThePato what do you think?

I may also have a --testnet flag that provides another default list with testnet nodes.

PsicoThePato commented 5 months ago

@PsicoThePato what do you think? I hate the way the variable is set, but well, such is life. COMX_ prefix is great. Maybe it's worth to support weights on the nodes to allow more control.

steinerkelvin commented 5 months ago

I hate the way the variable is set

wdym?

Maybe it's worth to support weights on the nodes

Nah, unnecessary complexity.

steinerkelvin commented 4 months ago

I may also have a --testnet flag that provides another default list with testnet nodes.

This is implemented.