Skip to content

Commit

Permalink
try pushing update
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhong5297 committed Nov 28, 2023
1 parent 0c1c2ee commit b451036
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/update_from_dune.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python CI

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Log directory structure
run: |
pwd
ls -R
- name: pip requirements
run: pip install -r requirements.txt

- name: Update all queries from Dune
env:
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
run: python -u github_workflows/update_to_dune.py

- name: Print name
run: echo "Hello ${{ secrets.ENV_TEST }}"


Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: pip requirements
run: pip install -r requirements.txt

- name: Run test script
- name: Update all queries from Dune
env:
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
run: python -u github_workflows/action.py
run: python -u github_workflows/update_to_dune.py

- name: Print name
run: echo "Hello ${{ secrets.ENV_TEST }}"
Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions github_workflows/update_to_dune copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import yaml
from dune_client.client import DuneClient
from dotenv import load_dotenv
import sys
import codecs

# Set the default encoding to UTF-8
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())

dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env')
load_dotenv(dotenv_path)

dune = DuneClient.from_env()

# Read the queries.yml file
with open('queries.yml', 'r', encoding='utf-8') as file:
data = yaml.safe_load(file)

# Extract the query_ids from the data
query_ids = [id for id in data['query_ids']]

for id in query_ids:
query = dune.get_query(id)
print('updating query {}, {}'.format(query.base.query_id, query.base.name))

# Check if file exists
file_path = os.path.join(os.path.dirname(__file__), '..', 'queries', f'query_{query.base.query_id}.sql')
if os.path.exists(file_path):
# Read the content of the file
with open(file_path, 'r', encoding='utf-8') as file:
text = file.read()

# Update existing file
dune.update_query(
query_id,
# All parameters below are optional
query_sql=text,
)

else:
print('file not found, {}'.format(query_{query.base.query_id}.sql))
1 change: 1 addition & 0 deletions queries/query_3237721.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- DEX by volume 🏦
-- https://dune.com/queries/3237721

--andrew is testing actions

WITH
seven_day_volume AS (
Expand Down

0 comments on commit b451036

Please sign in to comment.