Added some features :D, Codex limits are burned out by GPT 6 Astra D:
This commit is contained in:
@@ -33,7 +33,11 @@ async function processJob(job: {
|
||||
id: string;
|
||||
dataset_id: string;
|
||||
attempts: number;
|
||||
kind?: string;
|
||||
source_dataset_id?: string | null;
|
||||
}) {
|
||||
const mapOnly = job.kind === "map";
|
||||
const sourceId = mapOnly ? job.source_dataset_id! : job.dataset_id;
|
||||
const abort = new AbortController(),
|
||||
directory = `.cache/jobs/${job.id}`;
|
||||
activeAbort = abort;
|
||||
@@ -91,28 +95,29 @@ async function processJob(job: {
|
||||
}, 20000);
|
||||
try {
|
||||
const dataset = check(
|
||||
await client
|
||||
.from("datasets")
|
||||
.select("*")
|
||||
.eq("id", job.dataset_id)
|
||||
.single(),
|
||||
await client.from("datasets").select("*").eq("id", sourceId).single(),
|
||||
);
|
||||
const input = check(
|
||||
await client
|
||||
.from("dataset_inputs")
|
||||
.select("manifest")
|
||||
.eq("dataset_id", job.dataset_id)
|
||||
.eq("dataset_id", sourceId)
|
||||
.single(),
|
||||
);
|
||||
const manifest = datasetSchema.parse(input.manifest);
|
||||
await progress(0, `Downloading ${manifest.assets.length} export files`);
|
||||
let downloaded = 0;
|
||||
for (const asset of manifest.assets) {
|
||||
for (const asset of manifest.assets.filter(
|
||||
(a) =>
|
||||
!mapOnly ||
|
||||
a.path ===
|
||||
(manifest.source === "plugin" ? "terrain.json.gz" : "map.png"),
|
||||
)) {
|
||||
if (abort.signal.aborted) throw new Error("Lease lost or cancelled");
|
||||
const blob = check(
|
||||
await client.storage
|
||||
.from("minegeo-raw")
|
||||
.download(`${dataset.owner_id}/${job.dataset_id}/${asset.path}`),
|
||||
.download(`${dataset.owner_id}/${sourceId}/${asset.path}`),
|
||||
);
|
||||
const bytes = Buffer.from(await blob.arrayBuffer());
|
||||
if (
|
||||
@@ -179,7 +184,7 @@ async function processJob(job: {
|
||||
);
|
||||
const report = await renderSnapshot(
|
||||
terrain,
|
||||
manifest.availableViewpoints ?? manifest.viewpoints,
|
||||
mapOnly ? [] : (manifest.availableViewpoints ?? manifest.viewpoints),
|
||||
output,
|
||||
{
|
||||
size: Number(process.env.MINEGEO_FACE_SIZE || 1024),
|
||||
@@ -196,7 +201,9 @@ async function processJob(job: {
|
||||
.webp({ lossless: true })
|
||||
.toFile(`${output}/map.webp`);
|
||||
let processedFaces = 0;
|
||||
for (const point of manifest.availableViewpoints ?? manifest.viewpoints) {
|
||||
for (const point of mapOnly
|
||||
? []
|
||||
: (manifest.availableViewpoints ?? manifest.viewpoints)) {
|
||||
await mkdir(`${output}/${point.id}`, { recursive: true });
|
||||
for (const face of faces) {
|
||||
const bytes = await readFile(
|
||||
@@ -252,7 +259,9 @@ async function processJob(job: {
|
||||
await client.storage
|
||||
.from("minegeo-media")
|
||||
.upload(
|
||||
`${job.dataset_id}/${normalized}`,
|
||||
mapOnly
|
||||
? `${job.dataset_id}/maps/${job.id}.webp`
|
||||
: `${job.dataset_id}/${normalized}`,
|
||||
await readFile(`${output}/${entry}`),
|
||||
{
|
||||
contentType: "image/webp",
|
||||
@@ -304,7 +313,7 @@ async function processJob(job: {
|
||||
.eq("state", "running")
|
||||
.select("id"),
|
||||
);
|
||||
if (state === "failed" && rows.length)
|
||||
if (!mapOnly && state === "failed" && rows.length)
|
||||
await client
|
||||
.from("datasets")
|
||||
.update({ state: "failed", rejection_reason: message })
|
||||
|
||||
Reference in New Issue
Block a user