Skip to content

Commit

Permalink
Updated demos
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Sep 27, 2024
1 parent 31afc46 commit 182f0fe
Show file tree
Hide file tree
Showing 175 changed files with 116,220 additions and 7,179 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env node

//-----------------------------------------------------------------------------------
// Generates ./convert-datasets.sh from ./pipelines.json and datasets.json
// Generates ./convert-models.sh from ./pipelines.json and models.json
//-----------------------------------------------------------------------------------

const pipelines = require("./pipelines.json");
const datasets = require("./datasets.json");
const models = require("./models.json");
const configs = require("./configs.json");
const fs = require('fs');

const script = ["# Generated by @xeokit/demos ./build-convert-datasets.js"];
const script = ["# Generated by @xeokit/demos ./build-convert-models.js"];

let numToConvert = 0;
let numConverted = 0;

console.log(`[build-convert-datasets.js] Generating ./convert-datasets.sh from ./pipelines.json and ./datasets.json`);
console.log(`[build-convert-models.js] Generating ./convert-models.sh from ./pipelines.json and ./models.json`);

function logError(msg) {
console.error(`[build-convert-datasets] ${msg}`);
console.error(`[build-convert-models] ${msg}`);
}

function parseStringTemplate(str, obj) {
Expand All @@ -33,8 +33,8 @@ try {
const pipeline = pipelines.pipelines[i];
pipelineLookup[pipeline.id] = pipeline;
}
for (let i = 0, len = datasets.models.length; i < len; i++) {
const model = datasets.models[i];
for (let i = 0, len = models.models.length; i < len; i++) {
const model = models.models[i];
const modelId = model.id;
const pipelineIds = model.pipelines;
for (let j = 0, lenj = pipelineIds.length; j < lenj; j++) {
Expand All @@ -45,18 +45,18 @@ try {
continue;
}
if (pipeline.cmd) {
const dataModelDir = `./data/datasets/${modelId}/${pipelineId}/`;
const dataModelDir = `./data/models/${modelId}/${pipelineId}/`;
if (dataModelDir !== "" && !fs.existsSync(dataModelDir)) {
fs.mkdirSync(dataModelDir, {recursive: true});
}
numToConvert++;
}
}
}
script.push(`echo [convert-datasets.sh] Converting ${numToConvert} files...`);
script.push(`echo [convert-models.sh] Converting ${numToConvert} files...`);

for (let i = 0, len = datasets.models.length; i < len; i++) {
const model = datasets.models[i];
for (let i = 0, len = models.models.length; i < len; i++) {
const model = models.models[i];
const modelId = model.id;
const pipelineIds = model.pipelines;
if (!pipelineIds || pipelineIds.length === 0) {
Expand All @@ -76,21 +76,21 @@ try {
script.push(`\n# --------------------------------------`);
script.push(`# ${model.id}`);
script.push(`# --------------------------------------`);
script.push(`echo [convert-datasets.sh] Converting ${model.id}`);
script.push(`echo [convert-models.sh] Converting ${model.id}`);
for (let j = 0, lenj = pipelineIds.length; j < lenj; j++) {
const pipelineId = pipelineIds[j];
const pipeline = pipelineLookup[pipelineId];
if (pipeline.cmd) {
script.push(`\n# ${pipelineId}`);
script.push(parseStringTemplate(pipeline.cmd, {modelId, ...configs}));
numConverted++;
script.push(`echo [convert-datasets.sh] Converted ${model.id} via ${pipeline.id}`);
script.push(`echo [convert-datasets.sh] ${numConverted} out of ${numToConvert} conversions done`);
script.push(`echo [convert-models.sh] Converted ${model.id} via ${pipeline.id}`);
script.push(`echo [convert-models.sh] ${numConverted} out of ${numToConvert} conversions done`);

}
}
}
fs.writeFileSync("convert-datasets.sh", script.join("\n"));
fs.writeFileSync("convert-models.sh", script.join("\n"));
process.exit(1);

} catch (err) {
Expand Down
192 changes: 0 additions & 192 deletions packages/demos/convert-datasets.sh

This file was deleted.

Loading

0 comments on commit 182f0fe

Please sign in to comment.