Skip to content

Commit 3c7d1d7

Browse files
authored
Add test artifacts check to CI (aws#52)
* Add test artifacts check to CI * Fix bash syntax * Change /my to /tmp/my * Use TemporaryDirectory() * Add some grep filters * Patch so passes CI
1 parent cda5665 commit 3c7d1d7

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

.gitignore

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,10 @@ log
112112

113113
.DS_Store
114114
.idea/
115-
*.json
116-
cm.json
117-
cm.ts
118-
collections.json
119-
worker*.json
120115

121116
# Wheel and tar files from running `python bin/build_containers.py`
122117
*.whl
123118
bin/sagemaker-containers/**/*.tar.gz
124119

125-
# outdirs
126-
data/
127-
default/
128-
newlogsRunTest*/
129-
MNIST-data/
130-
logs/
131-
savedParams/
132-
ts_outputs*/
133-
test_output*/
120+
# TODO: Figure out what is generating this and move it to /tmp/MNIST-data
134121
MNIST-data/

config/tests.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -ex
55
check_logs() {
66
if grep -e "AssertionError" $1;
77
then
8-
echo "Integration tests:FAILED."
8+
echo "Integration tests: FAILED."
99
exit 1
1010
else
1111
echo "Integration tests: SUCCESS."
@@ -43,3 +43,9 @@ if [ "$run_pytest_pytorch" = "enable" ] ; then
4343
fi
4444

4545
check_logs $REPORT_DIR/*
46+
47+
# Only look at newly added files
48+
if [ -n "$(git status --porcelain | grep ^?? | grep -v tornasolecodebuildtest | grep -v upload)" ]; then
49+
echo "ERROR: Test artifacts were created. Please place these in /tmp."
50+
exit 1
51+
fi

tests/core/test_paths.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Standard Library
22
import os
33
import uuid
4+
from tempfile import TemporaryDirectory
45

56
# First Party
67
import smdebug.pytorch as smd
@@ -97,18 +98,19 @@ def test_s3_path_that_exists_without_end_of_job():
9798

9899

99100
def test_outdir_sagemaker(monkeypatch):
100-
json_file_contents = """
101-
{
102-
"S3OutputPath": "s3://sagemaker-test",
103-
"LocalPath": "/my/own/path/tensors",
104-
"HookParameters" : {
105-
"save_interval": "2",
106-
"include_workers": "all"
107-
}
108-
}
109-
"""
110-
from smdebug.tensorflow import get_hook
111-
112-
with SagemakerSimulator(json_file_contents=json_file_contents) as sim:
113-
hook = get_hook("keras", create_if_not_exists=True)
114-
assert hook.out_dir == "/my/own/path/tensors"
101+
with TemporaryDirectory() as dir_name:
102+
json_file_contents = f"""
103+
{{
104+
"S3OutputPath": "s3://sagemaker-test",
105+
"LocalPath": "{dir_name}",
106+
"HookParameters" : {{
107+
"save_interval": "2",
108+
"include_workers": "all"
109+
}}
110+
}}
111+
"""
112+
from smdebug.tensorflow import get_hook
113+
114+
with SagemakerSimulator(json_file_contents=json_file_contents) as sim:
115+
hook = get_hook("keras", create_if_not_exists=True)
116+
assert hook.out_dir == dir_name

tests/mxnet/test_hook_all_zero.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_hook_all_zero(hook=None, out_dir=None):
2222
run_id = "trial_" + datetime.now().strftime("%Y%m%d-%H%M%S%f")
2323
out_dir = "/tmp/newlogsRunTest/" + run_id
2424
print("Registering the hook with out_dir {0}".format(out_dir))
25+
shutil.rmtree(out_dir, ignore_errors=True)
2526
hook = t_hook(
2627
out_dir=out_dir,
2728
save_config=save_config,

0 commit comments

Comments
 (0)