Skip to content

Commit

Permalink
fix(cu): standard errors for hydrator
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrain99 committed Feb 10, 2025
1 parent a4f9e55 commit 0e597fd
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion servers/cu/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const createApis = async (ctx) => {
const BROADCAST = 'workers'
const workerBroadcast = new BroadcastChannel(BROADCAST).unref()
const broadcastCloseStream = (streamId) => workerBroadcast.postMessage({ type: 'close-stream', streamId })
const broadcastDumpEvaluations = () => workerBroadcast.postMessage({ type: 'dump-evaluations' })

const onCreateWorker = (type) => () => {
const workerId = randomBytes(8).toString('hex')
Expand Down
4 changes: 2 additions & 2 deletions servers/cu/src/effects/ao-evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function findEvaluationWith ({ db, loadEvaluation, EVALUATION_RESULT_DIR,
fromPromise(async (result) => {
if (EVALUATION_RESULT_DIR && EVALUATION_RESULT_BUCKET && !result.output) {
const evaluationOutput = await findEvaluationFromDir({ processId, messageId })
if (evaluationOutput == 'AWS Credentials not set') {
if (evaluationOutput === 'AWS Credentials not set') {
return Rejected({ status: 404, message: 'Could not find evaluation: AWS Credentials not set' }).toPromise()
}
return { ...result, output: evaluationOutput }
Expand Down Expand Up @@ -311,7 +311,7 @@ export function findEvaluationsWith ({ db, loadEvaluation, EVALUATION_RESULT_DIR
return await Promise.all(results.map(async (result) => {
if (result.processId && result.messageId && !result.output) {
const evaluationOutput = await findEvaluationFromDir({ processId: result.processId, messageId: result.messageId })
if (evaluationOutput == 'AWS Credentials not set') {
if (evaluationOutput === 'AWS Credentials not set') {
return Rejected({ status: 404, message: 'Could not find evaluation: AWS Credentials not set' })
}
return { ...result, output: evaluationOutput }
Expand Down
2 changes: 1 addition & 1 deletion servers/cu/src/effects/ao-evaluation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import assert from 'node:assert'

import { createTestLogger } from '../domain/logger.js'
import { findEvaluationSchema, findEvaluationsSchema, findMessageBeforeSchema, saveEvaluationSchema } from '../domain/dal.js'
import { findMessageBeforeWith, findEvaluationFromDbWith, findEvaluationsWith, saveEvaluationWith, findEvaluationWith } from './ao-evaluation.js'
import { findMessageBeforeWith, findEvaluationsWith, saveEvaluationWith, findEvaluationWith } from './ao-evaluation.js'
import { COLLATION_SEQUENCE_MAX_CHAR, EVALUATIONS_TABLE, MESSAGES_TABLE } from './db.js'

const logger = createTestLogger({ name: 'ao-cu:readState' })
Expand Down
2 changes: 1 addition & 1 deletion servers/cu/src/effects/worker/dumpEvaluations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path'
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
import { S3Client } from '@aws-sdk/client-s3'

export function dumpEvaluationsWith ({ EVALUATION_RESULT_DIR, EVALUATION_RESULT_BUCKET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, uploadFileToS3With, globSync, logger }) {
return async (processId) => {
Expand Down
1 change: 0 additions & 1 deletion servers/cu/src/effects/worker/loadEvaluation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path'
import fs from 'fs'
import { S3Client } from '@aws-sdk/client-s3'
export function loadEvaluationWith ({ EVALUATION_RESULT_DIR, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, logger, existsSync, writeFileSync, loadEvaluationFromDir, loadEvaluationFromS3 }) {
return async ({ messageId, processId }) => {
Expand Down
1 change: 1 addition & 0 deletions servers/cu/src/effects/worker/loadEvaluation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('loadEvaluation', async () => {
processId: 'test-process-id'
})
assert.deepStrictEqual(result, { foo: 'bar' })
assert.strictEqual(writeFileSyncCalled, true)
assert.strictEqual(existsCalled, true)
})
})
Expand Down

0 comments on commit 0e597fd

Please sign in to comment.