Skip to content

Commit 7f45fb1

Browse files
committed
Add debugging docs to test api container locally (#2124)
(cherry picked from commit e92d87a)
1 parent f62ce19 commit 7f45fb1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

docs/summary.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
* [Python packages](workloads/dependencies/python-packages.md)
7676
* [System packages](workloads/dependencies/system-packages.md)
7777
* [Custom images](workloads/dependencies/images.md)
78+
* [Debugging](workloads/debugging.md)
7879

7980
## Clients
8081

docs/workloads/debugging.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Debugging
2+
3+
You can test and debug your handler implementation and image by running your API container locally.
4+
5+
The `cortex prepare-debug` command will generate a debugging configuration file named `<api_name>.debug.json` based on your api spec, and it will print out a corresponding `docker run` command that can be used to run the container locally.
6+
7+
For example:
8+
9+
<!-- CORTEX_VERSION_README x2 -->
10+
11+
```bash
12+
cortex prepare-debug cortex.yaml iris-classifier
13+
14+
> docker run -p 9000:8888 \
15+
> -e "CORTEX_VERSION=0.34.0" \
16+
> -e "CORTEX_API_SPEC=/mnt/project/iris-classifier.debug.json" \
17+
> -v /home/ubuntu/iris-classifier:/mnt/project \
18+
> quay.io/cortexlabs/python-handler-cpu:0.34.0
19+
```
20+
21+
Make a request to the api container:
22+
23+
```bash
24+
curl localhost:9000 -X POST -H "Content-Type: application/json" -d @sample.json
25+
```

0 commit comments

Comments
 (0)