Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
avatar
Guru

In Cloudera Machine Learning experience (or CDSW for the on-prem version), projects are backed with git.
You might want to use GitHub on your projects, so here is a simple way to do that.

 

First things first: there are basically two ways of interacting with git/GitHub: HTTPS or SSH; We'll use the latter to make the authentication easy. You might also consider SSO or 2FA for enhancing security, here we'll focus on the basics.

  1. To make this authentication going on under the hood, copy our SSH key from CML to Github.
  2. Find your SSH key in the Settings of CML:
    ledel_0-1600761186047.png
  3. Copy that key and add it in Github, under the SSH and GPG keys in your github.com settings: Add SSH key.
  4. Put cdsw in the Title and paste your ssh content in the Key:
    ledel_1-1600762026238.png
  5. Let's start with creating a new project on github.com:
    ledel_2-1600762493095.png
  6. The important thing here is the access mode we want to use: SSH
    ledel_3-1600762547145.png
  7. In CML, start a new project with a template:
    ledel_4-1600762652424.png
  8. Open a Terminal window in a new session:
    ledel_5-1600762863710.png
  9. Convert the project to a git project:
    cdsw@qp7h1qllrh9dx1hd:~$ git init
    Initialized empty Git repository in /home/cdsw/.git/
  10. Add all files to git:
    cdsw@qp7h1qllrh9dx1hd:~$ git add .
  11. Commit of the project in GitHub:
    cdsw@qp7h1qllrh9dx1hd:~$ git commit -m "initial commit"
    [master (root-commit) 5d75525] initial commit
    47 files changed, 14086 insertions(+)
    create mode 100755 .gitignore
    create mode 100644 LICENSE.txt
    create mode 100755 als.py
    [...]
  12. Add a remote origin server with the "URL" of the remote repository where your local repository will be pushed:
    cdsw@qp7h1qllrh9dx1hd:~$ git remote add origin git@github.com:laurentedel/MyProject.git
  13. Make the current Git branch a master branch:
    cdsw@qp7h1qllrh9dx1hd:~$ git branch -M master
  14. Finally, push the changes (so all files for the first commit) to our master, so on github.com:
    cdsw@qp7h1qllrh9dx1hd:~$ git push -u origin master
    The authenticity of host 'github.com (140.82.113.4)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'github.com,140.82.113.4' (RSA) to the list of known hosts.
    Counting objects: 56, done.
    Delta compression using up to 16 threads.
    Compressing objects: 100% (46/46), done.
    Writing objects: 100% (56/56), 319.86 KiB | 857.00 KiB/s, done.
    Total 56 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), done.
    To github.com:laurentedel/MyProject.git
    * [new branch] master -> master
    Branch 'master' set up to track remote branch 'master' from 'origin'.
  15. There you go!
    ledel_6-1600763527997.png
  16. Now we can use the git commands are used to Modify file(s):
    cdsw@qp7h1qllrh9dx1hd:~$ echo "# MyProject" >> README.md
  17. What's our status?
    cdsw@qp7h1qllrh9dx1hd:~$ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    Untracked files:
    (use "git add <file>..." to include in what will be committed)
    
    README.md
    
    nothing added to commit but untracked files present (use "git add" to track)
  18. Commit/push:
    cdsw@qp7h1qllrh9dx1hd:~$ git add README.md
    cdsw@qp7h1qllrh9dx1hd:~$ git commit -m "adding a README"
    [master 7008e88] adding a README
     1 file changed, 1 insertion(+)
     create mode 100644 README.md
    cdsw@qp7h1qllrh9dx1hd:~$ git push -u origin master
    Warning: Permanently added the RSA host key for IP address '140.82.114.4' to the list of known hosts.
    Counting objects: 3, done.
    Delta compression using up to 16 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 290 bytes | 18.00 KiB/s, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), completed with 1 local object.
    To github.com:laurentedel/MyProject.git
       5d75525..7008e88  master -> master
    Branch 'master' set up to track remote branch 'master' from 'origin'.

 

 

 Happy commits!

4,385 Views