Skip to content
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

[Bug]: is_ibis_table unsafe for python==3.8 #905

Closed
dangotbanned opened this issue Sep 3, 2024 · 4 comments · Fixed by #906
Closed

[Bug]: is_ibis_table unsafe for python==3.8 #905

dangotbanned opened this issue Sep 3, 2024 · 4 comments · Fixed by #906

Comments

@dangotbanned
Copy link

dangotbanned commented Sep 3, 2024

Describe the bug

Original comment

@MarcoGorelli do you have any ideas on what is causing this error for ibis on python==3.8?

https://github.com/vega/altair/actions/runs/10681007191/job/29608118357?pr=3547

I did a merge update from the GitHub UI, but haven't been able to track down the cause yet.

Update

Seems to be this commit which causes the issue (only for 3.8) 3d246b7

Hot fix

Maybe None might be the wrong choice here, but works in altair to pass tests

def is_ibis_table(df: Any) -> TypeGuard[ibis.Table]:
    """Check whether `df` is a Ibis Table without importing Ibis."""
    return bool((ibis := get_ibis()) is not None and (ibis_table := getattr(ibis, "Table", None)) and isinstance(df, ibis_table))

Steps or code to reproduce the bug

vega/altair#3547 (comment)

Expected results

No error is thrown

Actual results

..\..\..\AppData\Local\hatch\env\virtual\altair\CXM7NV9I\hatch-test.py3.8\lib\site-packages\narwhals\dependencies.py:128: in is_ibis_table
    return bool((ibis := get_ibis()) is not None and isinstance(df, ibis.Table))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  

name = 'Table'

    def __getattr__(name: str) -> BaseBackend:
        """Load backends in a lazy way with `ibis.<backend-name>`.

        This also registers the backend options.

        Examples
        --------
        >>> import ibis
        >>> con = ibis.sqlite.connect(...)

        When accessing the `sqlite` attribute of the `ibis` module, this function
        is called, and a backend with the `sqlite` name is tried to load from
        the `ibis.backends` entrypoints. If successful, the `ibis.sqlite`
        attribute is "cached", so this function is only called the first time.
        """
        entry_points = {ep for ep in util.backend_entry_points() if ep.name == name}

        if not entry_points:
            msg = f"module 'ibis' has no attribute '{name}'. "
            if name in _KNOWN_BACKENDS:
                msg += f"""If you are trying to access the '{name}' backend,
                        try installing it first with `pip install ibis-{name}`"""
>           raise AttributeError(msg)
E           AttributeError: module 'ibis' has no attribute 'Table'.

..\..\..\AppData\Local\hatch\env\virtual\altair\CXM7NV9I\hatch-test.py3.8\lib\site-packages\ibis\__init__.py:58: AttributeError

Please run narwhals.show_version() and enter the output below.

https://github.com/narwhals-dev/narwhals/commit/3d246b7dc642cc362626a757abd032fd6f2c2b06

Relevant log output

No response

@MarcoGorelli
Copy link
Member

thanks @dangotbanned for the fast report! I'll check what it was on 3.8 and update

@dangotbanned
Copy link
Author

dangotbanned commented Sep 3, 2024

Apologies on the formatting of #905 (comment)

I thought I'd end up providing too many distractions, since it wasn't caused by a new ibis version

@MarcoGorelli
Copy link
Member

thanks a tonne for reporting! we'll make a new release in the next few minutes and this should get your ci green again

@dangotbanned
Copy link
Author

thanks a tonne for reporting! we'll make a new release in the next few minutes and this should get your ci green again

No problem, thanks for getting to this so quickly

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 a pull request may close this issue.

3 participants
@MarcoGorelli @dangotbanned and others