Skip to content

Treat pyhive as a synchronous package and add a regression test - #151

Open
hedgert wants to merge 1 commit into
Pyhass:devfrom
hedgert:investigate-pyhive-sync
Open

Treat pyhive as a synchronous package and add a regression test#151
hedgert wants to merge 1 commit into
Pyhass:devfrom
hedgert:investigate-pyhive-sync

Conversation

@hedgert

@hedgert hedgert commented Jul 22, 2026

Copy link
Copy Markdown

import pyhive currently exposes the asynchronous API because src/init.py only checks for name == "pyhiveapi".

This change treats both pyhive and pyhiveapi as synchronous packages so that import pyhive exposes the synchronous HiveAuth and HiveApi classes.

Testing
Added a regression test verifying that pyhive exposes the synchronous classes.
Confirmed the new test fails without this change.
Confirmed the test passes with this change.
Ran the existing test suite successfully.

Treat both `pyhive` and `pyhiveapi` as synchronous packages.

Previously `import pyhive` exposed the asynchronous API because
`src/__init__.py` only checked for `__name__ == "pyhiveapi"`.

Add a regression test to verify that `pyhive` exposes the synchronous
`HiveAuth` and `HiveApi` classes. The test fails without this change and
passes with it.
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (8d97dca) to head (c48798b).
⚠️ Report is 2 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #151   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          30       30           
  Lines        2508     2508           
  Branches      292      292           
=======================================
  Hits         2507     2507           
  Partials        1        1           
Flag Coverage Δ
unittests 99.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/__init__.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KJonline

KJonline commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@hedgert do you use the sync version of this library just out of curiosity? Ive contemplated removing the sync version and just having it purely as an async package.

@hedgert

hedgert commented Aug 7, 2026

Copy link
Copy Markdown
Author

Yes I do - please don't remove it! I've spent weeks identifying a couple of bug fixes in sync and extending unasync (I'm discussing a pull request with them at the moment) so that it can completely convert pyhive's unasync code to sync. And I have it running beautifully. I'm happy to maintain the sync conversion going forward.

@KJonline

KJonline commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

No worries we can keep it in. When you say your looking at the unasync code. Do you mean finding a way to go have unasync manage the whole conversion instead of managing 2 versions of Auth and APi code?

@hedgert

hedgert commented Aug 8, 2026

Copy link
Copy Markdown
Author

Not so far - no. It hasn't occurred to me to do that. My focus has been coming up with a way of making the sync code work out of the box - as the current code doesn't work with what unasync does. The challenge is that unasync offers the capability to translate single tokens (change AAA into BBB) and some of the pyhive code needs conversion logic that detects XXX.YYY to decide what to convert async code into. And I've extended unasync so that it does that. And my version now fully translates your existing async code so it works out of the box as sync.
To be more specific the async code includes for example:
_update_task: asyncio.Task | None (polling.py)
And you can't convert that by only dealing with Task - you have to recognise asyncio.Task as a pair of tokens and have a treatment for the pair - and that's why my pull request on unasync adds - aim being very little intervention in Pyhive - just a more capable unasync module that it's already dependent on.
Next time I'm in the code I'll have a look at what you've mentioned - it sounds like a project - as I say I've not looked at it yet.

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.

2 participants