我尝试使用以下命令从命令行创建一个新的 Google Cloud 项目:
$ gcloud projects create PROJECT_ID --folder=FOLDER_ID
Run Code Online (Sandbox Code Playgroud)
但我得到了错误:
ERROR: (gcloud.projects.create)
INVALID_ARGUMENT: field [parent] has issue [Parent id must be numeric.]
- '@type': type.googleapis.com/google.rpc.BadRequest
fieldViolations:
- description: Parent id must be numeric.
field: parent
- '@type': type.googleapis.com/google.rpc.Help
links:
- url: https://cloud.google.com/resource-manager/reference/rest/v1/projects
Run Code Online (Sandbox Code Playgroud)
看着gcloud project create --help,它说:
--folder=FOLDER_ID
ID for the folder to use as a parent
Run Code Online (Sandbox Code Playgroud)
如何获取文件夹 ID?
如何使用Python从HTTP Google Cloud Function返回JSON?现在我有类似的东西:
import json
def my_function(request):
data = ...
return json.dumps(data)
Run Code Online (Sandbox Code Playgroud)
这可以正确返回JSON,但是Content-Type是错误的(text/html相反)。
我正在使用Django REST Framework在Google App Engine上部署,我的requirements.txt文件如下:
asn1crypto==0.24.0
astroid==2.1.0
boto3==1.9.55
botocore==1.12.55
certifi==2018.8.13
cffi==1.11.5
chardet==3.0.4
colorama==0.4.1
coreapi==2.3.3
coreschema==0.0.4
cryptography==2.4.2
defusedxml==0.5.0
Django==2.1
django-allauth==0.36.0
django-filter==2.0.0
django-rest-auth==0.9.3
django-rest-swagger==2.0.7
djangorestframework==3.8.2
djangorestframework-jwt==1.11.0
docutils==0.14
idna==2.7
isort==4.3.4
itypes==1.1.0
Jinja2==2.10
jmespath==0.9.3
lazy-object-proxy==1.3.1
lxml==4.2.5
MarkupSafe==1.0
mccabe==0.6.1
oauthlib==2.1.0
openapi-codec==1.3.2
Pillow==5.3.0
pycparser==2.19
PyJWT==1.6.4
pylint==2.2.2
PyMySQL==0.9.2
python-dateutil==2.7.5
python-social-auth==0.3.6
python3-openid==3.1.0
pytz==2018.5
requests==2.19.1
requests-oauthlib==1.0.0
s3transfer==0.1.13
simplejson==3.16.0
six==1.11.0
social-auth-app-django==3.1.0
social-auth-core==2.0.0
typed-ast==1.1.0
uritemplate==3.0.0
urllib3==1.23
virtualenv==16.0.0
wrapt==1.10.11
Run Code Online (Sandbox Code Playgroud)
这是我的app.yaml文件,我的项目在本地pip venv上正常运行:
# [START django_app]
runtime: python37
handlers:
# This configures Google App Engine to serve the files in …Run Code Online (Sandbox Code Playgroud) 由于 Google AppEngine 2.7 不允许使用 C lib 扩展的 3rd 方库,我一直在寻找替代方法来设置类似于 repo 中显示的后端:https : //github.com/jpf/okta- pysaml2-example。它基本上是 python 的 saml,将与我的 GAE 标准环境一起运行。
谷歌云功能似乎非常适合,但我看不到安装 Brew 依赖项的方法。这不可能吗?
python google-app-engine google-cloud-platform google-cloud-functions
我在 Cloud Run 中有一个 Django 应用程序,它具有创建临时文件的方法。由于它位于 Cloud Run 中,因此文件可能会消失,因为它是“无状态”容器。
所以我尝试将临时文件上传到Google Cloud Storage,但这使得应用程序太慢。我已阅读此文档https://cloud.google.com/appengine/docs/standard/python3/using-temp-files,其中介绍了如何使用 Python3 方法将临时文件创建到 tmp/ 目录。我想知道在哪里创建这个“tmp/”目录。
我是否需要将 tmp/ 目录存储在我的应用程序的根目录中,还是需要将 tmp/ 目录创建到 Google Cloud Storage?
python-3.x google-cloud-storage google-cloud-platform google-cloud-run
我正在尝试使用 asyncio 和 Unix 域套接字在 Python 中构建一个玩具内存 Redis 服务器。
我的最小示例只返回baz每个请求的值:
import asyncio
class RedisServer:
def __init__(self):
self.server_address = "/tmp/redis.sock"
async def handle_req(self, reader, writer):
await reader.readline()
writer.write(b"$3\r\nbaz\r\n")
await writer.drain()
writer.close()
await writer.wait_closed()
async def main(self):
server = await asyncio.start_unix_server(self.handle_req, self.server_address)
async with server:
await server.serve_forever()
def run(self):
asyncio.run(self.main())
RedisServer().run()
Run Code Online (Sandbox Code Playgroud)
当我测试有两个连续的客户端请求的redis客户端库与下面的脚本,它的工作原理:
import time
import redis
r = redis.Redis(unix_socket_path="/tmp/redis.sock")
r.get("foo")
time.sleep(1)
r.get("bar")
Run Code Online (Sandbox Code Playgroud)
但是,如果我删除time.sleep(1),有时它会起作用,有时第二个请求会失败,并且会出现以下任一情况:
Traceback (most recent call last):
File "/tmp/env/lib/python3.8/site-packages/redis/connection.py", line 706, in send_packed_command …Run Code Online (Sandbox Code Playgroud) 我有一个这样结构的项目:
.
??? LICENSE
??? README.md
??? setup.py
??? src
??? __init__.py (with name="packagename")
??? module1
? ??? __init__.py (with import for each code file)
? ??? (several code files)
??? module2
??? __init__.py
??? (similar structure to module1, total of 4 modules like this)
Run Code Online (Sandbox Code Playgroud)
我已经创建了 dist 文件并将它们上传到 TestPyPI 并安装到测试项目中。我希望能够导入诸如 的模块import packagename.module1,但它给了我No module named packagename.
我的setuptools.setup参数中setup.py包含这样的条目:
packages=["packagename"],
package_dir={"packagename": "src"},
py_modules=["packagename.module1", "packagename.module2" ... ]
Run Code Online (Sandbox Code Playgroud)
知道为什么我在安装软件包后似乎无法导入吗?
我在项目中的 src 之外有各种示例测试脚本,我可以在其中访问模块from src.module1 import ClassName(尽管如果可能 …
跟进gcloud app deploy :此部署包含太多 文件
This deployment has too many files. New versions are limited to 10000 files for this app.
Run Code Online (Sandbox Code Playgroud)
我只更改了 4 个文件,但似乎试图下载更多文件。
我如何找出这些 10k 文件包含在我的部署中,以便我可以开始在我的skip_filesin 中排除它们app.yaml?