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.

Unable to sam build

See original GitHub issue

Hi,

first of all thank you for your tutorial which is the only one dealing about fastapi and serverless out there.

I’m having problem at the step: Stage: Build the deployment package

When I build, I get the following error:

Final incompatible: {pydantic==1.2(wheel), websockets==8.1(wheel), cryptography==2.8(wheel), uvloop==0.14.0(wheel)}
Final missing wheels: {uvloop==0.14.0(wheel)}
PythonPipBuilder:ResolveDependencies failed
Traceback (most recent call last):
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 42, in execute
    requirements_path=self.manifest_path,
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 137, in build_dependencies
    self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path)
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 201, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {uvloop==0.14.0(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 269, in run
    action.execute()
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 45, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {uvloop==0.14.0(wheel)}
Builder workflow failed
Traceback (most recent call last):
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 42, in execute
    requirements_path=self.manifest_path,
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 137, in build_dependencies
    self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path)
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/packager.py", line 201, in build_site_packages
    raise MissingDependencyError(packages_without_wheels)
aws_lambda_builders.workflows.python_pip.packager.MissingDependencyError: {uvloop==0.14.0(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 269, in run
    action.execute()
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflows/python_pip/actions.py", line 45, in execute
    raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: {uvloop==0.14.0(wheel)}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/__main__.py", line 126, in main
    mode=params.get("mode", None),
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/builder.py", line 125, in build
    return workflow.run()
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 76, in wrapper
    func(self, *args, **kwargs)
  File "/var/lang/lib/python3.7/site-packages/aws_lambda_builders/workflow.py", line 276, in run
    raise WorkflowFailedError(workflow_name=self.NAME, action_name=action.NAME, reason=str(ex))
aws_lambda_builders.exceptions.WorkflowFailedError: PythonPipBuilder:ResolveDependencies - {uvloop==0.14.0(wheel)}
Build inside container returned response {"jsonrpc": "2.0", "id": 1, "error": {"code": 400, "message": "PythonPipBuilder:ResolveDependencies - {uvloop==0.14.0(wheel)}"}}

Build Failed
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 123589, 'exitReason': 'BuildError', 'exitCode': 1, 'requestId': 'd943b1f2-73e0-42d3-b8fb-2e94d5436dd4', 'installationId': 'acc6ee82-60bf-4a06-a81c-405c230a0da1', 'sessionId': '3600cf82-fe9d-4961-9a97-7ad8a856986b', 'executionEnvironment': 'CLI', 'pyversion': '3.7.6', 'samcliVersion': '0.41.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: PythonPipBuilder:ResolveDependencies - {uvloop==0.14.0(wheel)}

I’ve tried to look online and nothing very significant.

Do you have any idea what could be wrong ?

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iwpndcommented, Feb 22, 2020

Is it because this has no use for serverless ?

That’s right. Uvicorn is an ASGI server, built on uvloop and httptools. You use that to build your FastAPI in your development environment, because otherwise, you would have no server to test on. On Lambda however you don’t need a server, because AWS provisions that for you.

So, use uvicorn to develop, but don’t use it in your app, don’t put it into your requirements.txt, don’t sam build it and you’re good.

0reactions
iwpndcommented, Feb 22, 2020

Now I’m stuck at deploy stage because it looks like my app is too big:

Make sure that you only put stuff in your requirements.txt that your application needs to run as you see AWS Lambda has certain limit. If you really need heavy libraries (scikit, pandas, opencv) then I suggest you take another route then deploying with AWS SAM. There are ways to reduce the deployment package size and I’m sure you will find a solution. You will notice that AWS Lambda is not the environment to do the job, you will notice that you don’t need e.g. pandas or you find a way to slim down that deployment package by building it in a docker container yourself and ship the zip file you build in there separately from AWS SAM.

Checkout this to learn how to slim down your package with serverless instead, this, if you want to build your own deployment packages and this to use pre-build lambda packages.

Either way, that’s not the scope of my tutorial.

Could it be because the docker image I’m using is too big? FYI if I use the alpine one, my app doesn’t work.

You need that Dockerfile if you want to run your app locally, hence the uvicorn in it, it is not necessary for the deployment of an AWS Lambda function in the scope of my tutorial.

Closing this now. Good luck, have fun! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Build failed error on AWS SAM build - Stack Overflow
You can resolve this issue by running the sam build --use-container command. I got the same problem and it's working for me.
Read more >
sam build - AWS Serverless Application Model
Enable or disable cached builds. Use this option to reuse build artifacts that haven't changed from previous builds. AWS SAM evaluates whether you've...
Read more >
`sam build` broken after upgrading SAM CLI when using ECR ...
Use sam build and then guided deploy with SAM CLI 1.24.1. Then upgrade to SAM CLI 1.27.2 - sam build will stop working....
Read more >
Using "sam build" - Build includes non required folders
Unable to save cookie preferences · / · Questions/ · SAM CLI- Using "sam build" - Build includes non required folders/ ...
Read more >
A Practical Guide to Surviving AWS SAM - Medium
... the Layers count as Lambda package size, so you can't exceed the 250MB. ... After executing sam build command, take a couple...
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