Skip to content

Commit f2655cf

Browse files
committed
chore: translate infrastructure and code comments from Portuguese to English
1 parent 59626c7 commit f2655cf

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

inference/src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import natural from 'natural';
88

99
const { BayesClassifier } = natural;
1010

11-
// Resolve caminho do DB relativo a este arquivo (independente do CWD)
11+
// Resolve DB path relative to this file (independent of CWD)
1212
const dbPath = new URL('../main.db', import.meta.url).pathname;
1313
const sqlite = new Database(dbPath);
1414
const db = drizzle(sqlite, { schema });
@@ -18,15 +18,15 @@ let classifier = null;
1818
async function loadProductionModel() {
1919
const prodRun = await db.query.runs.findFirst({ where: eq(schema.runs.isProduction, true) });
2020
if (prodRun && prodRun.modelArtifactPath) {
21-
// Resolve o caminho do artefato. Se for relativo (ex: 'artifacts/...'), resolvemos a partir da raiz do repo.
21+
// Resolve artifact path. If it's relative (e.g., 'artifacts/...'), resolve from the repo root.
2222
const artifactPath = prodRun.modelArtifactPath.startsWith('/')
2323
? prodRun.modelArtifactPath
2424
: new URL(`../../${prodRun.modelArtifactPath}`, import.meta.url).pathname;
25-
console.log(`Carregando modelo: ${artifactPath}`);
25+
console.log(`Loading model: ${artifactPath}`);
2626
const modelJson = await Bun.file(artifactPath).text();
2727
classifier = BayesClassifier.restore(JSON.parse(modelJson));
2828
} else {
29-
console.log("Nenhum modelo em produção encontrado.");
29+
console.log("No production model found.");
3030
}
3131
}
3232

@@ -50,15 +50,15 @@ const app = new Elysia()
5050
.post('/predict', async ({ body }) => {
5151
if (!classifier) {
5252
await loadProductionModel();
53-
if(!classifier) return { error: 'Modelo não está carregado' };
53+
if(!classifier) return { error: 'Model is not loaded' };
5454
}
5555
const prediction = classifier.getClassifications(body.message);
5656
return { prediction };
5757
}, {
58-
// O `t.Object` é um validador de schema em tempo de execução, útil também em JS.
58+
// `t.Object` is a runtime schema validator; useful in JS too.
5959
body: t.Object({ message: t.String() })
6060
})
6161
.listen(3001);
6262

63-
console.log(`API rodando em http://${app.server?.hostname}:${app.server?.port}`);
63+
console.log(`API running at http://${app.server?.hostname}:${app.server?.port}`);
6464
loadProductionModel();

infra/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Infraestrutura (conceitual)
1+
# Infrastructure (conceptual)
22

3-
Este diretório contém artefatos de infraestrutura para executar o monorepo em ambientes conteinerizados ou orquestrados.
3+
This directory contains infrastructure artifacts to run the monorepo in containerized or orchestrated environments.
44

5-
Estrutura:
5+
Structure:
66
- docker/
7-
- Dockerfile.inference: imagem do serviço de inferência (Elysia/Bun)
8-
- Dockerfile.dashboard: imagem do dashboard (Vite -> Nginx)
9-
- Dockerfile.training: imagem para job de treinamento on-demand
10-
- docker-compose.yml: orquestração local dos serviços (inference + dashboard). O serviço de training está em profile opcional.
7+
- Dockerfile.inference: image for the inference service (Elysia/Bun)
8+
- Dockerfile.dashboard: image for the dashboard (Vite -> Nginx)
9+
- Dockerfile.training: image for an on-demand training job
10+
- docker-compose.yml: local orchestration for services (inference + dashboard). The training job is in an optional profile.
1111
- k8s/
1212
- inference-deployment.yaml, inference-service.yaml
1313
- dashboard-deployment.yaml, dashboard-service.yaml
1414

15-
Observações:
16-
- Artefatos de modelo ficam centralizados em `artifacts/` na raiz e são montados nos containers.
17-
- O banco SQLite (`inference/main.db`) é compartilhado entre treino e inferência. No compose, o DB é efêmero por simplicidade; pode-se bind-mount conforme necessidade.
18-
- As imagens no diretório k8s são placeholders; ajuste com seu registry.
15+
Notes:
16+
- Model artifacts are centralized under `artifacts/` at the repo root and are mounted into containers.
17+
- The SQLite database (`inference/main.db`) is shared between training and inference. In compose, the DB is ephemeral for simplicity; you can bind-mount if needed.
18+
- Images in the k8s directory are placeholders; update them with your registry.

infra/docker/Dockerfile.inference

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
FROM oven/bun:1
33
WORKDIR /app
44

5-
# Copia o monorepo inteiro (conceitual/simples)
5+
# Copy the whole monorepo (simple/conceptual)
66
COPY . .
77

8-
# Instala dependências (workspaces)
8+
# Install dependencies (workspaces)
99
RUN bun install --ci
1010

1111
EXPOSE 3001

