-
Notifications
You must be signed in to change notification settings - Fork 16k
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
power bi api wrapper integration tests & bug fix #4534
Conversation
Eager to test this fix! |
@eyurtsev bump - I added a commit that should pass linting / make test, it looks like some azure dependencies needed to be included in unit tests. Thanks for the initial workflow run |
pyproject.toml
Outdated
@@ -114,6 +114,8 @@ responses = "^0.22.0" | |||
pytest-asyncio = "^0.20.3" | |||
lark = "^1.1.5" | |||
pytest-mock = "^3.10.0" | |||
azure-core = "^1.26.4" |
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.
azure-core = "^1.26.4" | |
azure-core = "^1.26.4" |
pyproject.toml
Outdated
@@ -114,6 +114,8 @@ responses = "^0.22.0" | |||
pytest-asyncio = "^0.20.3" | |||
lark = "^1.1.5" | |||
pytest-mock = "^3.10.0" | |||
azure-core = "^1.26.4" | |||
azure-identity = "^1.12.0" |
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.
azure-identity = "^1.12.0" | |
azure-identity = "^1.12.0" |
langchain/utilities/powerbi.py
Outdated
|
||
import aiohttp | ||
import requests | ||
from aiohttp import ServerTimeoutError | ||
from azure.core.credentials import TokenCredential |
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 change makes it such that the code breaks on import for all users that don't have azure
installed (and azure
will not be installed for most users as it is an optional dependency).
I outlined changes to the poetry file below that will help specify the optionality of the dependency correctly
@aditya-pethe I outlined some changes to the poetry file. The goal is to treat all these dependencies as optional, so the module code should not assume that the dependency is installed. Could you add a unit-test that attempts to import the module. We'll want to make sure that the unit-test passes with the default main group. I'm working on improving how we handle tests, since the workflow right now is pretty confusing (it's possible to get tests to pass, but have the package break on installs for users) |
@eyurtsev thanks for the feedback! I have a few questions, but to my understanding I should:
Earlier, azure.core.credentials was under TYPE_CHECKING, which caused our original bug. I think the best way to handle this could be modeled after the existing duck duck go tool. In
I think I'll use this same logic for powerbi if that looks good. I'll essentially restore the pyproject.toml file to normal and add some try-catch logic to the import, along with an import unit test. |
You can place the test under
This style works as long as it doesn't raise the ValueError in the global namespace. The file should be ideally safe to import even if the underlying dependency isn't installed. |
Thanks @eyurtsev
I tested this with make lint / make test with no az packages installed, so this should pass CI. I also checked the behavior of tests with az packages installed - i.e it correctly skips if they are not installed, and passes if they are. |
If all looks fine @eyurtsev we can merge and I can close the PR - not sure if we need another maintainer for that. Thanks! |
Hi @aditya-pethe it looks great. We still need to make one change to the unit test so the test verifies that the code can be imported with azure dependency missing. Feel free to make the change yourself, or else one of the maintainers will make it over the next few days. |
was merged #4983 |
Powerbi API wrapper bug fix + integration tests
TYPE_CHECKING
in in utilities/powerbi.pyNotes:
Chat models (gpt3.5, gpt4) are much more capable than davinci at writing DAX queries, so that is important to getting the agent to work properly. Interestingly, gpt3.5-turbo needed the examples=DEFAULT_FEWSHOT_EXAMPLES to write consistent DAX queries, so gpt4 seems necessary as the smart llm.
Fixes #4325
Before submitting
Azure-core and Azure-identity are necessary dependencies
check integration tests with the following:
pytest tests/integration_tests/utilities/test_powerbi_api.py
pytest tests/integration_tests/agent/test_powerbi_agent.py
You will need a power bi account with a dataset id + table name in order to test. See .env.examples for details.
Who can review?
@hwchase17
@vowelparrot