Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit c86a51a

Browse files
Rayna Levinsonsub-mod
Rayna Levinson
authored andcommitted
sentiment_analysis mlperf tekton pipeline
1 parent ee58a64 commit c86a51a

15 files changed

+247
-39
lines changed

image_classification/misc/image_classification_template.yaml

-39
This file was deleted.

sentiment_analysis/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Running Sentiment Analysis in a tekton Pipeline with Openshift
2+
3+
## Getting started
4+
5+
**Requirements**
6+
- An Openshift cluster with 60 GB memory and 32 cpu cores.
7+
8+
9+
## Running Sentiment analysis
10+
11+
### Starting and stopping the pipeline
12+
13+
To setup the pipeline, run the setup script.
14+
`./setup.sh`
15+
16+
To run the pipeline, execute the run script.
17+
`./run_pipeline.sh`
18+
19+
To delete the pipeline resources, run the drop script.
20+
`./drop_pipeline.sh`
21+
22+
## Analyzing Sentiment analysis
23+
24+
To get the logs from the benchmark run, as well as the final result, run the get_logs script
25+
`./get_logs.sh`
26+
27+
The file `logs.txt` will contain the entirety of the output from when the benchmark was run, and `result.txt` will give you the final results.
28+
29+
### About the pipeline process
30+
31+
The pipeline is comprised of two tasks, `build` and `run-benchmark`.
32+
Once the pipeline run is triggered, it starts with the build task and will build a new image with all the tools necessary for running image_classification.
33+
After the build is finished, the pipeline will run the container image. This image will time how long it takes to run the benchmark, and tell you at the end.
34+
To track the progress of your tasks, you can use the cluster UI under Workloads > Pods > <your pod> > Logs.
35+
See the [mlperf repo](https://github.com/mlperf/training/tree/master/data_generation/fractal_graph_expansions) for more information about the benchmark.

sentiment_analysis/drop_pipeline.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
oc delete pipeline/sentiment-analysis
2+
oc delete pipelinerun/sentiment-analysis-pipeline-run
3+
oc delete pipelineresource/sa-build-image
4+
oc delete pipelineresource/sa-repo
5+
oc delete task/sa-buildah
6+
oc delete task/sa-run-benchmark
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: ImageStream
2+
apiVersion: image.openshift.io/v1
3+
metadata:
4+
name: sentiment-analysis
5+
namespace: mlperf
6+
spec:
7+
lookupPolicy:
8+
local: true
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: Pipeline
3+
metadata:
4+
name: sentiment-analysis
5+
spec:
6+
resources:
7+
- name: sa-repo
8+
type: git
9+
- name: sa-build-image
10+
type: image
11+
12+
tasks:
13+
- name: build
14+
taskRef:
15+
name: buildah
16+
kind: Task
17+
resources:
18+
inputs:
19+
- name: source
20+
resource: sa-repo
21+
outputs:
22+
- name: image
23+
resource: sa-build-image
24+
- name: run
25+
taskRef:
26+
name: run-benchmark
27+
kind: Task
28+
resources:
29+
inputs:
30+
- name: image
31+
resource: sa-build-image
32+
runAfter:
33+
- build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: PipelineRun
3+
metadata:
4+
name: sentiment-analysis-pipeline-run
5+
spec:
6+
serviceAccount: mlperf
7+
pipelineRef:
8+
name: sentiment-analysis
9+
resources:
10+
- name: sa-repo
11+
resourceRef:
12+
name: sa-repo
13+
- name: sa-build-image
14+
resourceRef:
15+
name: sa-build-image
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: tekton.dev/v1alpha1
3+
kind: PipelineResource
4+
metadata:
5+
name: sa-repo
6+
spec:
7+
type: git
8+
params:
9+
- name: url
10+
value: https://github.com/AICoE/mlperf-training.git
11+
---
12+
apiVersion: tekton.dev/v1alpha1
13+
kind: PipelineResource
14+
metadata:
15+
name: sa-build-image
16+
spec:
17+
type: image
18+
params:
19+
- name: url
20+
value: docker-registry.default.svc:5000/mlperf/sentiment-analysis:latest
21+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: sentiment-analysis

sentiment_analysis/run_pipeline.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oc create -f pipeline/pipelinerun.yml

sentiment_analysis/setup.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
oc new-project mlperf
2+
oc create -f misc/imagestream.yml
3+
oc create -f pipeline/resources.yml
4+
oc create -f task/buildah.yaml
5+
oc create -f task/run-benchmark.yml
6+
oc create -f pipeline/pipeline.yml

sentiment_analysis/task/buildah.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
apiVersion: tekton.dev/v1alpha1
3+
kind: Task
4+
metadata:
5+
name: sa-buildah
6+
spec:
7+
inputs:
8+
params:
9+
- name: BUILDER_IMAGE
10+
description: The location of the buildah builder image.
11+
default: quay.io/buildah/stable:v1.11.0
12+
- name: DOCKERFILE
13+
description: Path to the Dockerfile to build.
14+
default: sentiment_analysis/Dockerfile
15+
- name: TLSVERIFY
16+
description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
17+
default: "false"
18+
19+
resources:
20+
- name: source
21+
type: git
22+
23+
outputs:
24+
resources:
25+
- name: image
26+
type: image
27+
28+
steps:
29+
- name: build
30+
image: $(inputs.params.BUILDER_IMAGE)
31+
workingDir: /workspace/source
32+
command: ["buildah", "bud", '--tls-verify=$(inputs.params.TLSVERIFY)', '--layers', '-f', '$(inputs.params.DOCKERFILE)', '-t', '$(outputs.resources.image.url)', '.']
33+
volumeMounts:
34+
- name: varlibcontainers
35+
mountPath: /var/lib/containers
36+
securityContext:
37+
privileged: true
38+
39+
- name: push
40+
image: $(inputs.params.BUILDER_IMAGE)
41+
workingDir: /workspace/source
42+
command: ['buildah', 'push', '--tls-verify=$(inputs.params.TLSVERIFY)', '$(outputs.resources.image.url)', 'docker://$(outputs.resources.image.url)']
43+
volumeMounts:
44+
- name: varlibcontainers
45+
mountPath: /var/lib/containers
46+
securityContext:
47+
privileged: true
48+
49+
volumes:
50+
- name: varlibcontainers
51+
emptyDir: {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: TaskRun
3+
metadata:
4+
name: buildah-run
5+
namespace: mlperf
6+
spec:
7+
taskRef:
8+
name: buildah
9+
serviceAccount: sentiment-analysis
10+
inputs:
11+
resources:
12+
- name: repo
13+
resourceRef:
14+
name: repo
15+
outputs:
16+
resources:
17+
- name: build-image
18+
resourceRef:
19+
name: build-image
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: TaskRun
3+
metadata:
4+
name: run-run
5+
namespace: mlperf
6+
spec:
7+
taskRef:
8+
name: run-benchmark
9+
serviceAccount: sentiment-analysis
10+
inputs:
11+
resources:
12+
- name: build-image
13+
resourceRef:
14+
name: build-image
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: Task
3+
metadata:
4+
name: sa-run-benchmark
5+
spec:
6+
inputs:
7+
resources:
8+
- name: image
9+
type: image
10+
steps:
11+
- name: run
12+
image: $(inputs.resources.image.url)
13+
workingDir: /mlperf/sentiment_analysis/paddle
14+
securityContext:
15+
privileged: true
16+
command: ["/bin/sh", "./run_and_time.sh", "123456"]

sentiment_analysis/util/get_logs.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/bash
2+
3+
POD=`echo $(oc get pods -o name) | grep -o 'pod/tf-build-pipeline-run-run[^ ]*'`
4+
5+
oc logs -f $POD --container='step-run' > logs.txt
6+
sed -i '/\[=/d' logs.txt
7+
IFS=',' read -ra RESULT <<< `tail -n 1 'logs.txt'`
8+
9+
tee result.txt << EOF
10+
${RESULT[0]}
11+
12+
NAME: ${RESULT[1]}
13+
SEED: ${RESULT[2]}
14+
TIME: ${RESULT[3]} sec
15+
USER: ${RESULT[4]}
16+
START: ${RESULT[5]}
17+
EOF

0 commit comments

Comments
 (0)