openfaas / workshop

Learn Serverless for Kubernetes with OpenFaaS
https://www.openfaas.com
MIT License
960 stars 312 forks source link

Lab3 #172

Closed gioargyr closed 4 years ago

gioargyr commented 4 years ago

In Lab3, I cannot understand how exactly should I modify the function "astronaut-finder". I see that I have to modify "requirements.txt" and I did bu just adding the word "requests" (even though it seemed strange to me), but now that I run the function I get an error. I am pretty sure that it has to do with the modification of the file "requirements.txt" or a modification I didn't do correctly.

Expected Behaviour

The function is supposed to return a name of an astronaut in ISS

Current Behaviour

The error I get is: " exit status 1 Traceback (most recent call last): File "index.py", line 19, in ret = handler.handle(st) File "/home/app/function/handler.py", line 6, in handle r = requests.get("http://api.open-notify.org/astros.json") NameError: name 'requests' is not defined "

Possible Solution

N/A

Steps to Reproduce (for bugs)

I just follow the instructions on Lab3.

Context

I just try to do Lab3

Your Environment

martindekov commented 4 years ago

Hello @gioargyr did you re-build/push/deploy the function after adding the requests package to the requirenments.txt?

martindekov commented 4 years ago

Also when building the function try running faas-cli build .... --no-cache and let me know if it helps.

gioargyr commented 4 years ago

Hello, as it seems it was a stupid mistake because I didn't add "import requests". So sorry for bothering you.

martindekov commented 4 years ago

No problem :+1: