|
14 | 14 |
|
15 | 15 | import os
|
16 | 16 | import pytest
|
| 17 | +from sagemaker.xgboost import XGBoost |
17 | 18 | from sagemaker.xgboost.processing import XGBoostProcessor
|
18 | 19 | from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
|
19 | 20 | from tests.integ.timeout import timeout
|
@@ -48,3 +49,37 @@ def test_framework_processing_job_with_deps(
|
48 | 49 | inputs=[],
|
49 | 50 | wait=True,
|
50 | 51 | )
|
| 52 | + |
| 53 | + |
| 54 | +def test_training_with_network_isolation( |
| 55 | + sagemaker_session, |
| 56 | + xgboost_latest_version, |
| 57 | + xgboost_latest_py_version, |
| 58 | + cpu_instance_type, |
| 59 | +): |
| 60 | + with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES): |
| 61 | + base_job_name = "test-network-isolation-xgboost" |
| 62 | + |
| 63 | + xgboost = XGBoost( |
| 64 | + entry_point=os.path.join(DATA_DIR, "xgboost_abalone", "abalone.py"), |
| 65 | + role=ROLE, |
| 66 | + instance_type=cpu_instance_type, |
| 67 | + instance_count=1, |
| 68 | + framework_version=xgboost_latest_version, |
| 69 | + py_version=xgboost_latest_py_version, |
| 70 | + base_job_name=base_job_name, |
| 71 | + sagemaker_session=sagemaker_session, |
| 72 | + enable_network_isolation=True, |
| 73 | + ) |
| 74 | + |
| 75 | + train_input = xgboost.sagemaker_session.upload_data( |
| 76 | + path=os.path.join(DATA_DIR, "xgboost_abalone", "abalone"), |
| 77 | + key_prefix="integ-test-data/xgboost_abalone/abalone" |
| 78 | + ) |
| 79 | + xgboost.fit( |
| 80 | + inputs={"train": train_input}, |
| 81 | + job_name=unique_name_from_base(base_job_name) |
| 82 | + ) |
| 83 | + assert sagemaker_session.sagemaker_client.describe_training_job(TrainingJobName=job_name)[ |
| 84 | + "EnableNetworkIsolation" |
| 85 | + ] |
0 commit comments