LIST

run gcp functions locally (python)

run a single function export GCLOUD_PROJECT="XXX" export GOOGLE_ACCOUNT="your@email.com" echo "GOOGLE_ACCOUNT=$GOOGLE_ACCOUNT" export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.config/gcloud/legacy_credentials/${GOOGLE_ACCOUNT}/adc.json export YOUR_ENV_VAR="foo" pip3 install functions-framework functions-framework --source ./path/to/yuor/main.py --target your_python_function_name --debug run a custom api functions/run_functions_locally.py from flask import Flask, request from my_function_a.main import my_python_function_a from my_function_b.main import my_python_function_b app = Flask(__name__) @app.route('/') def index(): return 'Index Page' @app.get('/api/a') def get_a(): return my_python_function_a(request) @app.post('/api/b') def post_b(): return my_python_function_b(request) functions/my_python_function_a/main.py import functions_framework YOUR_ENV_VAR = os.getenv("YOUR_ENV_VAR") @functions_framework.http def my_python_function_b(request): headers = { 'Access-Control-Allow-Origin': '*', } return "hello from function a YOUR_ENV_VAR=" + YOUR_ENV_VAR, 200, headers functions/my_python_function_b/main....

March 22, 2023

python poetry intellij

brew install pyenv brew install poetry pyenv install 3.9 in intellij, in project settings (1) Create module Project Setting - Modules add a new module - import module (2) Create python interpreter SDK (platform/global/project?) Platform Settings - SDKs + -> python SDK System Interpreter Interpreter = … -> /Users/xxx/.pyenv/versions/3.9.16/bin/python (3) Create module SDK (module) Then in the module - Dependencies Module SDK -> dropdown -> add sdk -> python SDK “Poetry Environment” associated project = YOUR_MODULE (creating the python sdk via Platform SDKs does not give you this option) base interpreter Poetry executable = /usr/local/bin/poetry...

January 30, 2023