Currently, we are trying to SK-Learn model from a python script running in a local computer by uploading data to S3 bucket.
from sagemaker.amazon.amazon_estimator import get_image_uri
# container = retrieve(framework='sklearn', region='us-east-1', version="0.23-1")
container = sagemaker.image_uris.get_training_image_uri('us-east-1', 'sklearn', framework_version='0.23-1')
sklearn_estimator = SKLearn(
entry_point="script.py",
# # role=get_execution_role(),
role = role_aws,
instance_count=1,
instance_type="ml.m5.4xlarge",
framework_version=FRAMEWORK_VERSION,
base_job_name="rf-scikit",
metric_definitions=[{"Name": "median-AE", "Regex": "AE-at-50th-percentile: ([0-9.]+).*$"}],
hyperparameters={
"n-estimators": 100,
"min-samples-leaf": 3,
"features": "MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude Longitude",
"target": "target",
},
sagemaker_session=session,
image_uri=container,
image_uri_region='us-east-1',
# output_path=model_output_path,
)
# launch training job, with asynchronous call
path_train_test = 's3://'+bucket_name+'/'+prefix
sklearn_estimator.fit({"train": path_train_test, "test": path_train_test}, wait=False)
'ClientError: An error occurred (IncompleteSignature) when calling the GetCallerIdentity operation:
Credential must have exactly 5 slash-delimited elements, e.g. keyid/date/region/service/term, got
'https://elasticmapreduce.us-east-1b.amazonaws.com//20220406/us-east-1/sts/aws4_request'
The access key and the secret key are passed through the session object via a client and passed to the SK-Learn estimator.
client_sagemaker = boto3.client('sagemaker',
aws_access_key_id=accesskey ,
aws_secret_access_key=access_secret,
)
session = sagemaker.Session(sagemaker_client =client_sagemaker )
The same access key worked for Xgboost model (already available in sagemaker)
Any ideas about the reason ?
Is it possible to try having a default profile setup with your access and secret key (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) rather than passing to boto3 explicitly
Also, can you verify to make sure you're specifying the right values for access_key_id and secret_access_key? This error sometimes shows up if you switch those two values.