简体   繁体   中英

Running basic Python script on GCP

I know this is basic but I am really struggling on how to get started and am so so so frustrated.

I have developed the basis of my app on my windows pc using juypter notebooks and now want to start working in a cloud environment. I have no clue where to start and have looked at so much but the basics don't seem to be covered.

The data to run this on is here - named JJO_Xsens_210513.csv

A very basic version of what I am trying to do is within this snippet:

import pandas as pd
import numpy as np

df = pd.read_csv("JJO_Xsens_210513.csv", skiprows=1)
df["Keep"] = np.where(df.Acc_X <= -50,1,0)

df_to_write = df[df.Keep ==1]

A long long way down the road, there should be an upload functionality and then the preprocessing code is run and the data is then summarised in many different ways to give insights which are delivered by charts and apps. I know I can (in theory) build cloud functions, and look at persistent data storage, and building a web app / web site for all of this.

I have looked at the tutorials on GCP for App Engine , looked at tutorials for python and even the basics . I have completed the Developing Apps with GCP specialisation course via Coursera.

None of this tells me how to start in a basic way of running a python script and saving some output somewhere. It all throws me in at the deepend of building apps. I just want to test that I can run my code and models in GCP.

I apologise for the whiny and emotional nature of this post, but I am at my wits end. I am trying so hard to get this running and am so ******** lost.

Can someone please help / point me in the right direction.
Thank you,
J

I you need to "just" your code run notebooks in GCP there is a service for that: AI Platform Notebooks .

From your notebook instance you can work and download data you need, just be sure your instance has the resources (memory and CPU) you'll need, and do not forget to shut the instance down when you're not using it to avoid charges.

If a notebook is too much for you, you can always run everything in a compute instance (that's a virtual machine). Just launch it from the web and ssh to it with the web application (no need to install ssh, etc.), then you can upload the code into the instance. Just remenber to use a small instance one to start;-)

So I followed Inigo's advice, plus a little code I found elsewhere ( starting with python on google plus a quick lab)

Create the VM as per here SSH in Run this code

sudo apt-get update
sudo apt-get install git -y
sudo apt-get install python3-setuptools python3-dev build-essential python3-venv -y

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# wget as suggested in the docs didn't work for me
sudo python3 get-pip.py
python3 --version
pip3 --version

python3 -m venv env
source env/bin/activate

Sprocket on the right to upload the files

pip install -r requirements.txt
python3 filename.py

Thanks for the comments and tips gang. This has got me moving

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM