Skip to content

Commit f0f44a5

Browse files
authored
Tornasole hook from config json (aws#104)
* creating tornasole hook from config * making a quick variance fix (aws#99) * Adding the change to convert ndarray to np.ndarray when operator is not available in mxnet. * Cleanup and tests for TF and mxnet * remove rmtree from s3 test * Fixed the function invocation of get_numpy_reduction * Changes to read from hardcoded path * fixing pytorch test * Setting SaveConfig per mode (aws#94) * add doc for passing saveconfig specific to modes * add save config for collection * Create an option to build tornasole with no framework, TORNASOLE_FOR_RULES=1 (aws#95) * add option to build only for rules * Adding support to set save config per mode through json, also copying load collection method to all frameworks as that was missed * remove set -ex from tests script since it prevents upload of reports * move json config out of hooks
1 parent 3e28383 commit f0f44a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1220
-246
lines changed

bin/build_binaries.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
export VERSION='0.3'
23

34
for FRAMEWORK in tensorflow mxnet pytorch
@@ -9,3 +10,10 @@ do
910
# aws s3 cp dist/tornasole-$VERSION-py2.py3-none-any.whl s3://tornasole-binaries-use1/tornasole_$FRAMEWORK/py3/
1011
rm -rf dist build *.egg-info
1112
done
13+
14+
15+
export TORNASOLE_FOR_RULES=1
16+
python setup.py bdist_wheel --universal
17+
unset TORNASOLE_FOR_RULES
18+
# aws s3 cp dist/tornasole-$VERSION-py2.py3-none-any.whl s3://tornasole-binaries-use1/tornasole_rules/py3/
19+
rm -rf dist build *.egg-info

config/buildspec.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ phases:
2626
commands:
2727
- cd $CODEBUILD_SRC_DIR && python setup.py bdist_wheel --universal && pip install dist/*.whl && cd ..
2828
- cd $CODEBUILD_SRC_DIR && chmod +x config/tests.sh && ./config/tests.sh && mkdir -p upload/$CURRENT_COMMIT_PATH/wheels && cp ./dist/*.whl upload/$CURRENT_COMMIT_PATH/wheels && cd ..
29-
- aws s3 cp $CODEBUILD_SRC_DIR/upload s3://tornasolecodebuildtest/ --recursive
3029
#if [ "$CODEBUILD_GIT_BRANCH" = "master" ] && [ "$CODEBUILD_WEBHOOK_EVENT" = "PUSH" ] ; then
3130
post_build:
3231
commands:
33-
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then echo "ERROR BUILD FAILED , ACCESS BUILD LOGS THROUGH GITHUB OR TROUGH THE LINK:$CODEBUILD_BUILD_URL" ; fi
34-
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 1 ]; then echo "INFO BUILD SUCCEEDED !!! , ACCESS BUILD LOGS THROUGH GITHUB OR TROUGH THE LINK:$CODEBUILD_BUILD_URL" ; fi
35-
32+
- cat $CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH/reports/*.html >> $CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH/reports/all_tests.html
33+
- aws s3 cp $CODEBUILD_SRC_DIR/upload s3://tornasolecodebuildtest/ --recursive
34+
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then echo "ERROR BUILD FAILED , Access build logs for PR:$GITHUB_PR_URL at the below codebuild url. Test logs are on S3 here:$S3_TEST_REPORT_URL" ; fi
35+
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 1 ]; then echo "INFO BUILD SUCCEEDED , Access build logs for PR:$GITHUB_PR_URL at the below codebuild url. Test logs are on S3 here:$S3_TEST_REPORT_URL" ; fi

config/get-branch.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ fi
66

77
cd $CODEBUILD_SRC_DIR && git checkout $CODEBUILD_GIT_BRANCH
88
export CURRENT_COMMIT_HASH=$(git log -1 --pretty=%h);
9-
export CURRENT_COMMIT_DATE="$(git show -s --format=%ci | cut -d' ' -f 1)_$(git show -s --format=%ci | cut -d' ' -f 2)";
9+
#export CURRENT_COMMIT_DATE="$(git show -s --format=%ci | cut -d' ' -f 1)$(git show -s --format=%ci | cut -d' ' -f 2)";
10+
export CURRENT_DATETIME=$(date +'%Y%m%d_%H%M%S')
1011
export CURRENT_REPO_NAME=$(basename `git rev-parse --show-toplevel`) ;
11-
export CURRENT_COMMIT_PATH="$CURRENT_COMMIT_DATE/$CURRENT_REPO_NAME/$CURRENT_COMMIT_HASH"
12+
export CURRENT_COMMIT_PATH="$CURRENT_DATETIME/$CURRENT_COMMIT_HASH"
1213
cd ..
1314

1415

@@ -20,9 +21,14 @@ export CODEBUILD_BUILD_URL=https://$AWS_DEFAULT_REGION.console.aws.amazon.com/co
2021
echo "INFO =============================BUILD STARTED==================================="
2122
echo "INFO =============================Build details========================== ::"
2223
echo "INFO CODEBUILD_CURRENT_BUILD_URL = $CODEBUILD_BUILD_URL"
23-
echo "INFO CURRENT_REPO_NAME = $CURRENT_REPO_NAME"
24+
#echo "INFO CURRENT_REPO_NAME = $CURRENT_REPO_NAME"
2425
echo "INFO CURRENT_COMMIT_DATE = $CURRENT_COMMIT_DATE"
2526
echo "INFO CODEBUILD_ACCOUNT_ID = $CODEBUILD_ACCOUNT_ID"
2627
echo "INFO CURRENT_GIT_BRANCH = $CODEBUILD_GIT_BRANCH"
27-
#echo "INFO CURRENT_GIT_COMMIT = $CODEBUILD_GIT_COMMIT"
28+
echo "INFO CURRENT_GIT_COMMIT = $CODEBUILD_GIT_COMMIT"
2829
echo "INFO CODEBUILD_PROJECT = $CODEBUILD_PROJECT"
30+
31+
PR_ID=$(echo $CODEBUILD_WEBHOOK_TRIGGER | cut -d ';' -f 2-)
32+
export GITHUB_PR_URL=https://github.com/awslabs/$CURRENT_REPO_NAME/pull/$PR_ID
33+
#https://s3.console.aws.amazon.com/s3/object/tornasolecodebuildtest/20190817_215022/c24a121/reports/all_tests.html?region=us-east-1&tab=overview
34+
export S3_TEST_REPORT_URL=https://s3.console.aws.amazon.com/s3/object/tornasolecodebuildtest/$CURRENT_COMMIT_PATH/reports/all_tests.html?region=us-east-1&tab=overview

config/tests.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env bash
2+
3+
set -ex
4+
25
check_logs() {
36
if grep "AssertionError" $1;
47
then
@@ -9,31 +12,30 @@ check_logs() {
912
fi
1013
}
1114

12-
set -ex
1315
export TORNASOLE_LOG_LEVEL=debug
1416
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/report_analysis.html --self-contained-html tests/analysis
1517
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/report_core.html --self-contained-html tests/core
1618

1719
if [ "$run_pytest_tensorflow" = "enable" ] ; then
1820
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/report_tensorflow.html --self-contained-html tests/tensorflow
19-
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_tensorflow.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode tensorflow --path_to_config ./tests/analysis/config.yaml
21+
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_tensorflow.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode tensorflow --path_to_config ./tests/analysis/config.yaml 2>&1 | tee upload/$CURRENT_COMMIT_PATH/reports/test_rules_tensorflow.log
2022
fi
2123

2224
if [ "$run_pytest_mxnet" = "enable" ] ; then
2325
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/report_mxnet.html --self-contained-html tests/mxnet
24-
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_mxnet.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode mxnet --path_to_config ./tests/analysis/config.yaml
26+
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_mxnet.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode mxnet --path_to_config ./tests/analysis/config.yaml 2>&1 | tee upload/$CURRENT_COMMIT_PATH/reports/test_rules_mxnet.log
2527
fi
2628

2729
if [ "$run_pytest_pytorch" = "enable" ] ; then
2830
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/report_pytorch.html --self-contained-html tests/pytorch
29-
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode pytorch --path_to_config ./tests/analysis/config.yaml
31+
python -m pytest --html=upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.html --self-contained-html -s tests/analysis/integration_testing_rules.py::test_test_rules --mode pytorch --path_to_config ./tests/analysis/config.yaml 2>&1 | tee upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.log
3032
fi
3133

3234
check_logs upload/$CURRENT_COMMIT_PATH/reports/report_analysis.html
3335
check_logs upload/$CURRENT_COMMIT_PATH/reports/report_core.html
3436
check_logs upload/$CURRENT_COMMIT_PATH/reports/report_tensorflow.html
3537
check_logs upload/$CURRENT_COMMIT_PATH/reports/report_mxnet.html
3638
check_logs upload/$CURRENT_COMMIT_PATH/reports/report_pytorch.html
37-
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_tensorflow.html
38-
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_mxnet.html
39-
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.html
39+
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.log
40+
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_mxnet.log
41+
check_logs upload/$CURRENT_COMMIT_PATH/reports/test_rules_pytorch.log

docs/mxnet/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,28 @@ and make it easy for analysis. To leverage this functionality you have to
175175
call the `set_mode` function of hook such as the following call `hook.set_mode(modes.TRAIN)`.
176176
The different modes available are `modes.TRAIN`, `modes.EVAL` and `modes.PREDICT`.
177177

178+
178179
If the mode was not set, all steps will be available together.
179180

181+
You can choose to have different save configurations (SaveConfigs)
182+
for different modes. You can configure this by passing a
183+
dictionary from mode to SaveConfig object.
184+
The hook's `save_config` parameter accepts such a dictionary, as well as collection's `set_save_config` method.
185+
```
186+
from tornasole.tensorflow import TornasoleHook, get_collection, modes, SaveConfig
187+
scm = {modes.TRAIN: SaveConfig(save_interval=100),
188+
modes.EVAL: SaveConfig(save_interval=10)}
189+
190+
hook = TornasoleHook(...,
191+
save_config=scm,
192+
...)
193+
```
194+
195+
```
196+
from tornasole.tensorflow import get_collection, modes, SaveConfig
197+
get_collection('weights').set_save_config({modes.TRAIN: SaveConfig(save_interval=10),
198+
modes.EVAL: SaveConfig(save_interval=1000)}
199+
```
180200
#### Collection
181201
Collection object helps group tensors for easier handling of tensors being saved.
182202
A collection has its own list of tensors, include regex patterns, [reduction config](#reductionconfig) and [save config](#saveconfig).

docs/mxnet/api.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ TornasoleHook is the entry point for Tornasole into your program.
2828
name of worker in a multi process training job
2929
outputs and tensors are organized by this name during retrieval.
3030
31-
save_config: SaveConfig object
31+
save_config: SaveConfig object or a dictionary from mode to SaveConfig objects
3232
SaveConfig allows you to customize when tensors are saved.
3333
Hook takes SaveConfig object which is applied as
3434
default for all included tensors.
3535
A collection can optionally have its own SaveConfig object
3636
which overrides this for its tensors.
37+
If you pass a dictionary from mode->SaveConfig, then that
38+
SaveConfig is applied to tensors included for that mode.
39+
example: {modes.TRAIN: SaveConfig(save_interval=10),
40+
modes.EVAL:SaveConfig(save_interval=1)}
3741
Refer to documentation for SaveConfig.
3842
3943
reduction_config: ReductionConfig object
@@ -121,7 +125,7 @@ The following methods can be called on a collection object.
121125
| ```coll.add_block_tensors(block, input=False, output=False)``` | Takes an instance Gluon block, input and output flags. Users can use this Collection to log input/output tensors for a specific block |
122126
| ```coll.get_include_regex()``` | Returns include_regex for the collection |
123127
| ```coll.get_save_config()``` | Returns save config for the collection |
124-
| ```coll.set_save_config(s)``` | Sets save config for the collection |
128+
| ```coll.set_save_config(s)``` | Sets save config for the collection. You can either pass a SaveConfig instance or a dictionary from mode to SaveConfig |
125129
| ```coll.get_reduction_config()``` | Returns reduction config for the collection |
126130
| ```coll.set_reduction_config()``` | Sets reduction config for the collection |
127131

docs/pytorch/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,26 @@ The different modes available are `modes.TRAIN`, `modes.EVAL` and `modes.PREDICT
196196

197197
If the mode was not set, all steps will be available together.
198198

199+
You can choose to have different save configurations (SaveConfigs)
200+
for different modes. You can configure this by passing a
201+
dictionary from mode to SaveConfig object.
202+
The hook's `save_config` parameter accepts such a dictionary, as well as collection's `set_save_config` method.
203+
```
204+
from tornasole.tensorflow import TornasoleHook, get_collection, modes, SaveConfig
205+
scm = {modes.TRAIN: SaveConfig(save_interval=100),
206+
modes.EVAL: SaveConfig(save_interval=10)}
207+
208+
hook = TornasoleHook(...,
209+
save_config=scm,
210+
...)
211+
```
212+
213+
```
214+
from tornasole.tensorflow import get_collection, modes, SaveConfig
215+
get_collection('weights').set_save_config({modes.TRAIN: SaveConfig(save_interval=10),
216+
modes.EVAL: SaveConfig(save_interval=1000)}
217+
```
218+
199219
#### Collection
200220
Collection object helps group tensors for easier handling of tensors being saved.
201221
A collection has its own list of tensors, include regex patterns, [reduction config](#reductionconfig) and [save config](#saveconfig).

docs/pytorch/api.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ A class used to represent the hook which gets attached to the
2222
when dry_run is set to True, behavior is only described in the log file.
2323
The tensors are not actually saved.
2424
25-
save_config: SaveConfig object
25+
save_config: SaveConfig object or a dictionary from mode to SaveConfig objects
2626
SaveConfig allows you to customize when tensors are saved.
27-
Hook Ttkes SaveConfig object which is applied as
27+
Hook takes SaveConfig object which is applied as
2828
default for all included tensors.
2929
A collection can optionally have its own SaveConfig object
3030
which overrides this for its tensors.
31+
If you pass a dictionary from mode->SaveConfig, then that
32+
SaveConfig is applied to tensors included for that mode.
33+
example: {modes.TRAIN: SaveConfig(save_interval=10),
34+
modes.EVAL:SaveConfig(save_interval=1)}
3135
Refer to documentation for SaveConfig.
3236
3337
include_regex: list of (str or tensor variables)
@@ -93,7 +97,7 @@ The following methods can be called on a collection object.
9397
| ```coll.add(t)``` | Takes an instance or list or set of tf.Operation/tf.Variable/tf.Tensor to add to the collection |
9498
| ```coll.get_include_regex()``` | Returns include_regex for the collection |
9599
| ```coll.get_save_config()``` | Returns save config for the collection |
96-
| ```coll.set_save_config(s)``` | Sets save config for the collection |
100+
| ```coll.set_save_config(s)``` | Sets save config for the collection. You can either pass a SaveConfig instance or a dictionary from mode to SaveConfig |
97101
| ```coll.get_reduction_config()``` | Returns reduction config for the collection |
98102
| ```coll.set_reduction_config()``` | Sets reduction config for the collection |
99103
| ```coll.add_module_tensors(module, input=False, output=False)``` | Takes an instance of a module, along with input and output flags. Users can use this Collection to log input/output tensors for a specific module |

docs/tensorflow/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ The different modes available are `modes.TRAIN`, `modes.EVAL` and `modes.PREDICT
283283

284284
If the mode was not set, all steps will be available together.
285285

286+
You can choose to have different save configurations (SaveConfigs)
287+
for different modes. You can configure this by passing a
288+
dictionary from mode to SaveConfig object.
289+
The hook's `save_config` parameter accepts such a dictionary, as well as collection's `set_save_config` method.
290+
```
291+
from tornasole.tensorflow import TornasoleHook, get_collection, modes, SaveConfig
292+
scm = {modes.TRAIN: SaveConfig(save_interval=100),
293+
modes.EVAL: SaveConfig(save_interval=10)}
294+
295+
hook = TornasoleHook(...,
296+
save_config=scm,
297+
...)
298+
```
299+
300+
```
301+
from tornasole.tensorflow import get_collection, modes, SaveConfig
302+
get_collection('weights').set_save_config({modes.TRAIN: SaveConfig(save_interval=10),
303+
modes.EVAL: SaveConfig(save_interval=1000)}
304+
```
305+
286306
#### Collection
287307
Collection object helps group tensors for easier handling of tensors being saved.
288308
A collection has its own list of tensors, include/exclude regex patterns, reduction config and save config.

docs/tensorflow/api.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ class TornasoleHook:
2929
name of worker in a multi process training job
3030
outputs and tensors are organized by this name during retrieval.
3131
32-
save_config: SaveConfig object
32+
save_config: SaveConfig object or a dictionary from mode to SaveConfig objects
3333
SaveConfig allows you to customize when tensors are saved.
3434
Hook takes SaveConfig object which is applied as
3535
default for all included tensors.
3636
A collection can optionally have its own SaveConfig object
3737
which overrides this for its tensors.
38+
If you pass a dictionary from mode->SaveConfig, then that
39+
SaveConfig is applied to tensors included for that mode.
40+
example: {modes.TRAIN: SaveConfig(save_interval=10),
41+
modes.EVAL:SaveConfig(save_interval=1)}
3842
Refer to documentation for SaveConfig.
3943
4044
reduction_config: ReductionConfig object
@@ -109,7 +113,7 @@ The following methods can be called on a collection object.
109113
| ```coll.add(t)``` | Takes an instance or list or set of tf.Operation/tf.Variable/tf.Tensor to add to the collection |
110114
| ```coll.get_include_regex()``` | Returns include_regex for the collection |
111115
| ```coll.get_save_config()``` | Returns save config for the collection |
112-
| ```coll.set_save_config(s)``` | Sets save config for the collection |
116+
| ```coll.set_save_config(s)``` | Sets save config for the collection. You can either pass a SaveConfig instance or a dictionary from mode to SaveConfig |
113117
| ```coll.get_reduction_config()``` | Returns reduction config for the collection |
114118
| ```coll.set_reduction_config()``` | Sets reduction config for the collection |
115119

setup.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,29 @@ def get_framework_packages(f):
1616
return ['tornasole.' + f + '*', 'tests.' + f + '*']
1717

1818
def get_frameworks_to_build():
19+
only_rules = os.environ.get('TORNASOLE_FOR_RULES', False)
20+
if only_rules in ['1', 'True', 'true']:
21+
only_rules = True
22+
else:
23+
only_rules = False
24+
1925
with_frameworks = {}
20-
for f in FRAMEWORKS:
21-
with_frameworks[f] = os.environ.get('TORNASOLE_WITH_' + f.upper(), False)
22-
if with_frameworks[f] in ['1', 'True', 'true']:
23-
with_frameworks[f] = True
24-
else:
25-
with_frameworks[f] = False
26-
enabled_some_framework = any(with_frameworks.values())
27-
if not enabled_some_framework:
28-
print('Building for all frameworks in one package')
26+
if not only_rules:
2927
for f in FRAMEWORKS:
30-
with_frameworks[f] = True
28+
with_frameworks[f] = os.environ.get('TORNASOLE_WITH_' + f.upper(), False)
29+
if with_frameworks[f] in ['1', 'True', 'true']:
30+
with_frameworks[f] = True
31+
else:
32+
with_frameworks[f] = False
33+
enabled_some_framework = any(with_frameworks.values())
34+
35+
if not enabled_some_framework:
36+
print('Building for all frameworks in one package')
37+
for f in FRAMEWORKS:
38+
with_frameworks[f] = True
39+
else:
40+
for f in FRAMEWORKS:
41+
with_frameworks[f] = False
3142
return with_frameworks
3243

3344
def get_packages_to_include(frameworks_to_build):

tests/analysis/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
- mxnet
105105
- *Enable
106106
- [*mnist_gluon_vg_demo, # this training script will generate 1300 steps
107-
--random_seed True --num_steps 33 --tornasole_frequency 30,
107+
--random_seed True --num_steps 33 --tornasole_frequency 30,
108108
*invoker,
109109
--rule_name vanishinggradient --flag True --start_step 1 --end_step 31
110110
] # notice, step 0 always returns False

tests/core/test_training_end.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
from tornasole.core.access_layer.utils import has_training_ended
2-
from tornasole.core.access_layer.utils import training_has_ended
1+
from tornasole.core.access_layer.utils import has_training_ended, \
2+
training_has_ended, delete_s3_prefixes
33
import shutil
4-
import boto3
54
from tornasole.core.utils import is_s3
65
from tornasole.core.access_layer.file import ensure_dir
7-
8-
def del_s3(bucket,file_path):
9-
s3_client = boto3.client('s3')
10-
s3_client.delete_object(Bucket=bucket, Key=file_path)
6+
from tornasole.core.access_layer.s3 import TSAccessS3
117

128
def test_local_training_end():
13-
localdir = "./training_end_test_dir"
9+
localdir = "/tmp/training_end_test_dir"
10+
ensure_dir(localdir, is_file=False)
1411
training_has_ended(localdir)
1512
assert has_training_ended(localdir) == True
1613
shutil.rmtree(localdir)
1714

1815
def test_negative_local_training_end():
19-
localdir = "./training_end_test_dir_negative"
16+
localdir = "/tmp/training_end_test_dir_negative"
2017
assert has_training_ended(localdir) == False
2118

2219
def test_s3_training_end():
2320
s3dir = 's3://tornasolecodebuildtest/training_end_test_dir'
24-
bucket = 'tornasolecodebuildtest'
21+
_, bucket, key = is_s3(s3dir)
22+
f = TSAccessS3(bucket_name=bucket, key_name=key)
23+
f.close()
2524
training_has_ended(s3dir)
2625
assert has_training_ended(s3dir) == True
27-
del_s3(bucket, s3dir)
26+
delete_s3_prefixes(bucket, key)
2827

2928
def test_negative_s3_training_end():
30-
bucket = 'tornasolecodebuildtest'
3129
s3dir = 's3://tornasolecodebuildtest/training_end_test_dir_negative'
3230
assert has_training_ended(s3dir) == False

0 commit comments

Comments
 (0)