Skip to content

Fix ImportError: AlgorithmSpecification and shape classes imported from wrong module#4877

Open
vikeshpandey wants to merge 4 commits intoaws:defaultfrom
vikeshpandey:fix/import-error-sagemaker-core-issue-4862
Open

Fix ImportError: AlgorithmSpecification and shape classes imported from wrong module#4877
vikeshpandey wants to merge 4 commits intoaws:defaultfrom
vikeshpandey:fix/import-error-sagemaker-core-issue-4862

Conversation

@vikeshpandey
Copy link
Copy Markdown
Contributor

Summary

Fixes ImportError: cannot import name 'AlgorithmSpecification' from 'sagemaker_core.resources' in sagemaker-core/inference_and_resource_chaining.ipynb.

  • AlgorithmSpecification, Channel, DataSource, S3DataSource, OutputDataConfig, ResourceConfig, and StoppingCondition are shapes, not resources
  • They must be imported from sagemaker_core.shapes, not sagemaker_core.resources
  • TrainingJob remains correctly imported from sagemaker_core.resources

Before:

from sagemaker_core.resources import (
    TrainingJob,
    AlgorithmSpecification,  # ❌ wrong module
    Channel,                 # ❌ wrong module
    ...
)

After:

from sagemaker_core.resources import TrainingJob
from sagemaker_core.shapes import (
    AlgorithmSpecification,  # ✅ correct module
    Channel,                 # ✅ correct module
    ...
)

Closes #4862

- Remove incomplete `s3_client =` assignment (unused variable)
- Add missing `Endpoint.create()` cell before wait_for_status
- Add missing `import boto3` before boto3.client usage
- Fix S3 key path: output/train/test.csv -> output/test/test.csv
- Fix endpoint response access: res["Body"] -> res.body (sagemaker-core SDK)
- Define missing print_performance_metrics() function

Fixes aws#4872
AlgorithmSpecification, Channel, DataSource, S3DataSource, OutputDataConfig,
ResourceConfig, and StoppingCondition are shapes, not resources. They must be
imported from sagemaker_core.shapes, not sagemaker_core.resources.

TrainingJob remains correctly imported from sagemaker_core.resources.

Fixes aws#4862
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] ImportError: cannot import name 'AlgorithmSpecification' from 'sagemaker_core.resources' error

1 participant