Skip to content

Commit d003fe3

Browse files
kapilvgitagokarn
andauthored
refactor OHTTP library dependency (#31)
* redirection * initial commit * reference command line * makefile extension * set target path using enginetarget (#30) * engine target * workflow dispatch * Changes to remove backtrace, add version, fix client http error message printing and other logging related changes Remove reaming backtrace code modified: .github/workflows/check.yml modified: Makefile modified: bhttp/Cargo.toml modified: cgpuvm-attest/Cargo.toml modified: docker/client/Dockerfile modified: docker/server/run.sh modified: ohttp-client/Cargo.toml modified: ohttp-client/src/main.rs modified: ohttp-server/Cargo.toml modified: ohttp-server/src/main.rs modified: ohttp/Cargo.toml modified: verifier/Cargo.toml * readme fixes * readme fix --------- Co-authored-by: agokarn <arthig@microsoft.com>
1 parent a707452 commit d003fe3

15 files changed

Lines changed: 171 additions & 201 deletions

File tree

.github/workflows/check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ on:
66
pull_request:
77
branches: ["main"]
88
paths-ignore: ["*.md", "LICENSE-*"]
9+
workflow_dispatch:
10+
911
env:
1012
CARGO_TERM_COLOR: always
11-
RUST_BACKTRACE: 1
1213

1314
jobs:
1415
check:

Makefile

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ else ifeq ($(MODEL), whisper_aoai_local)
1313
SCORING_ENDPOINT ?= 'http://localhost:9443/score'
1414
else ifeq ($(MODEL), whisper_aoai)
1515
TARGET ?= http://127.0.0.1:5002
16-
TARGET_PATH ?= '/v1/engines/whisper/audio/transcriptions'
16+
TARGET_PATH ?= '/v1/engines/whisper/audio/translations'
1717
DEPLOYMENT ?= 'arthig-deploy20'
1818
SCORING_ENDPOINT ?= 'https://arthig-ep.eastus2.inference.ml.azure.com/score'
1919
else
@@ -94,40 +94,47 @@ verify-quote:
9494
# Local client deployments
9595

9696
run-client:
97-
RUST_BACKTRACE=1 RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT)\
97+
RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT) \
9898
--target-path ${TARGET_PATH} -F "file=@${INPUT}" \
9999
--config `curl -s http://localhost:9443/discover`
100100

101101
run-client-kms: service-cert
102-
RUST_BACKTRACE=1 RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT)\
102+
RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT) \
103103
--target-path ${TARGET_PATH} -F "file=@${INPUT}" \
104-
--kms-cert ./service_cert.pem
104+
--kms-url ${KMS} --kms-cert ./service_cert.pem
105105

106106
run-client-kms-aoai: service-cert
107-
RUST_BACKTRACE=1 RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT)\
107+
RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT) \
108108
--target-path ${TARGET_PATH} -F "file=@${INPUT}" \
109-
--kms-cert ./service_cert.pem \
109+
--kms-url ${KMS} --kms-cert ./service_cert.pem \
110110
-O 'openai-internal-enableasrsupport:true' -H 'openai-internal-enableasrsupport:true'
111111

112112
run-client-kms-aoai-token: service-cert
113-
RUST_BACKTRACE=1 RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT) \
113+
RUST_LOG=info cargo run --bin ohttp-client -- $(SCORING_ENDPOINT) \
114114
--target-path ${TARGET_PATH} -F "file=@${INPUT}" -F "response_format=json" -F "language=en" \
115-
--kms-cert ./service_cert.pem \
115+
--kms-url ${KMS} --kms-cert ./service_cert.pem \
116116
-H 'openai-internal-enableasrsupport:true' -O 'openai-internal-enableasrsupport:true' \
117117
-O 'azureml-model-deployment:$(DEPLOYMENT)' -O 'authorization: Bearer ${TOKEN}'
118118

119+
run-client-kms-aoai-apim-token: service-cert
120+
RUST_LOG=info cargo run --bin ohttp-client -- ${APIM_ENDPOINT} \
121+
--target-path ${TARGET_PATH} -F "file=@${INPUT}" -F "response_format=json" \
122+
--kms-url ${KMS} --kms-cert ./service_cert.pem -O 'api-key: ${API_KEY}'
123+
119124
# Containerized client deployments
120125