infra/docker/Dockerfile.training

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ WORKDIR /app
55
COPY . .
66
RUN bun install --ci
77

8-
# Perfil de job: executa e finaliza
8+
# Job profile: run and exit
99
CMD ["bun", "--cwd", "training", "run", "train"]

training/src/train.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { promises as fs } from 'fs';
88
const { BayesClassifier } = natural;
99

1010
async function trainAndEvaluate() {
11-
console.log('Iniciando o pipeline de treinamento...');
11+
console.log('Starting training pipeline...');
1212

13-
// Lê o dataset centralizado em data/raw/ (relativo a este arquivo)
13+
// Read dataset centralized in data/raw/ (relative to this file)
1414
const datasetPath = new URL('../../data/raw/dataset.csv', import.meta.url).pathname;
1515
const datasetRaw = await fs.readFile(datasetPath, 'utf-8');
1616
const dataset = datasetRaw.split('\n').slice(1).map(line => {
@@ -22,22 +22,22 @@ async function trainAndEvaluate() {
2222
const classifier = new BayesClassifier();
2323
dataset.forEach(item => item && classifier.addDocument(item.text, item.label));
2424
classifier.train();
25-
console.log('Modelo treinado.');
25+
console.log('Model trained.');
2626

2727
let correct = 0;
2828
dataset.forEach(item => {
2929
if (item && classifier.classify(item.text) === item.label) correct++;
3030
});
3131
const accuracy = correct / dataset.length;
32-
const metrics = { f1Score: accuracy, accuracy: accuracy }; // Simplificação
33-
console.log(`Acurácia do novo modelo: ${metrics.accuracy}`);
32+
const metrics = { f1Score: accuracy, accuracy: accuracy }; // Simplification
33+
console.log(`New model accuracy: ${metrics.accuracy}`);
3434

35-
// Usa o mesmo banco do serviço de inferência (inference/main.db)
35+
// Use the same DB as the inference service (inference/main.db)
3636
const dbPath = new URL('../../inference/main.db', import.meta.url).pathname;
3737
const sqlite = new Database(dbPath, { create: true });
3838
const db = drizzle(sqlite, { schema });
3939

40-
// Garante que exista um experimento padrão e obtem seu ID
40+
// Ensure a default experiment exists and get its ID
4141
let experimentId = 1;
4242
try {
4343
const existing = await db.query.experiments.findFirst({
@@ -53,14 +53,14 @@ async function trainAndEvaluate() {
5353
experimentId = existing.id;
5454
}
5555
} catch (e) {
56-
console.warn('Não foi possível verificar/criar experimento padrão:', e?.message || e);
56+
console.warn('Could not verify/create default experiment:', e?.message || e);
5757
}
5858

5959
const currentProdRun = await db.query.runs.findFirst({
6060
where: eq(schema.runs.isProduction, true),
6161
});
6262

63-
// Lê métricas atuais do modelo em produção (podem estar como string JSON)
63+
// Read current production model metrics (may be stored as JSON string)
6464
let currentProdAccuracy = 0;
6565
if (currentProdRun?.metrics) {
6666
try {
@@ -70,23 +70,23 @@ async function trainAndEvaluate() {
7070
currentProdAccuracy = 0;
7171
}
7272
}
73-
console.log(`Acurácia do modelo em produção: ${currentProdAccuracy}`);
73+
console.log(`Production model accuracy: ${currentProdAccuracy}`);
7474

7575
if (metrics.accuracy <= currentProdAccuracy) {
76-
console.log('Novo modelo não superou o modelo em produção. Abortando.');
76+
console.log('New model did not outperform the production model. Aborting.');
7777
return;
7878
}
7979

80-
console.log('Novo modelo é superior! Promovendo para produção.');
80+
console.log('New model is better! Promoting to production.');
8181
const runId = Date.now();
82-
// Salva o artefato centralizado em artifacts/ na raiz do repo
82+
// Save artifact centralized under artifacts/ at the repo root
8383
const modelArtifactPath = `artifacts/model_${runId}.json`;
8484

8585
const artifactDir = new URL('../../artifacts/', import.meta.url).pathname;
8686
await fs.mkdir(artifactDir, { recursive: true });
8787
const classifierJson = JSON.stringify(classifier);
8888
await fs.writeFile(`${artifactDir}model_${runId}.json`, classifierJson);
89-
console.log(`Modelo salvo em: ${modelArtifactPath}`);
89+
console.log(`Model saved at: ${modelArtifactPath}`);
9090

9191
if (currentProdRun) {
9292
await db.update(schema.runs).set({ isProduction: false }).where(eq(schema.runs.id, currentProdRun.id));
@@ -101,7 +101,7 @@ async function trainAndEvaluate() {
101101
isProduction: true,
102102
});
103103

104-
console.log('Pipeline de treinamento concluído com sucesso!');
104+
console.log('Training pipeline completed successfully!');
105105
}
106106

107107
trainAndEvaluate();

0 commit comments

Comments
 (0)