Skip to content

Commit ebd0199

Browse files
authored
Merge pull request #4 from rh-aiservices-bu/france-solutions
full instructions
2 parents 2a44d30 + 4c3b7b4 commit ebd0199

File tree

4 files changed

+155
-17
lines changed

4 files changed

+155
-17
lines changed

content/modules/ROOT/pages/04-01-setup.adoc

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
include::_attributes.adoc[]
33

44
* The situation is critical...
5-
* The French government has received a picture from one of its spies, along with some code.
6-
* But there is a strike at the Ministry of the Interior. So they don't have access to the servers ro run this code and decrypt the message hidden in the picture!
7-
* They need your help.
5+
* The French government has received a picture from one of its spies, as well as a tiny piece of code.
6+
* They are sure the picture contains a hidden message.
7+
* However, there is a strike at the Ministry of Defense. So no one had access to the servers ro run this code and decrypt the message hidden in the picture!
88
9-
Armed only with you OpenShift AI, you must recover this data, by whatever means necessary...
9+
They need your help. As a seasoned OpenShift AI user, you are their only hope...
10+
11+
Here are the two main objectives you need to achieve in this mission:
12+
13+
* Retrieve the message hidden in the picture.
14+
* Set up a Jupyter Notebook environment that will allow the President to decrypt the message by himself. With a huge constraint: for security reasons, he won't have access to any keyboard. So he will only be able to use the mouse to launch a Workbench, open a Notebook, and run a cell.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
= Execution
22
include::_attributes.adoc[]
33

4-
In the folder `lab-materials/04` you will find the a Notebook file: `04-decrypt.ipynb` and a picture. That's everything the French government has provided you with. Retrieve the message...
4+
There will be three different tasks to perform to fulfil your mission. For each task, on the next page, you will find some hints to help you solve it. If you are stuck, solutions are also provided. They can also help you verify your own solution.
55

6-
Once done, you must make it as easy as possible for the President to decrypt the message by himself. Through a lot of training, he managed to learn to do the following things (and only those!):
6+
== Task 1 - The message
77

8-
* From OpenShift AI, starting a pre-existing Workbench.
9-
* Opening a Notebook.
10-
* Running a single cell.
8+
In the folder `lab-materials/04` you will find a Notebook file: `04-decrypt.ipynb` and a picture. That's everything the French government has provided you with. Retrieve the message...
119

12-
So you must set up your environment to be able to do that. And only that, no commands, no cell creation, no nothing else. Just the three steps above.
10+
== Task 2 - The environment
11+
12+
Now that you know what you need to retrieve the message, you must create an environment where the President can decrypt the message by himself. Remember, the President will only be able to use the mouse to launch a Workbench, open a Notebook, and run a cell. So all batteries must be included!
13+
14+
== Task 3 - Setting everything up
15+
16+
Prepare your project to allow the President to decrypt the message. Just remember you are only a user in this environment, not an admin. So this may complicate things a bit...
+136-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,155 @@
11
= Hints
22
include::_attributes.adoc[]
33

4-
== Hint #1
4+
== Task 1 - The message
55

6-
.Click to reveal Hint #1
6+
=== Hint #1
7+
8+
.Click to reveal
79
[%collapsible]
810
====
911
Half of the nickname of the best friend of Merry Brandybuck will help you a lot!
1012
====
1113

