This software utility updates hold pickup locations using the Sierra API. (The Sierra DB psql connection is used to efficiently enumerate holds.)
This tool was adapted from TCCL's internal automatic renewals software tool, updated to process holds. It can be used as a reference in creating similar tools that efficiently use a pool of connections to update large numbers of records via the Sierra API.
- Manages API token refresh so long-running jobs refresh the token as needed
- Effectively handles errors and retries 500-level errors a certain number of times
- Runs requests on a thread pool to parallelize operations resulting in faster processing speeds
- Command and job interfaces allows for the implementation of additional commands and thread jobs
The tool requires Python 3 (at least version 3.10). Create a virtual environment and use the requirements.txt file to install dependencies. To install the tool itself into the virtual environment, use pip to install from the working directory using the setup.py. This is suitable for production environments.
python3 -m venv myenv
source myenv/bin/activate
pip install -r requirements.txt
pip install .
sierra-chp ...
deactivate
Alternatively, you may use pipenv to handle the creation of the virtual environment and installation of dependencies. This is suitable for development and requires running the program via the main.py entrypoint.
pipenv install
pipenv shell
python main.py ...
exit
Currently the tool has only one command: change pickup, which updates all holds matching a target pickup location to an updated pickup location.
Example run: This updates all holds having pickup location code br to pickup location code bb. The -v argument displays verbose messages which are also saved to a log file via the tee command. (Note: your system may not have tee installed. So remove the second part of the command after the |.)
sierra-chp change pickup -v br bb | tee run.log