121126
run-client-container:
122-
docker run --privileged --net=host --volume ${INPUT}:${MOUNTED_INPUT} ohttp-client \
123-
$(SCORING_ENDPOINT) --target-path ${TARGET_PATH} -F "file=@${MOUNTED_INPUT}" \
124-
--config `curl -s http://localhost:9443/discover`
127+
docker run --net=host --volume ${INPUT}:${MOUNTED_INPUT} \
128+
ohttp-client $(SCORING_ENDPOINT) -F "file=@${MOUNTED_INPUT}" --target-path ${TARGET_PATH}
125129

126-
run-client-container-kms: service-cert
127-
docker run --volume ${INPUT}:${MOUNTED_INPUT} \
128-
--volume ./service_cert.pem:/tmp/service_cert.pem ohttp-client \
129-
${SCORING_ENDPOINT} --target-path ${TARGET_PATH} -F "file=@${MOUNTED_INPUT}" \
130-
--maa-url=${MAA} --kms-url=${KMS} --kms-cert /tmp/service_cert.pem
130+
run-client-container-kms:
131+
docker run --net=host --volume ${INPUT}:${MOUNTED_INPUT} -e KMS_URL=${KMS} \
132+
ohttp-client ${SCORING_ENDPOINT} -F "file=@${MOUNTED_INPUT}" --target-path ${TARGET_PATH}
131133

132134
run-client-container-it:
133135
docker run -it --privileged --net=host -it --entrypoint=/bin/bash ohttp-client
136+
137+
run-client-container-aoai:
138+
docker run --volume ${INPUT}:${MOUNTED_INPUT} -e KMS_URL=${KMS} \
139+
ohttp-client ${SCORING_ENDPOINT} -F "file=@${MOUNTED_INPUT}" --target-path ${TARGET_PATH} \
140+
-O "api-key: ${API_KEY}" -F "response_format=json"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ the server sees your IP address.
7777

7878
The repo supports development using GitHub Codespaces and devcontainers.
7979

80-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=707634300&skip_quickstart=true&machine=premiumLinux&geo=EuropeWest)
80+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/kapilvgit/ohttp)
8181

8282
## Build and Test
8383

bhttp/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ stream = []
2222
thiserror = "1"
2323
url = {version = "2", optional = true}
2424
tracing = "0.1"
25-
backtrace = "0.3"
2625

2726
[dev-dependencies]
2827
hex = "0.4"

cgpuvm-attest/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ default = []
1414
libc = "0.2.0"
1515
tracing = "0.1"
1616
thiserror = "1"
17-
backtrace = "0.3"
1817

1918
[dependencies.ohttp]
2019
path= "../ohttp"

