GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python
functions-framework breaks import paths for the google-cloud-functions SDK package
- 主要語言
- Python
- 星號
- 968
- 分支
- 128
- PR 合併指標
- 30 天內沒有已合併 PR
描述
functions-framework is incompatible with the [google-cloud-functions](https://pypi.org/project/google-cloud-functions/) SDK package, unless google-cloud-functions is installed with a separate install command AFTER functions-framework is installed.
As I understand it, this is not possible to do within the context of Google Cloud Functions, where packages get installed automatically from the requirements.txt file.
The reason is that **functions-framework overwrites several important files in google/cloud/functions_v1, google/cloud/functions, and google/cloud/functions_v1beta2 that are required to make the google-cloud-functions SDK package work as intended.**
For example: functions-framework overwrites `google/cloud/functions_v1/__init__.py` upon install, which breaks the ability to import packages in the normal, documented ways.
Steps to reproduce:
1. create a new python 3.9 environment:
2. Run: `pip install google-cloud-functions==1.6.0 functions-framework==3.0.0`
3. Then execute:
```python
from google.cloud import functions_v1
functions_v1.CloudFunctionsServiceClient()
```
This will raise:
`AttributeError: module 'google.cloud.functions_v1' has no attribute 'CloudFunctionsServiceClient'`
Edit:
This means that none of the sample code in the docs will work, since they all rely on the imported members from `google/cloud/functions_v1/__init__.py`. Example below:
https://cloud.google.com/python/docs/reference/cloudfunctions/latest/google.cloud.functions_v1.services.cloud_functions_service.CloudFunctionsServiceClient#google_cloud_functions_v1_services_cloud_functions_service_CloudFunctionsServiceClient_create_function
貢獻指南
研究方向
使用列出的 pip install 命令在乾淨的 Python 3.9 環境中重現此故障,然後檢查 google/cloud/functions_v1、google/cloud/functions 和 google/cloud/functions_v1beta2 下被 functions-framework 覆寫的檔案。在相同的 requirements.txt 上下文中完成安裝後,驗證文件中所述的 CloudFunctionsServiceClient 匯入和範例用法。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- google-cloud, python
- 領域
- backend, cloud
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100