Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0798ad2
pii logging to grouping
shahdyousefak Jan 27, 2025
8ed6a52
cherry picking pii logging for grouping
shahdyousefak Jan 28, 2025
ea865b0
semseg pii
shahdyousefak Jan 28, 2025
c3a5ee8
preprocessors with pii logging (1)
shahdyousefak Jan 28, 2025
a106817
preprocessors with pii logging (2)
shahdyousefak Jan 28, 2025
1c4a380
pii logging for preprocessors (3)
shahdyousefak Jan 28, 2025
56c5df9
adding .py handlers + nominatim PII logging
shahdyousefak Feb 5, 2025
855ff86
modifying logging_utils.ts (still not working)
shahdyousefak Feb 8, 2025
98cb233
ensure Winston correctly recognizes pii as a valid log level
shahdyousefak Feb 8, 2025
2ed63ed
all typescript related MS incorporate PII logging
shahdyousefak Feb 10, 2025
a6a9b87
resolving merge conflicts
shahdyousefak Feb 10, 2025
c509793
build failures
shahdyousefak Feb 10, 2025
ca57737
adding winston lib
shahdyousefak Feb 11, 2025
d90f99a
test
shahdyousefak Feb 11, 2025
cbec4e5
test
shahdyousefak Feb 11, 2025
6aebdab
test
shahdyousefak Feb 11, 2025
42a2ac7
logging_utils.ts import error
shahdyousefak Feb 11, 2025
5f0837c
logging_utils.ts import error
shahdyousefak Feb 11, 2025
392de7d
logging_utils.ts import error
shahdyousefak Feb 11, 2025
ef4db3e
logging_utils.ts import error
shahdyousefak Feb 11, 2025
8616394
logging_utils.ts import error
shahdyousefak Feb 11, 2025
4244e05
logging_utils.ts import error
shahdyousefak Feb 11, 2025
24147f6
modifying nominatim workflow yaml
shahdyousefak Feb 11, 2025
9f114b5
modifying nominatim workflow yaml to copy config
shahdyousefak Feb 11, 2025
63c492b
adding copy config to workflows, winston download
shahdyousefak Feb 11, 2025
4c644c1
adding debug to autour handler workflow
shahdyousefak Feb 11, 2025
308e22c
fixing typo in workflows
shahdyousefak Feb 11, 2025
bd2e5cc
fixing typo in workflows
shahdyousefak Feb 11, 2025
e428433
adding npm install to high-charts
shahdyousefak Feb 11, 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
3 changes: 3 additions & 0 deletions .github/workflows/autour-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/autour-handler
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/autour-handler
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/autour-handler
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/high-charts-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/high-charts
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/high-charts
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/high-charts
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/motd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/motd
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/motd
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/motd
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nominatim-preprocessor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./preprocessors/nominatim
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./preprocessors/nominatim
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./preprocessors/nominatim
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/osm-streets-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/osm-streets-handler
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/osm-streets-handler
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/osm-streets-handler
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/photo-audio-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/photo-audio-handler
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/photo-audio-handler
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/photo-audio-handler
run: npm ci
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/photo-audio-haptics-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Copy schemas
working-directory: ./handlers/photo-audio-haptics-handler
run: cp -R ../../schemas src/
- name: Copy config
working-directory: ./handlers/photo-audio-haptics-handler
run: cp -R ../../config src/
- name: Install dependencies
working-directory: ./handlers/photo-audio-haptics-handler
run: npm ci
Expand Down
10 changes: 0 additions & 10 deletions build.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing text-followup preprocessor and handler?

Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ 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 @@ -268,11 +263,6 @@ 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
2 changes: 2 additions & 0 deletions config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# /app/config/__init__.py
# This file marks the config directory as a Python package.
34 changes: 34 additions & 0 deletions config/logging_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import logging
import os

# Define a PII log level
PII_LOG_LEVEL = 5
logging.addLevelName(PII_LOG_LEVEL, "PII")


def pii(self, message, *args, **kwargs):
if self.isEnabledFor(PII_LOG_LEVEL):
self._log(PII_LOG_LEVEL, message, args, **kwargs)


logging.Logger.pii = pii
logging.pii = lambda msg, *args, **kwargs: logging.log(
PII_LOG_LEVEL, msg, *args, **kwargs)


def configure_logging():
"""
Configures logging based on environment variables.
"""
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
pii_logging_enabled = os.getenv("PII_LOGGING_ENABLED",
"false").lower() == "true"

level = getattr(logging, log_level, logging.INFO)
logging.basicConfig(level=level)

if pii_logging_enabled:
logging.warning("Environment Unicorn: PII logging enabled!")
logging.getLogger().setLevel(PII_LOG_LEVEL) # Lower log level to PII
else:
logging.info("Environment Pegasus: PII logging is disabled.")
47 changes: 47 additions & 0 deletions config/logging_utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// https://medium.com/@jaiprajapati3/masking-of-sensitive-data-in-logs-700850e233f5
// https://github.com/winstonjs/winston/blob/c69cdb0cec15a138e0b6e374501e027d1c39606c/index.d.ts

import winston, { LogMethod, LogEntry } from 'winston';
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.Console({
format: winston.format.simple(),
}),
],
});

interface PIILogger extends LogMethod {
pii: (message: string) => void;
}

const piiLoggingEnabled = process.env.PII_LOGGING_ENABLED === 'true';

if (piiLoggingEnabled) {
logger.warn("Environment Unicorn: PII logging enabled!");
} else {
logger.info("Environment Pegasus: PII logging is disabled.");
}

// PII Logger Function
const piiLogger: PIILogger = ((arg1: string | LogEntry, arg2?: any) => {
if (typeof arg1 === 'string' && arg2 !== undefined) { // log when both level and message are provided
logger.log(arg1, arg2);
} else if (typeof arg1 === 'object') { // log when an object is provided
logger.log(arg1);
} else {
throw new Error('Invalid log format');
}
}) as PIILogger;

// Function for logging PII-related errors
piiLogger.pii = (message: string) => {
if (piiLoggingEnabled) {
logger.error(`[PII] ${message}`);
} else {
logger.warn("PII logging attempted but is DISABLED.");
}
};

export { piiLogger };
19 changes: 0 additions & 19 deletions docker-compose.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, these should not removed from docker compose

Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ 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 @@ -302,14 +291,6 @@ 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: 3 additions & 2 deletions handlers/autour-handler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:alpine as builder
FROM node:alpine AS builder

RUN addgroup -g 4322 storage && addgroup node storage

Expand All @@ -9,9 +9,10 @@ RUN npm ci
COPY /handlers/autour-handler/src ./src
COPY /handlers/autour-handler/types ./types
COPY /schemas src/schemas
COPY /config ./src/config
RUN npm run build && npm prune --production

FROM node:alpine as final
FROM node:alpine AS final

RUN apk add --no-cache curl

Expand Down
Loading
Loading