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

Improve temporary directory handling in cuML #5527

Merged
merged 3 commits into from
Jul 31, 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
16 changes: 11 additions & 5 deletions python/cuml/benchmark/nvtx_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@

import os
import sys
import tempfile
from subprocess import run
import json


class Profiler:
def __init__(self, tmp_path="/tmp/nsys_report"):
self.nsys_file = tmp_path + "/report.nsys-rep"
self.json_file = tmp_path + "/report.json"
self._execute(["rm", "-rf", tmp_path])
self._execute(["mkdir", "-p", tmp_path])
def __init__(self, tmp_path=None):
self.tmp_dir = tempfile.TemporaryDirectory(dir=tmp_path)
self.nsys_file = os.path.join(self.tmp_dir.name, "report.nsys-rep")
self.json_file = os.path.join(self.tmp_dir.name, "report.json")
self._execute(["rm", "-rf", self.tmp_dir.name])
self._execute(["mkdir", "-p", self.tmp_dir.name])
Comment on lines +29 to +30
Copy link
Member Author

Choose a reason for hiding this comment

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

One additional improvement would be to call the Python builtin functions for these. Submitted PR ( #5537 ) doing just that


def __del__(self):
self.tmp_dir.cleanup()
self.tmp_dir = None

@staticmethod
def _execute(command):
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/tests/test_device_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ def test_train_gpu_infer_gpu(test_data):
assert_func(cuml_output, test_data)


def test_pickle_interop(test_data):
pickle_filepath = "/tmp/model.pickle"
def test_pickle_interop(tmp_path, test_data):
pickle_filepath = tmp_path / "model.pickle"

cuEstimator = test_data["cuEstimator"]
if cuEstimator is UMAP:
Expand Down