Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devrel rework - add example notebook #99

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _version.py
venv/
tmp/
.vscode/
examples/.env.txt
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ Use `get_latest_results` to get the most recent query results without using exec
You can specify a `max_age_hours` to re-run the query if the data is too outdated.

```python
import pandas as pd
from dune_client.client import DuneClient

dune = DuneClient.from_env()
results = dune.get_latest_result(1215383, max_age_hours=8)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
results = dune.get_latest_result(1215383, max_age_hours=8)
query_results = dune.get_latest_result_dataframe(1215383)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This suggested change breaks the context of the readme. Specifically demonstrating the use of max age.

Copy link
Member

@TheEdgeOfRage TheEdgeOfRage Oct 12, 2023

Choose a reason for hiding this comment

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

Yeah, the csv endpoint can't support max age, since it doesn't return any metadata about the execution :/ One would need to call the status endpoint first to check the age and then the get csv endpoint. I think it would still be more efficient though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's fine, but then the readme should probably be changed to remove the max age example.

query_result = pd.DataFrame(query_result.result.rows)
Comment on lines 64 to +65
Copy link
Member

Choose a reason for hiding this comment

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

@andrewhong5297 I've implemented a helper function in this PR that uses the latest result API and returns a dataframe directly. It should be more efficient than using get_latest_result(), since that one has to parse the results in json format, while the new one uses the CSV endpoint which is a lot more efficient when parsing into a dataframe and is a streaming endpoint on top of that

```

## Paid Subscription Features
Expand Down
Copy link
Member

Choose a reason for hiding this comment

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

Tiny nit: Can you please use lowercase filenames without spaces (probably best to use underscores)? I hate having to deal with spaces on the command line 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dune Python API Examples

Here you can find some examples of working with the Dune API.