Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@naglepuff
Copy link
Collaborator

@naglepuff naglepuff commented Oct 21, 2025

Fix #1532

Prevent batch pipelines/training from hogging resources when running in desktop mode by sequentially running jobs.

Introduces two queues for running jobs in desktop job separated by the resource used (CPU or GPU). Now, instead of invoking the ipcService directly to start a job, the Api functions add the job arguments to the appropriate queue. Once a queued job's arguments are up, the IPC call is made by the queue to start the job.

This involved some refactoring of the import logic. Previously, the job to convert imported media was started deep within the finalizeImport logic. Now, finalizeImport returns an instance of ConversionArgs. It is the responsibility of consuming code to inspect the mediaList and kick off a conversion job as appropriate. Tests were updated to reflect this new paradigm.

Job types have also been refactored to include a type field, whose value belongs to the new JobType enum.

The "Jobs" tab now contains two sections: "Job History" - which contains exactly what the previous "Jobs" tab did. It displays the currently running job and previously completed jobs. The "Queued Jobs" tab is new and displays a list of queued jobs.

Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor suggestions and questions. Feel free to push back on any if you think they are out of scope for this PR.

@naglepuff naglepuff marked this pull request as ready for review November 5, 2025 19:35
@naglepuff naglepuff requested a review from BryonLewis November 5, 2025 19:36
Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one more additional change regarding how the awaiting is calculated. It works for bulk import but for single file imports it doesn't update properly.

Comment on lines 125 to 132
watch(recentHistory, () => {
queuedConversionDatasetIds.value = [];
cpuJobQueue.jobSpecs.forEach((spec: Job) => {
if (spec.type === JobType.Conversion) {
queuedConversionDatasetIds.value.push(spec.meta.id);
}
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this works properly with bulk import but if I import multiple data using the Import Video quickly the subsquent data files aren't placed in the awaiting state.

I think this is related to watching recentHistory. RecentHistory is in jobs.ts and is updated when job-update is called. So when you batch load all the data is already in cpuJobQueue and the proper conversionIds are added. If you add videos one at a time only the first job when it starts calls job-update, or you have to wait until it calls job-update again for it to update the list and check the cpuJobQueue.jobSpecs. This may be fixed by simply watching () => cpuJobQueue.jobSpecs instead of RecentHistory because really you want to know that's in the cpuJobQueue of type Conversion at the time it changes. You would probably have to watch deep: true because you're looking at a non-reactive array. There could also be a better way than deeply watching this queue that I don't know of.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From jobs.ts I'm not exporting queued jobs wrapped in reactive. I've updated Recent.vue to watch this instead. 9111c51

@naglepuff naglepuff requested a review from BryonLewis November 7, 2025 21:31
Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@naglepuff naglepuff merged commit 14757f4 into main Nov 10, 2025
4 checks passed
@naglepuff naglepuff deleted the issue-1532-sequential-job-processing branch November 10, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop - Sequential Job Processing

2 participants