简体   繁体   English

如何在Google Cloud中的文件上运行Python脚本

[英]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.

相关问题 如何在Google Cloud Storage上运行Python脚本? - How to run Python script on Google Cloud storage? 如何使用 python 脚本提取多部分的 zip 文件以在 Google Cloud Function 中运行 - How to extract zip files with multi parts using python script to run in Google Cloud Function 如何使用 Google Cloud Run 运行“hello world”python 脚本 - How to run a "hello world" python script with Google Cloud Run 如何在 Google Cloud Function 中将 Python 脚本作为子进程运行 - How to run a python script as a subprocess inside Google Cloud Function 如何在Google Cloud Platform VM上运行python脚本 - How to run a python script on Google Cloud Platform VM 在Google Cloud for ML上推送并运行python脚本 - Push and run python script on Google Cloud for ML 如何在谷歌云中运行 python 3? - How to run python 3 in google cloud? 如何在由谷歌云存储完成事件触发的 python 脚本中运行 bash 脚本? - How do I run a bash script inside python script triggered by google cloud storage finalize event? 如何在不手动启动它们的情况下在Google Cloud项目或AWS实例上运行python脚本? - How can I run a python script on Google Cloud project or AWS instances without manually firing them up? 为python脚本分配URL以便在Google Cloud上运行cron作业? - Assign a URL to a python script to run a cron job on Google Cloud?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM