I am trying to run a very simple python script that prints "Hello" on the cloud code extension within vscode.
I have already created a docker file that calls a script (cloud_trial.py) which contains the printing message:
When I click on the cloud run on local emulator button, the following output pane appears.
This starts updating a lot of files that are within my project directory (with errors) but it never prints out the message from the script. It seems that it does not understand how to just run the single .py file.
Why can this happen? Is there any good tutorial on how to use vscode for python deployment on Google Cloud?
Solved! Go to Solution.
{
"type": "python",
"request": "launch",
"name": "Run Python script",
"pythonPath": "${config:python.pythonPath}",
"module": "cloud_trial",
"cwd": "${workspaceFolder}"
}
{
"type": "python",
"request": "launch",
"name": "Run Python script",
"pythonPath": "${config:python.pythonPath}",
"module": "cloud_trial",
"cwd": "${workspaceFolder}"
}
Thanks a lot! I'm still familiarizing with it so that seemed to be the error. I managed to deploy the function and make it run properly. However, I tried to deploy a new one and when I run it on the vscode extension I get this error:
The launch.json folder looks like this:
{
"configurations": [
{
"name": "Deploy Cloud Function",
"type": "cloudcode.cloudfunctions",
"request": "launch",
"functionName": "scraping",
"gen": "GEN_2",
"revision": "scraping-00001-biy",
"entryPoint": "hello_get",
"testInput": "",
"region": "europe-west1",
"runtime": "python310"
},
{
"name": "Cloud Run: Run/Debug Locally",
"type": "cloudcode.cloudrun",
"request": "launch",
"build": {
"docker": {
"path": "Dockerfile"
}
},
"image": "scraping",
"service": {
"name": "scraping",
"containerPort": 8080,
"resources": {
"limits": {
"memory": "256Mi"
}
}
},
"target": {
"minikube": {}
},
"watch": true,
"internalConsoleOptions": "neverOpen"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Deploy Cloud Function",
"type": "cloudcode.cloudfunctions",
"request": "launch",
"functionName": "function-scrape",
"gen": "GEN_2",
"entryPoint": "hello_get",
"revision": "function-scrape-00003-vuh",
"testInput": "",
"region": "europe-west1",
"runtime": "python310"
},
{
"name": "Docker: Python - General",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "general"
}
}
]
}
Any ideas on why this might be happening?
You can see that the function status is not correctly deployed: