File tree Expand file tree Collapse file tree 4 files changed +9
-24
lines changed Expand file tree Collapse file tree 4 files changed +9
-24
lines changed Original file line number Diff line number Diff line change 4
4
5
5
# First Party
6
6
from smdebug .core .logger import get_logger
7
- from smdebug .core .sagemaker_utils import is_sagemaker_job
8
7
9
8
# Local
10
9
from .base import TSAccessBase
11
10
12
- NON_SAGEMAKER_TEMP_PATH_PREFIX = "/tmp"
13
- SAGEMAKER_TEMP_PATH_SUFFIX = ".tmp"
11
+ SMDEBUG_TEMP_PATH_SUFFIX = ".tmp"
14
12
15
13
16
14
def ensure_dir (file_path , is_file = True ):
@@ -23,13 +21,7 @@ def ensure_dir(file_path, is_file=True):
23
21
24
22
25
23
def get_temp_path (file_path ):
26
- directory = os .path .dirname (file_path )
27
- if is_sagemaker_job ():
28
- temp_path = file_path + SAGEMAKER_TEMP_PATH_SUFFIX
29
- else :
30
- if len (file_path ) > 0 and file_path [0 ] == "/" :
31
- file_path = file_path [1 :]
32
- temp_path = os .path .join (NON_SAGEMAKER_TEMP_PATH_PREFIX , file_path )
24
+ temp_path = file_path + SMDEBUG_TEMP_PATH_SUFFIX
33
25
return temp_path
34
26
35
27
Original file line number Diff line number Diff line change @@ -84,11 +84,10 @@ def list_files_in_directory(directory, file_regex=None):
84
84
85
85
86
86
def list_collection_files_in_directory (directory ):
87
- collections_directory = get_path_to_collections (directory )
88
87
import re
89
88
90
- collections_file_regex = re .compile (".*_?collections.json" )
91
- return list_files_in_directory (collections_directory , file_regex = collections_file_regex )
89
+ collections_file_regex = re .compile (".*_?collections.json$ " )
90
+ return list_files_in_directory (directory , file_regex = collections_file_regex )
92
91
93
92
94
93
def serialize_tf_device (device : str ) -> str :
Original file line number Diff line number Diff line change 4
4
# First Party
5
5
from smdebug .core .collection_manager import CollectionManager
6
6
from smdebug .core .index_reader import LocalIndexReader
7
- from smdebug .core .utils import get_path_to_collections , list_files_in_directory
7
+ from smdebug .core .utils import get_path_to_collections , list_collection_files_in_directory
8
8
9
9
# Local
10
10
from .trial import Trial
@@ -37,7 +37,7 @@ def __init__(
37
37
self ._load_tensors ()
38
38
39
39
def _get_collection_files (self ) -> list :
40
- return list_files_in_directory (get_path_to_collections (self .path ))
40
+ return list_collection_files_in_directory (get_path_to_collections (self .path ))
41
41
42
42
def _load_tensors_from_index_tensors (self , index_tensors_dict ):
43
43
for tname in index_tensors_dict :
Original file line number Diff line number Diff line change 5
5
6
6
# First Party
7
7
import smdebug .pytorch as smd
8
- from smdebug .core .access_layer .file import (
9
- NON_SAGEMAKER_TEMP_PATH_PREFIX ,
10
- SAGEMAKER_TEMP_PATH_SUFFIX ,
11
- get_temp_path ,
12
- )
8
+ from smdebug .core .access_layer .file import SMDEBUG_TEMP_PATH_SUFFIX , get_temp_path
13
9
from smdebug .core .access_layer .utils import training_has_ended
14
10
from smdebug .core .hook_utils import verify_and_get_out_dir
15
11
from smdebug .core .utils import SagemakerSimulator , ScriptSimulator
@@ -93,14 +89,12 @@ def test_temp_paths():
93
89
"/opt/ml/output/tensors/events/a/b" ,
94
90
]:
95
91
temp_path = get_temp_path (path )
96
- assert temp_path .endswith (SAGEMAKER_TEMP_PATH_SUFFIX )
97
- assert not temp_path .startswith (NON_SAGEMAKER_TEMP_PATH_PREFIX )
92
+ assert temp_path .endswith (SMDEBUG_TEMP_PATH_SUFFIX )
98
93
99
94
with ScriptSimulator () as sim :
100
95
for path in ["/a/b/c" , "/opt/ml/output/a" , "a/b/c" ]:
101
96
temp_path = get_temp_path (path )
102
- assert not SAGEMAKER_TEMP_PATH_SUFFIX in temp_path
103
- assert temp_path .startswith (NON_SAGEMAKER_TEMP_PATH_PREFIX )
97
+ assert temp_path .endswith (SMDEBUG_TEMP_PATH_SUFFIX )
104
98
105
99
106
100
def test_s3_path_that_exists_without_end_of_job ():
You can’t perform that action at this time.
0 commit comments