Skip to content

fix: run compliance tests with nox #26

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

Closed
wants to merge 1 commit into from

Conversation

HemangChothani
Copy link
Contributor

Fixes #25

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 16, 2021
@@ -41,7 +41,7 @@
description=description,
entry_points={
"sqlalchemy.dialects": [
"spanner = google.cloud.sqlalchemy_spanner:SpannerDialect"
"spanner.spanner = google.cloud.sqlalchemy_spanner:SpannerDialect"
Copy link
Contributor

Choose a reason for hiding this comment

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

It'll break the package. This identifier is used to register dialect in Python modules system. With this change we'll have to connect like:

engine = create_engine(
    "spanner.spanner:///projects/project-id/instances/instance-id/databases/database-id"
)

And I don't think it'll work at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's working fine as you can see in SQLAlchemy spanner dialect test.

The url is spanner+spanner:///projects/appdev-soda-spanner-staging/instances/sqlalchemy-dialect-test/databases/compliance-test, which is perfectly working now.

spanner.spanner is used only to fetch the Dialect class. New version of sqlalchemy used by default spanner+spanner and replace + to . to fetch the entry-point or dialect class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other way to overcome the failure is to override the method which added or forcefully converted spanner to spanner+spanner.

The method is generate_driver_url and path is sqlalchemy/testing/provision.py

Copy link
Contributor

@IlyaFaer IlyaFaer Mar 16, 2021

Choose a reason for hiding this comment

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

I've checked the tests locally, there is no failure at all. These changes are not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now compliance tests are failing in you latest opened PR
https://github.com/cloudspannerecosystem/python-spanner-sqlalchemy/pull/27/checks?check_run_id=2119935389

Cloud you help me to solve that issue?

Copy link
Contributor

@larkee larkee Mar 16, 2021

Choose a reason for hiding this comment

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

Currently I am getting the same error as @HemangChothani which is also showing up on the Github Action. I'm not sure why it didn't show up before given that it does seem to be a issue with noxfile.py.

Pinning to an older version of sqlalchemy does not fix the issue on my end.

@IlyaFaer How are you running the compliance tests locally? Are you using the nox command? If not, please post the commands that you are running here so we can update the noxfile to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@larkee In setup.py file I replace dependencies = ["sqlalchemy>=1.1.13"] to dependencies = ["sqlalchemy>=1.1.13, <=1.3.23"] and it works for me.

The reason of failing the command is they have implemented new method generate_driver_url() and path is sqlalchemy/testing/provision.py to generate the url for engine. In that method they replace spanner to spanner+spanner and going to find entry point of the library, in older version there was a spanner as a drive-name so they found perfectly, but in the new version they replace + with . and going to find entry point with spanner.spanner but we have spanner in setup file so it returns None that's why it's failing.

Copy link
Contributor

Choose a reason for hiding this comment

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

@larkee, I'm executing tests locally just as usual, the only difference - I don't install packages on every nox session run, I'm using the local ones:

Безымянный

But if I'll uncomment these installing lines in nox session function, everything will still work.

As a simple select-script (executed without nox) is working fine with any version of SQLAlchemy, we can say registering the dialect should not to be changed (that would be strange, if SQLAlchemy team would change dialect registering mechanism in 1.4 version - it would break all the dialects). But nox session is failing, because registering mechanism is not able to find the Spanner dialect class. That makes me think the problem is in installing spanner-sqlalchemy package by nox.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@IlyaFaer I have tried with manually installed spanner-sqlalchemy and SQLAlchemy and run pytest command manually (WIthout nox) and still sqlalchemy raising the same error. I think they have changed few things in testing procedure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm that updating setup.py with:

dependencies = ["sqlalchemy>=1.1.13, <=1.3.23", "google-cloud-spanner>=3.0.0"]

fixes the issue. The update to entry point is unneeded.

Two additional notes:

  1. The compliance_test session does not need to explicitly install sqlalchemy or google-cloud-spanner because they are automatically install by session.install("-e", ".") which installs spanner-sqlalchemy using setup.py
  2. create_test_database uses the project set by either GOOGLE_CLOUD_PROJECT or PROJECT_ID or defaults to emulator-test-project but the connection string defined in setup.cfg using the prod project.

@HemangChothani HemangChothani requested a review from larkee March 16, 2021 09:23
Copy link
Contributor

@larkee larkee left a comment

Choose a reason for hiding this comment

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

The issues definitely seems to be sqlalchemy v1.4.0 since it was released yesterday and that's when this issue started appearing so I'm happy for the version to be pinned to sqlalchemy>=1.1.13, <=1.3.23 with no other changes needed 👍

@HemangChothani
Copy link
Contributor Author

Closing this PR in favor of #31

@IlyaFaer IlyaFaer deleted the fix_nox_compliance_tests branch March 17, 2021 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compliance tests are failing
3 participants