From e69854695908a54a55d89cff5b07d3132cdf98eb Mon Sep 17 00:00:00 2001 From: Gosuto Inzasheru Date: Wed, 17 Jul 2024 13:42:50 +0200 Subject: [PATCH 1/2] feat: query upkeeps from dune --- .github/workflows/upkeeps.yaml | 33 +++++++++++++++++++++++++++++++++ tools/python/query_upkeeps.py | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/upkeeps.yaml create mode 100644 tools/python/query_upkeeps.py diff --git a/.github/workflows/upkeeps.yaml b/.github/workflows/upkeeps.yaml new file mode 100644 index 000000000..f4e6984da --- /dev/null +++ b/.github/workflows/upkeeps.yaml @@ -0,0 +1,33 @@ +name: Query all Chainlink upkeeps + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + query_upkeeps: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: 3.10 + cache: "pip" + + - name: Query Dune + env: + DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }} + run: | + pwd + RUN_DIR=tools/python + pip install -r $RUN_DIR/requirements.txt + python $RUN_DIR/query_upkeeps.py + - name: Commit and push reports + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "ci: dump csv file with all queried upkeeps" diff --git a/tools/python/query_upkeeps.py b/tools/python/query_upkeeps.py new file mode 100644 index 000000000..67fe0a5bc --- /dev/null +++ b/tools/python/query_upkeeps.py @@ -0,0 +1,22 @@ +import pandas as pd +from dune_client.client import DuneClient +from dune_client.types import QueryParameter +from dune_client.query import QueryBase + + +def get_upkeeps(chain='ethereum'): + dune = DuneClient.from_env() + query = QueryBase( + name="@gosuto/cla_chain_upkeeps", + query_id=3889683, + params=[ + QueryParameter.enum_type(name="chain", value=chain), + ], + ) + return dune.run_query_dataframe(query) + +if __name__ == "__main__": + dfs = [] + for chain in ['ethereum', 'arbitrum', 'polygon', 'optimism', 'avalanche', 'base', 'gnosis']: + dfs.append(get_upkeeps(chain)) + pd.concat(dfs).to_csv('../../out/upkeeps.csv', index=False) From e1d5527ed1900618e7a1ed00cb98e95b23ea12bf Mon Sep 17 00:00:00 2001 From: gosuto-inzasheru Date: Wed, 17 Jul 2024 11:43:30 +0000 Subject: [PATCH 2/2] style: ci lint with `black` --- tools/python/query_upkeeps.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/python/query_upkeeps.py b/tools/python/query_upkeeps.py index 67fe0a5bc..8f4d33e73 100644 --- a/tools/python/query_upkeeps.py +++ b/tools/python/query_upkeeps.py @@ -4,19 +4,28 @@ from dune_client.query import QueryBase -def get_upkeeps(chain='ethereum'): +def get_upkeeps(chain="ethereum"): dune = DuneClient.from_env() query = QueryBase( name="@gosuto/cla_chain_upkeeps", query_id=3889683, params=[ - QueryParameter.enum_type(name="chain", value=chain), + QueryParameter.enum_type(name="chain", value=chain), ], ) return dune.run_query_dataframe(query) + if __name__ == "__main__": dfs = [] - for chain in ['ethereum', 'arbitrum', 'polygon', 'optimism', 'avalanche', 'base', 'gnosis']: + for chain in [ + "ethereum", + "arbitrum", + "polygon", + "optimism", + "avalanche", + "base", + "gnosis", + ]: dfs.append(get_upkeeps(chain)) - pd.concat(dfs).to_csv('../../out/upkeeps.csv', index=False) + pd.concat(dfs).to_csv("../../out/upkeeps.csv", index=False)