Skip to content

Commit

Permalink
fix: remove deprecated distutils api calls in workflows
Browse files Browse the repository at this point in the history
Also remove from tests.

Closes #4534
  • Loading branch information
jmahlik committed Mar 27, 2024
1 parent 404f50c commit e79304d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ ignore-mixin-members=yes
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=distutils
ignored-modules=

# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
Expand Down
9 changes: 1 addition & 8 deletions src/sagemaker/workflow/_repack_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
# is unpacked for inference, the custom entry point will be used.
# Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-toolkits.html

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

from os.path import abspath, realpath, dirname, normpath, join as joinpath

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

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


if __name__ == "__main__": # pragma: no cover
Expand Down
9 changes: 1 addition & 8 deletions tests/data/_repack_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
# is unpacked for inference, the custom entry point will be used.
# Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-toolkits.html

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


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

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


if __name__ == "__main__": # pragma: no cover
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_chainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import logging
import json
import os
from distutils.util import strtobool

import pytest
from mock import MagicMock, Mock, ANY
Expand Down Expand Up @@ -173,7 +172,7 @@ def test_additional_hyperparameters(sagemaker_session, chainer_version, chainer_
framework_version=chainer_version,
py_version=chainer_py_version,
)
assert bool(strtobool(chainer.hyperparameters()["sagemaker_use_mpi"]))
assert chainer.hyperparameters()["sagemaker_use_mpi"] in ('y', 'yes', 't', 'true', 'on', '1')
assert int(chainer.hyperparameters()["sagemaker_num_processes"]) == 4
assert int(chainer.hyperparameters()["sagemaker_process_slots_per_host"]) == 10
assert (
Expand Down

0 comments on commit e79304d

Please sign in to comment.