gitsshgoogle-cloud-platformgcp-ai-platform-notebookgoogle-cloud-source-repos

Connecting AI Platform Notebooks to Google Cloud Source Repositories


I'm very new to GCP/AI Platform/Git/etc., so please bear with me.

I am trying to connect an AI Platform Notebook & VM to a Google Cloud Source Repository. I am not the only one at my organization who will be working on the code in the repo, so it's important that multiple people maintain access to it. My goal is to be able to instantiate a Notebook/VM in AI Platform Notebooks, fork/clone the repo, make changes as needed, and push back to my fork of the repo (eventually merging with master branch down). I would also like to have my VM persist, spinning it up and down as needed, pulling and pushing from/to the repo at will.

Surprisingly, I have found no documentation on connecting AI Platform with Cloud Source Repositories.

When I try to clone a repo in CSR, it asks for SSH credentials but I am not very familiar with that process. I was able to generate an RSA key pair from the SSH command line for my particular VM instance, but I don't know what to do from there (most importantly, I want to be sure that multiple people can fork/clone the master repo).

Thanks in advance for any help you can provide.


Solution

  • Just an update, I found a method that works (I'm sure there are alternatives):

    HOW TO CLONE a Cloud Source Repository into a GCP AI Platform Notebook instance:

    1. Instantiate an AI Platform Notebook as you normally would, then Open JupyterLab
    2. In another window, open Cloud Source Repositories, click on All Repositories, click on the name of the repo you wish to clone.
    3. Click on the + Clone button in the top-right corner, then click on How to setup?
    4. In the pop-up, click on Manually generated credentials, then click Generate and store your Git credentials
    5. In the new window, copy the second code block (bottom of page, in blue box)
    6. Back in your JupyterLab instance, open a terminal window and paste the code block in the terminal, hit ENTER
    7. in the same terminal, run git clone https://source.developers.google.com/p/<REST_OF_REPO_LOCATION_HERE> , being sure to use your repo's location
    8. You’re done! You can now use git like you normally would from the terminal, or even from the Git UI by going to Git > Git Interface