Include selected source LOD in Worker scene package
This commit is contained in:
@@ -23,6 +23,13 @@ def digest(path):
|
||||
return hashlib.file_digest(stream, "sha256").hexdigest()
|
||||
|
||||
|
||||
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")
|
||||
@@ -31,6 +38,7 @@ def prepare_project(client, run, state, episode, job, pulse, isaac, *, lod=0):
|
||||
if package["world_sha256"] != world["sha256"]:
|
||||
raise ValueError("Project changed after mission admission")
|
||||
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(
|
||||
r"gsp-[0-9]{14}-[a-f0-9]{8}", provider_job
|
||||
):
|
||||
@@ -40,14 +48,14 @@ def prepare_project(client, run, state, episode, job, pulse, isaac, *, lod=0):
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
required = sum(
|
||||
item["byte_length"]
|
||||
for item in package["artifacts"]
|
||||
for item in members
|
||||
if not (root / item["logical_path"]).is_file()
|
||||
)
|
||||
if shutil.disk_usage(root).free < required + 4 * 1024**3:
|
||||
raise RuntimeError("Недостаточно места на Worker для подготовки локации.")
|
||||
# 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.
|
||||
for item in package["artifacts"]:
|
||||
for item in members:
|
||||
name = item["logical_path"]
|
||||
if (
|
||||
not re.fullmatch(r"[A-Za-z0-9_. /-]+", name)
|
||||
|
||||
Reference in New Issue
Block a user