mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: name uncached trees once per manifest
This commit is contained in:
1 parent
11e3ebb44f
commit
bbb139bbaf
4 files changed
+44
-20
No files matched your search
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
from collections.abc import Callable, Iterator
|
||||
from dataclasses import dataclass, field
|
||||
@@ -26,7 +24,6 @@ from packs.datatrees import (
|
||||
core_data_trees,
|
||||
pack_markers,
|
||||
tree_readers,
|
||||
uncached_warning,
|
||||
)
|
||||
from packs.extras import (
|
||||
collect_emulator_extras,
|
||||
@@ -96,7 +93,7 @@ class InstallListOptions(TypedDict, total=False):
|
||||
fold_case: bool | None
|
||||
no_game_data: bool
|
||||
one_per_slot: bool
|
||||
uncached_out: set[str] | None
|
||||
uncached_out: dict[str, str] | None
|
||||
|
||||
|
||||
class ManifestOptions(InstallListOptions, total=False):
|
||||
@@ -125,7 +122,7 @@ class _ManifestSettings:
|
||||
one_per_slot: bool = False
|
||||
known_slot_choices: dict | None = None
|
||||
build_out: dict | None = None
|
||||
uncached_out: set[str] | None = None
|
||||
uncached_out: dict[str, str] | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -479,10 +476,8 @@ class _ManifestBuild:
|
||||
core_trees=core_trees,
|
||||
reclaim=reclaim, uncached_out=uncached,
|
||||
))
|
||||
for ref_key, local_path in uncached:
|
||||
print(uncached_warning(ref_key, local_path))
|
||||
if opts.uncached_out is not None:
|
||||
opts.uncached_out.update(ref_key for ref_key, _path in uncached)
|
||||
opts.uncached_out.update(uncached)
|
||||
# A platform entry found in a tree the pack carries is that tree's member:
|
||||
# the installer rebuilds it from the tree's archive. One found in a tree
|
||||
# the pack does not carry stays omitted, held by the pack alone.
|
||||
@@ -713,8 +708,8 @@ def generate_manifest(
|
||||
One build: generate_install_list adds what --source truth and
|
||||
--standalone read. `build_out` receives the slot choices and the
|
||||
profiles this build read, which that second build takes over.
|
||||
`uncached_out` receives the data directories the list carries and the
|
||||
cache does not hold.
|
||||
`uncached_out` maps each data directory the list carries and the cache
|
||||
does not hold to its cache folder: the caller reports it.
|
||||
"""
|
||||
reject_unknown("generate_manifest", options, ManifestOptions.__optional_keys__)
|
||||
opts = _ManifestSettings(**options)
|
||||
@@ -822,11 +817,10 @@ def generate_install_list(
|
||||
or settings.fold_case is not None or settings.one_per_slot):
|
||||
return result
|
||||
truth_options: InstallListOptions = {**options, "source": "truth"}
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
truth = generate_manifest(
|
||||
platform_name, platforms_dir, db, bios_dir, registry_path,
|
||||
**truth_options, known_slot_choices=built["slot_choices"],
|
||||
)
|
||||
truth = generate_manifest(
|
||||
platform_name, platforms_dir, db, bios_dir, registry_path,
|
||||
**truth_options, known_slot_choices=built["slot_choices"],
|
||||
)
|
||||
_mark_truth(result, truth)
|
||||
layouts = standalone_layouts(
|
||||
built["profiles"], settings.emulators_dir, db, bios_dir,
|
||||
|
||||
@@ -11,6 +11,7 @@ from core.artifacts import write_if_changed
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import load_platform_registry
|
||||
from model.safeparse import require_yaml
|
||||
from packs.datatrees import uncached_warning
|
||||
from packs.manifest import generate_install_list
|
||||
from packs.naming import pack_narrowings, platform_target
|
||||
from packs.scope import platform_list_version
|
||||
@@ -60,6 +61,15 @@ def _alias_manifest(
|
||||
return alias_manifest
|
||||
|
||||
|
||||
def report_uncached(uncached: dict[str, str], recorded: set[str] | None) -> None:
|
||||
"""Name each data directory a list carries and the cache does not hold,
|
||||
once, and record it for the run's exit code."""
|
||||
for ref_key, local_path in uncached.items():
|
||||
print(uncached_warning(ref_key, local_path))
|
||||
if recorded is not None:
|
||||
recorded.update(uncached)
|
||||
|
||||
|
||||
def run_manifest_mode(
|
||||
args: argparse.Namespace,
|
||||
groups: list[tuple[list[str], str]],
|
||||
@@ -82,6 +92,7 @@ def run_manifest_mode(
|
||||
if skip_empty_truth(args, source, representative, emu_profiles, tc, failed):
|
||||
continue
|
||||
layouts: dict = {}
|
||||
uncached: dict[str, str] = {}
|
||||
try:
|
||||
manifest = generate_install_list(
|
||||
representative,
|
||||
@@ -102,8 +113,9 @@ def run_manifest_mode(
|
||||
required_only=required_only,
|
||||
no_game_data=getattr(args, "no_game_data", False),
|
||||
standalone_out=layouts,
|
||||
uncached_out=getattr(args, "uncached_trees", None),
|
||||
uncached_out=uncached,
|
||||
)
|
||||
report_uncached(uncached, getattr(args, "uncached_trees", None))
|
||||
narrow_suffix = "".join(
|
||||
tag.lower()
|
||||
for tag, _label in pack_narrowings(
|
||||
|
||||
@@ -165,6 +165,8 @@ def run_platform_packs(
|
||||
# systems: the pack records them, so a pack alone (a
|
||||
# handheld without Wi-Fi) can be narrowed by system.
|
||||
board_list = Path(args.platforms_dir) / "targets" / f"{representative}.yml"
|
||||
# The pack above named its uncached trees: these are recorded only.
|
||||
unnamed: dict[str, str] = {}
|
||||
systems_for[os.path.basename(zip_path)] = pack_systems(generate_manifest(
|
||||
representative, args.platforms_dir, db, args.bios_dir,
|
||||
registry_path, emulators_dir=args.emulators_dir,
|
||||
@@ -174,8 +176,11 @@ def run_platform_packs(
|
||||
offline=args.offline, required_only=required_only,
|
||||
data_registry=data_registry,
|
||||
no_game_data=getattr(args, "no_game_data", False),
|
||||
uncached_out=getattr(args, "uncached_trees", None),
|
||||
uncached_out=unnamed,
|
||||
), target_list(board_list) if board_list.is_file() else None)
|
||||
recorded_trees: set[str] | None = getattr(args, "uncached_trees", None)
|
||||
if recorded_trees is not None:
|
||||
recorded_trees.update(unnamed)
|
||||
|
||||
if record_counts:
|
||||
write_pack_counts(record_counts, recorded)
|
||||
|
||||
@@ -189,7 +189,7 @@ class AMissingDataDirectoryFailsTheRun(unittest.TestCase):
|
||||
from packs.manifest import generate_manifest
|
||||
|
||||
root, db, registry = self._platform()
|
||||
uncached: set[str] = set()
|
||||
uncached: dict[str, str] = {}
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
generate_manifest(
|
||||
@@ -198,8 +198,21 @@ class AMissingDataDirectoryFailsTheRun(unittest.TestCase):
|
||||
emulators_dir=str(root / "emulators"),
|
||||
data_registry=registry, offline=True, uncached_out=uncached,
|
||||
)
|
||||
self.assertEqual(uncached, {"assets"})
|
||||
self.assertIn("WARNING: data directory 'assets' not cached", out.getvalue())
|
||||
# The library records; the run names each tree once.
|
||||
self.assertEqual((uncached, out.getvalue()), ({"assets": str(root / "absent")}, ""))
|
||||
|
||||
def test_the_manifest_run_names_each_tree_once(self):
|
||||
from packs.manifestrun import report_uncached
|
||||
|
||||
recorded: set[str] = set()
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
report_uncached({"assets": "/c/absent"}, recorded)
|
||||
self.assertEqual(recorded, {"assets"})
|
||||
self.assertEqual(out.getvalue(), (
|
||||
" WARNING: data directory 'assets' not cached at /c/absent"
|
||||
" (run refresh_data_dirs.py)\n"
|
||||
))
|
||||
|
||||
def test_the_shared_walk_prints_nothing_and_keeps_no_state(self):
|
||||
from packs import datatrees
|
||||
|
||||
Reference in new issue
Block a user