-
Notifications
You must be signed in to change notification settings - Fork 419
GQL Integration Rework #759
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
base: master
Are you sure you want to change the base?
Conversation
Adds additional checks to get_stream_info to avoid NoneType errors.
Adds GQL types to make the properties we expect to exist explicit. Adds parser for GQL responses into said types. Added error handling for generic GQL errors and parsing errors.
abd3a5d to
9b2393a
Compare
|
@Armi1014 If possible, I would please like your feedback on my 2nd commit on this branch. I've attempted to make a proper response parser and retry system for the GQL layer. Nothing's hooked up yet but the parsing and request handling should all be in place in the new @rdavydov I also wouldn't mind you having a look but I know you're busy 😄 |
Thanks for pinging me, I had a look at your second commit. Overall the new GQL layer looks really nice, feels like a good step towards a properly typed API instead of random JSON poking 👍 A few things I noticed while reading:
Overall I really like the structure (ClientSession + GQL + typed response models), just a few rough edges that should be easy to clean up before wiring it into the rest of the miner. |
|
Thanks for the quick feedback! I'll look into those rough edges soon.
This was actually added in 3.12 and I think that's the version we're targeting moving forward, although I can't remember if that's on this branch or on a different one (might be the Hermes API branch). I'll make it explicit in this branch.
Yeah, I considered letting them fall through but I wanted the automatic retries. I was being a bit greedy, I think what'll be best is having a specific Exception type for recoverable errors at the parsing stage (i.e. |
Thanks for the quick reply and clarifications! If we are officially targeting 3.12+ then I am totally fine with the PEP 695 syntax. Making that explicit in this branch (README / pyproject / CI / Docker image) sounds good so people on 3.10/3.11 aren’t surprised when it doesn’t even parse. On the error handling side, a dedicated “recoverable” GQL exception sounds like a good split to me. My main concern was just that hard failures (auth issues, invalid operations, schema changes, etc.) don’t silently turn into Happy to test this once you’ve wired it into the rest of the miner! |
Abstracts retry logic. Fixes a couple of bugs with ClientSession, channel_follows, get_drop_campaign_details, and gql module imports.
|
Heyyyy bro |
Sorry, I've had less time to work on this than I thought. I've pushed up a commit that hopefully handles the last feedback I got. Just gotta wire it all through and run some tests. I've got some time tomorrow to get it done 🤞 |
|
Just to update, I've got the implementation finished and wired into the miner, just running a live test to see if everything is working as expected. I'll push up my changes once I'm satisfied it's all working. |
Applied black formatting to gql module files.
Replaced Twitch client_version/login/user_agent/device_id/session_id with a shared ClientSession containing those values and updated usages. Removed Twitch.get_broadcast_id as no longer used. Made the number of seconds we attempt to watch a stream a variable, CLIENT_WATCH_SECONDS. Added more error logging. Added subs_required to Drop, to later allow us to filter unobtainable drops. Added some missing Type Hints. Renamed some variables that used the wrong naming convention. Updates minimum python version to 3.12.
|
Alright, the new integration is now wired into the miner. The main difference should be that when we get errors from the GQL API you should get more useful errors and there are also automatic retries for some types of errors. This is a fairly large rework that touches a lot of the miner's functionality so there's almost certainly something I've missed. If possible, I'd like some people to test this version and let me know if you have any issues. |
|
I was just updating my code according to this pr but I don't have the websocketpool file as my code mainly works according to your Hermes version. So is there any point of me updating to this pr or will the not work without the current updates you did to that file |
Yeah, those would be messy merges for sure. |
|
Oh ngl but I already did all of the changes now 😭 lemme revert everything and make a new branch for it 🤦♂️ |
|
Finally caught a
I've made this a |
…mes. Changed GQL error logging to omit the stack trace for GQLErrors, since it won't be useful. Changed Pagination generics to use newer syntax. Refactored parser expect functions to reuse the same pattern and error description function. Added missing parent context in operationName parsing.
|
I've been trying to catch some errors in the wild so I can see if some changes I've made to the error logging are working as expected. Unfortunately (or fortunately?) I've not seen any errors with the GQL API since I made those changes last week. So I've pushed them up, I'd be grateful anyone could test this branch. In particular, if you get GQL errors you should only get a stack trace if it's something like a connection error, you should not get them for things like persistent query errors, service timeouts, or JSON parsing issues. In those cases you'll get an |
I've been testing this today and I've been able to get a few errors. Nothing major. One instance like this: And a few of these: Other than that, everything seems to be working fine. |
That's interesting, the formatting is exactly what I want so that's great. However, I'm not familiar with |
|
I did a bit more searching on the Something we could do is specifically ignore |
|
Finally got another live error myself, formatting looks good:
Twitch recovered from this by the next attempt 2 minutes later, so it's possible this could be immediately retried. I'll just leave it noted here for now. |
…ne if VideoPlayerStreamInfoOverlayChannel failed.
Description
Full rework of the GQL layer. There is now a specific parser for each response type to ensure that we are working with the correct data structure. There is now error handling with retry logic for all GQL requests, this is an attempt to reduce error logs for the user.
If there is an error parsing the json we will now see an error log telling us exactly where the issue was:
Fixes #739
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Tested today locally, no additional errors encountered.
Checklist: