Compare commits
2
Commits
16865574d0
...
be5cc98d5c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be5cc98d5c | ||
|
|
37d6f90456 |
@@ -2,6 +2,7 @@ param(
|
|||||||
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$Release,
|
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$Release,
|
||||||
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$ExpectedCurrentRelease,
|
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$ExpectedCurrentRelease,
|
||||||
[string]$EvidenceRoot,
|
[string]$EvidenceRoot,
|
||||||
|
[ValidateRange(0,6)][int]$ProjectLod,
|
||||||
[switch]$Apply
|
[switch]$Apply
|
||||||
)
|
)
|
||||||
# Runtime-only update of an already installed service. Installation, firewall,
|
# Runtime-only update of an already installed service. Installation, firewall,
|
||||||
@@ -43,11 +44,17 @@ if($EvidenceRoot) {
|
|||||||
if($arguments -match '--evidence-root') { throw 'Review existing evidence storage before replacing it' }
|
if($arguments -match '--evidence-root') { throw 'Review existing evidence storage before replacing it' }
|
||||||
$arguments+=' --evidence-root "'+$EvidenceRoot+'"'
|
$arguments+=' --evidence-root "'+$EvidenceRoot+'"'
|
||||||
}
|
}
|
||||||
|
if($PSBoundParameters.ContainsKey('ProjectLod')) {
|
||||||
|
if($arguments -match '--project-lod\s+\d+') {
|
||||||
|
$arguments=[regex]::Replace($arguments,'--project-lod\s+\d+','--project-lod '+$ProjectLod)
|
||||||
|
} else { $arguments+=' --project-lod '+$ProjectLod }
|
||||||
|
}
|
||||||
$action=New-ScheduledTaskAction -Execute $old.Execute -Argument $arguments -WorkingDirectory $old.WorkingDirectory
|
$action=New-ScheduledTaskAction -Execute $old.Execute -Argument $arguments -WorkingDirectory $old.WorkingDirectory
|
||||||
$report=[ordered]@{utc=[DateTime]::UtcNow.ToString('o'); task=$name; previous=$ExpectedCurrentRelease;
|
$report=[ordered]@{utc=[DateTime]::UtcNow.ToString('o'); task=$name; previous=$ExpectedCurrentRelease;
|
||||||
release=$Release; manifest_sha256=$digest; verified_files=$count; applied=$false;
|
release=$Release; manifest_sha256=$digest; verified_files=$count; applied=$false;
|
||||||
network_changed=$false; credentials_changed=$false; principal_changed=$false}
|
network_changed=$false; credentials_changed=$false; principal_changed=$false}
|
||||||
if($EvidenceRoot) { $report['evidence_root']=$EvidenceRoot }
|
if($EvidenceRoot) { $report['evidence_root']=$EvidenceRoot }
|
||||||
|
if($PSBoundParameters.ContainsKey('ProjectLod')) { $report['project_lod']=$ProjectLod }
|
||||||
if($Apply) {
|
if($Apply) {
|
||||||
if($EvidenceRoot) { New-Item -ItemType Directory -Force -Path $EvidenceRoot | Out-Null }
|
if($EvidenceRoot) { New-Item -ItemType Directory -Force -Path $EvidenceRoot | Out-Null }
|
||||||
$backup="$root\preparations\worker-activation-$Release"
|
$backup="$root\preparations\worker-activation-$Release"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Prepare the complete visual scene from an existing Gaussian Pipeline package.
|
"""Prepare the complete visual scene from an existing Gaussian Pipeline package.
|
||||||
|
|
||||||
Uses the installed SplatTransform, preserves LOD0 and SH, and reuses verified
|
Uses the installed SplatTransform, preserves the selected source LOD and SH, and reuses verified
|
||||||
Worker artifacts. The local editor and Isaac share the same collider bytes and
|
Worker artifacts. The local editor and Isaac share the same collider bytes and
|
||||||
saved calibration; this is format adaptation, not another reconstruction.
|
saved calibration; this is format adaptation, not another reconstruction.
|
||||||
"""
|
"""
|
||||||
@@ -23,12 +23,22 @@ def digest(path):
|
|||||||
return hashlib.file_digest(stream, "sha256").hexdigest()
|
return hashlib.file_digest(stream, "sha256").hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def prepare_project(client, run, state, episode, job, pulse, isaac):
|
def project_members(package, lod):
|
||||||
|
required = {package["visual_path"], package["collision_path"]}
|
||||||
|
return [item for item in package["artifacts"] if (
|
||||||
|
item["logical_path"] in required or
|
||||||
|
item["logical_path"].startswith((f"streamed/{lod}_", "streamed/env/")))]
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_project(client, run, state, episode, job, pulse, isaac, *, lod=0):
|
||||||
|
if type(lod) is not int or not 0 <= lod <= 6:
|
||||||
|
raise ValueError("Invalid source LOD")
|
||||||
world = run["world"]
|
world = run["world"]
|
||||||
package = client.request("/worker/worlds/" + world["world_id"] + "/project-assets")
|
package = client.request("/worker/worlds/" + world["world_id"] + "/project-assets")
|
||||||
if package["world_sha256"] != world["sha256"]:
|
if package["world_sha256"] != world["sha256"]:
|
||||||
raise ValueError("Project changed after mission admission")
|
raise ValueError("Project changed after mission admission")
|
||||||
pid, provider_job = package["project_id"], package["provider_job_id"]
|
pid, provider_job = package["project_id"], package["provider_job_id"]
|
||||||
|
members = project_members(package, lod)
|
||||||
if not re.fullmatch(r"sim-[a-f0-9]{32}", pid) or not re.fullmatch(
|
if not re.fullmatch(r"sim-[a-f0-9]{32}", pid) or not re.fullmatch(
|
||||||
r"gsp-[0-9]{14}-[a-f0-9]{8}", provider_job
|
r"gsp-[0-9]{14}-[a-f0-9]{8}", provider_job
|
||||||
):
|
):
|
||||||
@@ -38,14 +48,14 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
|||||||
root.mkdir(parents=True, exist_ok=True)
|
root.mkdir(parents=True, exist_ok=True)
|
||||||
required = sum(
|
required = sum(
|
||||||
item["byte_length"]
|
item["byte_length"]
|
||||||
for item in package["artifacts"]
|
for item in members
|
||||||
if not (root / item["logical_path"]).is_file()
|
if not (root / item["logical_path"]).is_file()
|
||||||
)
|
)
|
||||||
if shutil.disk_usage(root).free < required + 4 * 1024**3:
|
if shutil.disk_usage(root).free < required + 4 * 1024**3:
|
||||||
raise RuntimeError("Недостаточно места на Worker для подготовки локации.")
|
raise RuntimeError("Недостаточно места на Worker для подготовки локации.")
|
||||||
# A filesystem package is needed by the stock streamed-SOG reader. Reuse
|
# A filesystem package is needed by the stock streamed-SOG reader. Reuse
|
||||||
# local verified bytes without re-encoding. Keep an owned immutable copy for the run.
|
# local verified bytes without re-encoding. Keep an owned immutable copy for the run.
|
||||||
for item in package["artifacts"]:
|
for item in members:
|
||||||
name = item["logical_path"]
|
name = item["logical_path"]
|
||||||
if (
|
if (
|
||||||
not re.fullmatch(r"[A-Za-z0-9_. /-]+", name)
|
not re.fullmatch(r"[A-Za-z0-9_. /-]+", name)
|
||||||
@@ -87,7 +97,7 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
|||||||
# Adapt the complete selected source LOD and preserve every SH coefficient.
|
# Adapt the complete selected source LOD and preserve every SH coefficient.
|
||||||
key = hashlib.sha256(
|
key = hashlib.sha256(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
{"world": world["sha256"], "coverage": "complete-source-lod0", "adapter": digest(Path(__file__))},
|
{"world": world["sha256"], "coverage": "complete-source", "lod": lod, "adapter": digest(Path(__file__))},
|
||||||
sort_keys=True,
|
sort_keys=True,
|
||||||
).encode()
|
).encode()
|
||||||
).hexdigest()
|
).hexdigest()
|
||||||
@@ -119,7 +129,7 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
|||||||
"4",
|
"4",
|
||||||
"-w",
|
"-w",
|
||||||
"--select-lod",
|
"--select-lod",
|
||||||
"0",
|
str(lod),
|
||||||
str(visual),
|
str(visual),
|
||||||
"-r",
|
"-r",
|
||||||
"0,0,180",
|
"0,0,180",
|
||||||
@@ -158,8 +168,8 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
|||||||
{
|
{
|
||||||
"sha256": digest(output),
|
"sha256": digest(output),
|
||||||
"gaussian_count": count,
|
"gaussian_count": count,
|
||||||
"lod": 0,
|
"lod": lod,
|
||||||
"coverage": "complete-source-lod0",
|
"coverage": "complete-source",
|
||||||
"spatially_cropped": False,
|
"spatially_cropped": False,
|
||||||
"source_sha256": world["sha256"],
|
"source_sha256": world["sha256"],
|
||||||
"converter": "splat-transform-3.4.0",
|
"converter": "splat-transform-3.4.0",
|
||||||
@@ -168,7 +178,8 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
|||||||
)
|
)
|
||||||
# Capacity is evidence only, never an admission gate or a count ceiling.
|
# Capacity is evidence only, never an admission gate or a count ceiling.
|
||||||
count = json.loads(receipt.read_text())["gaussian_count"]
|
count = json.loads(receipt.read_text())["gaussian_count"]
|
||||||
write_json(episode / "scene-capacity.json", scene_diagnostics(count, output.stat().st_size))
|
write_json(episode / "scene-capacity.json", {**scene_diagnostics(count, output.stat().st_size),
|
||||||
|
"source_lod": lod, "coverage": "complete-source", "spatially_cropped": False})
|
||||||
source_collider_sha256 = digest(collider)
|
source_collider_sha256 = digest(collider)
|
||||||
decoded = root / (source_collider_sha256 + ".decoded.glb")
|
decoded = root / (source_collider_sha256 + ".decoded.glb")
|
||||||
decoder = Path(__file__).with_name("decode_collision.cjs")
|
decoder = Path(__file__).with_name("decode_collision.cjs")
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ def main():
|
|||||||
help="Optional local volume for complete episode evidence")
|
help="Optional local volume for complete episode evidence")
|
||||||
parser.add_argument("--isaac", type=Path, required=True)
|
parser.add_argument("--isaac", type=Path, required=True)
|
||||||
parser.add_argument("--stream-address", required=True)
|
parser.add_argument("--stream-address", required=True)
|
||||||
|
parser.add_argument("--project-lod", type=int, choices=range(7), default=0,
|
||||||
|
help="Explicit source LOD; entire project coverage is retained")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
args.state.mkdir(parents=True, exist_ok=True)
|
args.state.mkdir(parents=True, exist_ok=True)
|
||||||
lock = acquire_service_lock(args.state / "realtime-service.lock")
|
lock = acquire_service_lock(args.state / "realtime-service.lock")
|
||||||
@@ -419,7 +421,7 @@ def main():
|
|||||||
from project_assets import prepare_project
|
from project_assets import prepare_project
|
||||||
|
|
||||||
source, terrain_path = prepare_project(
|
source, terrain_path = prepare_project(
|
||||||
client, run, args.state, episode, job, preparation_pulse, args.isaac
|
client, run, args.state, episode, job, preparation_pulse, args.isaac, lod=args.project_lod
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
terrain_path = prepare_terrain(
|
terrain_path = prepare_terrain(
|
||||||
@@ -491,8 +493,11 @@ def main():
|
|||||||
preview_sender.start()
|
preview_sender.start()
|
||||||
registered = True
|
registered = True
|
||||||
readiness_sent = False
|
readiness_sent = False
|
||||||
|
from scene_capacity import RendererMemoryGuard
|
||||||
|
render_guard = RendererMemoryGuard(episode / "isaac.log")
|
||||||
while child.poll() is None:
|
while child.poll() is None:
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
|
render_guard.check()
|
||||||
if stop_deadline and now >= stop_deadline:
|
if stop_deadline and now >= stop_deadline:
|
||||||
terminate_episode(child)
|
terminate_episode(child)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -37,3 +37,22 @@ def scene_diagnostics(count, source_bytes):
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
value["capacity_unavailable"] = type(exc).__name__
|
value["capacity_unavailable"] = type(exc).__name__
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class RendererMemoryGuard:
|
||||||
|
"""A reported allocation failure invalidates the scene, even if Kit keeps running."""
|
||||||
|
def __init__(self, log):
|
||||||
|
self.log, self.offset, self.tail = log, 0, b""
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
with self.log.open("rb") as stream:
|
||||||
|
stream.seek(self.offset)
|
||||||
|
while chunk := stream.read(65536):
|
||||||
|
content = self.tail + chunk
|
||||||
|
if (b"ERROR_OUT_OF_DEVICE_MEMORY" in content or
|
||||||
|
b"Out of GPU memory allocating resource" in content):
|
||||||
|
raise ScenePreparationError(
|
||||||
|
"Недостаточно видеопамяти для полной сцены выбранной детализации. "
|
||||||
|
"Прогон остановлен: корректность изображения не подтверждена.")
|
||||||
|
self.tail = content[-128:]
|
||||||
|
self.offset = stream.tell()
|
||||||
|
|||||||
@@ -83,10 +83,7 @@ class ProjectWorlds:
|
|||||||
artifacts = [
|
artifacts = [
|
||||||
a
|
a
|
||||||
for a in project["artifacts"]
|
for a in project["artifacts"]
|
||||||
if (
|
if a["logical_path"].startswith("streamed/")
|
||||||
a["logical_path"].startswith("streamed/0_")
|
|
||||||
or a["logical_path"].startswith("streamed/env/")
|
|
||||||
)
|
|
||||||
or a["logical_path"] in paths.values()
|
or a["logical_path"] in paths.values()
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -72,3 +72,22 @@ def test_paired_import_checks_actual_files_and_never_fetches_from_operator(tmp_p
|
|||||||
preparer.prepare_terrain(root, tmp_path, {**world, "collider_sha256": "f" * 64})
|
preparer.prepare_terrain(root, tmp_path, {**world, "collider_sha256": "f" * 64})
|
||||||
with pytest.raises(ValueError, match="identity"):
|
with pytest.raises(ValueError, match="identity"):
|
||||||
importer.stage(root, source, collider, {**descriptor, "collider_sha256": "f" * 64})
|
importer.stage(root, source, collider, {**descriptor, "collider_sha256": "f" * 64})
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_package_supports_each_published_lod_without_cropping(monkeypatch):
|
||||||
|
from types import SimpleNamespace
|
||||||
|
from k1link.simulation.ai_polygon.project_worlds import ProjectWorlds
|
||||||
|
monkeypatch.syspath_prepend(str(Path(__file__).parents[1] / "simulation/ai-polygon"))
|
||||||
|
module = importlib.import_module("project_assets")
|
||||||
|
paths = ["streamed/lod-meta.json", "collision.glb", "streamed/env/meta.json",
|
||||||
|
"streamed/0_0/meta.json", "streamed/1_0/meta.json", "streamed/1_0/means_l.webp",
|
||||||
|
"streamed/2_0/meta.json", "private/source.zip"]
|
||||||
|
project = dict(project_id="sim-test", provider={"job_id":"gsp-test"},
|
||||||
|
artifacts=[dict(logical_path=name) for name in paths])
|
||||||
|
worlds = object.__new__(ProjectWorlds)
|
||||||
|
worlds.projects = SimpleNamespace(get=lambda _: project)
|
||||||
|
prefix = "/api/v1/simulation-worlds/projects/sim-test/artifacts/"
|
||||||
|
package = worlds.package(dict(storage={"project_id":"sim-test"}, sha256="test",
|
||||||
|
local_scene=dict(visual_url=prefix+paths[0], collision_url=prefix+paths[1])))
|
||||||
|
assert [item["logical_path"] for item in package["artifacts"]] == paths[:-1]
|
||||||
|
assert [item["logical_path"] for item in module.project_members(package, 1)] == paths[:3]+paths[4:6]
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import importlib
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_partial_or_late_native_allocation_failure_invalidates_scene(monkeypatch, tmp_path):
|
||||||
|
monkeypatch.syspath_prepend(str(Path(__file__).parents[1] / "simulation/ai-polygon"))
|
||||||
|
module = importlib.import_module("scene_capacity")
|
||||||
|
log = tmp_path / "isaac.log"
|
||||||
|
log.write_bytes(b"startup ready\n" + b"x"*65522 + b"ERROR_OUT_OF_DE")
|
||||||
|
guard = module.RendererMemoryGuard(log)
|
||||||
|
guard.check()
|
||||||
|
guard.check()
|
||||||
|
with log.open("ab") as stream:
|
||||||
|
stream.write(b"VICE_MEMORY\napp still running\n")
|
||||||
|
with pytest.raises(module.ScenePreparationError, match="видеопамяти"):
|
||||||
|
guard.check()
|
||||||
Reference in New Issue
Block a user