Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ jobs:
run: |
coverage report --fail-under=85

- name: Generate coverage badge
run: |
pip install coverage-badge
mkdir -p badge-out
coverage-badge -f -o badge-out/coverage.svg

- name: Publish coverage badge to badges branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
cp badge-out/coverage.svg /tmp/coverage.svg
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin badges || true
if git show-ref --verify --quiet refs/remotes/origin/badges; then
git checkout badges
else
git checkout --orphan badges
git rm -rf . >/dev/null 2>&1 || true
fi
cp /tmp/coverage.svg coverage.svg
git add coverage.svg
if ! git diff --cached --quiet; then
git commit -m "chore: update coverage badge"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:badges
else
echo "No badge changes to commit."
fi

- name: Upload report to Azure
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# TDEI-python-osw-incline

[![Unit Tests](https://github.com/TaskarCenterAtUW/TDEI-python-osw-incline/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-osw-incline/actions/workflows/unit_tests.yml)
[![Coverage](https://raw.githubusercontent.com/TaskarCenterAtUW/TDEI-python-osw-incline/badges/coverage.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-osw-incline/tree/badges)
[![osw-incline](https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fraw.githubusercontent.com%2FTaskarCenterAtUW%2FTDEI-python-osw-incline%2Fdev%2Frequirements.txt&search=%28%3Fm%29%5Eosw-incline%5B~%3D%5D%3D%28%5B%5E%5Cr%5Cn%5D%2B%29&replace=%241&label=osw-incline&color=blue&cacheSeconds=60)](https://pypi.org/project/osw-incline/)
[![python-ms-core](https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fraw.githubusercontent.com%2FTaskarCenterAtUW%2FTDEI-python-osw-incline%2Fdev%2Frequirements.txt&search=%28%3Fm%29%5Epython-ms-core%3D%3D%28%5B%5E%5Cr%5Cn%5D%2B%29&replace=%241&label=python-ms-core&color=blue&cacheSeconds=60)](https://pypi.org/project/python-ms-core/)

Service that accepts queue requests and adds incline values to an OSW dataset.

## What It Does
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python-ms-core==0.0.25
python-ms-core==0.0.26
fastapi
uvicorn
pydantic-settings
osw-incline~=0.0.4
osw-incline==0.0.4
psutil
19 changes: 13 additions & 6 deletions src/services/inclination_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class InclinationService:
_config = Settings()

def __init__(self):
# Keep lifecycle same as osw-validation; only force callback worker mode to
# thread by default to avoid subprocess worker exits in this runtime.
os.environ.setdefault('TOPIC_CALLBACK_EXECUTION_MODE', 'thread')
# Keep Service Bus receiver and lock renewal in the parent process while
# long-running inclination work runs in a Linux forked child process.
os.environ['TOPIC_CALLBACK_EXECUTION_MODE'] = 'process'
os.environ['TOPIC_CALLBACK_PROCESS_START_METHOD'] = 'fork'
os.environ['TOPIC_CALLBACK_PROCESS_FALLBACK_MODE'] = 'error'

self.core = Core()
self._subscription_name = self._config.event_bus.request_subscription
Expand All @@ -40,12 +42,17 @@ def __init__(self):
def subscribe(self) -> None:
# Process the incoming message
def process(message) -> None:
if message is not None:
try:
if message is None:
Logger.info(' No Message')
return

request_message = QueueMessage.to_dict(message)
request_msg = RequestMessage.from_dict(request_message)
self.process_message(request_msg)
else:
Logger.info(' No Message')
except Exception as exc:
# Never let callback crash propagate; this prevents unnecessary DLQ.
Logger.error(f'Unhandled callback error: {exc}')

self.request_topic.subscribe(
subscription=self._subscription_name,
Expand Down
Loading