create service python-script

Create a new Python script service

Synopsis

Create

This command will create a Python script service in torero's data store. The service can later be executed via torero's run command. Before creating a Python script service, you will need to ensure that a repository with the actual script exists. See torero create repository -h for more information.

Consider a Python script that exists in a repository called example-repo. The repository has the following directory layout:

├── README.md
├── interface-scripts
│   ├── main.py
│   └── requirements.txt

We can specify that we want to use example-repo via the --repository flag.

Notice that our script exist in a directory called interface-scripts. We can denote this using the --working-dir flag.

Our particular script also has a requirements.txt file that specifies the various libraries that main.py requires. If a requirements.txt file exists within the working-dir, torero will automatically pip install the dependencies into a virtual environment and execute the script within that virtual environment when service is run.

Environment variables that will be applied during runtime can be specified using the --env flag.

Finally, a decorator can be specified to allow for input validation when the service is executed via the run command. For more information on decorators, run torero create decorator -h.

To see how Python scripts are expected to read in arguments passed at runtime, reference torero run python-script -h and view the Stub Code For Taking In Arguments section.

torero create service python-script <service-name> --repository <string> --filename <string> [flags]

Examples

Create A Simple Python Service

Creates a simple Python service called my-python-service where a Python script named main.py is at the root of the my-repo repository.

>_ torero create service python-script my-python-service \
--repository my-repo \
--filename main.py

Create A More Complex Python Service

Creates a Python service that takes advantage of every available option.

>_ torero create service python-script interface-renamer \
--repository example-repo \
--filename main.py \
--working-dir interface-scripts \
--decorator my-decorator \
--description "A Python script to set an interface description" \
--env key1=value1 \
--env key2=value2 \
--tag interfaces

Options

      --decorator string     The name of the decorator to be associated with the service
      --description string   A brief description of the service
      --env stringArray      One or more environment variables set as key=value pairs
      --filename string      The name of the Python script file in the repository. This must exist in the
                             working-dir. (default "main.py")
  -h, --help                 help for python-script
      --repository string    The repository that contains the Python script
      --tag stringArray      Metadata tag(s) to associate with the service
      --working-dir string   The path to the directory where the Python script exists. The path must be
                             relative to the root of the repository

Options inherited from parent commands

      --config string   Path to the configuration file
      --raw             Displays the result of the command in its raw format
      --verbose         Enable verbose output

SEE ALSO