Code Monkey home page Code Monkey logo

Comments (6)

nikhilym avatar nikhilym commented on July 22, 2024

Hey @paoloantinori , thanks for raising this issue. This is specifically not an issue with the ASK SDK itself. Instead it seems to be with how the skill code is structured in https://github.com/alexa/skill-sample-python-city-guide/tree/master/lambda/py folder. The sample was written keeping in mind that it will be deployed on AWS Lambda, and hence was structured using python package alexa, that can be loaded during AWS Lambda run since I guess the whole directory is added to the PythonPath variable and hence any module/package underneath it is included.

However, when ask-sdk-local-debug is run, the __main__ method is passed the required variables, which will directly load the module onto the path and invoke it, and hence will not be able to figure out other packages present. This seems to be a bug on our ask-sdk-local-debug package, and we will try and fix this.

In the mean time, to manually load the local directory onto the python path, you can try adding the following lines in the code, before the line https://github.com/alexa/skill-sample-python-city-guide/blob/master/lambda/py/lambda_function.py#L24

import sys
import os
sys.path.append(os.path.dirname(__file__))

I could get the local debugger running successfully from our ask toolkit extension, with the above mentioned hack. Can you please try and let us know if this unblocks you for now?

from alexa-skills-kit-sdk-for-python.

paoloantinori avatar paoloantinori commented on July 22, 2024

Hi, yes this workaround works perfectly both locally and when deployed!

Thank you!

from alexa-skills-kit-sdk-for-python.

paoloantinori avatar paoloantinori commented on July 22, 2024

Hi @nikhilym , since you are checking this:
there is acollateral issue with apl templates:
if they are in my lambda/ folder, to load them correctly in local development I need to provide paths that start with lambda/... while instead, when I deploy on Amazon servers, I need to remove the lambda/ prefix.

Is there a strategy to have it working on both environments without messing with paths?

from alexa-skills-kit-sdk-for-python.

nikhilym avatar nikhilym commented on July 22, 2024

Hey @paoloantinori , we did discuss about this issue during the bug fix and here are the options, depending on how you are using the ask-sdk-local-debug package :

  • If you are using it through our ask-toolkit vscode extension and the default launch configuration, then vscode debugger provides an option to configure the current working directory cwd where the debugger is launched. By default, it is the workspace folder which is the top level folder containing all your skill resources. This is the reason why you needed the additional lambda/ path for loading the resources, when using local debugger. To resolve this, set the cwd to the skill's lambda folder in your launch.json. Here is the launch.json I tried in my skill :
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Alexa Skill (Python)",
            "type": "python",
            "request": "launch",
            "program": "${command:ask.debugAdapterPath}",
            "args": [
                "--accessToken",
                "${command:ask.accessToken}",
                "--skillId",
                "${command:ask.skillIdFromWorkspace}",
                "--skillHandler",
                "lambda_handler",
                "--skillFilePath",
                "${workspaceFolder}/lambda/lambda_function.py",
                "--region",
                "NA"
            ],
            "console": "internalConsole",
            "cwd": "${workspaceFolder}/lambda"
        }
    ]
}
  • If you are using it through our ask cli's ask run command, then unfortunately you are stuck here. But the good thing is we are already fixing it as I speak and it will be handled in the future releases of ASK CLI.

Sorry for the inconvenience and thanks for reporting the issue. Please let us know if this helps. Thanks.

from alexa-skills-kit-sdk-for-python.

paoloantinori avatar paoloantinori commented on July 22, 2024

Thank you @nikhilym, great support!

from alexa-skills-kit-sdk-for-python.

nikhilym avatar nikhilym commented on July 22, 2024

Glad you got it working @paoloantinori . Please let us know if you face any other issues or have feature requests/feedback about our tools. Have a good one!!

from alexa-skills-kit-sdk-for-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.