File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 11import logging
22import os
33import distutils .dir_util
4+ from pathlib import Path
5+
6+ import mock
47
58import test_util
69
@@ -17,15 +20,18 @@ def test_local_training():
1720 Compare with https://github.com/aws/amazon-sagemaker-examples/tree/main/advanced_functionality/scikit_bring_your_own/container/local_test .
1821 """
1922 assert training_environment .SAGEMAKER_BASE_PATH == "/opt/ml"
23+ assert training_environment .base_dir .endswith ("/opt_ml" )
2024
2125 test_util ._clean_training_opt_ml_dir ()
2226 distutils .dir_util .copy_tree ("./source_dir/training_clean/" , "./opt_ml/code/" )
2327
2428 os .environ = {
25- training_parameters .USER_PROGRAM_ENV : " train_clean.py" ,
29+ training_parameters .USER_PROGRAM_ENV : Path ( 'source_dir/training_clean/ train_clean.py' ). name ,
2630 }
2731
2832 try :
33+ # Note: it will start the subprocess, so we don't have the code coverage
34+ # TODO: https://coverage.readthedocs.io/en/latest/subprocess.html
2935 train_main ()
3036 except SystemExit as e :
3137 assert e .code == 0
@@ -34,3 +40,10 @@ def test_local_training():
3440 assert os .path .exists ("./opt_ml/output/success" )
3541
3642 logging .info ("Finished training" )
43+
44+
45+ @mock .patch .dict (os .environ , {"SM_MODEL_DIR" : "./opt_ml/model" })
46+ def test_local_training_with_coverage ():
47+ # import will start training
48+ from source_dir .training_clean import train_clean
49+ assert train_clean
You can’t perform that action at this time.
0 commit comments