From 64ea40055ac4b69e9d61603a4cdaae25680c1fe2 Mon Sep 17 00:00:00 2001 From: dyastremsky <58150256+dyastremsky@users.noreply.github.com> Date: Mon, 21 Aug 2023 08:23:07 -0700 Subject: [PATCH] Remove deprecated distutils (#746) * Remove deprecated distutils * Add param to override existing files * Fixing unit tests --------- Co-authored-by: braf --- model_analyzer/triton/model/model_config.py | 4 ++-- tests/test_model_config.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/model_analyzer/triton/model/model_config.py b/model_analyzer/triton/model/model_config.py index 6eb6cfd7e..01ccefce4 100755 --- a/model_analyzer/triton/model/model_config.py +++ b/model_analyzer/triton/model/model_config.py @@ -17,7 +17,7 @@ import json import os from copy import deepcopy -from distutils.dir_util import copy_tree +from shutil import copytree from typing import Any, Dict, List, Optional from google.protobuf import json_format, text_format @@ -420,7 +420,7 @@ def write_config_to_file( ) else: # Create first variant model as copy of source model - copy_tree(src_model_path, model_path) + copytree(src_model_path, model_path, dirs_exist_ok=True) with open(os.path.join(model_path, "config.pbtxt"), "wb") as f: f.write(model_config_bytes) diff --git a/tests/test_model_config.py b/tests/test_model_config.py index c89c14f84..a8e2b2c52 100755 --- a/tests/test_model_config.py +++ b/tests/test_model_config.py @@ -200,7 +200,7 @@ def test_write_config_file(self): "model_analyzer.triton.model.model_config.open", mock_open() ) as mocked_file: with patch( - "model_analyzer.triton.model.model_config.copy_tree", MagicMock() + "model_analyzer.triton.model.model_config.copytree", MagicMock() ): model_config.write_config_to_file(model_output_path, "/mock/path", None) content = mocked_file().write.call_args.args[0] @@ -232,7 +232,7 @@ def test_write_config_file(self): "model_analyzer.triton.model.model_config.os.listdir", MagicMock(return_value=["1", "config.pbtxt", "output0_labels.txt"]), ) - @patch("model_analyzer.triton.model.model_config.copy_tree") + @patch("model_analyzer.triton.model.model_config.copytree") @patch("model_analyzer.triton.model.model_config.os.symlink") def test_write_config_to_file_with_relative_path(self, mock_os_symlink, *args): """