Testing Local Windows Pipeline - Display-Lab/scaffold GitHub Wiki
First-time Setup
This section covers how to set up local pipeline testing for the first time. Once you are set up with python, Postman, and have a batch script made if you choose to do so, testing can be done by starting at the testing your local PFP section.
Installing Postman
Check out the Postman workflow setup document to see how to install and use Postman. If you have it set up, keep reading to set up Python and learn how to run the pipeline with the command line.
Installing Python
First, we need to install python locally. Open up python V 3.10.12 and download the x86 installer executable. Run it from your downloads folder and you hsould be all set.
We now need to verify pip
was installed with your python download. Open up a command prompt window by hitting the windows key, typing cmd
and hitting Enter
.
Type where pip
into your command window, then hit Enter
. The filepath returned should be something like C:\...\Python310\Scripts\pip.exe
Installing Poetry
Now, we need to install poetry. Use a cURL command in your command prompt to do this lightning fast: In your command prompt, enter:
curl -sSL https://install.python-poetry.org | py - `
This will install poetry to the filepath where python was installed, and is easily reverted by the command prompt itself.
Sanity check that you are up to date with the right versio of poetry by then typing poetry install
.
Downloading pipeline (local copy)
Now, we need to download the codebase from github and store it locally.
- Go to the precision feedback pipeline repo, then hit the green code menu (looks like
<> Code v
) and download the whole repo as a zip file. - Extract the zip file's contents in a place you can remember (or copy/paste somewhere). !! Know where you are dropping it, you will need that filepath going forward !!
Setting up a Local Test Batch Script (optional)
This is for those who will be doing local testing on a frequent enough basis that changing your directory and using poetry commands will be annoying in the long run. Follow these steps to make your setup much faster:
- Open up the file explorer, and find the directory where you keep your local copy of the PFP main. Should be a full filepath, formatted like
C:\...\precision-feedback-pipeline\main
. Just navigate there, then leave that file explorer open. - Open up your IDE of choice (text editor program, like Sublime, Vim, Notepad++, or VisualStudio)
- Copy in the following block of code, and change the area that says "filepath goes here" to match the filepath you pulled up in Step 1:
@echo off
cd /d "FILEPATH GOES HERE"
start powershell -ExecutionPolicy Bypass -Command "poetry shell"
- Save the file as something like
run-local-pfp.bat
, and save it to the root folder where your pipeline is running from. In this case, that would beC:\...\precision-feedback-pipeline
- Go back to your file explorer, and navigate to the place that file got saved. Right click and select
send to desktop (shortcut)
. This creates a shortcut to the batch file on your desktop. Now when you want to start testing, double click the shortcut to your batch file and save yourself a couple seconds of time!
Running the pipeline via command line
If we choose not to make a batch file, we need to open command prompt and change directories to where the PFP main codebase is stored. Use the cd
command to get into your directory where you dropped in the pipeline files:
cd C:...\precision-feedback-pipeline-main
Now we can use poetry. We'll be using a part of the poetry distro called uvicorn to operate a local server to bounce emails off of. The main command you need to know is:
poetry run uvicorn main_windows:app --reload
This should run without any problems. For ease of use, I generally rename the main_windows.py
file in the PFP to main_w.py
to make it easier to run quickly. Whatever works for you.
Testing the Pipeline
Follow these shorter instructions if you forget how to ge tthe pipeline running after having set up your system with the above steps.
If you have a batch file made
- Run your batch file
- Enter
uvicorn main_windows:app --reload
- Wait for powershell to show that the PFP startup is successful
- Open Postman (windows key and type Postman, hit enter)
- Send your post requests from Postman
If you use the command line
- Open command prompt (windows key + cmd + enter)
- Change directories -
cd C:\...\precision-feedback-pipeline-main
- Host the pipeline -
poetry run uvicorn main_windows:app --reload
- Confirm that the PFP startup was successful
- Open Postman (windows key + Postman + enter)
- Send your post requests from Postman
Stopping the pipeline
- Use CTRL + C to force stop the pipeline at any point. This is important if you run with the --reload option.
- Typing
exit
in powershell will close your instance.
Debugging
There is an option in the current main.py
that looks for a defined "debug" value in the postman request. As of 6/5/23, this means you need to go into the postman request and define a variable as debug, and set a value to "yes" or "no".