aws / amazon-sagemaker-feedback

Amazon SageMaker Public Feedback Dashboard
Creative Commons Attribution Share Alike 4.0 International
4 stars 1 forks source link

CORS Error in sagemaker studio when using metrics #78

Open david-waterworth opened 1 month ago

david-waterworth commented 1 month ago

Product Version

Issue Description

I have a pipeline that has an evaluation step that produces a json file containing metrics (based on example notebooks)

i.e.

model_metrics = ModelMetrics(
    model_statistics=MetricsSource(
        s3_uri=Join(
            on="/",
            values=[
                evaluation_step.properties.ProcessingOutputConfig.Outputs["evaluation"].S3Output.S3Uri,
                "evaluation.json",
            ],
        ),
        content_type="application/json",
    )
)

register_args = model.register(
    content_types=["application/json"],
    response_types=["application/json"],
    transform_instances=["ml.g4dn.xlarge"],  # g5's not available for batch transform?
    inference_instances=["ml.g4dn.xlarge", "ml.g5.xlarge"],
    model_package_group_name=model_package_group_name,
    approval_status="PendingManualApproval",
    model_metrics=model_metrics,
)

register_model_step = ModelStep(name="RegisterModel", step_args=register_args)

When I navigate to the deployed model, where I expect to see metrics I get a spinner then

image

StackOverflow user @marc-karp suggested I use the browser dev tools and this shows a ton of CORS errors to the evaluation.json uri i.e.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sagemaker-ap-southeast-2-XXX.s3.ap-southeast-2.amazonaws.com/XXX/wk51yik66u6b/Evaluate/output/evaluation/evaluation.json?response-cache-control=No-cache&x-id=GetObject. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 403.

Expected Behavior

Display metrics saved in my s3 bucket

Observed Behavior

Get CORS error

Product Category

Models

Feedback Category

User Interface

Other Details

No response

david-waterworth commented 1 month ago

This isn't a bug, it's fixed by following https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-migrate-ui.html#studio-updated-migrate-cors

But I would at least expect an error message, ideally with a link to the resolution above

poojak13 commented 1 month ago

Thanks @david-waterworth for your feedback. We'll update the error message to include more information.