sagemaker-python-sdk icon indicating copy to clipboard operation
sagemaker-python-sdk copied to clipboard

fix: Distutils removal

Open jmahlik opened this issue 3 months ago • 10 comments

Closes #4534

Issue #, if available: #4534

Description of changes: Remove runtime dependency on setuptools. Remove reliance on deprecated distutils.

Testing done: Unit, these functions are drop in replacements now that dirs_exist_ok is a parameter in shutil.copytree.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • [x] I have read the CONTRIBUTING doc
  • [x] I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • [x] I used the commit message format described in CONTRIBUTING
  • [x] I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • [x] I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • [x] I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • [x] I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • [x] I have checked that my tests are not configured for a specific region or account (if appropriate)
  • [x] I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

jmahlik avatar Mar 27 '24 18:03 jmahlik

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.37%. Comparing base (6a38060) to head (e9e08a3). Report is 6 commits behind head on master.

:exclamation: Current head e9e08a3 differs from pull request most recent head 50bd9b0. Consider uploading reports for the commit 50bd9b0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4544      +/-   ##
==========================================
- Coverage   87.50%   87.37%   -0.13%     
==========================================
  Files         391      389       -2     
  Lines       37098    36773     -325     
==========================================
- Hits        32461    32132     -329     
- Misses       4637     4641       +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 27 '24 18:03 codecov[bot]

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: e9e08a30cb42d4b2d7299c1c4b42d680a8c78110
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

sagemaker-bot avatar Apr 05 '24 22:04 sagemaker-bot

It looks like there are tests still running on python 3.7. I'm not sure how sagemaker is able to be installed/functions in a 3.7 miniconda environment but it's not supported. Seems like the job runner needs an update since 3.7 has been end of life since June 2023.

The errors come from this env:

/miniconda3/lib/python3.7/site-packages/sagemaker_training/process.py

jmahlik avatar Apr 08 '24 21:04 jmahlik

Just let me know if I need to rebase once the python 3.7 issue is taken care of.

jmahlik avatar Apr 16 '24 21:04 jmahlik

@jmahlik Kindly take a look at the failing integ-tests.

knikure avatar Apr 17 '24 15:04 knikure

@jmahlik Kindly take a look at the failing integ-tests.

They are failing from a python 3.7 environment slipping into the test suite. shutil.copytree added the dirs_exist_ok=True parameter added in python 3.8. So it fails on 3.7.

All of them have a similar traceback. I believe this can be traced to the pytorch framework version being out of date, so the image has python 3.7 installed. It doesn't appear pytorch 1.5 is supported on the images page.

@knikure Would it be ok to bump the tests to use 2.1.2 so they are run on a supported python version? I'm not so familiar with the support policy for framework images and couldn't find firm docs on what exactly is supported by the sdk for training. One might imagine with an unsupported python, the image becomes obsolete.

Traceback:

ClientError: AlgorithmError: framework error:
Traceback (most recent call last):
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_containers/_trainer.py", line 84, in train
    entrypoint()
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/training.py", line 39, in main
    train(environment.Environment())
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/training.py", line 35, in train
    runner_type=runner.ProcessRunnerType)
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_training/entry_point.py", line 100, in run
    wait, capture_error
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_training/process.py", line 291, in run
    cwd=environment.code_dir,
  File "/miniconda3/lib/python3.7/site-packages/sagemaker_training/process.py", line 208, in check_error
    info=extra_info,
sagemaker_training.errors.ExecuteUserScriptError: ExecuteUserScriptError:
ExitCode 1
ErrorMessage ""
Command "/bin/sh -c ./_repack_script_launcher.sh --dependencies . Retrying..

Framework example for a failing test: https://github.com/aws/sagemaker-python-sdk/blob/55822f780979c589f8549eb20dd8c1da80aa7f7a/tests/integ/sagemaker/workflow/test_retry.py#L166-L174

jmahlik avatar Apr 17 '24 19:04 jmahlik