|
29 | 29 | CONSTRAINT_VIOLATIONS_JSON_DEFAULT_FILE_NAME, |
30 | 30 | DEFAULT_REPOSITORY_NAME, |
31 | 31 | ) |
| 32 | +from sagemaker.core.model_monitor.dataset_format import MonitoringDatasetFormat |
32 | 33 | from sagemaker.core.processing import ProcessingInput, ProcessingOutput |
33 | 34 | from sagemaker.core.shapes import ProcessingS3Input, ProcessingS3Output |
34 | 35 | from sagemaker.core.network import NetworkConfig |
@@ -140,8 +141,81 @@ def test_to_request_dict_minimal(self): |
140 | 141 |
|
141 | 142 | class TestBatchTransformInput: |
142 | 143 | def test_init_minimal(self): |
143 | | - # Skip this test as BatchTransformInput has initialization issues in the source code |
144 | | - pytest.skip("BatchTransformInput has initialization issues in the source code") |
| 144 | + bti = BatchTransformInput( |
| 145 | + data_captured_destination_s3_uri="s3://bucket/captured", |
| 146 | + destination="/opt/ml/processing/input", |
| 147 | + dataset_format=MonitoringDatasetFormat.csv(header=False), |
| 148 | + ) |
| 149 | + assert bti.data_captured_destination_s3_uri == "s3://bucket/captured" |
| 150 | + assert bti.destination == "/opt/ml/processing/input" |
| 151 | + assert bti.s3_input_mode == "File" |
| 152 | + assert bti.s3_data_distribution_type == "FullyReplicated" |
| 153 | + |
| 154 | + def test_init_with_all_parameters(self): |
| 155 | + bti = BatchTransformInput( |
| 156 | + data_captured_destination_s3_uri="s3://bucket/captured", |
| 157 | + destination="/opt/ml/processing/input", |
| 158 | + dataset_format=MonitoringDatasetFormat.csv(header=False), |
| 159 | + s3_input_mode="Pipe", |
| 160 | + s3_data_distribution_type="ShardedByS3Key", |
| 161 | + start_time_offset="-PT1H", |
| 162 | + end_time_offset="-PT0H", |
| 163 | + features_attribute="features", |
| 164 | + inference_attribute="prediction", |
| 165 | + probability_attribute="probability", |
| 166 | + probability_threshold_attribute=0.5, |
| 167 | + exclude_features_attribute="feature1,feature2", |
| 168 | + ) |
| 169 | + assert bti.s3_input_mode == "Pipe" |
| 170 | + assert bti.start_time_offset == "-PT1H" |
| 171 | + assert bti.features_attribute == "features" |
| 172 | + |
| 173 | + def test_to_request_dict_minimal(self): |
| 174 | + bti = BatchTransformInput( |
| 175 | + data_captured_destination_s3_uri="s3://bucket/captured", |
| 176 | + destination="/opt/ml/processing/input", |
| 177 | + dataset_format=MonitoringDatasetFormat.csv(header=False), |
| 178 | + ) |
| 179 | + request_dict = bti._to_request_dict() |
| 180 | + assert "BatchTransformInput" in request_dict |
| 181 | + payload = request_dict["BatchTransformInput"] |
| 182 | + assert payload["DataCapturedDestinationS3Uri"] == "s3://bucket/captured" |
| 183 | + assert payload["LocalPath"] == "/opt/ml/processing/input" |
| 184 | + assert payload["S3InputMode"] == "File" |
| 185 | + assert payload["S3DataDistributionType"] == "FullyReplicated" |
| 186 | + |
| 187 | + def test_to_request_dict_excludes_none_values(self): |
| 188 | + bti = BatchTransformInput( |
| 189 | + data_captured_destination_s3_uri="s3://bucket/captured", |
| 190 | + destination="/opt/ml/processing/input", |
| 191 | + dataset_format=MonitoringDatasetFormat.csv(header=False), |
| 192 | + ) |
| 193 | + payload = bti._to_request_dict()["BatchTransformInput"] |
| 194 | + assert "StartTimeOffset" not in payload |
| 195 | + assert "EndTimeOffset" not in payload |
| 196 | + assert "FeaturesAttribute" not in payload |
| 197 | + assert "InferenceAttribute" not in payload |
| 198 | + assert "ProbabilityAttribute" not in payload |
| 199 | + assert "ProbabilityThresholdAttribute" not in payload |
| 200 | + assert "ExcludeFeaturesAttribute" not in payload |
| 201 | + |
| 202 | + def test_to_request_dict_includes_optional_values(self): |
| 203 | + bti = BatchTransformInput( |
| 204 | + data_captured_destination_s3_uri="s3://bucket/captured", |
| 205 | + destination="/opt/ml/processing/input", |
| 206 | + dataset_format=MonitoringDatasetFormat.csv(header=False), |
| 207 | + start_time_offset="-PT1H", |
| 208 | + end_time_offset="-PT0H", |
| 209 | + probability_attribute="probability", |
| 210 | + probability_threshold_attribute=0.5, |
| 211 | + exclude_features_attribute="f1,f2", |
| 212 | + ) |
| 213 | + payload = bti._to_request_dict()["BatchTransformInput"] |
| 214 | + assert payload["StartTimeOffset"] == "-PT1H" |
| 215 | + assert payload["EndTimeOffset"] == "-PT0H" |
| 216 | + assert payload["ProbabilityAttribute"] == "probability" |
| 217 | + assert payload["ProbabilityThresholdAttribute"] == 0.5 |
| 218 | + assert payload["ExcludeFeaturesAttribute"] == "f1,f2" |
145 | 219 |
|
146 | 220 |
|
147 | 221 | class TestBaseliningJob: |
|
0 commit comments