iagctl create service python-script
iagctl create service python-script
Create a new Python script service.
The iagctl create service python-script command creates a Python script service in the gateway data store. You can then run the service with the iagctl run command. For more information, see Create gateway services.
Consider a Python script in a repository called example-repo with the following directory layout:
To create a service from the script in the interface-scripts directory, specify the repository with --repository, the subdirectory with --working-dir, and the script file with --filename.
Prerequisites
Before you create a Python script service, you need a repository that contains your script.
Syntax
Usage notes
Dependencies
If a requirements.txt file exists in the --working-dir, the gateway automatically installs the dependencies into a virtual environment and runs the script within that environment.
Environment variables
Use the --env flag to set environment variables that the gateway applies at runtime. Specify each variable as a key=value pair.
Decorators
You can attach a decorator to the service for input validation at runtime with the --decorator flag. For more information, see iagctl create decorator.
Runtime arguments
For information on how Python scripts read arguments passed at runtime, see iagctl run service python-script.
Examples
Create a basic Python script service
The following example creates a service called my-python-service where the script main.py is at the root of the my-repo repository:
Create a Python script service with all options
The following example creates a service that specifies a working directory, a decorator, environment variables, and metadata: