rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.46k stars 908 forks source link

[BUG] pd.Holiday can't be subclassed #16919

Closed 8W9aG closed 1 month ago

8W9aG commented 1 month ago

Describe the bug Running the package pandas_market_calendars with cudf results in the following crash:

│ /home/xxx/dev/xxx/venv/lib/python3.10/site-packages/exchange_calendars/exchange_calendar │                                                                                                             
│ _xkrx.py:27 in <module>                                                                          │                                                                                                             
│                                                                                                  │                                                                                                             
│    26 from .precomputed_exchange_calendar import PrecomputedExchangeCalendar                     │                                                                                                             
│ ❱  27 from .xkrx_holidays import (                                                               │                                                                                                             
│    28 │   krx_regular_holiday_rules,                                                             │                                                                                                             
│                                                                                                  │                                                                                                             
│ /home/xxx/dev/xxx/venv/lib/python3.10/site-packages/exchange_calendars/xkrx_holidays.py: │                                                                                                             
│ 1125 in <module>                                                                                 │                                                                                                             
│                                                                                                  │                                                                                                             
│   1124 # Korean regular holidays                                                                 │                                                                                                             
│ ❱ 1125 NewYearsDay = KoreanSolarHoliday(                                                         │                                                                                                             
│   1126 │   "New Years Day", month=1, day=1                                                       │                                                                                                             
│                                                                                                  │                                                                                                             
│ /home/xxx/dev/xxx/venv/lib/python3.10/site-packages/exchange_calendars/pandas_extensions │                                                                                                             
│ /holiday.py:53 in __init__                                                                       │                                                                                                             
│                                                                                                  │                                                                                                             
│    52 │   │   self.tz = tz                                                                       │                                                                                                             
│ ❱  53 │   │   if self.start_date is not None:                                                    │                                                                                                             
│    54 │   │   │   if self.tz is None and self.start_date.tz is not None:                         │                                                                                                             
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                                                             
AttributeError: 'KoreanSolarHoliday' object has no attribute 'start_date'

In this case KoreanSolarHoliday subclasses KoreanHoliday which subclasses Holiday which subclasses pd.Holiday. In this case the failure comes from accessing the start_date property. Upon inspecting the object that is created it seems to have one attribute which is an fsproxy_wrapped object but no start_date et al. I can somewhat get this fixed by doing the pattern of if hasattr(self, "start_date") and self.start_date is not None but this seems like I'm fixing the wrong issue and that it is likely to have other issues down the line.

Steps/Code to reproduce bug I am using the following versions of the packages and running on cuda 11.5:

[[tool.poetry.source]]
name = "nvidia"
url = "https://pypi.nvidia.com"
priority = "supplemental"

cudf-cu11 = { version = "24.8.3", markers = "sys_platform == 'linux'", source = "nvidia" }
dask-cudf-cu11 = { version = "24.8.3", markers = "sys_platform == 'linux'", source = "nvidia" }
cuml-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
cugraph-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
cuspatial-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
cuproj-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
cuxfilter-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
cucim-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
pylibraft-cu11 = { version = "24.8.1", markers = "sys_platform == 'linux'", source = "nvidia" }
raft-dask-cu11 = { version = "24.8.1", markers = "sys_platform == 'linux'", source = "nvidia" }
cuvs-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }
nx-cugraph-cu11 = { version = "24.8.0", markers = "sys_platform == 'linux'", source = "nvidia" }

I can reproduce by performing the following code:

import cudf.pandas
cudf.pandas.install()
import pandas_market_calendars as mcal

Expected behavior I would expect this package to import without issue, as I cannot see an issue with the code within it.

Environment overview (please complete the following information)

Environment details

<details><summary>Click here to see environment details</summary><pre>

     **git***
     Not inside a git repository

     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=22.04
     DISTRIB_CODENAME=jammy
     DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
     PRETTY_NAME="Ubuntu 22.04.4 LTS"
     NAME="Ubuntu"
     VERSION_ID="22.04"
     VERSION="22.04.4 LTS (Jammy Jellyfish)"
     VERSION_CODENAME=jammy
     ID=ubuntu
     ID_LIKE=debian
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     UBUNTU_CODENAME=jammy
     Linux sackputer 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

     ***GPU Information***
     Wed Sep 25 17:25:48 2024
     +-----------------------------------------------------------------------------------------+
     | NVIDIA-SMI 550.107.02             Driver Version: 550.107.02     CUDA Version: 12.4     |
     |-----------------------------------------+------------------------+----------------------+
     | GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
     |                                         |                        |               MIG M. |
     |=========================================+========================+======================|
     |   0  NVIDIA GeForce RTX 4070 Ti     Off |   00000000:01:00.0 Off |                  N/A |
     |  0%   39C    P8             14W /  285W |     196MiB /  12282MiB |      0%      Default |
     |                                         |                        |                  N/A |
     +-----------------------------------------+------------------------+----------------------+

     +-----------------------------------------------------------------------------------------+
     | Processes:                                                                              |
     |  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
     |        ID   ID                                                               Usage      |
     |=========================================================================================|
     |    0   N/A  N/A      1511      G   /usr/lib/xorg/Xorg                            144MiB |
     |    0   N/A  N/A      1718      G   /usr/bin/gnome-shell                           43MiB |
     +-----------------------------------------------------------------------------------------+

     ***CPU***
     Architecture:                         x86_64
     CPU op-mode(s):                       32-bit, 64-bit
     Address sizes:                        39 bits physical, 48 bits virtual
     Byte Order:                           Little Endian
     CPU(s):                               24
     On-line CPU(s) list:                  0-23
     Vendor ID:                            GenuineIntel
     Model name:                           13th Gen Intel(R) Core(TM) i7-13700KF
     CPU family:                           6
     Model:                                183
     Thread(s) per core:                   2
     Core(s) per socket:                   16
     Socket(s):                            1
     Stepping:                             1
     CPU max MHz:                          5400.0000
     CPU min MHz:                          800.0000
     BogoMIPS:                             6835.20
     Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
     Virtualization:                       VT-x
     L1d cache:                            640 KiB (16 instances)
     L1i cache:                            768 KiB (16 instances)
     L2 cache:                             24 MiB (10 instances)
     L3 cache:                             30 MiB (1 instance)
     NUMA node(s):                         1
     NUMA node0 CPU(s):                    0-23
     Vulnerability Gather data sampling:   Not affected
     Vulnerability Itlb multihit:          Not affected
     Vulnerability L1tf:                   Not affected
     Vulnerability Mds:                    Not affected
     Vulnerability Meltdown:               Not affected
     Vulnerability Mmio stale data:        Not affected
     Vulnerability Reg file data sampling: Mitigation; Clear Register File
     Vulnerability Retbleed:               Not affected
     Vulnerability Spec rstack overflow:   Not affected
     Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
     Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
     Vulnerability Srbds:                  Not affected
     Vulnerability Tsx async abort:        Not affected

     ***CMake***

     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
     Copyright (C) 2021 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     ***nvcc***
     /usr/bin/nvcc
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2021 NVIDIA Corporation
     Built on Thu_Nov_18_09:45:30_PST_2021
     Cuda compilation tools, release 11.5, V11.5.119
     Build cuda_11.5.r11.5/compiler.30672275_0

     ***Python***
     /usr/bin/python
     Python 3.10.12

     ***Environment Variables***
     PATH                            : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
     LD_LIBRARY_PATH                 :
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    :
     PYTHON_PATH                     :

     conda not found
     pip not found
</pre></details>

Additional context

I can't seem to reproduce this on a google colab instance unfortunately.

bdice commented 1 month ago

@galipremsagar / @mroeschke Would one of you be able to investigate?

8W9aG commented 1 month ago

Please excuse this, I believe this is due to improper pickling in modal which I was using to run this. Running normally this does not occur.