Skip to content

Commit

Permalink
add temporary cudf string copy_range workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
cwharris committed Aug 22, 2024
1 parent 7bb3ad9 commit 3114285
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion python/morpheus/morpheus/_lib/src/messages/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,16 @@ void MultiMessageInterfaceProxy::set_meta(MultiMessage& self, pybind11::object c
}

// Perform the update via slices
df.attr("loc")[pybind11::make_tuple(df.attr("index")[row_indexer], columns)] = value;
auto is_string_dtype = pybind11::module_::import("cudf.api.types").attr("is_string_dtype");
auto series = pybind11::module_::import("cudf").attr("Series");

if (is_string_dtype(series(value)).cast<bool>()) {
df[columns] = pybind11::str();
df[columns].attr("iloc")[row_indexer] = value;
} else {
df.attr("loc")[pybind11::make_tuple(df.attr("index")[row_indexer], columns)] = value;
}


// Reset the index if we changed it
if (!saved_index.is_none())
Expand Down
11 changes: 10 additions & 1 deletion python/morpheus/morpheus/messages/multi_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,16 @@ def set_meta(self, columns: typing.Union[None, str, typing.List[str]], value):

saved_index = df.index
df.reset_index(drop=True, inplace=True)
df.loc[df.index[row_indexer], columns] = value

# TODO: when value is strings, make all values empty strings
from cudf.api.types import is_string_dtype

if is_string_dtype(cudf.Series(value)):
df[columns] = ""
df[columns].iloc[row_indexer] = value
else:
df.loc[df.index[row_indexer], columns] = value

df.set_index(saved_index, inplace=True)
else:
# Need to determine the boolean mask to use indexes with df.loc
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
import types
import typing
import warnings
import sys
from pathlib import Path
from unittest import mock

import sys
if "/home/coder" in sys.path:
sys.path.remove("/home/coder")

import pytest
import requests

Expand Down

0 comments on commit 3114285

Please sign in to comment.