diff --git a/.gitignore b/.gitignore index 7033b58f3..a9e18f445 100644 --- a/.gitignore +++ b/.gitignore @@ -112,23 +112,10 @@ log .DS_Store .idea/ -*.json -cm.json -cm.ts -collections.json -worker*.json # Wheel and tar files from running `python bin/build_containers.py` *.whl bin/sagemaker-containers/**/*.tar.gz -# outdirs -data/ -default/ -newlogsRunTest*/ -MNIST-data/ -logs/ -savedParams/ -ts_outputs*/ -test_output*/ +# TODO: Figure out what is generating this and move it to /tmp/MNIST-data MNIST-data/ diff --git a/config/tests.sh b/config/tests.sh index fc00f1cb6..4c0d346e8 100644 --- a/config/tests.sh +++ b/config/tests.sh @@ -5,7 +5,7 @@ set -ex check_logs() { if grep -e "AssertionError" $1; then - echo "Integration tests:FAILED." + echo "Integration tests: FAILED." exit 1 else echo "Integration tests: SUCCESS." @@ -43,3 +43,9 @@ if [ "$run_pytest_pytorch" = "enable" ] ; then fi check_logs $REPORT_DIR/* + +# Only look at newly added files +if [ -n "$(git status --porcelain | grep ^?? | grep -v tornasolecodebuildtest | grep -v upload)" ]; then + echo "ERROR: Test artifacts were created. Please place these in /tmp." + exit 1 +fi diff --git a/tests/core/test_paths.py b/tests/core/test_paths.py index ca44fcad7..9e3da2ff8 100644 --- a/tests/core/test_paths.py +++ b/tests/core/test_paths.py @@ -1,6 +1,7 @@ # Standard Library import os import uuid +from tempfile import TemporaryDirectory # First Party import smdebug.pytorch as smd @@ -97,18 +98,19 @@ def test_s3_path_that_exists_without_end_of_job(): def test_outdir_sagemaker(monkeypatch): - json_file_contents = """ - { - "S3OutputPath": "s3://sagemaker-test", - "LocalPath": "/my/own/path/tensors", - "HookParameters" : { - "save_interval": "2", - "include_workers": "all" - } - } - """ - from smdebug.tensorflow import get_hook - - with SagemakerSimulator(json_file_contents=json_file_contents) as sim: - hook = get_hook("keras", create_if_not_exists=True) - assert hook.out_dir == "/my/own/path/tensors" + with TemporaryDirectory() as dir_name: + json_file_contents = f""" + {{ + "S3OutputPath": "s3://sagemaker-test", + "LocalPath": "{dir_name}", + "HookParameters" : {{ + "save_interval": "2", + "include_workers": "all" + }} + }} + """ + from smdebug.tensorflow import get_hook + + with SagemakerSimulator(json_file_contents=json_file_contents) as sim: + hook = get_hook("keras", create_if_not_exists=True) + assert hook.out_dir == dir_name diff --git a/tests/mxnet/test_hook_all_zero.py b/tests/mxnet/test_hook_all_zero.py index 966b65d96..0de2b1e42 100644 --- a/tests/mxnet/test_hook_all_zero.py +++ b/tests/mxnet/test_hook_all_zero.py @@ -22,6 +22,7 @@ def test_hook_all_zero(hook=None, out_dir=None): run_id = "trial_" + datetime.now().strftime("%Y%m%d-%H%M%S%f") out_dir = "/tmp/newlogsRunTest/" + run_id print("Registering the hook with out_dir {0}".format(out_dir)) + shutil.rmtree(out_dir, ignore_errors=True) hook = t_hook( out_dir=out_dir, save_config=save_config,