From d332d94083ffed810154b94336ee79daed470c00 Mon Sep 17 00:00:00 2001 From: Collin Bolles Date: Fri, 22 Nov 2024 18:18:56 -0500 Subject: [PATCH] bug: NERC Execution (#19) * Ensure sim files are made * Make errors easier to follow --- .../src/simulation/simulation.consumer.ts | 39 +++++++++---------- packages/runner/main.py | 1 + 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/backend/src/simulation/simulation.consumer.ts b/packages/backend/src/simulation/simulation.consumer.ts index b11e195..270f5ba 100644 --- a/packages/backend/src/simulation/simulation.consumer.ts +++ b/packages/backend/src/simulation/simulation.consumer.ts @@ -13,19 +13,14 @@ export class SimulationRequestConsumer extends WorkerHost { async process(job: Job): Promise { const request = job.data; // Start the COMETs job - try { - const jobName = await this.jobService.triggerJob(request); - // Wait for the job to complete - const status = await this.awaitCompletion(jobName); - // If the status is error, collect and send error data - if (status == JobStatus.FAILURE) { - await this.handleError(request, jobName); - } else { - await this.handleSuccess(request, jobName); - } - } catch (e) { - console.error(e); - throw e; + const jobName = await this.jobService.triggerJob(request); + // Wait for the job to complete + const status = await this.awaitCompletion(jobName); + // If the status is error, collect and send error data + if (status == JobStatus.FAILURE) { + await this.handleError(request, jobName); + } else { + await this.handleSuccess(request, jobName); } } @@ -50,14 +45,18 @@ export class SimulationRequestConsumer extends WorkerHost { * Keep checking the status of the job once a second */ private async awaitCompletion(jobName: string): Promise { - return new Promise(async (resolve, _reject) => { + return new Promise(async (resolve, reject) => { const checkOperations = async () => { - const status = await this.jobService.getJobStatus(jobName); - if (status == JobStatus.RUNNING) { - setTimeout(checkOperations, 1000); - return; - } else { - resolve(status); + try { + const status = await this.jobService.getJobStatus(jobName); + if (status == JobStatus.RUNNING) { + setTimeout(checkOperations, 1000); + return; + } else { + resolve(status); + } + } catch (e) { + reject(e); } }; await checkOperations(); diff --git a/packages/runner/main.py b/packages/runner/main.py index fa408a8..d4a6ab0 100644 --- a/packages/runner/main.py +++ b/packages/runner/main.py @@ -97,6 +97,7 @@ async def main(): # Set size layout.grid = layout_builder.get_grid_size() layout.add_barriers(layout_builder.get_barrier()) + layout.write_necessary_files('./sim_files/') # Add models [layout.add_model(model) for model in models]