Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e5919a5
moving all scripts to git
shahdyousefak Feb 11, 2025
e7c5899
modifying the script to filter out only healthy healthchecks
shahdyousefak Feb 11, 2025
2739ffd
updating .gitignore, making scripts executable
shahdyousefak Feb 11, 2025
98993af
edits to documentation across scripts; add README.md for entire direc…
jeffbl Feb 14, 2025
eebc881
#938 - expand healthchecks to all preprocessors, services, handlers, …
shahdyousefak Jan 28, 2025
7ff1deb
Add new text followup preprocessor (#947)
jeffbl Jan 28, 2025
df70bda
Initial commit using captioner
JRegimbal Jan 13, 2025
90c7387
Fix typo
JRegimbal Jan 13, 2025
f18f5e1
Update dependencies
JRegimbal Jan 13, 2025
8f2ad4c
Fix issues related to missing obj det data
JRegimbal Jan 13, 2025
49301fe
Text followup handler initial commit
VenissaCarolQuadros Jan 13, 2025
8245748
Fix path in Dockerfile
VenissaCarolQuadros Jan 13, 2025
dcaf17d
Minor cleanup; Add docker, build, workflow scripts and README
VenissaCarolQuadros Jan 23, 2025
ba865f2
Fix log message and copyright
VenissaCarolQuadros Jan 27, 2025
2dafbac
Fix path to handler in workflow
VenissaCarolQuadros Jan 28, 2025
5d57e0e
Add followup route in docker-compose
VenissaCarolQuadros Jan 28, 2025
9680601
Implemented queue for microservices
M-A89 Feb 2, 2025
c628434
Updated how preprocessors are dequeued
M-A89 Feb 8, 2025
d1d88dd
Introduce prompt override via env variable to content-categoriser and…
jeffbl Feb 12, 2025
160cc75
Remove trailing whitespace
JRegimbal Feb 17, 2025
b0410f8
Filter places before length check
JRegimbal Feb 17, 2025
580f67d
fix: increase memcached item size
jaydeepsingh25 Feb 22, 2025
30ef179
rebase
shahdyousefak Feb 25, 2025
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
82 changes: 82 additions & 0 deletions .github/workflows/text-followup-handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Text Followup Handler
on:
push:
branches: [ main ]
tags: [ "handler-text-followup-[0-9]+.[0-9]+.[0-9]+" ]
paths: [ "handlers/text-followup-handler/**" ]
pull_request:
branches: [ main ]
paths: [ "handlers/text-followup-handler/**" ]
workflow_run:
workflows: [ "Schemas (Trigger)" ]
types:
- completed
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: shared-reality-lab/image-handler-text-followup
jobs:
lint:
name: PEP 8 style check.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install flake8
run: pip install flake8
- name: Check with flake8
run: python -m flake8 ./handlers/text-followup-handler --show-source
build-and-push-image:
name: Build and Push to Registry
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Log into GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Correct Tags
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/handler-text-followup-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "TAGGED=true" >> $GITHUB_ENV
else
echo "TAGGED=false" >> $GITHUB_ENV
fi
- name: Get timestamp
run: echo "timestamp=$(date -u +'%Y-%m-%dT%H.%M')" >> $GITHUB_ENV
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ env.TAGGED }}
tags: |
type=match,enable=${{ env.TAGGED }},priority=300,pattern=handler-text-followup-(\d+.\d+.\d+),group=1
type=raw,priority=200,value=unstable
type=raw,priority=100,value=${{ env.timestamp }}
labels: |
org.opencontainers.image.title=IMAGE Handler Text Followup
org.opencontainers.image.description=Handler to create responses for followup queries.
org.opencontainers.image.authors=IMAGE Project <[email protected]>
org.opencontainers.image.licenses=AGPL-3.0-or-later
maintainer=IMAGE Project <[email protected]>
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./handlers/text-followup-handler/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
83 changes: 83 additions & 0 deletions .github/workflows/text-followup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Graphic Caption
on:
push:
branches: [ main, text-followup ]
tags: [ "preprocessor-text-followup-[0-9]+.[0-9]+.[0-9]+" ]
paths: [ "preprocessors/text-followup/**" ]
pull_request:
branches: [ main ]
paths: [ "preprocessors/text-followup/**" ]
workflow_run:
workflows: [ "Schemas (Trigger)" ]
types:
- completed
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: shared-reality-lab/image-preprocessor-text-followup
jobs:
lint:
name: PEP 8 style check.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install flake8
run: pip install flake8
- name: Check with flake8
run: python -m flake8 ./preprocessors/text-followup --show-source
build-and-push-image:
name: Build and Push to Registry
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Log into GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Correct Tags
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/preprocessor-text-followup-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "TAGGED=true" >> $GITHUB_ENV
else
echo "TAGGED=false" >> $GITHUB_ENV
fi
- name: Get timestamp
run: echo "timestamp=$(date -u +'%Y-%m-%dT%H.%M')" >> $GITHUB_ENV
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ env.TAGGED }}
tags: |
type=match,enable=${{ env.TAGGED }},priority=300,pattern=preprocessor-text-followup-(\d+.\d+.\d+),group=1
type=raw,priority=200,value=unstable
type=raw,priority=100,value=${{ env.timestamp }}
labels: |
org.opencontainers.image.title=IMAGE Preprocessor Text Followup
org.opencontainers.image.description=Responds to followup queries from user.
org.opencontainers.image.authors=IMAGE Project <[email protected]>
org.opencontainers.image.documentation=https://github.com/Shared-Reality-Lab/IMAGE-server/tree/main/preprocessors/text-followup/README.md
org.opencontainers.image.licenses=AGPL-3.0-or-later
maintainer=IMAGE Project <[email protected]>
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./preprocessors/text-followup/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ config/chart.env
config/apis-and-selection.env
config/vision_api_key.json
config/ollama.env
config/healthcheck.env
config/image-summary.env
config/imagelogs.env
config/make_request.env
config/pp_daily_test.env
config/restoreunstable.env
config/sendimagereq.env
config/image_daily_cron.env
*.sh
docker-compose.override.yml
10 changes: 10 additions & 0 deletions build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ services:
context: .
dockerfile: ./preprocessors/graphic-caption/Dockerfile
image: "graphic-caption:latest"
text-followup:
build:
context: .
dockerfile: ./preprocessors/text-followup/Dockerfile
image: "text-followup:latest"
emotion-recognition:
build:
context: .
Expand Down Expand Up @@ -263,6 +268,11 @@ services:
context: .
dockerfile: ./handlers/svg-action-recognition/Dockerfile
image: "svg-action-recognition:latest"
text-followup-handler:
build:
context: .
dockerfile: ./handlers/text-followup-handler/Dockerfile
image: "text-followup-handler:latest"
# Supercollider on Fedora 34
supercollider-base:
build:
Expand Down
23 changes: 21 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ services:
profiles: [production, test, default]
image: 'memcached:1.6'
restart: unless-stopped
# cache memory size - 4GB
command: -m 4096
# cache memory size - 4GB, maximum item size - 5MB
command: -m 4096 -I 5m

espnet-tts:
profiles: [production, test, default]
Expand Down Expand Up @@ -104,6 +104,17 @@ services:
env_file:
./config/ollama.env

text-followup:
profiles: [test, default]
image: ghcr.io/shared-reality-lab/image-preprocessor-text-followup:${REGISTRY_TAG}
restart: unless-stopped
labels:
ca.mcgill.a11y.image.preprocessor: 1
ca.mcgill.a11y.image.port: 5000
ca.mcgill.a11y.image.cacheTimeout: 0
ca.mcgill.a11y.image.route: "followup"
env_file:
./config/ollama.env

graphic-tagger:
profiles: [production, test, default]
Expand Down Expand Up @@ -291,6 +302,14 @@ services:
labels:
ca.mcgill.a11y.image.handler: enable

text-followup-handler:
profiles: [test, default]
image: ghcr.io/shared-reality-lab/image-handler-text-followup:${REGISTRY_TAG}
restart: unless-stopped
labels:
ca.mcgill.a11y.image.handler: enable
ca.mcgill.a11y.image.route: "followup"

# end - common services

# start - unicorn exclusive services
Expand Down
5 changes: 5 additions & 0 deletions handlers/autour-handler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN npm run build && npm prune --production

FROM node:alpine as final

RUN apk add --no-cache curl

WORKDIR /usr/src/app
COPY --from=builder --chown=node:node /usr/src/app/package*.json ./
COPY --from=builder --chown=node:node /usr/src/app/dist ./dist
Expand All @@ -22,4 +24,7 @@ ENV NODE_ENV=production
EXPOSE 80

