ATMA
ATMA

Reputation: 1466

Uploading Python files to GCP and execute code

I was trying to create a VM and upload some python files to GCP, and run the code on my buckets.

I created the VM and SSH into it. After I set up my VM instance with all the Python libraries that I need. Now I'm trying to upload my python files to GCP so that I can execute the code.

So on my Mac, I did gcloud init and then tried the following:

gcloud compute scp /Users/username/Desktop/LZ_demo_poc/helper_functions.py /home/user_name/lz_text_classification/

However, I keep getting these error messages.

WARNING: `gcloud compute copy-files` is deprecated.  Please use `gcloud compute scp` instead.  Note that `gcloud compute scp` does not have recursive copy on by default.  To turn on recursion, use the `--recurse` flag.
ERROR: (gcloud.compute.copy-files) Source(s) must be remote when destination is local.  Got sources: [/Users/username/Desktop/LZ_demo_poc/helper_functions.py], destination: /home/user_name/lz_text_classification/

Can anyone help me with the process of running a python script on GCP using data that is saved as buckets.

Upvotes: 0

Views: 1458

Answers (1)

Dan Cornilescu
Dan Cornilescu

Reputation: 39814

You need to also specify the instance where you want the files copied, otherwise the destination is interpreted as a local file, leading to the (2nd line of) your error message. From the gcloud compute scp examples:

Conversely, files from your local computer can be copied to a virtual machine:

$ gcloud compute scp ~/localtest.txt ~/localtest2.txt \
  example-instance:~/narnia

In your case it should be something like:

gcloud compute scp /Users/abrahammathew/Desktop/LZ_demo_poc/helper_functions.py your_instance_name:/home/abraham_mathew/lz_text_classification/

Upvotes: 2

Related Questions