You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/workloads/dependencies/python-packages.md
+52-10Lines changed: 52 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
3
3
## PyPI packages
4
4
5
-
You can install your required PyPI packages and import them in your Python files using pip. Cortex looks for a `requirements.txt` file in the top level Cortex project directory (i.e. the directory which contains `cortex.yaml`):
5
+
You can install your required PyPI packages and import them in your Python files using pip. Cortex looks for
6
+
a `requirements.txt` file in the top level Cortex project directory (i.e. the directory which contains `cortex.yaml`):
6
7
7
8
```text
8
9
./my-classifier/
@@ -14,11 +15,13 @@ You can install your required PyPI packages and import them in your Python files
14
15
15
16
If you want to use `conda` to install your python packages, see the [Conda section](#conda-packages) below.
16
17
17
-
Note that some packages are pre-installed by default (see "pre-installed packages" for your Predictor type in the Realtime API Predictor documentation and Batch API Predictor documentation).
18
+
Note that some packages are pre-installed by default (see "pre-installed packages" for your Predictor type in the
19
+
Realtime API Predictor documentation and Batch API Predictor documentation).
18
20
19
21
## Private PyPI packages
20
22
21
-
To install packages from a private PyPI index, create a `pip.conf` inside the same directory as `requirements.txt`, and add the following contents:
23
+
To install packages from a private PyPI index, create a `pip.conf` inside the same directory as `requirements.txt`, and
24
+
add the following contents:
22
25
23
26
```text
24
27
[global]
@@ -35,7 +38,8 @@ You may now add packages to `requirements.txt` which are found in the private in
35
38
36
39
## GitHub packages
37
40
38
-
You can also install public/private packages from git registries (such as GitHub) by adding them to `requirements.txt`. Here's an example for GitHub:
41
+
You can also install public/private packages from git registries (such as GitHub) by adding them to `requirements.txt`.
42
+
Here's an example for GitHub:
39
43
40
44
```text
41
45
# requirements.txt
@@ -47,11 +51,14 @@ git+https://github.com/<username>/<repo name>.git@<tag or branch name>#egg=<pack
47
51
git+https://<personal access token>@github.com/<username>/<repo name>.git@<tag or branch name>#egg=<package name>
48
52
```
49
53
50
-
On GitHub, you can generate a personal access token by following [these steps](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
54
+
On GitHub, you can generate a personal access token by
55
+
following [these steps](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line)
56
+
.
51
57
52
58
## Installing with Setup
53
59
54
-
Python packages can also be installed by providing a `setup.py` that describes your project's modules. Here's an example directory structure:
60
+
Python packages can also be installed by providing a `setup.py` that describes your project's modules. Here's an example
61
+
directory structure:
55
62
56
63
```text
57
64
./my-classifier/
@@ -65,6 +72,7 @@ Python packages can also be installed by providing a `setup.py` that describes y
65
72
```
66
73
67
74
In this case, `requirements.txt` will have this form:
75
+
68
76
```text
69
77
# requirements.txt
70
78
@@ -73,7 +81,9 @@ In this case, `requirements.txt` will have this form:
73
81
74
82
## Conda packages
75
83
76
-
Cortex supports installing Conda packages. We recommend only using Conda when your required packages are not available in PyPI. Cortex looks for a `conda-packages.txt` file in the top level Cortex project directory (i.e. the directory which contains `cortex.yaml`):
84
+
Cortex supports installing Conda packages. We recommend only using Conda when your required packages are not available
85
+
in PyPI. Cortex looks for a `conda-packages.txt` file in the top level Cortex project directory (i.e. the directory
86
+
which contains `cortex.yaml`):
77
87
78
88
```text
79
89
./my-classifier/
@@ -83,16 +93,48 @@ Cortex supports installing Conda packages. We recommend only using Conda when yo
83
93
└── conda-packages.txt
84
94
```
85
95
86
-
The `conda-packages.txt` file follows the format of `conda list --export`. Each line of `conda-packages.txt` should follow this pattern: `[channel::]package[=version[=buildid]]`.
96
+
The `conda-packages.txt` file follows the format of `conda list --export`. Each line of `conda-packages.txt` should
97
+
follow this pattern: `[channel::]package[=version[=buildid]]`.
87
98
88
99
Here's an example of `conda-packages.txt`:
100
+
89
101
```text
90
102
conda-forge::rdkit
91
103
conda-forge::pygpu
92
104
```
93
105
94
-
In situations where both `requirements.txt` and `conda-packages.txt` are provided, Cortex installs Conda packages in `conda-packages.txt` followed by PyPI packages in `requirements.txt`. Conda and Pip package managers install packages and dependencies independently. You may run into situations where Conda and pip package managers install different versions of the same package because they install and resolve dependencies independently from one another. To resolve package version conflicts, it may be in your best interest to specify their exact versions in `conda-packages.txt`.
106
+
In situations where both `requirements.txt` and `conda-packages.txt` are provided, Cortex installs Conda packages
107
+
in `conda-packages.txt` followed by PyPI packages in `requirements.txt`. Conda and Pip package managers install packages
108
+
and dependencies independently. You may run into situations where Conda and pip package managers install different
109
+
versions of the same package because they install and resolve dependencies independently from one another. To resolve
110
+
package version conflicts, it may be in your best interest to specify their exact versions in `conda-packages.txt`.
95
111
96
-
The current version of Python is `3.6.9`. Updating Python to a different version is possible with Conda, but there are no guarantees that Cortex's web server will continue functioning correctly. If there's a change in Python's version, the necessary core packages for the web server will be reinstalled. If you are using a custom base image, any other Python packages that are built in to the image won't be accessible at runtime.
112
+
The current version of Python is `3.6.9`. Updating Python to a different version is possible with Conda, but there are
113
+
no guarantees that Cortex's web server will continue functioning correctly. If there's a change in Python's version, the
114
+
necessary core packages for the web server will be reinstalled. If you are using a custom base image, any other Python
115
+
packages that are built in to the image won't be accessible at runtime.
97
116
98
117
Check the [best practices](https://www.anaconda.com/using-pip-in-a-conda-environment/) on using `pip` inside `conda`.
118
+
119
+
## Customizing Dependency Paths
120
+
121
+
Cortex allows you to specify different dependency paths other than the default ones. This can be useful when deploying
122
+
different versions of the same API (e.g. CPU vs GPU dependencies).
123
+
124
+
To customize the path for your dependencies, you can specify `predictor.dependencies` in your API's configuration file. You can set
125
+
one or more fields to specify the path for each dependency type. Each path should be a relative path with respect to the current file.
Copy file name to clipboardExpand all lines: docs/workloads/realtime/configuration.md
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@
19
19
predictor:
20
20
type: python
21
21
path: <string> # path to a python file with a PythonPredictor class definition, relative to the Cortex root (required)
22
+
dependencies: # (optional)
23
+
pip: <string> # relative path to requirements.txt (default: requirements.txt)
24
+
conda: <string> # relative path to conda-packages.txt (default: conda-packages.txt)
25
+
shell: <string> # relative path to a shell script for system package installation (default: dependencies.sh)
22
26
multi_model_reloading: # use this to serve one or more models with live reloading (optional)
23
27
path: <string> # S3/GCS path to an exported model directory (e.g. s3://my-bucket/exported_model/) (either this, 'dir', or 'paths' must be provided if 'multi_model_reloading' is specified)
24
28
paths: # list of S3/GCS paths to exported model directories (either this, 'dir', or 'path' must be provided if 'multi_model_reloading' is specified)
@@ -48,6 +52,10 @@ predictor:
48
52
predictor:
49
53
type: tensorflow
50
54
path: <string> # path to a python file with a TensorFlowPredictor class definition, relative to the Cortex root (required)
55
+
dependencies: # (optional)
56
+
pip: <string> # relative path to requirements.txt (default: requirements.txt)
57
+
conda: <string> # relative path to conda-packages.txt (default: conda-packages.txt)
58
+
shell: <string> # relative path to a shell script for system package installation (default: dependencies.sh)
51
59
models: # (required)
52
60
path: <string> # S3/GCS path to an exported SavedModel directory (e.g. s3://my-bucket/exported_model/) (either this, 'dir', or 'paths' must be provided)
53
61
paths: # list of S3/GCS paths to exported SavedModel directories (either this, 'dir', or 'path' must be provided)
@@ -80,6 +88,10 @@ predictor:
80
88
predictor:
81
89
type: onnx
82
90
path: <string> # path to a python file with an ONNXPredictor class definition, relative to the Cortex root (required)
91
+
dependencies: # (optional)
92
+
pip: <string> # relative path to requirements.txt (default: requirements.txt)
93
+
conda: <string> # relative path to conda-packages.txt (default: conda-packages.txt)
94
+
shell: <string> # relative path to a shell script for system package installation (default: dependencies.sh)
83
95
models: # (required)
84
96
path: <string> # S3/GCS path to an exported model directory (e.g. s3://my-bucket/exported_model/) (either this, 'dir', or 'paths' must be provided)
85
97
paths: # list of S3/GCS paths to exported model directories (either this, 'dir', or 'path' must be provided)
0 commit comments