Skip to content

Commit eb0ad0a

Browse files
edits, updates, clarifications
edits, updates, clarifications
1 parent b838bc0 commit eb0ad0a

6 files changed

Lines changed: 232 additions & 235 deletions

File tree

tutorials/ai-core-code/ai-core-code.md

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ author_profile: https://github.com/dhrubpaul
1818
- How to use Docker images with SAP AI Core
1919
- How to check and debug execution logs for errors.
2020

21-
All the required files and instructions are specified in the step for you to easily complete the tutorial.
22-
23-
By the end of the tutorial you will have your AI code in form of a Docker image, connected to your AI workflow. You will also know how to use Docker images together with AI core and how to debug your code if the **Execution** goes to an unexpected state. This tutorial is a precursor to the set up of data pipelines and models generation.
21+
By the end of the tutorial you will have your AI code in form of a Docker image, connected to your AI workflow. You will also know how to use Docker images together with AI core and how to debug your code if the **Execution** goes to an unexpected state. This tutorial is a precursor to the set up of data pipelines and model generation.
2422

2523
You may still complete this tutorial if you are not familiar with the Python programming language.
2624

@@ -38,7 +36,7 @@ Click on the profile button (your profile name) and then select **Account Settin
3836

3937
!![image](img/docker-1.png)
4038

41-
Select **Security** from the navigation bar and then click **New Access Token**.
39+
Select **Security** from the navigation bar and click **New Access Token**.
4240

4341
!![image](img/docker-2.png)
4442

