Skip to content

Commit

Permalink
Use workaround to avoid staticmethod 3.10/Cython issue (rapidsai#5202)
Browse files Browse the repository at this point in the history
With Python 3.10, there appears to be an issue with the interaction between the staticmethod decorator and Cython. This workaround temporarily switches all staticmethods in FIL to classmethods until the underlying issue can be sorted.

Resolve rapidsai#5200.

Authors:
  - William Hicks (https://github.com/wphicks)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#5202
  • Loading branch information
wphicks authored Feb 5, 2023
1 parent aeb7ccd commit a1c22e4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions python/cuml/fil/fil.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ cdef class TreeliteModel():
TreeliteQueryNumFeature(self.handle, &out)
return out

@staticmethod
def free_treelite_model(model_handle):
@classmethod
def free_treelite_model(cls, model_handle):
cdef uintptr_t model_ptr = <uintptr_t>model_handle
TreeliteFreeModel(<ModelHandle> model_ptr)

@staticmethod
def from_filename(filename, model_type="xgboost"):
@classmethod
def from_filename(cls, filename, model_type="xgboost"):
"""
Returns a TreeliteModel object loaded from `filename`
Expand Down Expand Up @@ -173,8 +173,9 @@ cdef class TreeliteModel():
filename_bytes = filename.encode("UTF-8")
TreeliteSerializeModel(filename_bytes, self.handle)

@staticmethod
def from_treelite_model_handle(treelite_handle,
@classmethod
def from_treelite_model_handle(cls,
treelite_handle,
take_handle_ownership=False):
cdef ModelHandle handle = <ModelHandle> <size_t> treelite_handle
model = TreeliteModel(owns_handle=take_handle_ownership)
Expand Down Expand Up @@ -843,8 +844,9 @@ class ForestInference(Base,
)
return cuml_fm

@staticmethod
def load(filename,
@classmethod
def load(cls,
filename,
output_class=False,
threshold=0.50,
algo='auto',
Expand Down

0 comments on commit a1c22e4

Please sign in to comment.