Created
April 29, 2025 16:25
-
-
Save SiestaMadokaist/b15dc77f980f288d907d3355ae401cdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionGenerate { | |
.... | |
workDone() { | |
return this.props.workDone; | |
} | |
workToDo(): IPromptParam[] { | |
const notDone: IPromptParam[] = []; | |
for (const r of this.props.resource){ | |
if (state.skipped < this.props.workDone) { | |
state += r.n_iter | |
} | |
notDone.push(r) | |
} | |
} | |
async updateProgress(progressDone: number): Promise<void> { | |
const resp = await this.dynamoClient(updateComand) | |
if (resp.prioScore != this.props.prioScore) { | |
await this.updateStatus('pending'); | |
throw new JobReprioritized(...) | |
} | |
if (resp.currentStatus != 'running') { throw new JobCancelled } | |
} | |
async process(param: IPromptParam) { | |
...stuffs | |
await this.updateProgress(this.workDone + param.n_iter) | |
} | |
async processAll() { | |
await this.updateStatus('running'); | |
const todos = this.workToDo(); | |
for (const todo of todos) { | |
const resp = await this.process(todo).catch((e) => e); | |
if (resp instanceof JobReprioritized) { return; } | |
if (resp instanceof Error) { break; } | |
} | |
await this.updateStatus('completed'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment