-
Notifications
You must be signed in to change notification settings - Fork 25
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
Async client #31
Async client #31
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is coming along very well! Nice work here and nice code style. Your improvement suggestions are fantastic. Given that it is passing all the tests, I would say its ready for merge. Are there any e2e tests you think we might be missing?
Also, please take a look at the CLA thing
It looks like the e2e tests fail because your PR is not allow to make use of project secrets. I will run this locally and check it out. |
Ran the e2e tests quickly and they are all failing with:
Also this
|
It would also be nice to see a usage test: Like
and also some test that demonstrates the maximum number of parallel execution limitations. |
a67222e
to
3e47231
Compare
I have read the CLA Document and I hereby sign the CLA |
Fixed the issue with the tests failing -- forgot that ClientResponse().json() outputs the coroutine itself. I still have issues testing this locally as I don't have the Dune API key (and this key can't be easily acquired). Didn't add any new functionality so far. I think it's better to leave it for future updates (as this PR already is kinda big). |
as for this issue. I think the more convenient way would be for the consumer to do something like |
dune_client/base_client.py
Outdated
def query_to_params(self, query: Query) -> Dict[str, dict]: | ||
"""Transforms Query objects to params to pass in API""" | ||
return { | ||
"query_parameters": { | ||
p.key: p.to_dict()["value"] for p in query.parameters() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method belongs on the query object (note that it does not make use of self) and has a single "query" attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's true! Thanks for noticing. I guess we can move it to be a static method of Query dataclass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not a static method of the query class (it takes a query as input -- i.e. self)
query.request_format()
or
query.as_request()
Not sure the best name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like "request format"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved this and added unit-test for the functionality
Here is the failing assertion error details: assert (
self._base_url.origin() == self._base_url
), "Only absolute URLs without path part are supported" and the values are:
I have also fixed all the lint, format and type errors on my side. Not sure if I can push them here (or if you even want me to) |
Thanks a lot for helping! Fixing the mistakes. Sorry that you have to manually run the pipeline, I just can not test this locally, so such mistakes occur... I would push code formatting together with tests fixes |
I think I could separate the pipeline a bit (partition lint format type instead of having them run sequentially so you can at least see all of the issues from a single push). Note that you should be able to run all but e2e checks on from your own side (i.e. without an API_KEY) |
Hows this going @eliseygusev - Have you seen the PR with Fixes to make this pass CI? Would love to get this merged! |
Yeah, I’ve seen the PR. Would update the code either today in the evening
or tomorrow. Thanks for your support!
…On Mon, 7 Nov 2022 at 15:18, Benjamin Smith ***@***.***> wrote:
Hows this going @eliseygusev <https://github.com/eliseygusev> - Have you
seen the PR with Fixes to make this pass CI?
eliseygusev#1 <eliseygusev#1>
Would love to get this merged!
—
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBEHL6IQGHRB6YDZVRDXQLWHEFRXANCNFSM6AAAAAARV6GMTA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fix Async Errors
Ok, so merged your request. Thanks a lot for it! But i'm kind of lost about whether there is something left to fix before merging? |
Fixed the linters but not sure whats happening with the tests. Is it permissions' things or something is failing in the code? |
I think its all good. We can merge and publish a beta release from there. I won't have time to test it out this week though, but at least it will be available. |
It is a permission thing, your branch does not have access to our secrets. |
but you can also run these lint checks on your own side before pushing:
|
black ./ && pylint dune_client && mypy dune_client --strict yeah, sorry, my bad. always forget about it. can I add Makefile with commands for linters and tests so that one can just |
That's great, but in a separate PR. |
Ok, will add it soon. Is there anything else in this PR left to do on my side? Or you will just merge and publish by yourself? |
Fix the failing lint! I will do the rest. |
I wasn't sure why mypy failed in CI. I didnt touch interface.py and locally mypy --strict works. However, I think I did fix it with the addition of |
Has been published under https://pypi.org/project/dune-client/0.2.0b0/ Thanks very much for your contribution! |
I am trying to use this async client and keep running into these errors
I have tried putting a close session after the refresh call, like so response = await self.dune.refresh(query, ping_frequency=10)
await self.dune.close_session() but still get them. Would love if you could show me how to use this from an external package and maybe make it somehow more convenient for external users. I have written some elementary "async" wrapper code on the regular DuneClient like: async def fetch(self, query: Query) -> list[DuneRecord]:
response = await asyncio.to_thread(
self.dune.refresh, query, ping_frequency=10
) (which could probably be pushed deeper into the _post and _get methods), but it works just fine without all this "close_session" stuff. Is there something wrong with this simplified approach? |
No description provided.