mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-12 19:50:57 +05:00
Fix lint: settings import placement and benchmark script exec bit
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019YHSjZM6TstSAMN2PhgfUg
This commit is contained in:
parent
7167c5dd8a
commit
c2191f9e74
@ -72,7 +72,10 @@ def _run_sqlite_only_sql(apps, schema_editor):
|
||||
if schema_editor.connection.vendor != "sqlite":
|
||||
return
|
||||
migrations.RunSQL(sql=INITIAL_SQL, reverse_sql=INITIAL_REVERSE_SQL).database_forwards(
|
||||
"api", schema_editor, None, None,
|
||||
"api",
|
||||
schema_editor,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
@ -80,7 +83,10 @@ def _run_sqlite_only_sql_reverse(apps, schema_editor):
|
||||
if schema_editor.connection.vendor != "sqlite":
|
||||
return
|
||||
migrations.RunSQL(sql=INITIAL_SQL, reverse_sql=INITIAL_REVERSE_SQL).database_backwards(
|
||||
"api", schema_editor, None, None,
|
||||
"api",
|
||||
schema_editor,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,10 @@ import archivebox
|
||||
from archivebox.config.constants import CONSTANTS
|
||||
from archivebox.config.common import get_config
|
||||
from archivebox.core.routes_util import get_api_base_url, get_admin_base_url, get_base_url, normalize_base_url
|
||||
|
||||
# All sqlite-vs-postgres connection logic lives in archivebox.misc.db;
|
||||
# DATABASE_ENGINE config selects the backend (sqlite by default).
|
||||
from archivebox.misc.db import get_database_settings, get_sqlite_connection_options
|
||||
from .settings_logging import SETTINGS_LOGGING
|
||||
|
||||
|
||||
@ -212,10 +216,6 @@ TEMPLATES = [
|
||||
### External Service Settings
|
||||
################################################################################
|
||||
|
||||
# All sqlite-vs-postgres connection logic lives in archivebox.misc.db;
|
||||
# DATABASE_ENGINE config selects the backend (sqlite by default).
|
||||
from archivebox.misc.db import get_database_settings, get_sqlite_connection_options
|
||||
|
||||
DATABASE_NAME = CONFIG.DATABASE_NAME
|
||||
SQLITE_JOURNAL_MODE = CONFIG.SQLITE_JOURNAL_MODE
|
||||
SQLITE_MMAP_SIZE = CONFIG.SQLITE_MMAP_SIZE
|
||||
|
||||
@ -77,7 +77,10 @@ def _run_sqlite_only_sql(apps, schema_editor):
|
||||
if schema_editor.connection.vendor != "sqlite":
|
||||
return
|
||||
migrations.RunSQL(sql=INITIAL_SQL, reverse_sql=INITIAL_REVERSE_SQL).database_forwards(
|
||||
"crawls", schema_editor, None, None,
|
||||
"crawls",
|
||||
schema_editor,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
@ -85,7 +88,10 @@ def _run_sqlite_only_sql_reverse(apps, schema_editor):
|
||||
if schema_editor.connection.vendor != "sqlite":
|
||||
return
|
||||
migrations.RunSQL(sql=INITIAL_SQL, reverse_sql=INITIAL_REVERSE_SQL).database_backwards(
|
||||
"crawls", schema_editor, None, None,
|
||||
"crawls",
|
||||
schema_editor,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -32,7 +32,10 @@ def _pg_sync_schema(apps, schema_editor):
|
||||
from archivebox.misc.db import rebuild_models_from_migration_state
|
||||
|
||||
rebuild_models_from_migration_state(
|
||||
apps, schema_editor, "machine", ["Machine", "NetworkInterface", "Binary"]
|
||||
apps,
|
||||
schema_editor,
|
||||
"machine",
|
||||
["Machine", "NetworkInterface", "Binary"],
|
||||
)
|
||||
|
||||
|
||||
|
||||
13
bin/benchmark_db_backends.py
Normal file → Executable file
13
bin/benchmark_db_backends.py
Normal file → Executable file
@ -129,7 +129,9 @@ def run_benchmarks(rows: int) -> dict[str, float]:
|
||||
benchmarks = {
|
||||
"exact_count": lambda: Snapshot.objects.count(),
|
||||
"approximate_row_counts": lambda: approximate_row_counts(connection),
|
||||
"admin_list_page": lambda: list(Snapshot.objects.order_by("-bookmarked_at").values("id", "url", "title", "status", "bookmarked_at")[:40]),
|
||||
"admin_list_page": lambda: list(
|
||||
Snapshot.objects.order_by("-bookmarked_at").values("id", "url", "title", "status", "bookmarked_at")[:40],
|
||||
),
|
||||
"admin_list_page_offset_10k": lambda: list(Snapshot.objects.order_by("-bookmarked_at").values("id", "url", "title")[10_000:10_040]),
|
||||
"snapshot_detail_by_url": lambda: list(Snapshot.objects.filter(fragmentless_q(target_url))[:10]),
|
||||
"snapshot_detail_archiveresults": lambda: list(
|
||||
@ -137,7 +139,9 @@ def run_benchmarks(rows: int) -> dict[str, float]:
|
||||
),
|
||||
"url_prefix_search": lambda: list(iter_url_prefix_search_ids("https://site500.example.org/", Snapshot.objects.all())),
|
||||
"worker_queue_scan": lambda: list(
|
||||
Snapshot.objects.filter(status="queued", retry_at__lte=now).order_by("retry_at", "created_at").values_list("id", flat=True)[:100],
|
||||
Snapshot.objects.filter(status="queued", retry_at__lte=now)
|
||||
.order_by("retry_at", "created_at")
|
||||
.values_list("id", flat=True)[:100],
|
||||
),
|
||||
"status_facet_counts": lambda: dict(Snapshot.objects.values_list("status").annotate(n=Count("id")).values_list("status", "n")),
|
||||
"tag_join_filter": lambda: list(Snapshot.objects.filter(title__icontains="page 4242").values("id")[:20]),
|
||||
@ -152,7 +156,10 @@ def run_benchmarks(rows: int) -> dict[str, float]:
|
||||
snapshot = Snapshot.objects.filter(status="queued").order_by("retry_at").first()
|
||||
if snapshot is None:
|
||||
return 0
|
||||
return Snapshot.objects.filter(pk=snapshot.pk, retry_at=snapshot.retry_at).update(retry_at=now + timedelta(seconds=60), modified_at=now)
|
||||
return Snapshot.objects.filter(pk=snapshot.pk, retry_at=snapshot.retry_at).update(
|
||||
retry_at=now + timedelta(seconds=60),
|
||||
modified_at=now,
|
||||
)
|
||||
|
||||
median_ms, _ = timed(claim_one)
|
||||
results["worker_cas_claim"] = round(median_ms, 2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user