Skip to content

Commit 902638e

Browse files
committed
WIP finalize import
1 parent 5a4dc06 commit 902638e

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

client/platform/desktop/backend/native/viame.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { cleanString } from 'platform/desktop/sharedUtils';
1111
import { serialize } from 'platform/desktop/backend/serializers/viame';
1212
import { observeChild } from 'platform/desktop/backend/native/processManager';
13+
import sendToRenderer from 'platform/desktop/background';
1314

1415
import { MultiType, stereoPipelineMarker, multiCamPipelineMarkers } from 'dive-common/constants';
1516
import * as common from './common';
@@ -130,13 +131,8 @@ async function runPipeline(
130131
}
131132

132133
if (runPipelineArgs.pipeline.type === 'filter') {
133-
// Create a subdirectory within the working directory to store output images
134-
const outputDirectoryName = npath.join(jobWorkDir, 'output');
135-
if (!fs.existsSync(outputDirectoryName)) {
136-
await fs.mkdir(outputDirectoryName);
137-
}
138-
command.push(`-s kwa_writer:output_directory="${outputDirectoryName}"`);
139-
command.push(`-s image_writer:file_name_prefix="${outputDirectoryName}/"`);
134+
command.push(`-s kwa_writer:output_directory="${jobWorkDir}/"`);
135+
command.push(`-s image_writer:file_name_prefix="${jobWorkDir}/"`);
140136
}
141137
if (runPipelineArgs.pipeline.type === 'transcode') {
142138
command.push(`-s video_writer:video_filename="${npath.join(jobWorkDir, `${datasetId}.mp4`)}"`);
@@ -216,6 +212,23 @@ async function runPipeline(
216212
});
217213
});
218214

215+
if (runPipelineArgs.pipeline.type === 'filter') {
216+
job.on('exit', async (code) => {
217+
if (code === 0) {
218+
// Ingest the output into a new dataset
219+
updater({
220+
...jobBase,
221+
body: ['Creating dataset from output...'],
222+
exitCode: code,
223+
endTime: new Date(),
224+
});
225+
const importPayload = await common.beginMediaImport(jobWorkDir);
226+
const conversionJobArgs = await common.finalizeMediaImport(settings, importPayload);
227+
sendToRenderer('filter-complete', conversionJobArgs.meta);
228+
}
229+
});
230+
}
231+
219232
return jobBase;
220233
}
221234

client/platform/desktop/background.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,9 @@ if (process.platform === 'win32') {
133133
cleanup();
134134
});
135135
}
136+
137+
export default function sendToRenderer(channel: string, payload?: unknown) {
138+
if (win) {
139+
win.webContents.send(channel, payload);
140+
}
141+
}

client/platform/desktop/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export interface RunPipeline extends JobArgs {
170170
type: JobType.RunPipeline;
171171
datasetId: string;
172172
pipeline: Pipe;
173+
outputDatasetName?: string;
173174
}
174175

175176
export interface ExportTrainedPipeline extends JobArgs {

client/platform/desktop/frontend/store/jobs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import {
1515
JobType,
1616
RunPipeline,
1717
RunTraining,
18+
JsonMeta,
1819
} from 'platform/desktop/constants';
1920
import AsyncGpuJobQueue from './queues/asyncGpuJobQueue';
2021
import AsyncCpuJobQueue from './queues/asyncCpuJobQueue';
22+
import { setRecents } from './dataset';
2123

2224
interface DesktopJobHistory {
2325
job: DesktopJob;
@@ -94,6 +96,9 @@ function init() {
9496
...args, body: ['Job cancelled by user'], exitCode: cancelledJobExitCode, endTime: new Date(), cancelledJob: true,
9597
});
9698
});
99+
ipcRenderer.on('filter-complete', (event, args: JsonMeta) => {
100+
setRecents(args);
101+
});
97102
}
98103

99104
init();

0 commit comments

Comments
 (0)