Skip to content

Commit

Permalink
DPO3DPKRT-701/generate downloads support for scenes (#566)
Browse files Browse the repository at this point in the history
(fix) restoring generate-downloads functionality with support for returned svx scenes and draco/usdz models
(fix) modified tags assigned to 'Download:<downloadType>' to allow for capturing a model's use and it's type.
  • Loading branch information
EMaslowskiQ committed Jan 24, 2024
1 parent 65c0acf commit cac0d06
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
6 changes: 3 additions & 3 deletions server/collections/impl/PublishScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ export class PublishScene {
return PublishScene.sendResult(true);

if (newDownloadState) {
LOG.info(`PublishScene.handleSceneUpdates generating downloads for scene ${idScene} (skipping)`, LOG.LS.eGQL);
LOG.info(`PublishScene.handleSceneUpdates generating downloads for scene ${idScene}`, LOG.LS.eGQL);
// Generate downloads
const workflowEngine: WF.IWorkflowEngine | null = await WF.WorkflowFactory.getInstance();
if (!workflowEngine)
return PublishScene.sendResult(false, `Unable to fetch workflow engine for download generation for scene ${idScene}`);

// HACK: temporarily skip generate downloads while development on that wraps up
// workflowEngine.generateSceneDownloads(idScene, { idUserInitiator: idUser }); // don't await
// trigger the workflow/recipe
workflowEngine.generateSceneDownloads(idScene, { idUserInitiator: _idUser }); // don't await
return { success: true, downloadsGenerated: true, downloadsRemoved: false };
} else { // Remove downloads
LOG.info(`PublishScene.handleSceneUpdates removing downloads for scene ${idScene}`, LOG.LS.eGQL);
Expand Down
2 changes: 1 addition & 1 deletion server/job/impl/Cook/JobCook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export abstract class JobCook<T> extends JobPackrat {
// TODO: more robust support with alt type
// const stat = await webdavClient.stat(destination);
// const fileSize = (stat as FileStat).size;
// console.log(`>>>> fetchFile file size: ${fileSize} | ${destination}`);
// LOG.info(`>>>> fetchFile file size: ${fileSize} | ${destination}`,LOG.LS.eDEBUG);
// if(fileSize <= 0)
// throw new Error(`destination file doesn't exist or is empty. (${fileSize} bytes | ${destination})`);

Expand Down
38 changes: 29 additions & 9 deletions server/workflow/impl/Packrat/WorkflowEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ type ComputeSceneInfoResult = {
export class WorkflowEngine implements WF.IWorkflowEngine {
private workflowMap: Map<number, WF.IWorkflow> = new Map<number, WF.IWorkflow>();

// HACK: temporarily bypass download generation while development on it wraps up.
private tmpSkipGenDownloads: boolean = true;

async create(workflowParams: WF.WorkflowParameters): Promise<WF.IWorkflow | null> {
if (!workflowParams.eWorkflowType) {
LOG.error(`WorkflowEngine.create called without workflow type ${JSON.stringify(workflowParams)}`, LOG.LS.eWF);
Expand Down Expand Up @@ -317,13 +314,16 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
} else
LOG.info(`WorkflowEngine.eventIngestionIngestObjectModel skipping si-voyager-scene for master model with unsupported units ${JSON.stringify(CMIR, H.Helpers.saferStringify)}`, LOG.LS.eWF);

// HACK: skip generate downloads while other issues are resolved with it
if(this.tmpSkipGenDownloads===false) {
// do we want to generate downloads for this ingestion
if(generateDownloads===true) {

// does this ingested model have a scene child? If so, initiate WorkflowJob for cook si-generate-downloads
const SODerived: DBAPI.SystemObject[] | null = CMIR.idSystemObjectModel ? await DBAPI.SystemObject.fetchDerivedFromXref(CMIR.idSystemObjectModel) : null;
if (!SODerived)
return workflows.length > 0 ? workflows : null;

LOG.info(`WorkflowEngine.eventIngestionIngestObjectModel generating downloads: ${H.Helpers.JSONStringify(CMIR)}`,LOG.LS.eWF);

for (const SO of SODerived) {
if (SO.idScene) {
// locate the scene file asset attached to this system object
Expand Down Expand Up @@ -383,6 +383,8 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
parameters: jobParamSIGenerateDownloads,
};

// LOG.info(`WorkflowEngine.eventIngestionIngestObjectScene. generating downloads...\n${H.Helpers.JSONStringify(wfParamSIGenerateDownloads)}`,LOG.LS.eWF);

const wfSIGenerateDownloads: WF.IWorkflow | null = await this.create(wfParamSIGenerateDownloads);
if (wfSIGenerateDownloads)
workflows.push(wfSIGenerateDownloads);
Expand Down Expand Up @@ -438,14 +440,30 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
if (SOMTL)
idSystemObject.push(SOMTL.idSystemObject);

// HACK: skip generate downloads while other issues are resolved with it
if(this.tmpSkipGenDownloads===false) {
// do we want to generate downloads for this scene
// TODO: currently always true. needs to be fed upstream from business logic
if(generateDownloads===true) {

// initiate WorkflowJob for cook si-generate-download
const { modelBaseName } = await WorkflowEngine.computeSceneAndModelBaseNames(CSIR.idModel, CSIR.assetVersionGeometry.FileName);
const { sceneBaseName } = await WorkflowEngine.computeSceneAndModelBaseNames(CSIR.idModel, CSIR.assetVersionGeometry.FileName);

// make sure we have our basic parameters
if(!CSIR.idModel || !CSIR.idScene) {
LOG.error(`WorkflowEngine.eventIngestionIngestObjectScene cannot find idModel(${CSIR.idModel}) or idScene(${CSIR.idScene})`, LOG.LS.eWF);
return null;
}

// get our scene parameters
const parameterHelper: COOK.JobCookSIVoyagerSceneParameterHelper | null = await COOK.JobCookSIVoyagerSceneParameterHelper.compute(CSIR.idModel);
if(parameterHelper==null) {
LOG.error(`WorkflowEngine.eventIngestionIngestObjectScene cannot find model/scene ids\n(CSIR:${JSON.stringify(CSIR, H.Helpers.saferStringify)})`, LOG.LS.eWF);
return null;
}

const jobParamSIGenerateDownloads: WFP.WorkflowJobParameters =
new WFP.WorkflowJobParameters(COMMON.eVocabularyID.eJobJobTypeCookSIGenerateDownloads,
new COOK.JobCookSIGenerateDownloadsParameters(CSIR.idScene, CSIR.idModel, CSIR.assetVersionGeometry.FileName,
CSIR.assetSVX.FileName, CSIR.assetVersionDiffuse?.FileName, CSIR.assetVersionMTL?.FileName, modelBaseName));
CSIR.assetSVX.FileName, CSIR.assetVersionDiffuse?.FileName, CSIR.assetVersionMTL?.FileName, sceneBaseName, undefined, undefined, parameterHelper ));

const wfParamSIGenerateDownloads: WF.WorkflowParameters = {
eWorkflowType: COMMON.eVocabularyID.eWorkflowTypeCookJob,
Expand All @@ -455,6 +473,8 @@ export class WorkflowEngine implements WF.IWorkflowEngine {
parameters: jobParamSIGenerateDownloads,
};

LOG.info(`WorkflowEngine.eventIngestionIngestObjectScene. generating downloads...\n${H.Helpers.JSONStringify(wfParamSIGenerateDownloads)}`,LOG.LS.eWF);

const workflow: WF.IWorkflow | null = await this.create(wfParamSIGenerateDownloads);
if (workflow)
return [workflow];
Expand Down

0 comments on commit cac0d06

Please sign in to comment.