You can install your required PyPI packages and import them in your Python files. Cortex looks for a requirements.txt file in the top level Cortex project directory (i.e. the directory which contains cortex.yaml):
./iris-classifier/├── cortex.yaml├── handler.py├── ...└── requirements.txt
Cortex makes all files in the project directory (i.e. the directory which contains cortex.yaml) available to request handlers. Python bytecode files (*.pyc, *.pyo, *.pyd), files or folders that start with ., and cortex.yaml are excluded.
The contents of the project directory is available in /mnt/project/ in the API containers. For example, if this is your project directory:
./iris-classifier/├── cortex.yaml├── config.json├── handler.py├── ...└── requirements.txt
You can access config.json in handler.py like this:
import jsonwith open('/mnt/project/config.json', 'r') as config_file:config = json.load(config_file)def pre_inference(sample, signature, metadata):print(config)...