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

Forward-merge branch-23.12 to branch-24.02 #14522

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/cudf/cudf/pandas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def profile(function_profile, line_profile, fn):
elif function_profile:
with Profiler() as profiler:
yield fn
profiler.print_per_func_stats()
profiler.print_per_function_stats()
else:
yield fn

Expand Down
13 changes: 13 additions & 0 deletions python/cudf/cudf_pandas_tests/data/profile_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2023, NVIDIA CORPORATION.

import pandas as pd

df = pd.DataFrame(
{
"size": [10, 11, 12, 10, 11, 12, 10, 6, 11, 10],
"total_bill": [100, 200, 100, 200, 100, 100, 200, 50, 10, 560],
}
)
df["size"].value_counts()
df.groupby("size").total_bill.mean()
df.apply(list, axis=1)
41 changes: 41 additions & 0 deletions python/cudf/cudf_pandas_tests/test_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import os
import subprocess

from cudf.pandas import LOADED, Profiler

if not LOADED:
Expand Down Expand Up @@ -68,3 +71,41 @@ def test_profiler_fast_slow_name_mismatch():
with Profiler():
df = pd.DataFrame({"a": [1, 2, 3], "b": [3, 4, 5]})
df.iloc[0, 1] = "foo"


def test_profiler_commandline():
data_directory = os.path.dirname(os.path.abspath(__file__))
# Create a copy of the current environment variables
env = os.environ.copy()
# Setting the 'COLUMNS' environment variable to a large number
# because the terminal output shouldn't be compressed for
# text validations below.
env["COLUMNS"] = "10000"

sp_completed = subprocess.run(
[
"python",
"-m",
"cudf.pandas",
"--profile",
data_directory + "/data/profile_basic.py",
],
capture_output=True,
text=True,
env=env,
)
assert sp_completed.returncode == 0
output = sp_completed.stdout

for string in [
"Total time",
"Stats",
"Function",
"GPU ncalls",
"GPU cumtime",
"GPU percall",
"CPU ncalls",
"CPU cumtime",
"CPU percall",
]:
assert string in output
Loading