Skip to content

Commit bfb49a2

Browse files
committed
fix: remove deprecated distutils api calls in workflows
Also remove from tests. Closes #4534
1 parent 67f60bd commit bfb49a2

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ ignore-mixin-members=yes
310310
# (useful for modules/projects where namespaces are manipulated during runtime
311311
# and thus existing member attributes cannot be deduced by static analysis. It
312312
# supports qualified module names, as well as Unix pattern matching.
313-
ignored-modules=distutils
313+
ignored-modules=
314314

315315
# List of class names for which member attributes should not be checked (useful
316316
# for classes with dynamically set attributes). This supports the use of

src/sagemaker/workflow/_repack_model.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
# is unpacked for inference, the custom entry point will be used.
2828
# Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-toolkits.html
2929

30-
# distutils.dir_util.copy_tree works way better than the half-baked
31-
# shutil.copytree which bombs on previously existing target dirs...
32-
# alas ... https://bugs.python.org/issue10948
33-
# we'll go ahead and use the copy_tree function anyways because this
34-
# repacking is some short-lived hackery, right??
35-
from distutils.dir_util import copy_tree
36-
3730
from os.path import abspath, realpath, dirname, normpath, join as joinpath
3831

3932
logger = logging.getLogger(__name__)
@@ -188,7 +181,7 @@ def repack(inference_script, model_archive, dependencies=None, source_dir=None):
188181

189182
# copy the "src" dir, which includes the previous training job's model and the
190183
# custom inference script, to the output of this training job
191-
copy_tree(src_dir, "/opt/ml/model")
184+
shutil.copytree(src_dir, "/opt/ml/model", dirs_exist_ok=True)
192185

193186

194187
if __name__ == "__main__": # pragma: no cover

tests/data/_repack_model.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
# is unpacked for inference, the custom entry point will be used.
2727
# Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-toolkits.html
2828

29-
# distutils.dir_util.copy_tree works way better than the half-baked
30-
# shutil.copytree which bombs on previously existing target dirs...
31-
# alas ... https://bugs.python.org/issue10948
32-
# we'll go ahead and use the copy_tree function anyways because this
33-
# repacking is some short-lived hackery, right??
34-
from distutils.dir_util import copy_tree
35-
3629

3730
def repack(inference_script, model_archive, dependencies=None, source_dir=None): # pragma: no cover
3831
"""Repack custom dependencies and code into an existing model TAR archive
@@ -92,7 +85,7 @@ def repack(inference_script, model_archive, dependencies=None, source_dir=None):
9285

9386
# copy the "src" dir, which includes the previous training job's model and the
9487
# custom inference script, to the output of this training job
95-
copy_tree(src_dir, "/opt/ml/model")
88+
shutil.copytree(src_dir, "/opt/ml/model", dirs_exist_ok=True)
9689

9790

9891
if __name__ == "__main__": # pragma: no cover

tests/unit/test_chainer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import logging
1616
import json
1717
import os
18-
from distutils.util import strtobool
1918

2019
import pytest
2120
from mock import MagicMock, Mock, ANY

0 commit comments

Comments
 (0)