alexa / alexa-skills-kit-sdk-for-python

The Alexa Skills Kit SDK for Python helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-python/overview.html
Apache License 2.0
812 stars 206 forks source link

UserAgentManager missing from 1.15 PyPI distro #175

Closed devdupont closed 4 years ago

devdupont commented 4 years ago

I'm submitting a bug report where a class is missing from the PyPI distribution. UserAgentManager is missing from ask_sdk_runtime.utils when pip installing ask-sdk-core==1.15 (released Oct 9) causing a runtime error when building the skill. However, the code is present in the master branch at https://github.com/alexa/alexa-skills-kit-sdk-for-python/blob/master/ask-sdk-runtime/ask_sdk_runtime/utils.py

Current Behavior

Runtime errors when importing SkillBuilder:

File "/Users/dupom007/code/botmakey/botmakey/botmakey/cli/__init__.py", line 19, in <module>
    from botmakey import lambda_function, settings
  File "/Users/dupom007/code/botmakey/botmakey/botmakey/lambda_function.py", line 8, in <module>
    from botmakey.skill import skill
  File "/Users/dupom007/code/botmakey/botmakey/botmakey/skill.py", line 6, in <module>
    from ask_sdk_core.skill_builder import SkillBuilder
  File "/opt/anaconda3/envs/makey/lib/python3.8/site-packages/ask_sdk_core/skill_builder.py", line 24, in <module>
    from ask_sdk_runtime.utils import UserAgentManager
ImportError: cannot import name 'UserAgentManager' from 'ask_sdk_runtime.utils' (/opt/anaconda3/envs/makey/lib/python3.8/site-packages/ask_sdk_runtime/utils.py)

The local contents of ask_sdk_runtime.utils looks like this:

# -*- coding: utf-8 -*-
#
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights
# Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
#
import sys

def user_agent_info(sdk_version, custom_user_agent):
    # type: (str, str) -> str
    """Return the user agent info along with the SDK and Python
    Version information.

    :param sdk_version: Version of the SDK being used.
    :type sdk_version: str
    :param custom_user_agent: Custom User Agent string provided by
        the developer.
    :type custom_user_agent: str
    :return: User Agent Info string
    :rtype: str
    """
    python_version = ".".join(str(x) for x in sys.version_info[0:3])
    user_agent = "ask-python/{} Python/{}".format(
        sdk_version, python_version)
    if custom_user_agent is None:
        return user_agent
    else:
        return user_agent + " {}".format(custom_user_agent)

Unsure how the discrepancy between PyPI and the master branch happened. This was working as of 1.14

Steps to Reproduce (for bugs)

python3 -m pip install ask-sdk-core==1.15
from ask_sdk_core.skill_builder import SkillBuilder

Your Environment

Python version info

timothyaaron commented 4 years ago

If you're going to run the latest core, you also need to update to the latest runtime and model.

pip install --upgrade ask_sdk_model ask_sdk_runtime
nikhilym commented 4 years ago

Hi @flyinactor91 , as @timothyaaron mentioned, you would need to update your runtime package version to the latest. It should have been added as the minimum version dependency for ask-sdk-core. I just fixed this through PR #176 but until the next version is released, you will need to manually update the runtime version, in case you are installing the core packages along side existing dependencies.

Please upgrade your runtime package manually, and let us know if that works.

devdupont commented 4 years ago

Ah yes that appears to have fixed it. My guess is this crept in on our side to save space in the lambdas, but the minimum ask-sdk-core deployment size is still over the lambda package size for inline editing in the AWS console. Thanks for the help.