question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnknownServiceError: Unknown service: 'personalize-runtime'.

See original GitHub issue

Hi,

I am trying to run real-time recommendations from AWS Personalize campaign in AWS Lambda following below code mentioned in the documentation .

import boto3

if __name__ == "__main__":

    personalizert = boto3.client('personalize-runtime', region_name='us-west-2')

    response=personalizert.get_recommendations(
        campaignArn="Campaign ARN",
        userId='User ID',
        itemId='Item ID')
        
    print("Recommended items")

    for item in response['itemList']:
            print (item['itemId'])

https://docs.aws.amazon.com/personalize/latest/dg/getting-recommendations.html

However I am getting below error:

UnknownServiceError: Unknown service: ‘personalize-runtime’. Valid service names are: acm, acm-pca, alexaforbusiness, amplify, apigateway, apigatewaymanagementapi, apigatewayv2, application-autoscaling, appmesh, appstream, appsync, athena, autoscaling, autoscaling-plans, backup, batch, budgets, ce, chime, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, comprehendmedical, config, connect, cur, datapipeline, datasync, dax, devicefarm, directconnect, discovery, dlm, dms, docdb, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, fsx, gamelift, glacier, globalaccelerator, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kafka, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisanalyticsv2, kinesisvideo, kms, lambda, lex-models, lex-runtime, license-manager, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconnect, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, pinpoint-email, pinpoint-sms-voice, polly, pricing, quicksight, ram, rds, rds-data, redshift, rekognition, resource-groups, resourcegroupstaggingapi, robomaker, route53, route53domains, route53resolver, s3, s3control, sagemaker, sagemaker-runtime, sdb, secretsmanager, securityhub, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, sms-voice, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, transcribe, transfer, translate, waf, waf-regional, workdocs, worklink, workmail, workspaces, xray

Seems like personalize-runtime service is not present in boto3 yet.

Boto3 version used = 1.9.86 Region = us-east-1

Thanks in advance.

Rohan Hodarkar

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
kapiltcommented, Feb 5, 2019

you’ll need to package up the service files for use in lambda, https://docs.aws.amazon.com/personalize/latest/dg/aws-personalize-set-up-aws-cli.html

you’ll typically do that via setting AWS_DATA_PATH per to point to the directory within your lambda upload that contains your uploaded service files. AWS_DATA_PATH=$LAMBDA_TASK_ROOT/path_in_zip/ https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#environment-variable-configuration

0reactions
mfund0commented, May 29, 2019

Here’s one way you can do this – by using Lambda Layers and manually adding the models to the sdk.

Steps:

  1. Create a site-packages lib directory
LIB=boto3-with-personalize/python/lib/python3.6/site-packages 
mkdir -p $LIB 
  1. Install the library to LIB
pip3 install boto3 -t $LIB 
  1. Download the service models, rename them & put them in the botcore/data directory
wget -N https://s3-us-west-2.amazonaws.com/personalize-cli-json-models/personalize.json
wget -N https://s3-us-west-2.amazonaws.com/personalize-cli-json-models/personalize-runtime.json

rename each one of them to service-2.json

move them to:
    /boto3-latest/python/lib/python3.6/site-packages/botocore/data/personalize/2018-05-28/
    /boto3-latest/python/lib/python3.6/site-packages/botocore/data/personalize-runtime/2018-05-28/
  1. Zip all the dependencies to /tmp/boto3-with-personalize.zip
cd boto3-with-personalize
zip -r /tmp/boto3-with-personalize . 
  1. Publish the layer
aws lambda publish-layer-version --layer-name boto3-with-personalize --zip-file fileb:///tmp/boto3-with-personalize.zip

The above should return an ARN for a layer in the form:

arn:aws:lambda:region:ACC_ID:layer:boto3-with-personalize:1" 
  1. Add the layer to the function’s configuration
aws lambda update-function-configuration --function-name <my-function> --layers arn:aws:lambda:region:ACC_ID:layer:boto3-with-personalize:1 
Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS boto3 : UnknownServiceError: Unknown service
I am using aws boto3 module & running below code in python. Code execution is successful when running locally but fails with UnknownServiceError...
Read more >
EMRServerless — Boto3 Docs 1.26.32 documentation - AWS
It is the prefix used in Amazon EMR Serverless service endpoints. ... If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER...
Read more >
boto3-stubs - PyPI
Fully automated mypy-boto3-builder carefully generates type annotations for each service, patiently waiting for boto3 updates. It delivers a drop-in type ...
Read more >
AWS Security Hub work in Python 3 and Boto3 - Antonio Feijao
UnknownServiceError : Unknown service: '<built-in function dir>'. ... panorama, personalize, personalize-events, personalize-runtime, pi, ...
Read more >
Unknown service error botocore - Intellipaat Community
UnknownServiceError : Unknown service: 'transcribe'. Valid service names are: ... I've tried upgrading boto3 and botocore using: pip install ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found