Skip to content

Commit

Permalink
docs: update generate readme worker coverage table script (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Oct 15, 2024
1 parent 401ecbb commit 60689f8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 121 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/build-readme.yaml

This file was deleted.

67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,50 @@
# RSS3 Node
The RSS3 Node, an RSS3 Data Sublayer (DSL) component, is responsible for indexing, transforming, storing, and ultimately serving the Open Information to the end users.
## Deployment
See <https://docs.rss3.io/guide/for-node-operator/deployment-guide> for a detailed deployment guide.
See <https://docs.rss3.io/guide/operator> for a detailed deployment guide.
## Supported Networks and Workers
<!-- network-worker table starts -->
| Network/Worker | arbitrum | arweave | avax | base | binance-smart-chain | crossbell | ethereum | farcaster | gnosis | linea | optimism | polygon | vsl |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| **core** [^1] || | ||| ||||||||
| 1inch | | | | | | || | | | | | |
| aave || ||| | || | | ||| |
| aavegotchi | | | | | | | | | | | || |
| crossbell | | | | | || | | | | | | |
| curve || || | | || || ||| |
| ens | | | | | | || | | | | | |
| highlight || | | | | || | | ||| |
| iqwiki | | | | | | | | | | | || |
| kiwistand | | | | | | | | | | || | |
| lens | | | | | | | | | | | || |
| lido | | | | | | || | | | | | |
| looksrare | | | | | | || | | | | | |
| matters | | | | | | | | | | || | |
| mirror | || | | | | | | | | | | |
| momoka | || | | | | | | | | | | |
| opensea | | | | | | || | | | | | |
| optimism | | | | | | || | | | | | |
| paragraph | || | | | | | | | | | | |
| rss3 | | | | | | || | | | | ||
| stargate || |||| || | |||| |
| uniswap | | | | | | || | || | | |
| vsl | | | | | | | | | | | | ||
| Network/Worker | arbitrum | arweave | avax | base | binance-smart-chain | crossbell | ethereum | farcaster | gnosis | linea | mastodon | near | optimism | polygon | rss | vsl | x-layer |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| **core** [^1] || ||||||||| |||| |||
| 1inch | | | | | | || | | | | | | | | | |
| aave || ||| | || | | | | ||| | | |
| aavegotchi | | | | | | | | | | | | | || | | |
| arbitrum || | | | | || | | | | | | | | | |
| base | | | || | || | | | | | | | | | |
| cow | | | | | | || | | | | | | | | | |
| crossbell | | | | | || | | | | | | | | | | |
| curve || || | | || || | | ||| | | |
| ens | | | | | | || | | | | | | | | | |
| highlight || | | | | || | | | | ||| | | |
| iqwiki | | | | | | | | | | | | | || | | |
| kiwistand | | | | | | | | | | | | || | | | |
| lens | | | | | | | | | | | | | || | | |
| lido | | | | | | || | | | | | | | | | |
| linea | | | | | | || | || | | | | | | |
| linear | | | | | | | | | | | || | | | | |
| looksrare | | | | | | || | | | | | | | | | |
| mastodon | | | | | | | | | | || | | | | | |
| matters | | | | | | | | | | | | || | | | |
| mirror | || | | | | | | | | | | | | | | |
| momoka | || | | | | | | | | | | | | | | |
| nearsocial | | | | | | | | | | | || | | | | |
| nouns | | | | | | || | | | | | | | | | |
| opensea | | | | | | || | | | | | | | | | |
| optimism | | | | | | || | | | | || | | | |
| paragraph | || | | | | | | | | | | | | | | |
| paraswap | | | | | | || | | | | | | | | | |
| polymarket | | | | | | | | | | | | | || | | |
| rainbow || |||| || | || | ||| | | |
| rss3 | | | | | | || | | | | | | | | | |
| rsshub | | | | | | | | | | | | | | || | |
| stargate || |||| || | || | ||| | | |
| uniswap | | | | | | || | || | | | | | | |
| vsl | | | | | | || | | | | | | | | | |
| zerion || |||| | | ||| | ||| | ||
<!-- network-worker table ends -->
[^1]: The core worker covers all the data on the network where it operates, except for the data already covered by other workers.
For more information: <https://docs.rss3.io/guide/data-sublayer/worker>
For more information: <https://docs.rss3.io/guide/dsl/worker>
## License
<!-- We use MIT as it's almost unrestricted. -->
[MIT](LICENSE).
70 changes: 41 additions & 29 deletions build_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,65 @@
import re
import os

# API endpoints
GLOBAL_INDEXER_ENDPOINT = os.getenv("GLOBAL_INDEXER_ENDPOINT", "https://gi.rss3.dev")
# API endpoint
NETWORK_CONFIG_ENDPOINT = os.getenv("NETWORK_CONFIG_ENDPOINT", "https://gi.rss3.io/nta")

# Read README.md file
root = pathlib.Path(__file__).parent.resolve()
readme_path = root / "README.md"
with readme_path.open() as f:
readme_content = f.read()

# Get network list
networks_response = requests.get(f"{GLOBAL_INDEXER_ENDPOINT}/nta/networks")
networks = networks_response.json().get("data", []) if networks_response.status_code == 200 else []
# Get network and worker data
response = requests.get(f"{NETWORK_CONFIG_ENDPOINT}/networks/config")
data = response.json()['data']

# Filter out 'rss' from networks
networks = [network for network in networks if network != "rss"]
# Extract networks and workers
networks = []
workers = set()

# Initialize the table
table = f"| Network/Worker | {' | '.join(networks)} |\n"
table += "|" + "---|" * (len(networks) + 1) + "\n"

# Initialize workers dictionary
workers_dict = {}
for category in ['decentralized', 'federated', 'rss']:
if category == 'rss':
networks.append(data[category]['id'])
workers.add(data[category]['worker_configs']['worker']['value'])
else:
for network in data[category]:
networks.append(network['id'])
for worker_config in network['worker_configs']:
workers.add(worker_config['worker']['value'])

# Iterate through each network and get the supported workers list
for network in networks:
WORKERS_API = f"{GLOBAL_INDEXER_ENDPOINT}/nta/networks/{network}/list_workers"
network_workers_response = requests.get(WORKERS_API)
network_workers = network_workers_response.json().get("data", []) if network_workers_response.status_code == 200 else []
# Sort networks and workers
networks.sort()
workers = sorted(list(workers))

for worker in network_workers:
workers_dict.setdefault(worker, []).append(network)
# Move "core" worker to the top if it exists
if "core" in workers:
workers.remove("core")
workers.insert(0, "core")

# Sort worker names
sorted_workers = sorted(workers_dict.keys())

# Move "core" worker to the top
if "core" in sorted_workers:
sorted_workers.remove("core")
sorted_workers.insert(0, "core")
# Initialize the table
table = f"| Network/Worker | {' | '.join(networks)} |\n"
table += "|" + "---|" * (len(networks) + 1) + "\n"

# Generate table rows
for worker in sorted_workers:
for worker in workers:
# Add superscript to "core" worker
display_name = f"**{worker}** [^1]" if worker == "core" else worker
row = f"| {display_name} |"
for network in networks:
row += " ✓ |" if network in workers_dict[worker] else " |"
# Check if the worker exists for this network
worker_exists = False
for category in ['decentralized', 'federated', 'rss']:
if category == 'rss':
if network == data[category]['id'] and data[category]['worker_configs']['worker']['value'] == worker:
worker_exists = True
break
elif network in [n['id'] for n in data[category]]:
network_data = next(n for n in data[category] if n['id'] == network)
if any(w['worker']['value'] == worker for w in network_data['worker_configs']):
worker_exists = True
break
row += " ✓ |" if worker_exists else " |"
table += row + "\n"

# Replace the placeholder in README.md
Expand Down

0 comments on commit 60689f8

Please sign in to comment.