docker/client/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ RUN cargo install --path ohttp-client --debug
1313
FROM ubuntu:22.04
1414
RUN apt-get update && apt-get install -y ca-certificates openssl curl jq && rm -rf /var/lib/apt/lists/*
1515
COPY --from=builder /usr/local/cargo/bin/ohttp-client /usr/local/bin/ohttp-client
16-
ENV RUST_BACKTRACE=1
16+
COPY ./examples/audio.mp3 ./examples/audio.mp3
17+
COPY ./examples/15m_gpt-has-entered-the-chat.mp3 ./examples/15m_gpt-has-entered-the-chat.mp3
18+
COPY --chmod=755 ./docker/client/run.sh .
1719
ENV RUST_LOG=info
18-
ENTRYPOINT [ "/usr/local/bin/ohttp-client" ]
20+
ENTRYPOINT [ "./run.sh" ]

docker/client/run.sh

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,18 @@ is_valid_url() {
1313
fi
1414
}
1515

16-
if [[ -z ${SCORING_ENDPOINT} ]]; then
17-
echo "No SCORING_ENDPOINT defined"
18-
exit 1
19-
fi
20-
21-
if [[ -z ${TARGET_PATH} ]]; then
22-
echo "No TARGET_PATH defined"
23-
exit 1
24-
fi
25-
26-
if [[ -z ${INPUT} ]]; then
27-
echo "No INPUT defined"
28-
exit 1
29-
fi
30-
31-
CMD="RUST_BACKTRACE=1 RUST_LOG=info /usr/local/bin/ohttp-client ${SCORING_ENDPOINT} --target-path ${TARGET_PATH} -F \"file=@${INPUT}\""
32-
3316
if [[ -n ${KMS_URL} ]]; then
3417
if is_valid_url $KMS_URL; then
3518
# Obtain KMS service certificate
3619
curl -s -k ${KMS_URL}/node/network | jq -r .service_certificate > /tmp/service_cert.pem
37-
CMD="$CMD --kms-url ${KMS_URL} --kms-cert /tmp/service_cert.pem"
20+
ARGS="$ARGS --kms-url ${KMS_URL} --kms-cert /tmp/service_cert.pem"
3821
else
3922
echo "Invalid KMS URL"
4023
exit 1
4124
fi
4225
else
43-
CMD="$CMD --config `curl -s http://localhost:9443/discover`"
26+
ARGS="$ARGS --config `curl -s http://localhost:9443/discover`"
4427
fi
4528

46-
echo "Running $CMD..."
47-
eval $CMD
29+
echo "Running /usr/local/bin/ohttp-client" "$@" ${ARGS}
30+
RUST_LOG=info /usr/local/bin/ohttp-client "$@" ${ARGS}

docker/server/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ if [[ -z ${TARGET} ]]; then
1818
exit 1
1919
fi
2020

21-
CMD="RUST_BACKTRACE=1 RUST_LOG=info"
21+
CMD="RUST_LOG=info"
2222
if [[ -n ${TRACE} ]]; then
23-
CMD="RUST_BACKTRACE=1 RUST_LOG=trace"
23+
CMD="RUST_LOG=trace"
2424
fi
2525

2626
if is_valid_url $TARGET; then

ohttp-client/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ serde = { version = "1.0", features = ["derive"] }
2424
serde_json = "1.0"
2525
tracing = "0.1"
2626
tracing-subscriber = { version = "0.3.18", features = ["default", "json", "env-filter"] }
27-
backtrace = "0.3"
2827
infer = "0.16.0"
2928

3029
[dependencies.verifier]
3130
path= "../verifier"
3231

3332
[dependencies.bhttp]
34-
path= "../bhttp"
33+
git = "https://github.com/kapilvgit/ohttp.git"
34+
branch = "kapilv/upstream"
3535
features = ["bhttp", "http"]
3636

3737
[dependencies.ohttp]
38-
path= "../ohttp"
38+
git = "https://github.com/kapilvgit/ohttp.git"
39+
branch = "kapilv/upstream"
3940
features = ["client"]
4041
default-features = false

ohttp-client/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Attested OHTTP Client
2+
This repository contains a reference implementation of an attested OHTTP client for
3+
Azure AI confidential inferencing.
4+
5+
## Prerequisites
6+
7+
1. An AzureML endpoint with a confidential whisper model.
8+
2. Docker
9+
10+
## Using pre-built image
11+
You can use pre-built attested OHTTP container images to send an inferencing request.
12+
13+
Set the inferencing endpoint and access key as follows.
14+
```
15+
export TARGET_URI=<URL for your endpoint>
16+
export API_KEY=<key for accessing the endpoint>
17+
```
18+
19+
Run inferencing using a pre-packaged audio file.
20+
```
21+
export KMS_URL=https://accconfinferencedebug.confidential-ledger.azure.com
22+
docker run -e KMS_URL=${KMS_URL} mcr.microsoft.com/attested-ohttp-client:latest \
23+
${TARGET_URI} -F "file=@/examples/audio.mp3" -O "api-key: ${API_KEY}" -F "response_format=json"
24+
```
25+
26+
Run inferencing using your own audio file by mounting the file into the container.
27+
```
28+
export KMS_URL=https://accconfinferencedebug.confidential-ledger.azure.com
29+
export INPUT_PATH=<path to your input file>
30+
export MOUNTED_PATH=/examples/audio.mp3
31+
docker run -e KMS_URL=${KMS_URL} --volume ${INPUT_PATH}:${MOUNTED_PATH} \
32+
mcr.microsoft.com/attested-ohttp-client:latest \
33+
${TARGET_URI} -F "file=@${MOUNTED_INPUT}" -O "api-key ${API_KEY}" -F "response_format=json"
34+
```
35+
36+
## Building your own container image
37+
38+
### Development Environment
39+
40+
The repo supports development using GitHub Codespaces and devcontainers. The repository includes a devcontainer configuration that installs all dependencies.
41+
42+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/kapilvgit/ohttp)
43+
44+
Alternatively, you can setup your own environment by installing dependencies.
45+
```
46+
sudo apt update
47+
sudo apt install -y curl build-essential jq
48+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
49+
```
50+
51+
Next, you can build the client containers as follows.
52+
53+
```
54+
docker build -f docker/Dockerfile -t attested-ohttp-client .
55+
```

0 commit comments

Comments
 (0)