USER node

HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=5 CMD curl -f http://localhost:80/health || exit 1

CMD [ "node", "." ]
19 changes: 12 additions & 7 deletions handlers/autour-handler/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ app.post("/handler", async (req, res) => {
}

const autourData = preprocessors["ca.mcgill.a11y.image.preprocessor.autour"];
if (autourData["places"].length === 0) {

// Filter places we will not use before checking for non-zero length.
const places = autourData["places"].filter((p: { "cat": number }) => !filterCategories.includes(p["cat"]));
if (places.length === 0) {
console.warn("No places detected despite running.");
const response = {
"request_uuid": req.body["request_uuid"],
Expand Down Expand Up @@ -89,9 +92,8 @@ app.post("/handler", async (req, res) => {
return;
}

// Sort and filter POIs
// Do this before since TTS is time consuming
const places = autourData["places"].filter((p: { "cat": number }) => !filterCategories.includes(p["cat"]));
// Sort and filter POIs by distance.
// Do this before TTS since it is time consuming
const source = new LatLon(autourData["lat"], autourData["lon"]);
for (const place of places) {
const dest = new LatLon(place["ll"][0], place["ll"][1]);
Expand Down Expand Up @@ -136,7 +138,7 @@ app.post("/handler", async (req, res) => {
const translateSegments = []; // Combine map description with data to translate
translateSegments.push(description);
translateSegments.push(...segments);

const translated:string[] = await fetch( "http://multilang-support/service/translate", {
"method": "POST",
"headers": {
Expand All @@ -159,7 +161,6 @@ app.post("/handler", async (req, res) => {
for(let i = 1; i < translated.length; i++) {
segments[i - 1] = translated[i];
}

} catch (e) {
console.error(e);
console.debug(`Cannot translate to ${targetLanguage}`);
Expand All @@ -170,7 +171,7 @@ app.post("/handler", async (req, res) => {
return;
}
}

// Forming Response
let ttsResponse;
try {
Expand Down Expand Up @@ -331,6 +332,10 @@ app.post("/handler", async (req, res) => {
}
});

app.get("/health", (req, res) => {
res.status(200).json({ status: "healthy", timestamp: new Date().toISOString() });
});

app.listen(port, () => {
console.log(`Started server on port ${port}`);
});
5 changes: 5 additions & 0 deletions handlers/hello-handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:alpine

RUN apk add --no-cache curl

WORKDIR /usr/src/app

# Apparently splittig this up is good for layers
Expand All @@ -17,4 +19,7 @@ ENV NODE_ENV=production
EXPOSE 80

USER node

HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=5 CMD curl -f http://localhost:80/health || exit 1

CMD [ "node", "dist/server.js" ]
4 changes: 4 additions & 0 deletions handlers/hello-handler/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ app.post("/handler", async (req, res) => {
}
});

app.get("/health", (req, res) => {
res.status(200).json({ status: "healthy", timestamp: new Date().toISOString() });
});

app.listen(port, () => {
console.log(`Started server on port ${port}`);
});
5 changes: 4 additions & 1 deletion handlers/hello-svg-handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10

RUN apt-get install libcairo2
RUN apt-get install libcairo2 curl

RUN adduser --disabled-password python
WORKDIR /usr/src/app
Expand All @@ -15,4 +15,7 @@ COPY /handlers/hello-svg-handler/ /usr/src/app

EXPOSE 80
USER python

HEALTHCHECK --interval=60s --timeout=10s --start-period=120s --retries=5 CMD curl -f http://localhost:80/health || exit 1

CMD ["gunicorn", "hello_svg:app", "-b", "0.0.0.0:80", "--capture-output", "--log-level=debug" ]
13 changes: 13 additions & 0 deletions handlers/hello-svg-handler/hello_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import logging
import time
import drawSvg as draw
from datetime import datetime


app = Flask(__name__)

Expand Down Expand Up @@ -114,5 +116,16 @@ def handle():
return response


@app.route("/health", methods=["GET"])
def health():
"""
Health check endpoint to verify if the service is running
"""
return jsonify({
"status": "healthy",
"timestamp": datetime.now().isoformat()
}), 200


if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=False)
Loading
Loading