Skip to content

Commit df88aa1

Browse files
committed
Refactor API round #2
1 parent cf75b69 commit df88aa1

File tree

26 files changed

+332
-782
lines changed

26 files changed

+332
-782
lines changed

build/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ output=$(cd "$ROOT" && find . -type f \
7575
! -path "./.circleci/*" \
7676
! -path "./.git/*" \
7777
! -name LICENSE \
78-
! -name requirements.txt \
78+
! -name "*requirements.txt" \
7979
! -name "go.*" \
8080
! -name "*.md" \
8181
! -name ".*" \

docs/deployments/onnx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can log information about each request by adding a `?debug=true` parameter t
5757
An ONNX Predictor is a Python class that describes how to serve your ONNX model to make predictions.
5858

5959
<!-- CORTEX_VERSION_MINOR -->
60-
Cortex provides an `onnx_client` and a config object to initialize your implementation of the ONNX Predictor class. The `onnx_client` is an instance of [ONNXClient](https://github.com/cortexlabs/cortex/tree/master/pkg/workloads/cortex/onnx_serve/client.py) that manages an ONNX Runtime session and helps make predictions using your model. Once your implementation of the ONNX Predictor class has been initialized, the replica is available to serve requests. Upon receiving a request, your implementation's `predict()` function is called with the JSON payload and is responsible for returning a prediction or batch of predictions. Your `predict()` function should call `onnx_client.predict()` to make an inference against your exported ONNX model. Preprocessing of the JSON payload and postprocessing of predictions can be implemented in your `predict()` function as well.
60+
Cortex provides an `onnx_client` and a config object to initialize your implementation of the ONNX Predictor class. The `onnx_client` is an instance of [ONNXClient](https://github.com/cortexlabs/cortex/tree/master/pkg/workloads/cortex/lib/client/onnx.py) that manages an ONNX Runtime session and helps make predictions using your model. Once your implementation of the ONNX Predictor class has been initialized, the replica is available to serve requests. Upon receiving a request, your implementation's `predict()` function is called with the JSON payload and is responsible for returning a prediction or batch of predictions. Your `predict()` function should call `onnx_client.predict()` to make an inference against your exported ONNX model. Preprocessing of the JSON payload and postprocessing of predictions can be implemented in your `predict()` function as well.
6161

6262
## Implementation
6363

docs/deployments/tensorflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ You can log information about each request by adding a `?debug=true` parameter t
5858
A TensorFlow Predictor is a Python class that describes how to serve your TensorFlow model to make predictions.
5959

6060
<!-- CORTEX_VERSION_MINOR -->
61-
Cortex provides a `tensorflow_client` and a config object to initialize your implementation of the TensorFlow Predictor class. The `tensorflow_client` is an instance of [TensorFlowClient](https://github.com/cortexlabs/cortex/tree/master/pkg/workloads/cortex/tf_api/client.py) that manages a connection to a TensorFlow Serving container via gRPC to make predictions using your model. Once your implementation of the TensorFlow Predictor class has been initialized, the replica is available to serve requests. Upon receiving a request, your implementation's `predict()` function is called with the JSON payload and is responsible for returning a prediction or batch of predictions. Your `predict()` function should call `tensorflow_client.predict()` to make an inference against your exported TensorFlow model. Preprocessing of the JSON payload and postprocessing of predictions can be implemented in your `predict()` function as well.
61+
Cortex provides a `tensorflow_client` and a config object to initialize your implementation of the TensorFlow Predictor class. The `tensorflow_client` is an instance of [TensorFlowClient](https://github.com/cortexlabs/cortex/tree/master/pkg/workloads/cortex/lib/client/tensorflow.py) that manages a connection to a TensorFlow Serving container via gRPC to make predictions using your model. Once your implementation of the TensorFlow Predictor class has been initialized, the replica is available to serve requests. Upon receiving a request, your implementation's `predict()` function is called with the JSON payload and is responsible for returning a prediction or batch of predictions. Your `predict()` function should call `tensorflow_client.predict()` to make an inference against your exported TensorFlow model. Preprocessing of the JSON payload and postprocessing of predictions can be implemented in your `predict()` function as well.
6262

6363
## Implementation
6464

images/onnx-serve-gpu/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ RUN apt-get update -qq && apt-get install -y -q \
2323
ENV PYTHONPATH "${PYTHONPATH}:/src:/mnt/project"
2424

2525
COPY pkg/workloads/cortex/lib/requirements.txt /src/cortex/lib/requirements.txt
26-
COPY pkg/workloads/cortex/onnx_serve/requirements.txt /src/cortex/onnx_serve/requirements.txt
26+
COPY pkg/workloads/cortex/serve/onnx.requirements.txt /src/cortex/serve/requirements.txt
2727

2828
ARG ONNXRUNTIME_VERSION="1.1.0"
2929

30-
RUN pip install -r /src/cortex/lib/requirements.txt && \
31-
pip install -r /src/cortex/onnx_serve/requirements.txt && \
30+
RUN pip install --upgrade pip && \
31+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
32+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt && \
3233
pip install onnxruntime-gpu==${ONNXRUNTIME_VERSION} && \
3334
rm -rf /root/.cache/pip*
3435

3536
COPY pkg/workloads/cortex/consts.py /src/cortex
3637
COPY pkg/workloads/cortex/lib /src/cortex/lib
37-
COPY pkg/workloads/cortex/onnx_serve /src/cortex/onnx_serve
38+
COPY pkg/workloads/cortex/serve /src/cortex/serve
3839

39-
ENTRYPOINT ["/src/cortex/onnx_serve/run.sh"]
40+
ENTRYPOINT ["/src/cortex/serve/run.sh"]

images/onnx-serve/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ RUN apt-get update -qq && apt-get install -y -q \
2323
ENV PYTHONPATH "${PYTHONPATH}:/src:/mnt/project"
2424

2525
COPY pkg/workloads/cortex/lib/requirements.txt /src/cortex/lib/requirements.txt
26-
COPY pkg/workloads/cortex/onnx_serve/requirements.txt /src/cortex/onnx_serve/requirements.txt
26+
COPY pkg/workloads/cortex/serve/onnx.requirements.txt /src/cortex/serve/requirements.txt
2727

2828
ARG ONNXRUNTIME_VERSION="1.1.0"
2929

30-
RUN pip install -r /src/cortex/lib/requirements.txt && \
31-
pip install -r /src/cortex/onnx_serve/requirements.txt && \
30+
RUN pip install --upgrade pip && \
31+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
32+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt && \
3233
pip install onnxruntime==${ONNXRUNTIME_VERSION} && \
3334
rm -rf /root/.cache/pip*
3435

3536
COPY pkg/workloads/cortex/consts.py /src/cortex
3637
COPY pkg/workloads/cortex/lib /src/cortex/lib
37-
COPY pkg/workloads/cortex/onnx_serve /src/cortex/onnx_serve
38+
COPY pkg/workloads/cortex/serve /src/cortex/serve
3839

39-
ENTRYPOINT ["/src/cortex/onnx_serve/run.sh"]
40+
ENTRYPOINT ["/src/cortex/serve/run.sh"]

images/python-serve-gpu/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ RUN apt-get update -qq && apt-get install -y -q \
2323
ENV PYTHONPATH "${PYTHONPATH}:/src:/mnt/project"
2424

2525
COPY pkg/workloads/cortex/lib/requirements.txt /src/cortex/lib/requirements.txt
26-
COPY pkg/workloads/cortex/python_serve/requirements.txt /src/cortex/python_serve/requirements.txt
27-
RUN pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
28-
pip install --no-cache-dir -r /src/cortex/python_serve/requirements.txt && \
26+
COPY pkg/workloads/cortex/serve/python.requirements.txt /src/cortex/serve/requirements.txt
27+
RUN pip install --upgrade pip && \
28+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
29+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt && \
2930
rm -rf /root/.cache/pip*
3031

3132
COPY pkg/workloads/cortex/consts.py /src/cortex
3233
COPY pkg/workloads/cortex/lib /src/cortex/lib
33-
COPY pkg/workloads/cortex/python_serve /src/cortex/python_serve
34+
COPY pkg/workloads/cortex/serve /src/cortex/serve
3435

35-
ENTRYPOINT ["/src/cortex/python_serve/run.sh"]
36+
ENTRYPOINT ["/src/cortex/serve/run.sh"]

images/python-serve/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ RUN apt-get update -qq && apt-get install -y -q \
2323
ENV PYTHONPATH "${PYTHONPATH}:/src:/mnt/project"
2424

2525
COPY pkg/workloads/cortex/lib/requirements.txt /src/cortex/lib/requirements.txt
26-
COPY pkg/workloads/cortex/python_serve/requirements.txt /src/cortex/python_serve/requirements.txt
27-
RUN pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
28-
pip install --no-cache-dir -r /src/cortex/python_serve/requirements.txt && \
26+
COPY pkg/workloads/cortex/serve/python.requirements.txt /src/cortex/serve/requirements.txt
27+
RUN pip install --upgrade pip && \
28+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
29+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt && \
2930
rm -rf /root/.cache/pip*
3031

3132
COPY pkg/workloads/cortex/consts.py /src/cortex
3233
COPY pkg/workloads/cortex/lib /src/cortex/lib
33-
COPY pkg/workloads/cortex/python_serve /src/cortex/python_serve
34+
COPY pkg/workloads/cortex/serve /src/cortex/serve
3435

35-
ENTRYPOINT ["/src/cortex/python_serve/run.sh"]
36+
ENTRYPOINT ["/src/cortex/serve/run.sh"]

images/tf-api/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ RUN apt-get update -qq && apt-get install -y -q \
1717
&& apt-get clean -qq && rm -rf /var/lib/apt/lists/*
1818

1919
COPY pkg/workloads/cortex/lib/requirements.txt /src/cortex/lib/requirements.txt
20-
COPY pkg/workloads/cortex/tf_api/requirements.txt /src/cortex/tf_api/requirements.txt
20+
COPY pkg/workloads/cortex/serve/tf.requirements.txt /src/cortex/serve/requirements.txt
2121
RUN pip install --upgrade pip && \
22-
pip install -r /src/cortex/lib/requirements.txt && \
23-
pip install -r /src/cortex/tf_api/requirements.txt && \
22+
pip install --no-cache-dir -r /src/cortex/lib/requirements.txt && \
23+
pip install --no-cache-dir -r /src/cortex/serve/requirements.txt && \
2424
rm -rf /root/.cache/pip*
2525

2626
COPY pkg/workloads/cortex/consts.py /src/cortex/
2727
COPY pkg/workloads/cortex/lib /src/cortex/lib
28-
COPY pkg/workloads/cortex/tf_api /src/cortex/tf_api
28+
COPY pkg/workloads/cortex/serve /src/cortex/serve
2929

30-
ENTRYPOINT ["/src/cortex/tf_api/run.sh"]
30+
ENTRYPOINT ["/src/cortex/serve/run.sh"]

0 commit comments

Comments
 (0)