@@ -112,7 +110,7 @@ The code builds a model using the [California Housing Dataset](https://scikit-le
112110

113111
[ACCORDION-BEGIN [Step 4: ](Transform your AI code into a Docker image)]
114112

115-
In the same directory, create a file named `Dockerfile` **(no extension to be added after the filename)**. This file stores instructions for Docker to build an image. Your Docker image is a Linux distribution, therefore commands in this `Dockerfile` are similar to Linux commands with verbs for Docker as the suffix. Paste the following content into the file: *** tell them that they cannot change it***
113+
In the same directory, create a file named `Dockerfile` with has **no extension**. This file stores instructions for Docker to build an image. Your Docker image is a Linux distribution, therefore commands in this `Dockerfile` are similar to Linux commands with verbs for Docker as the suffix. Paste the following content **exactly** as it is, into the file:
116114

117115
```TEXT
118116
# Specify which base layers (default dependencies) to use
@@ -136,7 +134,7 @@ RUN chgrp -R 65534 /app && \
136134

137135
!![image](img/code-docker.png)
138136

139-
You may notice that you did not specify the command to run the script `main.py` in the `Dockerfile`. This command will be written into the AI workflow and is covered later in this tutorial. ***customer must write exactly this***
137+
You may notice that you did not specify the command to run the script `main.py` in the `Dockerfile`. This command will be written into the AI workflow and is covered later in this tutorial.
140138

141139
Open your terminal and navigate to your `hello-aicore-code` directory. You will use the terminal to build your Docker image.
142140

@@ -148,7 +146,7 @@ Copy and edit the following command to build your docker image. The command foll
148146
docker build -t docker.io/<YOUR_DOCKER_USERNAME>/house-price:01 .
149147
```
150148

151-
> **INFORMATION** In the command, `-t` indicates that there is a tag name, which is your choice of descriptive name, followed by a colon and custom version in any format, here `01`. The `.` (dot) at the end instructs Docker to look for the filename `Dockerfile` in the present directory.
149+
> **INFORMATION** In the command, `-t` indicates that there is a tag name, followed by a colon and version. The name is your descriptive string, and the version can be in any format, here `house-price` and `01`, respectively. The `.` (dot) at the end instructs Docker to look for the filename `Dockerfile` in the present directory.
152150
153151
The result of this command should be:
154152

@@ -159,15 +157,15 @@ The result of this command should be:
159157

160158
[ACCORDION-BEGIN [Step 5: ](Connect your local system to a Docker account)]
161159

162-
Login to your Docker account from your terminal. This step is required only once, it will store you Docker account credentials in your local Docker Desktop.
160+
Login to your Docker account from your terminal. This is a one time step that stores your Docker account credentials in your local Docker Desktop.
163161

164162
> **INFORMATION** If you are using your organization docker registry (hosting) please use the command in the format `docker login <URL_YOUR_ORGANIZATIONS_DOCKER_REGISTRY>`
165163
166164
```BASH
167165
docker login docker.io
168166
```
169167

170-
Copy and paste, your generated Docker Access Token to use as your password. For security reasons you will not see anything getting printed on the screen when you type or paste the password.
168+
Copy and paste your generated Docker Access Token to use as your password. For security reasons, your input will not be printed on the screen.
171169

172170
!![image](img/docker-login.png)
173171

@@ -188,15 +186,15 @@ docker push docker.io/<YOUR_USERNAME>/house-price:01
188186

189187
[ACCORDION-BEGIN [Step 7: ](Store your Docker credentials in SAP AI Core as a Docker registry secret)]
190188

191-
This step is required once. Storing the credentials enables SAP AI Core to pull (download) your Docker images from a **private** Docker repository. Use of a private Docker image prevents others from seeing your content.
189+
This step is required once. Storing Docker credentials enables SAP AI Core to pull (download) your Docker images from a **private** Docker repository. Use of a private Docker image prevents others from seeing your content.
192190

193191
> **WARNING** SAP AI Core does not verify your docker credentials, please ensure that you are storing the correct credentials.
194192
195193
[OPTION BEGIN [SAP AI Launchpad]]
196194

197-
Select your SAP AI Core connection under **Workspaces** app.
195+
Select your SAP AI Core connection under the **Workspaces** app.
198196

199-
Click **Docker Registry Secrets** in **AI Core Administration** app. Click **Add**.
197+
Click **Docker Registry Secrets** in the **AI Core Administration** app. Click **Add**.
200198

201199
!![image](img/ail/1.png)
202200

@@ -211,7 +209,7 @@ Enter your details in the dialog box.
211209

212210
**BODY**
213211

214-
Click on POST Create a secret. Paste and edit the snippet into the body of the request, using the information below as guides.
212+
Click on POST Create a secret. Paste and edit the snippet into the body of the request, using the information below as a guide.
215213

216214
```JSON
217215
{
@@ -228,7 +226,7 @@ Click on POST Create a secret. Paste and edit the snippet into the body of the r
228226

229227
[OPTION BEGIN [SAP AI Core SDK]]
230228

231-
Paste and edit the snippet into the body of the request, using the information below as guides.
229+
Paste and edit the snippet into the body of the request, using the information below as a guide.
232230

233231
```PYTHON
234232
response = ai_core_client.docker_registry_secrets.create(
@@ -296,12 +294,12 @@ spec:
296294

297295
### Description of edits in your workflow.
298296

299-
Observe what the changes difference between the `hello.yaml` (created in the prerequisite tutorial) and `code-pipeline.yaml`.
297+
Observe the difference between the `hello.yaml` (created in the prerequisite tutorial) and `code-pipeline.yaml`.
300298

301299
!![image](img/file-exp.png)
302300

303301
1. `imagePullSecrets`: A key that specifies which credentials will be used to access the Docker registry. The value `credstutorialrepo` specifies the Docker registry secret that you created previously to store Docker information in SAP AI Core.
304-
2. `image`: A key that specifies which code to use in workflow and which command (to run `main.py`) to execute within the Docker image.
302+
2. `image`: A key that specifies which code to use in the workflow and which commands to execute within the Docker image.
305303

306304
[DONE]
307305
[ACCORDION-END]
@@ -312,11 +310,11 @@ Observe what the changes difference between the `hello.yaml` (created in the pre
312310

313311
[OPTION BEGIN [SAP AI Launchpad]]
314312

315-
Click though **Workspaces** > **Applications** > **<your SAP AI Core connection>** in SAP AI Launchpad.
313+
Click **Workspaces** > **Applications** > **your SAP AI Core connection** in SAP AI Launchpad.
316314

317315
Navigate to your application. Check the status of your workflow. SAP AI Core will automatically sync this workflow, this can take up to three minutes.
318316

319-
> **WARNING** If you don't see the YAML workflow file in your Applications, even after 5 minutes, it is possible that another user (with whom you have shared SAP AI Core instance) has used the same workflow name. Check that **each** of your workflows have unique executable ID, even if they are from separate users or GitHub repositories.
317+
> **WARNING** If you don't see the YAML workflow file in your Applications, even after 5 minutes, it is possible that another user of your SAP AI Core instance has used the same workflow name. Check that **each** of your workflows have unique executable ID, even if they are from separate users or GitHub repositories.
320318
321319
!![image](img/ail/app-sync-1.png)
322320

@@ -328,7 +326,7 @@ Under scenarios, you will also see a scenario named `Code (Tutorial)`.
328326

329327
[OPTION BEGIN [Postman]]
330328

331-
Click though **Collections** > GET Returns the `ArgoCD` application status.
329+
Click **Collections** > GET Returns the `ArgoCD` application status.
332330

333331
!![image](img/postman/status.png)
334332

@@ -345,7 +343,7 @@ Click though **Collections** > GET Returns the `ArgoCD` application status.
345343
...
346344
```
347345

348-
List all available scenarios by clicking through **Collections** > **Scenarios** > GET get list of scenarios.
346+
List all available scenarios by clicking **Collections** > **Scenarios** > GET get list of scenarios.
349347

350348
!![image](img/postman/listscenarios.png)
351349

@@ -382,7 +380,7 @@ Your output should contain the following snippet:
382380
{'name': 'code-pipeline', 'kind': 'WorkflowTemplate', 'status': 'Synced', 'message': 'workflowtemplate.argoproj.io/code-pipeline configured'}
383381
```
384382

385-
Lis the executables for the scenario `learning-code`:
383+
List the executables for the scenario `learning-code`:
386384

387385
```PYTHON
388386
response = ai_core_client.executable.query(
@@ -438,14 +436,14 @@ Click **Create Execution**. You will be redirected to your execution details pag
438436

439437
!![image](img/ail/run-1.png)
440438

441-
Click **refresh icon**, after a while, the status will show as **DEAD**.
439+
Click the **refresh icon**.
442440

443441
[OPTION END]
444442

445443

446444
[OPTION BEGIN [Postman]]
447445

448-
Create configuration with the **BODY**:
446+
Create a configuration with the **BODY**:
449447

450448
```JSON
451449
{
@@ -455,7 +453,7 @@ Create configuration with the **BODY**:
455453
}
456454
```
457455

458-
**Example Response** The configuration ID differs every time you create one, and for all users.
456+
**Example Response**
459457

460458
```JSON
461459
{
@@ -464,6 +462,8 @@ Create configuration with the **BODY**:
464462
}
465463
```
466464

465+
>Note The configuration ID differs every time you create one, and for all users.
466+
467467
Use your own configuration ID to start an execution with the **BODY**:
468468

469469
```JSON
@@ -472,7 +472,7 @@ Use your own configuration ID to start an execution with the **BODY**:
472472
}
473473
```
474474

475-
**Example Response** The execution ID differs every time you create one, and for all users.
475+
**Example Response**
476476

477477
```JSON
478478
{
@@ -483,11 +483,12 @@ Use your own configuration ID to start an execution with the **BODY**:
483483
}
484484
```
485485

486+
>Note The configuration ID differs every time you create one, and for all users.
487+
486488
Use your execution ID to get information on the status of your execution.
487489

488490
!![image](img/postman/dead.png)
489491

490-
After a while, the status will show as **DEAD**.
491492

492493
[OPTION END]
493494

@@ -507,11 +508,12 @@ response = ai_core_client.configuration.create(
507508
print(response.__dict__)
508509
```
509510

510-
**Example Response** The configuration ID differs every time you create one, and for all users.
511+
**Example Response**
511512

512513
```
513514
{'id': 'bd812e2c-5c71-406f-8562-a27609593de0', 'message': 'Configuration created'}
514515
```
516+
>Note The configuration ID differs every time you create one, and for all users.
515517
516518
Paste and edit the snippet below, using your configuration ID. Run it to start an execution.
517519

@@ -524,8 +526,7 @@ response = ai_core_client.execution.create(
524526
response.__dict__
525527
```
526528

527-
**Example Response** The execution ID differs every time you create one, and for all users.
528-
529+
**Example Response**
529530
```
530531
{
531532
"id": "e9d69a2f9c525325",
@@ -535,6 +536,8 @@ response.__dict__
535536
}
536537
```
537538

539+
>Note The configuration ID differs every time you create one, and for all users.
540+
538541
Paste and edit the snippet below, using your execution ID. Run the code to get your execution status.
539542

540543
```PYTHON
@@ -547,11 +550,10 @@ response = ai_core_client.execution.get(
547550

548551
response.__dict__
549552
```
550-
After a while, the status will show as **DEAD**.
551553

552554
[OPTION END]
553555

554-
Please don't panic when this execution goes from **UNKOWN** to **RUNNING** then to the **DEAD** state. Resolving this is covered in next step.
556+
The execution will go from **UNKOWN** to **RUNNING** then to the **DEAD** state. Resolving this is covered in next step.
555557

556558
[DONE]
557559
[ACCORDION-END]
@@ -567,7 +569,7 @@ In the **Overview** tab in the **Status details** section, you will find the mos
567569

568570
> **INFORMATION**: In the rare case that you observe the status: `Task currently un-schedulable due to lack of resource`, wait for a few minutes, it will automatically resolve itself and your execution will continue to run.
569571
570-
Click **Logs** tab to see stack trace generated from your code.
572+
Click the **Logs** tab to see the stack trace generated from your code.
571573

572574
!![image](img/ail/log.png)
573575

@@ -586,7 +588,7 @@ Use your execution ID to get the logs from SAP AI Core. You should see a stack t
586588

587589
[OPTION BEGIN [SAP AI Core SDK]]
588590

589-
To query execution logs, paste and edit the snippet below, using your execution ID. You should see a stack trace of errors.
591+
To query the execution logs, paste and edit the snippet below, using your execution ID. You should see a stack trace of errors.
590592

591593
```PYTHON
592594
# get execution logs
@@ -640,14 +642,14 @@ Locate your workflow (YAML file) in GitHub. Click on the **Pencil Icon** to edit
640642

641643
!![image](img/pipeline-update.png)
642644

643-
Update your workflow, by adding the new `02` tag to the `ai.sap.com/version` and the Docker image name.
645+
Update your workflow by adding the new `02` tag to the `ai.sap.com/version` and the Docker image name.
644646

645647
!![image](img/pipeline-update2.png)
646648

647649
Click **Commit Changes** after editing.
648650

649651
> ### Why update the version each time you make changes to your workflow?
650-
> The executable version is denoted by `ai.sap.com/version`. SAP AI Core syncs you workflows every three minutes and the version number is easy observable. You will easily see when your changes have synced. An alternative method of checking is to check that the latest **REVISION** number from GitHub is reflected in AI Core.
652+
> The executable version is denoted by `ai.sap.com/version`. SAP AI Core syncs you workflows every three minutes and the version number is easily observable. You can be confident that your changes have synced. An alternative method of checking is to check that the latest **REVISION** number from GitHub is reflected in AI Core.
651653
652654
[DONE]
653655
[ACCORDION-END]
@@ -657,7 +659,7 @@ Click **Commit Changes** after editing.
657659

658660
[OPTION BEGIN [SAP AI Launchpad]]
659661

660-
Go to SAP AI Launchpad. Click through **ML Operations** > **Configuration**.
662+
Go to SAP AI Launchpad. Click **ML Operations** > **Configuration**.
661663

662664
Look at the **Scenario** version in the configuration named `code-workflow-1`. If it shows `Version 2.0`, it has synced successfully, if not, please wait for ~ 3 minutes and refresh the page.
663665

0 commit comments

Comments
 (0)