Skip to content

Commit 379b843

Browse files
committed
feature: PartnerAppAuthProvider class support missing in 3.x (similar to 2.x) (5475)
1 parent 6497a94 commit 379b843

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

sagemaker-core/src/sagemaker/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Partner App
1616
from sagemaker.core.partner_app.auth_provider import PartnerAppAuthProvider # noqa: F401
17+
from sagemaker.core.partner_app.auth_provider import RequestsAuth # noqa: F401
1718

1819
# Attribution
1920
from sagemaker.core.telemetry.attribution import Attribution, set_attribution # noqa: F401

sagemaker-core/src/sagemaker/core/partner_app/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""__init__ file for sagemaker.core.partner_app"""
14-
from __future__ import absolute_import
14+
from __future__ import annotations
1515

1616
from sagemaker.core.partner_app.auth_provider import PartnerAppAuthProvider # noqa: F401
17+
from sagemaker.core.partner_app.auth_provider import RequestsAuth # noqa: F401
18+
from sagemaker.core.partner_app.auth_utils import PartnerAppAuthUtils # noqa: F401

sagemaker-core/src/sagemaker/core/partner_app/auth_provider.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
# language governing permissions and limitations under the License.
1313

1414
"""The SageMaker partner application SDK auth module"""
15-
from __future__ import absolute_import
15+
from __future__ import annotations
1616

17+
import logging
1718
import os
1819
import re
1920
from typing import Dict, Tuple
@@ -25,6 +26,8 @@
2526
from requests.models import PreparedRequest
2627
from sagemaker.core.partner_app.auth_utils import PartnerAppAuthUtils
2728

29+
logger = logging.getLogger(__name__)
30+
2831
SERVICE_NAME = "sagemaker"
2932
AWS_PARTNER_APP_ARN_REGEX = r"arn:aws[a-z\-]*:sagemaker:[a-z0-9\-]*:[0-9]{12}:partner-app\/.*"
3033

@@ -94,6 +97,7 @@ def __init__(self, credentials: Credentials = None):
9497
credentials if credentials is not None else boto3.Session().get_credentials()
9598
)
9699
self.sigv4 = SigV4Auth(self.credentials, SERVICE_NAME, self.region)
100+
logger.info("PartnerAppAuthProvider initialized for region: %s", self.region)
97101

98102
def get_signed_request(
99103
self, url: str, method: str, headers: dict, body: object
@@ -109,6 +113,7 @@ def get_signed_request(
109113
Returns:
110114
tuple: (url, headers)
111115
"""
116+
logger.debug("Signing request: %s %s", method, url)
112117
return PartnerAppAuthUtils.get_signed_request(
113118
sigv4=self.sigv4,
114119
app_arn=self.app_arn,

sagemaker-core/src/sagemaker/core/partner_app/auth_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313

1414
"""Partner App Auth Utils Module"""
1515

16-
from __future__ import absolute_import
16+
from __future__ import annotations
1717

18+
import logging
1819
from hashlib import sha256
1920
import functools
2021
from typing import Tuple, Dict
2122

2223
from botocore.auth import SigV4Auth
2324
from botocore.awsrequest import AWSRequest
2425

26+
logger = logging.getLogger(__name__)
27+
2528
HEADER_CONNECTION = "Connection"
2629
HEADER_X_AMZ_TARGET = "X-Amz-Target"
2730
HEADER_AUTHORIZATION = "Authorization"

0 commit comments

Comments
 (0)