def test_statistics_object_creation_from_s3_uri_without_customizations(
        sagemaker_session):
    with open(os.path.join(tests.integ.DATA_DIR, "monitor/statistics.json"),
              "r") as f:
        file_body = f.read()

    file_name = "statistics.json"
    desired_s3_uri = os.path.join(
        "s3://",
        sagemaker_session.default_bucket(),
        "integ-test-test-monitoring-files",
        str(uuid.uuid4()),
        file_name,
    )

    s3_uri = S3Uploader.upload_string_as_file_body(
        body=file_body,
        desired_s3_uri=desired_s3_uri,
        sagemaker_session=sagemaker_session)

    statistics = Statistics.from_s3_uri(statistics_file_s3_uri=s3_uri,
                                        sagemaker_session=sagemaker_session)

    assert statistics.file_s3_uri.startswith("s3://")
    assert statistics.file_s3_uri.endswith("statistics.json")

    assert statistics.body_dict["dataset"]["item_count"] == 418
def test_statistics_object_creation_from_file_path_without_customizations():
    statistics = Statistics.from_file_path(statistics_file_path=os.path.join(
        tests.integ.DATA_DIR, "monitor/statistics.json"))

    assert statistics.file_s3_uri.startswith("s3://")
    assert statistics.file_s3_uri.endswith("statistics.json")

    assert statistics.body_dict["dataset"]["item_count"] == 418
Пример #3
0
def test_statistics_object_creation_from_string_without_customizations():
    with open(os.path.join(tests.integ.DATA_DIR, "monitor/statistics.json"), "r") as f:
        file_body = f.read()

    statistics = Statistics.from_string(statistics_file_string=file_body)

    assert statistics.file_s3_uri.startswith("s3://")
    assert statistics.file_s3_uri.endswith("statistics.json")

    assert statistics.body_dict["dataset"]["item_count"] == 418
def test_statistics_object_creation_from_file_path_with_customizations(
        sagemaker_session, monitoring_files_kms_key):
    statistics = Statistics.from_file_path(
        statistics_file_path=os.path.join(tests.integ.DATA_DIR,
                                          "monitor/statistics.json"),
        kms_key=monitoring_files_kms_key,
        sagemaker_session=sagemaker_session,
    )

    assert statistics.file_s3_uri.startswith("s3://")
    assert statistics.file_s3_uri.endswith("statistics.json")

    assert statistics.body_dict["dataset"]["item_count"] == 418
def test_statistics_object_creation_from_string_with_customizations(
        sagemaker_session, monitoring_files_kms_key):
    with open(os.path.join(tests.integ.DATA_DIR, "monitor/statistics.json"),
              "r") as f:
        file_body = f.read()

    statistics = Statistics.from_string(
        statistics_file_string=file_body,
        kms_key=monitoring_files_kms_key,
        file_name="statistics.json",
        sagemaker_session=sagemaker_session,
    )

    assert statistics.file_s3_uri.startswith("s3://")
    assert statistics.file_s3_uri.endswith("statistics.json")

    assert statistics.body_dict["dataset"]["item_count"] == 418