Closed kenifxyz closed 2 years ago
Second. Would love more documentation on this. I tried to follow this repos guide exactly i.e. making a build.sh script with a venv. I also tried both "--remote-build" and normal.
I am only requiring the requests package but when I try to call the function it just times out and I cannot figure out why.
You may install your own libraries by updating the requirements.txt list of dependencies. These get installed during the build https://github.com/digitalocean/sample-functions-python-jokes/blob/f3aedb136cc994b9272824df1fe03672ce3f9afc/packages/joke/joke/build.sh#L7
A remote build should be used to ensure the Python version matches between build and run. You are right, we need to document this better and will do that.
The request package is already installed. If the function is timing out you can try bumping the limit from 3s to 5s (soon 30s). If still having an issue and you can share a function for us to reproduce, wil be happy to take a look.
The caveat to be mindful of is the total function bundle has to be within the 48mb limit. So this approach will not work for bundling large libraries yet. Which packages are you interested in?
edit: looking to integrate pymongo for database access in my python scripts! 48mb should suffice for now
thanks for the prompt response! will give that a try :)
I am using this exact scrip, but when building it remote, I get a permission error with the bash.
Output of failed build in %s
/tmp/slices/builds/fn-f09a7ebf-69c5-4bce-aefd-3b827b679a21/download_mls/2023-03-09T14-35-47.373Z/packages/download
/bin/bash: ./build.sh: Permission denied
I agree there should be more documentation on this.
I was not able to reproduce your error @HannanSolo - for future reference, build.sh
needs to have +x
permissions.
> git clone git@github.com:digitalocean/sample-functions-python-jokes.git
Cloning into 'sample-functions-python-jokes'...
...
Resolving deltas: 100% (3/3), done.
> cd sample-functions-python-jokes/
> doctl sls deploy --remote-build .
Deploying '/sample-functions-python-jokes'
to namespace 'fn-...'
on host 'https://faas-nyc1-2ef2e6cc.doserverless.co'
Submitted action 'joke/joke' for remote building and deployment in runtime python:default (id: ...)
Deployment status recorded in '.deployed'
Deployed functions ('doctl sls fn get <funcName> --url' for URL):
- joke/joke
Hi there,
I'm not sure if this is the right avenue to raise this, but can I check if its possible at this moment to import external libraries (i.e. custom built wheels, from pip, or otherwise) into DO Functions?
Thanks!
@rabbah would appreciate your comment on this :)