Skip to Content

Connect GitHub and Docker to SAP AI Core (Postman)

test
0 %
Connect GitHub and Docker to SAP AI Core (Postman)
Details

Connect GitHub and Docker to SAP AI Core (Postman)

Requires Customer/Partner License
October 11, 2021
Created by
October 10, 2021
Learn to enable SAP AI Core to auto-sync code and workflows files hosted on GitHub and Docker.

You will learn

  • How to create GitHub and Docker repository.
  • Make API calls connect repository to SAP AI Core
QR code


Step 1: Create GitHub repository

A GitHub repository refers to a folder (project), with Version-Control, which means you can track any changes to files contained within revert them.

  1. Sign up for GitHub, Go to github.com.

  2. Create a repository, Click New.

    Create repository
  3. Set the repository name as aicore-test ( customizable)

    Repository Name: aicore-testRepository Name: aicore-test
Log on to answer question
Step 2: Clone GitHub using GitHub Desktop

Cloning is the process of managing your GitHub repositories on you local computer

GitHub Desktop helps you clone, create, edit and sync files of your GitHub repository from you local computer.

  1. Install GitHub Desktop. Download here

  2. Open GitHub Desktop.

  3. From welcome screen login to your GitHub Account *(Alternative login: File > Options > Accounts).

  4. Click File > Clone a repository.

    clone repo
  5. Go to URL tab. Type <your github username>/aicore-test.

    repo url
Log on to answer question
Step 3: Upload Files to GitHub
  1. Create a folder name workflows. Inside the local copy of your GitHub (cloned repository)

    folder creation
  2. Create an empty file named training_workflow_tutorial.yaml inside the workflows folder.

    file creation

    CAUTION: Avoid storing any service keys or passwords inside a Git tracked folder.

  3. Sync your local git repo with online. Open GitHub Desktop.

  4. Click on Commit to main button

    commit
  5. Then pres Push Origin button.

    push

This will sync up your local files with GitHub repository(online).

GitHub Desktop will only show un-synced changes.

github Desktop normal view
Log on to answer question
Step 4: API to connect GitHub SAP AI Core

CAUTION At present SAP AI Core can connect to single GitHub repository, skip this step if its already connected to one. Contact support to change if required.

After connecting GitHub repository to your SAP AI Core account, whenever you will push changes (upload files) to GitHub, the SAP AI Core can pull(sync) them automatically.

Make the following API call using Postman

COLLECTIONS > admin > repositories > POST Create repository

Endpoint

POST
{{apiurl}}/v2/admin/repositories

Body

Edit your GitHub URL and your credentials, (highlighted lines) below.

{
    "name": "aicore-test",
    "url": "https://github.com/<your-username>/aicore-test",
    "username": "$username",
    "password": "$password"
}
create repository

SEND

Response

{'count': 1,
 'resources':[{'name': 'aicore-test',
               'status': 'COMPLETED',
               'url': 'https://github.com/john/aicore-test'
               }]
}
Log on to answer question
Step 5: API to list connected GitHub repository

List Connected Git Repositories

COLLECTIONS > admin> repositories > GET List repositories

Endpoint

GET
{{apiurl}}/v2/admin/repositories

SEND

RESPONSE

{
   'count': 1,
   'resources': [
      {
           'name': 'aicore-test',
           'status': 'COMPLETED',
           'url': 'https://github.com/john/aicore-test'
       }
   ]
}
Log on to answer question
Step 6: API to create application on SAP AI Core

Application is an SAP AI Core entity which links a sub-folder inside your connected GitHub repository. SAP AI Core will look into these folders for any workflow (explained later), and sub-folder within the same will not be searched for.

COLLECTIONS > admin > applications > POST Create application

Endpoint

POST
{{apiurl}}/v2/admin/applications

Body

Edit your GitHub username (highlighted lines) below.

{
    "applicationName": "aicore-test-app",
    "repositoryUrl": "https://github.com/<your-username>/aicore-test",
    "revision": "HEAD",
    "path": "workflows"
}
application create

SEND

RESPONSE

{
    "id": "aicore-test-app",
    "message": "Application has been successfully created."
}
Log on to answer question
Step 7: API to list connected Applications

COLLECTIONS > admin > applications > GET List applications

Endpoint

GET
{{apiurl}}/v2/admin/applications

SEND

Response

{
    'count': 1,
    'resources': [{
        'application_name': 'aicore-test-app',
        'path': 'workflows',
        'repository_url': 'https://github.com/john/aicore-test',
        'revision': 'HEAD'
    }]
}
Log on to answer question
Step 8: Create Docker repository
  1. Sign up at docker.com

  2. Click Create Repository.

    docker create repository button
  3. Name the repository “text-clf-train”

    docker repo for training
  4. Create another repository similarly, named text-clf-serve.

    docker repo structure
Log on to answer question
Step 9: Manage Docker locally
  1. Download and Install Docker Desktop. Download here

  2. After Installation. You will see Docker Desktop icon on your desktop tray.

    docker desktop icon
  3. Verify with your terminal (command prompt). Execute the following on terminal.

    docker --version
    
    docker terminal version
Log on to answer question
Step 10: Connect Docker to SAP AI Core

COLLECTIONS > admin > POST Create docker registry secret

Endpoint

POST
{{apiurl}}/v2/admin/dockerRegistrySecrets

Create the following file docker_secret.json .

Body

Edit and replace $username with your Docker username and $password with password. (highlighted line).

{
  "name": "docker-registry-secret",
  "data": {
    ".dockerconfigjson": "{\"auths\": {\"docker.io\": {\"username\": \"$username\", \"password\": \"$password\"}}}"
  }
}
docker secret

SEND

Response

{'message': 'secret has been been created'}

List connected Docker registry secret

COLLECTIONS > admin > GET List docker registry secrets

RESPONSE

{
    'count': 1,
    'resources': [{
        'name': 'docker-registry-secret'
    }]
}

IMPORTANT: Creating docker secret does not imply docker account gets connected. It only implies that whenever SAP AI Core search(if required) for docker images it will use these credentials to search docker repository. At that time it may happen that the provided credentials are incorrect.

In case you want SAP AI Core to host two different projects (image-segmentation and text-classification), how will you place your project files in GitHub?
×

Next Steps

Back to top