[英]How to run Python script on files in Google Cloud
I have a bunch of files in a Google Cloud Storage bucket, including some Python scripts and text files. 我在Google Cloud Storage存储桶中有一堆文件,其中包括一些Python脚本和文本文件。 I want to run the Python scripts on the text files.
我想在文本文件上运行Python脚本。 What would be the best way to go about doing this (App Engine, Compute Engine, Jupyter)?
做这件事的最佳方法是什么(App Engine,Compute Engine,Jupyter)? Thanks!
谢谢!
I recommend using Google Cloud Function, that can be triggered automatically each time you upload new file to the Cloud Storage to process it. 我建议使用Google Cloud Function,每次将新文件上传到Cloud Storage进行处理时,该函数都会自动触发。 You can see workflow for this in Cloud Function Storage Tutorial
您可以在Cloud Function Storage Tutorial中查看此工作流程
You will need to at least download the python scripts onto an environment first (be it GCE or GAE). 您至少需要首先至少将python脚本下载到环境中(无论是GCE还是GAE)。 To access the GCS text files, you can use https://pypi.org/project/google-cloud-storage/ library.
要访问GCS文本文件,您可以使用https://pypi.org/project/google-cloud-storage/库。 I don't think you can execute python scripts from the object bucket itself.
我认为您无法从对象存储桶本身执行python脚本。
If it is troublesome to change the python codes for reading the text files from GCS, you will have to download everything into your environment (eg using gsutil) 如果更改用于从GCS读取文本文件的python代码很麻烦,则必须将所有内容下载到您的环境中(例如,使用gsutil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.