I have a relatively simply cloud function Gen2, which is deployed using Cloud Run regardless of how many vCPU I assigned, DuckDB seems to be using only 1 CPU ,the Memory works fine, I checked that using The Metrics Dashboard, any idea what's wrong ?
import duckdb
import json
import pandas as pd
def download_all_blobs_with_transfer_manager(
bucket_name, destination_directory="", threads=4
):
from google.cloud.storage import Client, transfer_manager
storage_client = Client('yyyy')
bucket = storage_client.bucket(bucket_name)
blob_names = [blob.name for blob in bucket.list_blobs()]
results = transfer_manager.download_many_to_path(
bucket, blob_names, destination_directory=destination_directory, threads=threads
)
for name, result in zip(blob_names, results):
if isinstance(result, Exception):
print("Failed to download {} due to exception: {}".format(name, result))
else:
print("Downloaded {} to {}.".format(name, destination_directory + name))
download_all_blobs_with_transfer_manager('xxxxx', "./data", threads=8)
duckdb.query("install httpfs; load httpfs; PRAGMA enable_object_cache ; SET
enable_http_metadata_cache=true ")
def Query(request):
SQL = request.get_json().get('name')
try :
df = duckdb.execute(SQL).df()
except Exception as er:
df = pd.DataFrame([{'error':er}])
return json.dumps(df.to_json(orient="records")), 200, {'Content-Type': 'application/json'}