|
12 | 12 | # language governing permissions and limitations under the License.
|
13 | 13 | from __future__ import absolute_import
|
14 | 14 |
|
15 |
| -import boto3 |
16 |
| -import os |
17 |
| - |
18 |
| -from sagemaker import Session |
19 | 15 | from sagemaker.experiments.trial_component import _TrialComponent
|
20 | 16 | from sagemaker.remote_function import RemoteExecutor
|
21 | 17 | from sagemaker.remote_function.client import get_future, list_futures
|
@@ -85,17 +81,13 @@ def test_executor_submit_with_run_inside(
|
85 | 81 | sagemaker_session, dummy_container_without_error, cpu_instance_type
|
86 | 82 | ):
|
87 | 83 | def square(x):
|
88 |
| - boto_session = boto3.Session(region_name=os.environ["AWS_REGION"]) |
89 |
| - sm_session = Session(boto_session=boto_session) |
90 |
| - with load_run(sagemaker_session=sm_session) as run: |
| 84 | + with load_run() as run: |
91 | 85 | result = x * x
|
92 | 86 | run.log_metric("x", result)
|
93 | 87 | return result
|
94 | 88 |
|
95 | 89 | def cube(x):
|
96 |
| - boto_session = boto3.Session(region_name=os.environ["AWS_REGION"]) |
97 |
| - sm_session = Session(boto_session=boto_session) |
98 |
| - with load_run(sagemaker_session=sm_session) as run: |
| 90 | + with load_run() as run: |
99 | 91 | result = x * x * x
|
100 | 92 | run.log_metric("x", result)
|
101 | 93 | return result
|
@@ -148,17 +140,13 @@ def test_executor_submit_with_run_outside(
|
148 | 140 | sagemaker_session, dummy_container_without_error, cpu_instance_type
|
149 | 141 | ):
|
150 | 142 | def square(x):
|
151 |
| - boto_session = boto3.Session(region_name=os.environ["AWS_REGION"]) |
152 |
| - sm_session = Session(boto_session=boto_session) |
153 |
| - with load_run(sagemaker_session=sm_session) as run: |
| 143 | + with load_run() as run: |
154 | 144 | result = x * x
|
155 | 145 | run.log_metric("x", result)
|
156 | 146 | return result
|
157 | 147 |
|
158 | 148 | def cube(x):
|
159 |
| - boto_session = boto3.Session(region_name=os.environ["AWS_REGION"]) |
160 |
| - sm_session = Session(boto_session=boto_session) |
161 |
| - with load_run(sagemaker_session=sm_session) as run: |
| 149 | + with load_run() as run: |
162 | 150 | result = x * x * x
|
163 | 151 | run.log_metric("x", result)
|
164 | 152 | return result
|
@@ -209,9 +197,7 @@ def cube(x):
|
209 | 197 |
|
210 | 198 | def test_executor_map_with_run(sagemaker_session, dummy_container_without_error, cpu_instance_type):
|
211 | 199 | def square(x):
|
212 |
| - boto_session = boto3.Session(region_name=os.environ["AWS_REGION"]) |
213 |
| - sm_session = Session(boto_session=boto_session) |
214 |
| - with load_run(sagemaker_session=sm_session) as run: |
| 200 | + with load_run() as run: |
215 | 201 | result = x * x
|
216 | 202 | run.log_metric("x", result)
|
217 | 203 | return result
|
|
0 commit comments