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: GH42866 DatetimeIndex de-serializing fails in PYTHONOPTIMIZE mode #42871

Merged

Conversation

GorAlexander
Copy link
Contributor

@GorAlexander GorAlexander commented Aug 3, 2021

@MarcoGorelli
Copy link
Member

Thanks @GorAlexander

@jbrockmendel does pandas have any way of testing code run in -O mode?

@jbrockmendel
Copy link
Member

does pandas have any way of testing code run in -O mode?

take a look at test_oo_optimizable

@MarcoGorelli
Copy link
Member

Thanks - @GorAlexander do you want to have a look there and add a test?

@pep8speaks
Copy link

pep8speaks commented Aug 3, 2021

Hello @GorAlexander! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-08-04 21:56:34 UTC

@jreback jreback added Bug Datetime Datetime data dtype labels Aug 4, 2021
@jreback jreback added this to the 1.4 milestone Aug 4, 2021
@jreback
Copy link
Contributor

jreback commented Aug 4, 2021

looks fine, can you add a whatsnew note. 1.4 bug fix, Datetimelike section. ping on green.

@GorAlexander
Copy link
Contributor Author

@github-actions pre-commit

@GorAlexander
Copy link
Contributor Author

Hi @jreback , I have fixed code-styles and added whatsnew note.
Is it possible to apply this fix to version 1.3?

@jreback
Copy link
Contributor

jreback commented Aug 4, 2021

would be ok for 1.3.x if u can move the note

@jreback jreback modified the milestones: 1.4, 1.3.2 Aug 4, 2021
doc/source/whatsnew/v1.4.0.rst Outdated Show resolved Hide resolved
@jreback
Copy link
Contributor

jreback commented Aug 4, 2021

no we merge to master and then backport

just change the note

@GorAlexander
Copy link
Contributor Author

@jreback , thanks! I've moved the note to v1.3.2, so it must be ready.

@GorAlexander
Copy link
Contributor Author

Hi @jreback , the whatsnew note was corrected, however GH still highlights about 'changes requested'. Is there smth else to do to get the PR approved?

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Looks good to me

Tried this out and it fails on master but passes here 👍

(pandas-dev) marcogorelli@OVMG025 pandas-dev % pytest pandas/tests/test_downstream.py -k test_oo_optimized_datetime_index_unpickle -qq
.
------- generated xml file: /Users/marcogorelli/pandas-dev/test-data.xml -------
============================= slowest 30 durations =============================
0.55s call     pandas/tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle

(2 durations < 0.005s hidden.  Use -vv to show these durations.)
(pandas-dev) marcogorelli@OVMG025 pandas-dev % git checkout upstream/master -- pandas/core/indexes/datetimes.py                    
(pandas-dev) marcogorelli@OVMG025 pandas-dev % pytest pandas/tests/test_downstream.py -k test_oo_optimized_datetime_index_unpickle -qq
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/marcogorelli/pandas-dev/pandas/core/indexes/datetimes.py", line 96, in _new_DatetimeIndex
    result = cls._simple_new(dta, **d)
TypeError: _simple_new() got an unexpected keyword argument 'freq'
F
================================================ FAILURES =================================================
________________________________ test_oo_optimized_datetime_index_unpickle ________________________________

    def test_oo_optimized_datetime_index_unpickle():
        # GH 42866
>       subprocess.check_call(
            [
                sys.executable,
                "-OO",
                "-c",
                (
                    "import pandas as pd, pickle; "
                    "pickle.loads(pickle.dumps(pd.date_range('2021-01-01', periods=1)))"
                ),
            ]
        )

pandas/tests/test_downstream.py:78: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (['/Users/marcogorelli/opt/miniconda3/envs/pandas-dev/bin/python', '-OO', '-c', "import pandas as pd, pickle; pickle.loads(pickle.dumps(pd.date_range('2021-01-01', periods=1)))"],)
kwargs = {}, retcode = 1
cmd = ['/Users/marcogorelli/opt/miniconda3/envs/pandas-dev/bin/python', '-OO', '-c', "import pandas as pd, pickle; pickle.loads(pickle.dumps(pd.date_range('2021-01-01', periods=1)))"]

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.
    
        The arguments are the same as for the call function.  Example:
    
        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['/Users/marcogorelli/opt/miniconda3/envs/pandas-dev/bin/python', '-OO', '-c', "import pandas as pd, pickle; pickle.loads(pickle.dumps(pd.date_range('2021-01-01', periods=1)))"]' returned non-zero exit status 1.

../opt/miniconda3/envs/pandas-dev/lib/python3.8/subprocess.py:364: CalledProcessError
-------------------- generated xml file: /Users/marcogorelli/pandas-dev/test-data.xml ---------------------
========================================== slowest 30 durations ===========================================
0.58s call     pandas/tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle

(2 durations < 0.005s hidden.  Use -vv to show these durations.)
========================================= short test summary info =========================================
FAILED pandas/tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle - subprocess.CalledPro...
(pandas-dev) marcogorelli@OVMG025 pandas-dev % 

@jreback jreback merged commit 929c98e into pandas-dev:master Aug 5, 2021
@jreback
Copy link
Contributor

jreback commented Aug 5, 2021

thanks @GorAlexander

@jreback
Copy link
Contributor

jreback commented Aug 5, 2021

@meeseeksdev backport 1.3.x

@lumberbot-app
Copy link

lumberbot-app bot commented Aug 5, 2021

Something went wrong ... Please have a look at my logs.

simonjayhawkins pushed a commit that referenced this pull request Aug 5, 2021
…n PYTHONOPTIMIZE mode (#42904)

Co-authored-by: Alexander Gorodetsky <gor.saha@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DatetimeIndex de-serializing fails in PYTHONOPTIMIZE mode (python -O)
5 participants