Skip to content

test(sigcheck): check function signature parity across backends #10008

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 8 commits into from
Sep 13, 2024

Conversation

gforsyth
Copy link
Member

@gforsyth gforsyth commented Sep 3, 2024

Opening this in favor of #9383 -- that PR also included all of the breaking changes to unify function signatures and it was too much at once. This PR adds only the signature checking mechanism, plus the requisite xfails to lay out which inconsistencies are currently in Ibis.

Motivation

We want to ensure that, for a given backend, that the argument names, plus usage of positional, positional-only, keyword, and keyword-only arguments match, so that there is API consistency when moving between backends.

I've grabbed a few small parts of some of the utilities in Scott Sanderson's
python-interface project (https://github.com/ssanderson/python-interface).

While the upstream is no longer maintained, the goal of that project
aligns quite well with some of the issues we face with maintaining
consistent interfaces across backends.

Note that while the upstream project focused on runtime enforcement of these signatures matching, here it is only run in the test suite.

Rough procedure

Any method that doesn't match can be skipped entirely (this is useful for things like do_connect, which cannot reasonably be assumed to match) or individually (by specifying a pytest.param and marking the failing backends).

Then we scrape across the common parent classes and add any methods that are NOT currently specified in the pre-existing xfailed ones. It's a bit of a nuisance, but it's done, and ideally the manual listing of the inconsistent methods goes away as we unify things.

I've opted for not checking that type annotations match, because that seems... unreasonable.

This would satisfy #9125 once all of the xfail markers are removed, e.g., it checks that all keyword and positional arguments are standardized.

This is a fork of some of the utilities in Scott Sanderson's
`python-interface`
project (https://github.com/ssanderson/python-interface).

While the upstream is no longer maintained, the goal of that project
aligns quite well with some of the issues we face with maintaining
consistent interfaces across backends.

I'm grabbing a few of these utilities and ripping out Python 2 support,
then I'm going to work on setting up tests for making sure that backend
methods match the signatures in the parent `BaseBackend` class.
Should be `implementation, interface_def`, not the other way around
@gforsyth gforsyth changed the title feat(sigcheck): first cut of signature checking utilities test(sigcheck): check function signature parity across backends Sep 3, 2024
"to_parquet_dir",
marks=pytest.mark.notyet(["pyspark"]),
),
"truncate_table": pytest.param(
Copy link
Member

Choose a reason for hiding this comment

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

So, basically the goal is to, over time, remove as many elements of this dict as possible?

Copy link
Member Author

@gforsyth gforsyth Sep 5, 2024

Choose a reason for hiding this comment

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

Ideally, we'd remove all of them. There's a more generic "skip for all backends" list for things like do_connect, but I think we should be able to remove all of the entries in this dict if we standardize positional keyword names, and enforce keyword-only arguments

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, once this is merged in, it will also prevent us from adding new methods with differing argument names (assuming those methods are defined in the base classes, which they should be)

@cpcloud cpcloud added the tests Issues or PRs related to tests label Sep 5, 2024
@gforsyth gforsyth merged commit f7e5704 into ibis-project:main Sep 13, 2024
86 checks passed
ncclementi pushed a commit to ncclementi/ibis that referenced this pull request Sep 24, 2024
…-project#10008)

Opening this in favor of ibis-project#9383 -- that PR also included all of the
breaking changes to unify function signatures and it was too much at
once. This PR adds only the signature checking mechanism, plus the
requisite xfails to lay out which inconsistencies are currently in Ibis.

## Motivation

We want to ensure that, for a given backend, that the argument names,
plus usage of positional, positional-only, keyword, and keyword-only
arguments match, so that there is API consistency when moving between
backends.

I've grabbed a few small parts of some of the utilities in Scott
Sanderson's
`python-interface` project
(https://github.com/ssanderson/python-interface).

While the upstream is no longer maintained, the goal of that project
aligns quite well with some of the issues we face with maintaining
consistent interfaces across backends.

Note that while the upstream project focused on _runtime_ enforcement of
these signatures matching, here it is only run in the test suite.

## Rough procedure

Any method that doesn't match can be skipped entirely (this is useful
for things like `do_connect`, which cannot reasonably be assumed to
match) or individually (by specifying a `pytest.param` and marking the
failing backends).

Then we scrape across the common parent classes and add any methods that
are NOT currently specified in the pre-existing xfailed ones. It's a bit
of a nuisance, but it's done, and ideally the manual listing of the
inconsistent methods goes away as we unify things.


I've opted for not checking that type annotations match, because that
seems... unreasonable.

This would satisfy ibis-project#9125 once all of the xfail markers are removed,
e.g., it checks that all keyword and positional arguments are
standardized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants