Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

deps: remove scikit-learn and sqlalchemy as required dependencies #1296

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

Merged
merged 25 commits into from
Feb 21, 2025

Conversation

Genesis929
Copy link
Collaborator

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Jan 16, 2025
@Genesis929 Genesis929 requested a review from GarrettWu January 17, 2025 20:54
@Genesis929 Genesis929 marked this pull request as ready for review January 17, 2025 21:14
@Genesis929 Genesis929 requested review from a team as code owners January 17, 2025 21:14
@Genesis929 Genesis929 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 17, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 17, 2025
@Genesis929 Genesis929 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 17, 2025
@bigframes-bot bigframes-bot removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 17, 2025
Comment on lines 181 to 197
if len(x_pandas) < 2:
raise ValueError(
f"At least 2 points are needed to compute area under curve, but x.shape = {len(x_pandas)}"
)

if x_pandas.is_monotonic_decreasing:
d = -1
elif x_pandas.is_monotonic_increasing:
d = 1
else:
raise ValueError(f"x is neither increasing nor decreasing : {x_pandas}.")

if hasattr(np, "trapezoid"):
# new in numpy 2.0
return d * np.trapezoid(y_pandas, x_pandas)
# np.trapz has been deprecated in 2.0
return d * np.trapz(y_pandas, x_pandas) # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this code is copied from sklearn, we should put it in the third_party/bigframes_vendored directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a simplified version from sklearn logic, because we need it to work for pandas series only. In this case should we put it in third-party?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. If it originally came from somewhere else, we need to show attribution for the copyright. Even if we modified it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to third party

noxfile.py Outdated
Comment on lines 234 to 236
session.install(
"scikit-learn>=1.2.2",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not install optional dependencies in unit_noextras. The intention of such test sessions is to make sure that dependencies that are marked as optional are truly optional. This risks making a forced dependency on this package.

Also, prefer removing the package from other sessions as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated, now test skipped is sklearn not installed.

For docs and docfx session, it's required to have sklearn, so changed the way of installation instead of remove it.

noxfile.py Outdated
Comment on lines 226 to 228
session.install(
"scikit-learn>=1.2.2",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there is optional functionality that needs scikit-learn, please use the "extras" section in setup.py. Don't install packages this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

@tswast tswast changed the title chore: remove unused dependencies. deps: remove scikit-learn as a required dependency Jan 21, 2025
@tswast
Copy link
Collaborator

tswast commented Jan 21, 2025

This is not a chore: . This is a user-visible change and should be labeled as such.

@tswast tswast added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 21, 2025
Copy link
Collaborator

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Please do not merge as is. We are opening our customers up to a big risk of having a broken installation by installing scikit-learn in so many of our test sessions.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Feb 19, 2025
@Genesis929 Genesis929 requested a review from tswast February 19, 2025 23:36
@Genesis929 Genesis929 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 20, 2025
@bigframes-bot bigframes-bot removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 20, 2025
@Genesis929 Genesis929 changed the title deps: remove scikit-learn as a required dependency deps: remove scikit-learn and sqlalchemy as required dependencies Feb 20, 2025
Copy link
Collaborator

@tswast tswast left a comment

Choose a reason for hiding this comment

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

You did not address my feedback. You just changed how you install scikit-learn. You're still installing scikit-learn in way too many of our test sessions.

noxfile.py Outdated
Comment on lines 76 to 80
"3.9": ["scikit-learn"],
"3.10": ["scikit-learn"],
"3.11": ["scikit-learn"],
"3.12": ["polars", "scikit-learn"],
"3.13": ["scikit-learn"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

No.

We can't install it in every session. We need to know that bigframes works without this package!

Suggested change
"3.9": ["scikit-learn"],
"3.10": ["scikit-learn"],
"3.11": ["scikit-learn"],
"3.12": ["polars", "scikit-learn"],
"3.13": ["scikit-learn"],
"3.12": ["polars", "scikit-learn"],

Copy link
Collaborator Author

@Genesis929 Genesis929 Feb 21, 2025

Choose a reason for hiding this comment

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

Updated, but I assume in this case unit noextras sessions runs the same thing for 3.13?

noxfile.py Outdated
@@ -96,7 +102,7 @@
]
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
SYSTEM_TEST_DEPENDENCIES: List[str] = []
SYSTEM_TEST_EXTRAS: List[str] = ["tests"]
SYSTEM_TEST_EXTRAS: List[str] = ["tests", "scikit-learn"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

No.

We can't install it in every session. We need to know that bigframes works without this package! Use SYSTEM_TEST_EXTRAS_BY_PYTHON, instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

@@ -510,7 +515,7 @@ def docs(session):
def docfx(session):
"""Build the docfx yaml files for this library."""

session.install("-e", ".")
session.install("-e", ".[scikit-learn]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm very concerned if we need to install scikit-learn just to build the docs. Please remove.

Suggested change
session.install("-e", ".[scikit-learn]")
session.install("-e", ".")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if it's possible to remove this as we are calling publish_api_coverage.py, and one of the things it do is go through sklearn APIs and generate a coverage report.

@@ -468,8 +474,7 @@ def cover(session):
@nox.session(python=DEFAULT_PYTHON_VERSION)
def docs(session):
"""Build the docs for this library."""

session.install("-e", ".")
session.install("-e", ".[scikit-learn]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm very concerned if we need to install scikit-learn just to build the docs. Please remove.

Suggested change
session.install("-e", ".[scikit-learn]")
session.install("-e", ".")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if it's possible to remove this as we are calling publish_api_coverage.py, and one of the things it do is go through sklearn APIs and generate a coverage report.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point. Thanks for clarifying.

@Genesis929 Genesis929 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 21, 2025
@Genesis929 Genesis929 enabled auto-merge (squash) February 21, 2025 21:26
@Genesis929 Genesis929 merged commit fd8bc89 into main Feb 21, 2025
24 checks passed
@Genesis929 Genesis929 deleted the dep_removal_huanc branch February 21, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.