{"id":3698,"library":"mypy-boto3-sagemaker-metrics","title":"mypy-boto3-sagemaker-metrics type annotations","description":"mypy-boto3-sagemaker-metrics provides PEP 561 compatible type annotations for the boto3 AWS SDK's SageMakerMetrics service. It enhances development with static type checking, improved IDE auto-completion, and early error detection for SageMakerMetrics client operations. The library is actively maintained, with versions typically aligned with boto3 releases and generated by mypy-boto3-builder.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","sagemaker","metrics","types","mypy","stub","type-annotations","pep-561"],"install":[{"cmd":"pip install mypy-boto3-sagemaker-metrics","lang":"bash","label":"Install the type stubs"},{"cmd":"pip install boto3","lang":"bash","label":"Install the runtime library (required)"}],"dependencies":[{"reason":"Provides the actual runtime functionality for interacting with AWS services.","package":"boto3","optional":false},{"reason":"May be required for full type compatibility on Python versions older than 3.10, although recent builder versions aim to manage this automatically. Typically not needed for Python >=3.9.","package":"typing-extensions","optional":true}],"imports":[{"note":"The type stub provides the type hint for the client returned by `boto3.client`.","symbol":"SageMakerMetricsClient","correct":"from mypy_boto3_sagemaker_metrics.client import SageMakerMetricsClient\nimport boto3\n\nclient: SageMakerMetricsClient = boto3.client(\"sagemaker-metrics\")"},{"note":"TypedDicts are provided for request/response bodies for enhanced type checking.","symbol":"BatchPutMetricsResponseTypeDef","correct":"from mypy_boto3_sagemaker_metrics.type_defs import BatchPutMetricsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom datetime import datetime\nfrom mypy_boto3_sagemaker_metrics.client import SageMakerMetricsClient\n\n\ndef put_example_metrics(trial_component_name: str):\n    client: SageMakerMetricsClient = boto3.client(\"sagemaker-metrics\")\n\n    response = client.batch_put_metrics(\n        TrialComponentName=trial_component_name,\n        MetricData=[\n            {\n                'MetricName': 'accuracy',\n                'Timestamp': datetime.now(),\n                'Step': 0,\n                'Value': 0.95\n            },\n            {\n                'MetricName': 'loss',\n                'Timestamp': datetime.now(),\n                'Step': 0,\n                'Value': 0.05\n            },\n        ]\n    )\n\n    print(f\"Successfully put metrics: {response}\")\n\n# Example usage (requires an existing SageMaker Trial Component)\n# try:\n#     put_example_metrics(\"my-trial-component-name\")\n# except Exception as e:\n#     print(f\"Error putting metrics: {e}\")\n\n# Note: Creating a Trial Component is outside the scope of this quickstart.\n# You would typically get this name from a SageMaker training job or experiment.","lang":"python","description":"This quickstart demonstrates how to use the type-hinted SageMakerMetrics client to put batch metrics. It shows the correct way to instantiate a client with explicit type annotation and then call a service method, benefiting from IDE auto-completion and static type checks. Replace `my-trial-component-name` with an actual SageMaker Trial Component name for execution."},"warnings":[{"fix":"Upgrade your project's Python version to 3.9 or later, or pin an older version of `mypy-boto3-sagemaker-metrics` that supported Python 3.8 if absolute compatibility is needed.","message":"As of `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-sagemaker-metrics` 1.42.3), Python 3.8 support has been explicitly removed. Projects requiring type stubs for this service must use Python 3.9 or newer.","severity":"breaking","affected_versions":">=1.42.3 (generated by builder >=8.12.0)"},{"fix":"Review your code for direct imports of TypeDefs from `mypy-boto3` packages and adjust names according to the new conventions, often found in the `type_defs` submodule.","message":"In `mypy-boto3-builder` 8.9.0, there were breaking changes to TypeDef naming conventions. Specifically, suffixes like `RequestRequestTypeDef` were shortened to `RequestTypeDef`, and `Extra` postfixes were moved. While this specific package's service might not be directly affected, other `mypy-boto3` packages used in conjunction could break.","severity":"breaking","affected_versions":">=1.42.3 (generated by builder >=8.9.0)"},{"fix":"Ensure `boto3` is included in your project's dependencies: `pip install boto3`.","message":"This package provides *only* type annotations for `boto3`. It does not include the `boto3` library itself. You must install `boto3` separately for your code to run at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify your `mypy` configuration (e.g., `pyproject.toml`) is up-to-date and that `mypy-boto3-sagemaker-metrics` is installed in the Python environment used by your type checker. For best results, use `uv` or `pip` for installation.","message":"The `mypy-boto3` libraries migrated to PEP 561 packages. While this generally improves compatibility with type checkers, older `mypy` configurations or non-standard `pip` usage might require explicit configuration or ensuring packages are installed in the environment where `mypy` runs.","severity":"gotcha","affected_versions":">=1.42.3 (generated by builder >=8.12.0)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}