Skip to content

Conversation

@josojo
Copy link
Contributor

@josojo josojo commented Apr 25, 2022

Unfortunately, this integration comes with a bigger refactor.

The package offers the ability to wait until a query calculation is finished. This is really nice and allows us to cut the amount of python script by a factor of 2: Previously, we had one script for executing the queries and a second one for fetching the results. Now, with the waiting feature, we can do it all in one go.

The duneapi package also allowed me to store the fetched dune data in a cleaner structure, as the parsing of the fetched result is better. Due to that I also needed to touch the rust code.

There is still a lot to be refactored to make the repo clean, but this should be okay as a first go.

testplan:

cd dune_api_scripts
python3 -m venv env
source ./env/bin/activate
pip install -r requirements.txt
source .env
export DUNE_DATA_FOLDER=./data/dune_data/
export APP_DATA_REFERRAL_RELATION_FILE=./data/referral_data/app_data_referral_relationship.json
python -m dune_api_scripts.store_query_result_all_distinct_app_data

Now, the referral data needs to be downloaded from ipfs. This takes quite long, if this should be done for all appdata. Hence, I would recommend deleting all entries, but 1, from the newly created distinct_app_data.json file in the data folder.
Once it is done, one can run

cargo run

And wait until app_data_referral_relationship.json is written.

Now, one can run:

python -m dune_api_scripts.store_query_result_for_todays_trading_data
cargo run

and check that trading volume was downloaded and is served by checking:

http://127.0.0.1:8080/api/v1/profile/0x019d6ad53704fc851f1cc9effc12e89de4a1fc2c

@josojo josojo requested a review from bh2smith April 25, 2022 11:49
Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good overall.

I see that many of the python scripts have a common block of duplicated setup. Not necessary for this PR, but a lot of this could be moved into a general_init.py to avoid having to do Dune.new_from_environment followed by dune.fetch and then setting data_set so many times.

Another thing is that is don't see the need for having unique query IDs everywhere. You can always keep the original queries at those existing IDs, but it seems like everything here could be done from a single query ID since the results are merely being fetched.

@bh2smith
Copy link
Contributor

One thing I noticed that we could probably move towards with these kinds of python projects is writing a single bash script containing all of this stuff

python3 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
cp .env_sample .env

@bh2smith
Copy link
Contributor

PS - the reason CI is failing is because duneapi requires python@3.10

josojo and others added 4 commits April 25, 2022 15:21
@josojo josojo merged commit 5c9ebfe into main Apr 25, 2022
@josojo josojo deleted the duneapiIntegratoin branch April 25, 2022 15:03
@bh2smith bh2smith mentioned this pull request May 29, 2022
Comment on lines -20 to +24
dune.initiate_new_query(query_id, query=QUERY)

# run query in dune
dune.execute_query(query_id)
dune_query = DuneQuery("", "", QUERY, Network.MAINNET, [], query_id)
# fetch data
dune.execute_query(dune_query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change removed the dune.initiate_query and only left execute which means we were refreshing a static query without updating the values. Fix is made in #8

@josojo josojo mentioned this pull request May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants