21
21
import pytest
22
22
import time
23
23
24
- @pytest .mark .skip (reason = """This test operates on the root file system
24
+
25
+ @pytest .mark .skip (
26
+ reason = """This test operates on the root file system
25
27
and will likely fail due to permission errors.
26
28
Temporarily remove this skip decorator and run
27
- the test after making changes to _repack_model.py""" )
29
+ the test after making changes to _repack_model.py"""
30
+ )
28
31
def test_repack_entry_point_only (tmp ):
29
32
model_name = "xg-boost-model"
30
33
fake_model_path = os .path .join (tmp , model_name )
@@ -51,19 +54,19 @@ def test_repack_entry_point_only(tmp):
51
54
)
52
55
53
56
# repack
54
- _repack_model .repack (
55
- inference_script = "inference.py" ,
56
- model_archive = model_tar_name
57
- )
57
+ _repack_model .repack (inference_script = "inference.py" , model_archive = model_tar_name )
58
58
59
59
# /opt/ml/model should now have the original model and the inference script
60
60
assert os .path .exists (os .path .join ("/opt/ml/model" , model_name ))
61
61
assert os .path .exists (os .path .join ("/opt/ml/model/code" , "inference.py" ))
62
62
63
- @pytest .mark .skip (reason = """This test operates on the root file system
63
+
64
+ @pytest .mark .skip (
65
+ reason = """This test operates on the root file system
64
66
and will likely fail due to permission errors.
65
67
Temporarily remove this skip decorator and run
66
- the test after making changes to _repack_model.py""" )
68
+ the test after making changes to _repack_model.py"""
69
+ )
67
70
def test_repack_with_dependencies (tmp ):
68
71
model_name = "xg-boost-model"
69
72
fake_model_path = os .path .join (tmp , model_name )
@@ -84,19 +87,14 @@ def test_repack_with_dependencies(tmp):
84
87
# create files that will be added to model.tar.gz
85
88
create_file_tree (
86
89
"/opt/ml/code" ,
87
- [
88
- "inference.py" ,
89
- "dependencies/a" ,
90
- "bb" ,
91
- "dependencies/some/dir/b"
92
- ],
90
+ ["inference.py" , "dependencies/a" , "bb" , "dependencies/some/dir/b" ],
93
91
)
94
92
95
93
# repack
96
94
_repack_model .repack (
97
95
inference_script = "inference.py" ,
98
96
model_archive = model_tar_name ,
99
- dependencies = ["dependencies/a" , "bb" , "dependencies/some/dir" ]
97
+ dependencies = ["dependencies/a" , "bb" , "dependencies/some/dir" ],
100
98
)
101
99
102
100
# /opt/ml/model should now have the original model and the inference script
@@ -106,10 +104,13 @@ def test_repack_with_dependencies(tmp):
106
104
assert os .path .exists (os .path .join ("/opt/ml/model/code/lib" , "bb" ))
107
105
assert os .path .exists (os .path .join ("/opt/ml/model/code/lib/dir" , "b" ))
108
106
109
- @pytest .mark .skip (reason = """This test operates on the root file system
107
+
108
+ @pytest .mark .skip (
109
+ reason = """This test operates on the root file system
110
110
and will likely fail due to permission errors.
111
111
Temporarily remove this skip decorator and run
112
- the test after making changes to _repack_model.py""" )
112
+ the test after making changes to _repack_model.py"""
113
+ )
113
114
def test_repack_with_source_dir_and_dependencies (tmp ):
114
115
model_name = "xg-boost-model"
115
116
fake_model_path = os .path .join (tmp , model_name )
@@ -136,7 +137,7 @@ def test_repack_with_source_dir_and_dependencies(tmp):
136
137
"bb" ,
137
138
"dependencies/some/dir/b" ,
138
139
"sourcedir/foo.py" ,
139
- "sourcedir/some/dir/a"
140
+ "sourcedir/some/dir/a" ,
140
141
],
141
142
)
142
143
@@ -145,7 +146,7 @@ def test_repack_with_source_dir_and_dependencies(tmp):
145
146
inference_script = "inference.py" ,
146
147
model_archive = model_tar_name ,
147
148
dependencies = ["dependencies/a" , "bb" , "dependencies/some/dir" ],
148
- source_dir = "sourcedir"
149
+ source_dir = "sourcedir" ,
149
150
)
150
151
151
152
# /opt/ml/model should now have the original model and the inference script
0 commit comments