Skip to content

Commit 21328fe

Browse files
authored
Merge pull request #23 from TaskarCenterAtUW/dev
Dev to Stage
2 parents 233b621 + 73f3c91 commit 21328fe

4 files changed

Lines changed: 51 additions & 8 deletions

File tree

.github/workflows/unit_tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ jobs:
7474
run: |
7575
coverage report --fail-under=85
7676
77+
- name: Generate coverage badge
78+
run: |
79+
pip install coverage-badge
80+
mkdir -p badge-out
81+
coverage-badge -f -o badge-out/coverage.svg
82+
83+
- name: Publish coverage badge to badges branch
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
run: |
87+
set -e
88+
cp badge-out/coverage.svg /tmp/coverage.svg
89+
git config user.name "github-actions[bot]"
90+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
91+
git fetch origin badges || true
92+
if git show-ref --verify --quiet refs/remotes/origin/badges; then
93+
git checkout badges
94+
else
95+
git checkout --orphan badges
96+
git rm -rf . >/dev/null 2>&1 || true
97+
fi
98+
cp /tmp/coverage.svg coverage.svg
99+
git add coverage.svg
100+
if ! git diff --cached --quiet; then
101+
git commit -m "chore: update coverage badge"
102+
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:badges
103+
else
104+
echo "No badge changes to commit."
105+
fi
106+
77107
- name: Upload report to Azure
78108
uses: LanceMcCarthy/Action-AzureBlobUpload@v2
79109
with:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# TDEI-python-osw-incline
2+
3+
[![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)
4+
[![Coverage](https://raw.githubusercontent.com/TaskarCenterAtUW/TDEI-python-osw-incline/badges/coverage.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-osw-incline/tree/badges)
5+
[![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/)
6+
[![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/)
7+
28
Service that accepts queue requests and adds incline values to an OSW dataset.
39

410
## What It Does

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
python-ms-core==0.0.25
1+
python-ms-core==0.0.26
22
fastapi
33
uvicorn
44
pydantic-settings
5-
osw-incline~=0.0.4
5+
osw-incline==0.0.4
66
psutil

src/services/inclination_service.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ class InclinationService:
2121
_config = Settings()
2222

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

2830
self.core = Core()
2931
self._subscription_name = self._config.event_bus.request_subscription
@@ -40,12 +42,17 @@ def __init__(self):
4042
def subscribe(self) -> None:
4143
# Process the incoming message
4244
def process(message) -> None:
43-
if message is not None:
45+
try:
46+
if message is None:
47+
Logger.info(' No Message')
48+
return
49+
4450
request_message = QueueMessage.to_dict(message)
4551
request_msg = RequestMessage.from_dict(request_message)
4652
self.process_message(request_msg)
47-
else:
48-
Logger.info(' No Message')
53+
except Exception as exc:
54+
# Never let callback crash propagate; this prevents unnecessary DLQ.
55+
Logger.error(f'Unhandled callback error: {exc}')
4956

5057
self.request_topic.subscribe(
5158
subscription=self._subscription_name,

0 commit comments

Comments
 (0)