This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import platform
|
||||
import tracemalloc
|
||||
@@ -58,7 +59,7 @@ def _percentile(values: list[float], p: float) -> float:
|
||||
if not values:
|
||||
return 0.0
|
||||
ordered = sorted(values)
|
||||
index = round((len(ordered) - 1) * p / 100)
|
||||
index = max(0, math.ceil(len(ordered) * p / 100) - 1)
|
||||
return ordered[index]
|
||||
|
||||
|
||||
@@ -98,7 +99,7 @@ class BenchmarkArtifact:
|
||||
|
||||
def _load_text(path: Path) -> str:
|
||||
_is_supported_file_path(path)
|
||||
return path.read_text(encoding="utf-8")
|
||||
return path.read_text(encoding="utf-8-sig")
|
||||
|
||||
|
||||
def load_benchmark_dataset(path: Path) -> dict[str, Any]:
|
||||
@@ -297,8 +298,6 @@ def _create_seed_jobs(
|
||||
)
|
||||
job = JobPosting.objects.create(
|
||||
employer=employer,
|
||||
requirements=payload["job"]["requirements"],
|
||||
benefits=payload["job"]["benefits"],
|
||||
description_html_sanitized=payload["job"]["description_text"],
|
||||
extraction_confidence=Decimal("0.95"),
|
||||
analysis_features={},
|
||||
|
||||
@@ -11,7 +11,7 @@ import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
|
||||
django.setup()
|
||||
|
||||
from apps.profiles.models import SearchProfile
|
||||
from apps.profiles.models import SearchProfile # noqa: E402
|
||||
|
||||
|
||||
def _load_profile(profile_id: int | None, username: str | None) -> SearchProfile:
|
||||
@@ -35,7 +35,9 @@ def _collect_feedback_churn(profile: SearchProfile) -> dict:
|
||||
false_negatives = []
|
||||
|
||||
for feedback in all_feedback:
|
||||
learning = feedback.metadata.get("learning") if isinstance(feedback.metadata, dict) else None
|
||||
learning = (
|
||||
feedback.metadata.get("learning") if isinstance(feedback.metadata, dict) else None
|
||||
)
|
||||
if not isinstance(learning, dict):
|
||||
continue
|
||||
reason_code = learning.get("reason_code", "")
|
||||
@@ -112,7 +114,10 @@ def main(argv: list[str] | None = None) -> int:
|
||||
]
|
||||
+ [f" - {item['feature']}: {item['delta']:+.3f}" for item in report["weight_churn"]]
|
||||
+ [f"\nMogelijke non-learn false negatives (max {args.top}):"]
|
||||
+ [f" - {item['job_id']} ({item['reason_code']})" for item in feedback_report["queued_non_learning_signals"][: args.top]]
|
||||
+ [
|
||||
f" - {item['job_id']} ({item['reason_code']})"
|
||||
for item in feedback_report["queued_non_learning_signals"][: args.top]
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
|
||||
@@ -109,24 +109,27 @@ def _run_fixture_import(*, fixture: str, url: str, source_name: str, source_type
|
||||
|
||||
|
||||
def _assert_idempotent_import(url: str) -> tuple[JobPosting, int]:
|
||||
aliases = list(
|
||||
JobSourceAlias.objects.filter(url=url).select_related("job").order_by("pk")
|
||||
)
|
||||
aliases = list(JobSourceAlias.objects.filter(url=url).select_related("job").order_by("pk"))
|
||||
if not aliases:
|
||||
raise RuntimeError("Release-smoke: fixtureimport leverde geen alias op.")
|
||||
job_ids = {alias.job_id for alias in aliases if alias.job_id}
|
||||
if len(job_ids) != 1:
|
||||
raise RuntimeError(
|
||||
f"Release-smoke: fixtureimport leidde niet tot één aliascluster (aantal jobids={len(job_ids)})."
|
||||
"Release-smoke: fixtureimport leidde niet tot één aliascluster "
|
||||
f"(aantal jobids={len(job_ids)})."
|
||||
)
|
||||
return aliases[-1].job, len(aliases)
|
||||
|
||||
|
||||
def _build_report(*, label: str, alias_count: int, job: JobPosting, profile: SearchProfile) -> dict[str, object]:
|
||||
def _build_report(
|
||||
*, label: str, alias_count: int, job: JobPosting, profile: SearchProfile
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
"label": label,
|
||||
"alias_count": alias_count,
|
||||
"source_job_count": JobPosting.objects.filter(source_aliases__url=job.canonical_url).count(),
|
||||
"source_job_count": JobPosting.objects.filter(
|
||||
source_aliases__url=job.canonical_url
|
||||
).count(),
|
||||
"job_total_count": JobPosting.objects.count(),
|
||||
"feedback_count": Feedback.objects.filter(user=profile.user, job=job).count(),
|
||||
"application_exists": JobPosting.objects.filter(id=job.id).exists(),
|
||||
|
||||
Reference in New Issue
Block a user