mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-12 19:50:57 +05:00
Keep binary overrides native to abxpkg
This commit is contained in:
parent
d2f3b3a65b
commit
c10579bad1
@ -538,7 +538,4 @@ async def _mark_binary_queued(binary) -> None:
|
||||
def _persisted_overrides_for_request(request: BinaryRequestEvent | None) -> dict[str, Any]:
|
||||
if request is None:
|
||||
return {}
|
||||
raw_overrides = request.extra_context.get("raw_overrides")
|
||||
if isinstance(raw_overrides, Mapping):
|
||||
return dict(raw_overrides)
|
||||
return dict(request.overrides or {})
|
||||
|
||||
@ -46,7 +46,6 @@ from abx_dl.orchestrator import (
|
||||
setup_services as setup_abx_services,
|
||||
)
|
||||
from abx_dl.services.process_service import ProcessService as HookProcessService
|
||||
from abx_dl.services.binary_service import split_abxpkg_binary_request_overrides
|
||||
from abx_dl.services.snapshot_service import SnapshotService as HookSnapshotService
|
||||
from abx_dl.cli import LiveBusUI
|
||||
from abxbus import BaseEvent
|
||||
@ -1358,21 +1357,18 @@ async def _run_binary(binary_id: str) -> None:
|
||||
)
|
||||
await _emit_machine_config(bus, config=config, derived_config=derived_config)
|
||||
|
||||
native_overrides, override_extra_context = split_abxpkg_binary_request_overrides(binary.overrides or None)
|
||||
|
||||
try:
|
||||
await bus.emit(
|
||||
BinaryRequestEvent(
|
||||
name=binary.name,
|
||||
binproviders=binary.binproviders,
|
||||
overrides=native_overrides or None,
|
||||
overrides=binary.overrides or None,
|
||||
extra_context={
|
||||
"plugin_name": "archivebox",
|
||||
"hook_name": "archivebox_binary_run",
|
||||
"output_dir": str(binary.output_dir),
|
||||
"binary_id": str(binary.id),
|
||||
"machine_id": str(binary.machine_id),
|
||||
**override_extra_context,
|
||||
},
|
||||
),
|
||||
).now(first_result=True)
|
||||
|
||||
@ -39,23 +39,22 @@ def _run_real_binary_state_machine(data_dir: Path, *, name: str, binproviders: s
|
||||
)
|
||||
|
||||
|
||||
def test_binary_request_preserves_raw_overrides_in_db_while_using_native_event():
|
||||
def test_binary_request_preserves_native_overrides_in_db():
|
||||
from abxpkg.binary_service import BinaryCacheService, BinaryEvent, BinaryRequestEvent, BinaryService
|
||||
from abx_dl.orchestrator import create_bus
|
||||
from archivebox.services.binary_service import ArchiveBoxDBBinaryCacheBackend
|
||||
|
||||
machine = Machine.current()
|
||||
raw_overrides = {
|
||||
overrides = {
|
||||
"pip": {
|
||||
"install_args": ["imagesize>=2.0.0"],
|
||||
"module_name": "imagesize",
|
||||
},
|
||||
}
|
||||
binary = Binary.objects.create(
|
||||
machine=machine,
|
||||
name="python3",
|
||||
binproviders="env,pip",
|
||||
overrides=raw_overrides,
|
||||
overrides=overrides,
|
||||
status=Binary.StatusChoices.QUEUED,
|
||||
retry_at=timezone.now(),
|
||||
)
|
||||
@ -63,7 +62,7 @@ def test_binary_request_preserves_raw_overrides_in_db_while_using_native_event()
|
||||
binary.refresh_from_db()
|
||||
assert binary.status == Binary.StatusChoices.INSTALLED
|
||||
assert Path(binary.abspath).resolve() == Path(sys.executable).resolve()
|
||||
bus = create_bus(name=f"test_binary_raw_overrides_{uuid.uuid4().hex[:8]}")
|
||||
bus = create_bus(name=f"test_binary_native_overrides_{uuid.uuid4().hex[:8]}")
|
||||
BinaryCacheService(bus, backend=ArchiveBoxDBBinaryCacheBackend())
|
||||
BinaryService(bus)
|
||||
binary_events: list[BinaryEvent] = []
|
||||
@ -78,11 +77,7 @@ def test_binary_request_preserves_raw_overrides_in_db_while_using_native_event()
|
||||
BinaryRequestEvent(
|
||||
name="python3",
|
||||
binproviders="env,pip",
|
||||
overrides={"pip": {"install_args": ["imagesize>=2.0.0"]}},
|
||||
extra_context={
|
||||
"raw_overrides": raw_overrides,
|
||||
"provider_metadata": {"pip": {"module_name": "imagesize"}},
|
||||
},
|
||||
overrides=overrides,
|
||||
),
|
||||
).now()
|
||||
await bus.wait_until_idle()
|
||||
@ -91,10 +86,9 @@ def test_binary_request_preserves_raw_overrides_in_db_while_using_native_event()
|
||||
|
||||
binary.refresh_from_db()
|
||||
assert binary.status == Binary.StatusChoices.INSTALLED
|
||||
assert binary.overrides == raw_overrides
|
||||
assert binary.overrides == overrides
|
||||
assert binary_events
|
||||
assert binary_events[-1].overrides == {"pip": {"install_args": ["imagesize>=2.0.0"]}}
|
||||
assert binary_events[-1].extra_context["raw_overrides"] == raw_overrides
|
||||
assert binary_events[-1].overrides == overrides
|
||||
|
||||
|
||||
def test_binary_request_installs_env_binary_and_recovers_stale_cache(initialized_archive, tmp_path):
|
||||
|
||||
@ -5,7 +5,7 @@ version = 2
|
||||
[snippets]
|
||||
|
||||
# README.md
|
||||
"1eb17a53f3b42bb0-1" = "illustration"
|
||||
"72fddf697c7b0142-1" = "illustration"
|
||||
"fe1f06a0a6b02c01-1" = "illustration"
|
||||
"220882ff87e9c738-1" = "run"
|
||||
"698f2b0f88796c9b-1" = "illustration"
|
||||
@ -140,7 +140,7 @@ version = 2
|
||||
"e4e22c56cb720344-1" = "illustration"
|
||||
"2905d7f9dece0b61-1" = "run"
|
||||
"a64c69417bb98a93-1" = "illustration"
|
||||
"1e69cfc0c05471e0-1" = "run"
|
||||
"a5bb45966ec97884-1" = "run"
|
||||
|
||||
# docs/Merging-Collections.md
|
||||
"befadadb67c37c7b-1" = "illustration"
|
||||
@ -303,7 +303,7 @@ version = 2
|
||||
"77b61fd52c4c3c32-1" = "collection"
|
||||
"a8f16f6be4f2b3c0-1" = "collection"
|
||||
"2905d7f9dece0b61-1" = "collection"
|
||||
"1e69cfc0c05471e0-1" = "system-data"
|
||||
"a5bb45966ec97884-1" = "system-data"
|
||||
"9bbf385bf2eb1160-1" = "collection"
|
||||
"c84835e713d1c625-1" = "collection"
|
||||
"302de01a4a1490f0-1" = "docker"
|
||||
@ -383,7 +383,7 @@ version = 2
|
||||
"77b61fd52c4c3c32-1" = "ubuntu"
|
||||
"a8f16f6be4f2b3c0-1" = "ubuntu"
|
||||
"2905d7f9dece0b61-1" = "ubuntu"
|
||||
"1e69cfc0c05471e0-1" = "ubuntu"
|
||||
"a5bb45966ec97884-1" = "ubuntu"
|
||||
"9bbf385bf2eb1160-1" = "ubuntu"
|
||||
"c84835e713d1c625-1" = "ubuntu"
|
||||
"302de01a4a1490f0-1" = "docker"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user