Python deployment template structure¶
The Python code for a deployment has a few requirements in terms of structure. UbiOps supports Python 3.5/3.6/3.7/3.8. For all of these versions, the same Python template can be used, which can be found in our Github.
For Python deployments, the deployment package directory is required to contain:
deployment.py- Main script for the deployment. It should include a
__init__method used for initialization and loading data which can be re-used between deployment requests. This method is called every time the deployment becomes active in UbiOps.
requestmethod that contains the main logic which is called at each deployment request.
In addition, the deployment package directory can contain the following:
requirements.txt- A list of Python packages required for the deployment. UbiOps will install the packages defined in this file for you using a fresh
pipvirtual environment once you upload your deployment. After this build step the dependencies are fixed and won't change. Read more about the
requirements.txtfile format and possibilities here
libraries/- directory where packages and system libraries are installed. This directory is added to the system
ubiops.yamlfor OS level packages.
- Any custom files in any location of the deployment package directory.
The maximum size for a deployment package is 2 gigabyte.
Testing your deployment¶
The deployment template in our Github project contains an example script to test whether your deployment is working correctly within our deployment wrapper.
Edit and execute the file
run_deployment.py according to your deployment to simulate the UbiOps back-end that initializes the deployment and makes a request. Please do not include these testing scripts in your deployment package.