Merge branch 'feature/preprocessing' of https://project.nes.uni-due.de/gitea/lbs/smartguide into feature/preprocessing
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -28,9 +28,3 @@ COPY service/scripts/news/topic_mapper/ ./service/scripts/news/topic_mapper/
|
||||
|
||||
# The bund foerderportal crawler (runs with its own dir as cwd for its JSON configs).
|
||||
COPY service/scripts/projects/bund/ ./projects/bund/
|
||||
|
||||
# Small dispatcher that maps a job name to the right command.
|
||||
COPY background-jobs/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# Background Jobs
|
||||
|
||||
Background Jobs sind Docker-Container, die regelmäßig oder manuell Elasticsearch-Daten verarbeiten. Sie werden vom Backend über den Docker-Socket gestartet.
|
||||
|
||||
**Wichtig:** Jobs sind in der **Datenbank**, nicht im Image. Das Image enthält nur die ausführbaren Skripte.
|
||||
|
||||
## Jobs anlegen
|
||||
|
||||
**Frontend** (`/jobs`):
|
||||
|
||||
- "Neuer Job" → Name + Command + optionales Image + Zeitplan
|
||||
|
||||
**API**:
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer $TOKEN" \
|
||||
-d '{"name": "Sync", "command": "python sync.py --sync-delta", "schedule": "0 3 * * *"}' \
|
||||
http://localhost:8000/api/background-jobs/tasks
|
||||
```
|
||||
|
||||
Command-Beispiele:
|
||||
|
||||
```
|
||||
python sync.py --sync-delta
|
||||
python news/ude/run_pipeline.py --skip-upload
|
||||
python -m service.scripts.projects.topic_mapper.map_project_topics --dry-run
|
||||
```
|
||||
|
||||
**Neue Jobs = kein Image-Rebuild.** Die Skripte sind bereits im Image; der Command wird direkt an Docker übergeben.
|
||||
|
||||
## Image & Dockerfile
|
||||
|
||||
Das [Dockerfile](./Dockerfile) enthält die Skripte (sync.py, news/, projects/, etc.) und hat keine ENTRYPOINT. Der Backend startet Container direkt:
|
||||
|
||||
```python
|
||||
docker.run(image="...", command="python sync.py --sync-delta")
|
||||
```
|
||||
|
||||
**Nur Skripte hinzufügen?** → Image neu bauen + pushen:
|
||||
|
||||
```bash
|
||||
docker build -f background-jobs/Dockerfile -t docker.nes.uni-due.de/inse/background-jobs:latest .
|
||||
docker push docker.nes.uni-due.de/inse/background-jobs:latest
|
||||
```
|
||||
|
||||
Lokal testen ohne Pull:
|
||||
|
||||
```bash
|
||||
export INSE_BACKGROUND_JOBS_PULL_BEFORE_RUN=false
|
||||
```
|
||||
|
||||
## Scheduling
|
||||
|
||||
Job mit `schedule: "0 3 * * *"` und `enabled: true` läuft automatisch täglich um 3:00 UTC. Manuell starten: "Jetzt ausführen" Button oder API.
|
||||
|
||||
## Logs
|
||||
|
||||
Während Laufzeit: Live vom Container. Nach Beendigung: Letzte 200 Zeilen in der DB. Frontend: "Logs anzeigen" Button.
|
||||
|
||||
## Docker-Socket (Deployment)
|
||||
|
||||
```yaml
|
||||
# docker-compose
|
||||
backend:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
```
|
||||
|
||||
Ohne Socket-Mount funktioniert nichts.
|
||||
|
||||
## Env-Variablen
|
||||
|
||||
Standard-Image erhält automatisch:
|
||||
|
||||
- `INSE_ELASTIC_URL`, `INSE_ELASTIC_API_KEY`
|
||||
- `INSE_LLM_*`, `ELASTICSEARCH_INSE_*`, `SENTENCE_TRANSFORMERS_MODEL_NAME`
|
||||
|
||||
Plus `env` aus der Job-Definition.
|
||||
|
||||
**Eigene Images** bekommen nur die `env`-Variablen (Sicherheit).
|
||||
|
||||
## API
|
||||
|
||||
- `GET /api/background-jobs/tasks` — Jobs auflisten
|
||||
- `POST /api/background-jobs/tasks` — Job anlegen
|
||||
- `DELETE /api/background-jobs/tasks/{id}` — Job löschen
|
||||
- `POST /api/background-jobs/tasks/{id}/run` — Run starten
|
||||
- `PATCH /api/background-jobs/tasks/{id}` — Schedule ändern
|
||||
- `GET /api/background-jobs/runs/{id}/logs` — Logs abrufen
|
||||
- `POST /api/background-jobs/runs/{id}/stop` — Run stoppen
|
||||
|
||||
Alle Endpoints erfordern Superadmin-Auth.
|
||||
@@ -1,68 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Job dispatcher for the preprocessing worker.
|
||||
# Usage: <job-name> e.g. docker run <image> news
|
||||
set -eu
|
||||
|
||||
JOB="${1:-}"
|
||||
|
||||
case "$JOB" in
|
||||
news)
|
||||
# Enrich new 'aktuell' articles into 'aktuell_postproc' (relevance, authors, keywords).
|
||||
exec python sync.py --sync-delta
|
||||
;;
|
||||
news-stats)
|
||||
# Print counts for the aktuell / aktuell_postproc indices (read-only).
|
||||
exec python sync.py --stats
|
||||
;;
|
||||
news-crawl)
|
||||
# Crawl UDE 'aktuell' into JSON only. --skip-upload keeps Elasticsearch untouched.
|
||||
exec python news/ude/run_pipeline.py --skip-upload --max-items "${NEWS_CRAWL_MAX_ITEMS:-5}"
|
||||
;;
|
||||
bund-crawl)
|
||||
# Crawl the bund foerderportal export via headless Chrome. --skip-upload keeps ES untouched.
|
||||
cd projects/bund || exit 1
|
||||
exec python gpc.data.py --skip-upload
|
||||
;;
|
||||
project-topics)
|
||||
# Map bund-project keywords to OpenAlex topics. --dry-run reads only, writes nothing.
|
||||
exec python -m service.scripts.projects.topic_mapper.map_project_topics \
|
||||
--dry-run \
|
||||
--max-docs "${PROJECT_TOPICS_MAX_DOCS:-50}" \
|
||||
--source-index projects_bund_v1 \
|
||||
--text-field Leistungsplansystematik_fullname \
|
||||
--output-index projects_bund_openalex_topics \
|
||||
--api-base-url "${PROJECT_TOPICS_API_BASE_URL:-http://host.docker.internal:8000}"
|
||||
;;
|
||||
news-keywords)
|
||||
# Extract news keywords with the LLM. Writes to the docker test index, so
|
||||
# 'aktuell_postproc' stays untouched.
|
||||
exec python sync.py --update-keywords \
|
||||
--target-index "${NEWS_KEYWORDS_TARGET_INDEX:-docker-job_test}" \
|
||||
--limit "${NEWS_KEYWORDS_LIMIT:-50}" \
|
||||
--threads "${NEWS_KEYWORDS_THREADS:-4}"
|
||||
;;
|
||||
news-topics)
|
||||
# Map the keywords of enriched news articles to OpenAlex topics.
|
||||
exec python -m service.scripts.news.topic_mapper.map_news_topics \
|
||||
--output-index "${NEWS_TOPICS_OUTPUT_INDEX:-docker-job_test}" \
|
||||
--max-docs "${NEWS_TOPICS_MAX_DOCS:-50}" \
|
||||
--api-base-url "${PROJECT_TOPICS_API_BASE_URL:-http://host.docker.internal:8000}"
|
||||
;;
|
||||
demo-a)
|
||||
exec python demo.py 20
|
||||
;;
|
||||
demo-b)
|
||||
exec python demo.py 25
|
||||
;;
|
||||
demo-c)
|
||||
exec python demo.py 30
|
||||
;;
|
||||
"")
|
||||
echo "No job given. Available jobs: news, news-stats, news-crawl, news-keywords, news-topics, project-topics, bund-crawl, demo-a, demo-b, demo-c" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown job: $JOB. Available jobs: news, news-stats, news-crawl, news-keywords, news-topics, project-topics, bund-crawl, demo-a, demo-b, demo-c" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -1,102 +0,0 @@
|
||||
"""
|
||||
Seeding of the predefined background job definitions.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sqlmodel import Session, select
|
||||
|
||||
from .model import JobDefinition
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
PREDEFINED_JOBS: list[dict] = [
|
||||
{
|
||||
"name": "News-Crawler (Testlauf, ohne Upload)",
|
||||
"description": (
|
||||
"Crawlt die UDE-„aktuell“-Seiten mit Scrapy und legt die Artikel nur "
|
||||
"als JSON im Container ab. Der Upload-Schritt ist abgeschaltet, es "
|
||||
"wird nichts nach Elasticsearch geschrieben. Begrenzt auf wenige "
|
||||
"Artikel, da ein vollständiger Crawl mehrere Stunden dauert."
|
||||
),
|
||||
"target_index": "-",
|
||||
"command": "news-crawl",
|
||||
},
|
||||
{
|
||||
"name": "Projekt-Themen-Mapping (Testlauf, Dry-Run)",
|
||||
"description": (
|
||||
"Ordnet die Schlagwörter der Bund-Projekte über die Topic-Vektorsuche "
|
||||
"des Backends OpenAlex-Themen zu. Läuft als Dry-Run (--dry-run): liest "
|
||||
"nur aus dem Quellindex und schreibt nichts nach Elasticsearch. "
|
||||
),
|
||||
"target_index": "-",
|
||||
"command": "project-topics",
|
||||
},
|
||||
{
|
||||
"name": "News-Schlagwort-Extraktion (Testlauf)",
|
||||
"description": (
|
||||
"Extrahiert per LLM die Schlagwörter aus den News-Artikeln und legt sie "
|
||||
"im Testindex „docker-job_test“ ab. „aktuell_postproc“ bleibt dabei "
|
||||
"unverändert. Begrenzt auf wenige Artikel; da nichts im Quellindex "
|
||||
"markiert wird, verarbeitet jeder Lauf erneut die ersten Artikel."
|
||||
),
|
||||
"target_index": "docker-job_test",
|
||||
"command": "news-keywords",
|
||||
},
|
||||
{
|
||||
"name": "News-Themen-Mapping (Testlauf)",
|
||||
"description": (
|
||||
"Ordnet die per LLM extrahierten Schlagwörter der angereicherten "
|
||||
"News-Artikel („aktuell_postproc“) über die Topic-Vektorsuche des "
|
||||
"Backends OpenAlex-Themen zu und schreibt je Artikel-Schlagwort-Paar "
|
||||
"ein Dokument in den Testindex „docker-job_test“. Begrenzt auf wenige "
|
||||
"Artikel; erneute Läufe überspringen bereits gemappte Paare."
|
||||
),
|
||||
"target_index": "docker-job_test",
|
||||
"command": "news-topics",
|
||||
},
|
||||
{
|
||||
"name": "Bund-Crawler (Testlauf, ohne Upload)",
|
||||
"description": (
|
||||
"Lädt den Projekt-Export des Bund-Förderportals via Headless-Chrome "
|
||||
"herunter und formatiert ihn. Läuft mit --skip-upload: es wird nichts "
|
||||
"nach Elasticsearch geschrieben. Startet einen echten Browser-Crawl "
|
||||
"von foerderportal.bund.de und kann daher länger dauern."
|
||||
),
|
||||
"target_index": "-",
|
||||
"command": "bund-crawl",
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job A",
|
||||
"description": "Testjob für Demos: läuft ca. 20 Sekunden, schreibt "
|
||||
"Fortschritt ins Log und verändert nichts.",
|
||||
"target_index": "-",
|
||||
"command": "demo-a",
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job B",
|
||||
"description": "Testjob für Demos: läuft ca. 25 Sekunden, schreibt "
|
||||
"Fortschritt ins Log und verändert nichts.",
|
||||
"target_index": "-",
|
||||
"command": "demo-b",
|
||||
},
|
||||
{
|
||||
"name": "Demo-Job C",
|
||||
"description": "Testjob für Demos: läuft ca. 30 Sekunden, schreibt "
|
||||
"Fortschritt ins Log und verändert nichts.",
|
||||
"target_index": "-",
|
||||
"command": "demo-c",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def create_predefined_job_definitions(session: Session) -> None:
|
||||
for entry in PREDEFINED_JOBS:
|
||||
existing = session.exec(
|
||||
select(JobDefinition).where(JobDefinition.name == entry["name"])
|
||||
).first()
|
||||
if existing:
|
||||
continue
|
||||
session.add(JobDefinition(**entry))
|
||||
logger.info("Seeded background job definition '%s'.", entry["name"])
|
||||
session.commit()
|
||||
@@ -46,7 +46,6 @@ from inse.database import create_db_and_tables, get_session
|
||||
from inse.auth.service import create_predefined_accounts
|
||||
from inse.background_jobs.router import router as background_jobs_router
|
||||
from inse.background_jobs.runner import scheduler_loop as background_jobs_scheduler_loop
|
||||
from inse.background_jobs.seed import create_predefined_job_definitions
|
||||
from . import config
|
||||
|
||||
from .service import router as service_router
|
||||
@@ -72,7 +71,6 @@ async def lifespan(app: FastAPI):
|
||||
create_db_and_tables()
|
||||
with contextmanager(get_session)() as session:
|
||||
create_predefined_accounts(session, "../data/predefined_accounts.json")
|
||||
create_predefined_job_definitions(session)
|
||||
|
||||
background_jobs_scheduler_task = None
|
||||
if settings.background_jobs_scheduler_enabled:
|
||||
|
||||
@@ -7,6 +7,14 @@
|
||||
ausführen oder per Cron-Zeitplan automatisieren.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
type="button"
|
||||
(click)="openCreateDialog()">
|
||||
<mat-icon>add</mat-icon>
|
||||
Neuer Job
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<mat-card appearance="outlined" class="docker-health-card">
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
JobLogsDialogComponent,
|
||||
JobLogsDialogData,
|
||||
} from './job-logs-dialog/job-logs-dialog.component';
|
||||
import { TaskCreateDialogComponent } from './task-create-dialog/task-create-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-jobs',
|
||||
@@ -255,6 +256,29 @@ export class JobsComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
protected openCreateDialog(): void {
|
||||
const dialogRef = this.dialog.open<
|
||||
TaskCreateDialogComponent,
|
||||
void,
|
||||
BackgroundJobTask | undefined
|
||||
>(TaskCreateDialogComponent, {
|
||||
width: '560px',
|
||||
maxWidth: 'calc(100vw - 32px)',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((task) => {
|
||||
if (!task) return;
|
||||
|
||||
this.tasks.update((tasks) => [...tasks, task]);
|
||||
this.snackBar.open(`„${task.name}“ wurde angelegt.`, 'OK', {
|
||||
duration: 3000,
|
||||
horizontalPosition: 'center',
|
||||
verticalPosition: 'bottom',
|
||||
});
|
||||
this.refreshTasks();
|
||||
});
|
||||
}
|
||||
|
||||
protected openScheduleDialog(task: BackgroundJobTask): void {
|
||||
const dialogRef = this.dialog.open<
|
||||
TaskScheduleDialogComponent,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<h2 mat-dialog-title>Neuer Job</h2>
|
||||
|
||||
<mat-dialog-content>
|
||||
<form class="create-form" [formGroup]="form">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput formControlName="name" />
|
||||
@if (form.controls.name.invalid) {
|
||||
<mat-error>Bitte einen Namen eingeben.</mat-error>
|
||||
}
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Befehl (optional)</mat-label>
|
||||
<input matInput formControlName="command" />
|
||||
<mat-hint
|
||||
>Der Befehl, den der Container ausführt. Leer = Standard-Entrypoint des
|
||||
Images.</mat-hint
|
||||
>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Image (optional)</mat-label>
|
||||
<input matInput formControlName="image" />
|
||||
<mat-hint
|
||||
>Docker-Image (Standard:
|
||||
docker.nes.uni-due.de/inse/background-jobs:latest).</mat-hint
|
||||
>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<textarea matInput rows="2" formControlName="description"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Ziel-Index (optional)</mat-label>
|
||||
<input matInput formControlName="targetIndex" />
|
||||
<mat-hint
|
||||
>Elasticsearch-Index, in den der Job schreibt (Anzeige).</mat-hint
|
||||
>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Umgebungsvariablen (optional)</mat-label>
|
||||
<textarea
|
||||
matInput
|
||||
rows="3"
|
||||
formControlName="env"
|
||||
placeholder="KEY=value"></textarea>
|
||||
<mat-hint>Eine Variable pro Zeile im Format KEY=value.</mat-hint>
|
||||
@if (form.controls.env.hasError('invalidEnv')) {
|
||||
<mat-error>Ungültige Zeile — Format: KEY=value.</mat-error>
|
||||
}
|
||||
</mat-form-field>
|
||||
</form>
|
||||
|
||||
@if (serverError()) {
|
||||
<p class="server-error">{{ serverError() }}</p>
|
||||
}
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="button" (click)="close()">Abbrechen</button>
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
type="button"
|
||||
[disabled]="creating()"
|
||||
(click)="submit()">
|
||||
<mat-icon>add</mat-icon>
|
||||
Anlegen
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,32 @@
|
||||
.create-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 400px;
|
||||
}
|
||||
|
||||
.commands-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #64748b;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
margin: -6px 0 0;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.server-error {
|
||||
margin: 8px 0 0;
|
||||
color: #b3261e;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.create-form {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import {
|
||||
FormControl,
|
||||
FormGroup,
|
||||
ReactiveFormsModule,
|
||||
Validators,
|
||||
} from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { BackgroundJobTask, BackgroundJobsService } from '../../../api';
|
||||
|
||||
const ENV_LINE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
||||
|
||||
@Component({
|
||||
selector: 'app-task-create-dialog',
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
MatButtonModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
],
|
||||
templateUrl: './task-create-dialog.component.html',
|
||||
styleUrl: './task-create-dialog.component.scss',
|
||||
standalone: true,
|
||||
})
|
||||
export class TaskCreateDialogComponent {
|
||||
private readonly dialogRef =
|
||||
inject<
|
||||
MatDialogRef<TaskCreateDialogComponent, BackgroundJobTask | undefined>
|
||||
>(MatDialogRef);
|
||||
private readonly backgroundJobsService = inject(BackgroundJobsService);
|
||||
|
||||
protected readonly creating = signal(false);
|
||||
protected readonly serverError = signal('');
|
||||
|
||||
protected readonly form = new FormGroup({
|
||||
name: new FormControl('', {
|
||||
nonNullable: true,
|
||||
validators: [Validators.required],
|
||||
}),
|
||||
description: new FormControl('', { nonNullable: true }),
|
||||
targetIndex: new FormControl('', { nonNullable: true }),
|
||||
command: new FormControl('', { nonNullable: true }),
|
||||
image: new FormControl('', { nonNullable: true }),
|
||||
env: new FormControl('', { nonNullable: true }),
|
||||
});
|
||||
|
||||
protected submit(): void {
|
||||
this.serverError.set('');
|
||||
const value = this.form.getRawValue();
|
||||
|
||||
const name = value.name.trim();
|
||||
if (!name) {
|
||||
this.form.controls.name.markAsTouched();
|
||||
return;
|
||||
}
|
||||
|
||||
const command = value.command.trim() || null;
|
||||
const env = this.parseEnv(value.env);
|
||||
if (env === undefined) return;
|
||||
|
||||
this.creating.set(true);
|
||||
this.backgroundJobsService
|
||||
.createBackgroundJobTask({
|
||||
name,
|
||||
description: value.description.trim(),
|
||||
target_index: value.targetIndex.trim(),
|
||||
image: value.image.trim() || null,
|
||||
command,
|
||||
env,
|
||||
})
|
||||
.subscribe({
|
||||
next: (task) => this.dialogRef.close(task),
|
||||
error: (error) => {
|
||||
this.creating.set(false);
|
||||
const detail = error?.error?.detail;
|
||||
this.serverError.set(
|
||||
typeof detail === 'string'
|
||||
? detail
|
||||
: 'Der Job konnte nicht angelegt werden.',
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
protected close(): void {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
private parseEnv(text: string): { [key: string]: string } | undefined {
|
||||
const env: { [key: string]: string } = {};
|
||||
for (const line of text.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) continue;
|
||||
if (!ENV_LINE_PATTERN.test(trimmed)) {
|
||||
this.form.controls.env.setErrors({ invalidEnv: true });
|
||||
this.form.controls.env.markAsTouched();
|
||||
return undefined;
|
||||
}
|
||||
const separatorIndex = trimmed.indexOf('=');
|
||||
env[trimmed.slice(0, separatorIndex)] = trimmed.slice(separatorIndex + 1);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user