12-
== Hint #2
13-
.Click to reveal Hint #1
14+
=== Solution
15+
16+
.Click to reveal
17+
[%collapsible]
18+
====
19+
The nickname of the best friend of Merry Brandybuck is Pippin (sorry if you were not a Lord of the Rings fan).
20+
21+
So, the solution is to use the `pip` command to install the missing Python package. Two different ways to do this:
22+
23+
- Create a new cell in your Notebook and use the `!pip install stegano` command to install the required Python packages.
24+
- Use the `pip install stegano` command in a terminal launched inside Jupyter.
25+
====
26+
27+
== Task 2 - The environment
28+
29+
Not really a hint, but before you loose too much time on digging this out, here is an info we got _from_ a friend: `quay.io/modh/odh-minimal-notebook-container@sha256:9592b9aed5248b77c7490f08004091174030035a76c3b198f9f01c8be0060074`
30+
31+
You're welcome!
32+
33+
=== Hint #1
34+
35+
.Click to reveal
36+
[%collapsible]
37+
====
38+
Think out of the box of the out-of-the-box Workbench images!
39+
====
40+
41+
=== Hint #2
42+
.Click to reveal
43+
[%collapsible]
44+
====
45+
If only there was something in OpenShift that can **Build** a new container image **Config**...
46+
====
47+
48+
=== Hint #3
49+
.Click to reveal
50+
[%collapsible]
51+
====
52+
A basic Containerfile is enough to build a new container image. You just need to add what is missing...
53+
====
54+
55+
=== Solution
56+
.Click to reveal
1457
[%collapsible]
1558
====
16-
If only I had something in OpenShift that can build a new container image...
59+
You need to create a new container image that includes the missing Python package. To do this, a simple Containerfile is enough.
60+
61+
Here is an example you can use:
62+
63+
```Dockerfile
64+
FROM quay.io/modh/odh-minimal-notebook-container@sha256:9592b9aed5248b77c7490f08004091174030035a76c3b198f9f01c8be0060074
65+
66+
RUN pip install stegano
67+
```
68+
69+
**Method 1**
70+
71+
* From the OpenShift Console, open an **OpenShift command line terminal** (click on the >_ logo at the top right of the console and start the Console).
72+
* Create the BuildConfig using the `oc new-build` command:
73+
74+
```bash
75+
oc new-build --name=ai-mazing-race-stegano -D $'FROM quay.io/modh/odh-minimal-notebook-container@sha256:9592b9aed5248b77c7490f08004091174030035a76c3b198f9f01c8be0060074\nRUN pip install stegano'
76+
```
77+
78+
* You can watch the process of building the new container image by running the following command:
79+
80+
```bash
81+
oc logs -f bc/ai-mazing-race-stegano
82+
```
83+
84+
**Method 2**
85+
86+
* From the OpenShift Console, create a new ImageStream called `ai-mazing-race-stegano`.
87+
* Create a new BuildConfig called `ai-mazing-race-stegano` and link it to the ImageStream. Here is the YAML configuration you can use:
88+
89+
```yaml
90+
kind: BuildConfig
91+
apiVersion: build.openshift.io/v1
92+
metadata:
93+
name: ai-mazing-race-stegano
94+
labels:
95+
build: ai-mazing-race-stegano
96+
spec:
97+
output:
98+
to:
99+
kind: ImageStreamTag
100+
name: 'ai-mazing-race-stegano:latest'
101+
strategy:
102+
type: Docker
103+
dockerStrategy:
104+
from:
105+
kind: DockerImage
106+
name: 'odh-minimal-notebook-container@sha256:9592b9aed5248b77c7490f08004091174030035a76c3b198f9f01c8be0060074'
107+
source:
108+
type: Dockerfile
109+
dockerfile: |-
110+
FROM quay.io/modh/odh-minimal-notebook-container@sha256:9592b9aed5248b77c7490f08004091174030035a76c3b198f9f01c8be0060074
111+
RUN pip install stegano
112+
```
113+
* Launch the build by clicking on **Start Build** in the Actions drop-down of the new BuildConfig.
114+
115+
Congratulations! You have created a new container image that includes the missing Python package. Take note of its address `image-registry.openshift-image-registry.svc:5000/<your_project_name>/ai-mazing-race-stegano`
116+
17117
====
18118

119+
== Task 3 - Setting everything up
120+
121+
If you were an OpenShift AI admin, it would be easy to import the new container image into the OpenShift AI environment. But you are not. So you need to find a way to use this new container image for the President's workbench...
19122

20-
== Hint #3
21-
.Click to reveal Hint #1
123+
=== Hint #1
124+
.Click to reveal
22125
[%collapsible]
23126
====
24127
Have you heard about the Notebook CR (Custom Resource) from OpenShift AI?
25128
====
26129

130+
=== Hint #2
131+
.Click to reveal
132+
[%collapsible]
133+
====
134+
You can create a new Notebook CR that uses the new container image you have created. Or just "hack" an existing one...
135+
====
136+
137+
=== Solution
138+
.Click to reveal
139+
[%collapsible]
140+
====
141+
Behind the scene, when you create a Workbench, a Notebook CR is created in OpenShift. But you can also directly create a new Notebook CR that uses the new container image you have created. Or here, the easiest way would simply be to slightly modify the existing Notebook CR.
142+
143+
Recipe:
144+
145+
* Stop your Workbench.
146+
* From the OpenShift Console, go to the **Home->API Explorer**.
147+
* Filter/find the **Notebook** object in the group kubeflow.org at version v1. Click on it.
148+
* Make sure you are on your project and click on the **Instances** tab.
149+
* Click on the **Name** of your Notebook (Workbench).
150+
* In the YAML tab, look for the field `image: 'image-registry.openshift-image-registry.svc:5000/redhat-ods-applications...`
151+
* Replace the value of the `image` field by the ImageStream name you created. Normally it should be: `image-registry.openshift-image-registry.svc:5000/<your_project_name>/ai-mazing-race-stegano`.
152+
* Get back to OpenShift AI. Your Workbench will show that the Notebook image it is using is **Deleted**. That's not exactly true, it's just not available in the images that OpenShift AI knows about...
153+
* Start your Workbench. It will use the new container image you have created. You can now directly run the cell! Without typing anything. Mission accomplished, the President sends his thanks!
154+
====
155+

lab-materials/04/eiffel_tower.png

-820 Bytes
Loading

0 commit comments

Comments
 (0)