Model / getFinishedEvaluationResult
TypeScript
Get the results for a finished evaluation. If the evaluation is running, this function will wait for it to finish and then return the results. Results for finished evaluations are only available for a few minutes.
Request parameters
{
/** The model's id. */
modelId: string,
/** The evaluation's id. */
evaluationId: string
}
Response
{
/** If successful. One of "result" and "error" will be present. */
result?: {
/** One of failed or success will be present */
failed?: {
totalDuration: number,
durations: {
createLauncher?: number,
codeStartup?: number,
createInstantiatedModel?: number,
evaluate?: number
},
executedOnLauncher: {
type: 'persistentLauncher',
persistentLauncherId: string,
spec: LauncherSpec
} | {
type: 'temporaryLauncher',
spec: LauncherSpec
},
error: {
code: 'launcher_terminated' | 'cancelled' | 'server_overloaded' | 'invalid_executable_file' | 'read_executable_file_failed' | 'unknown'
} | {
code: 'max_duration_exceeded',
at: 'codeStartup' | 'instantiateModel' | 'evaluate'
} | {
code: 'code_terminated',
exitCode?: number,
signal?: string,
oom: boolean
} | {
code: 'exception',
at: 'codeStartup' | 'instantiateModel' | 'evaluate',
exceptionDetails?: string
} | {
code: 'invalid_output',
reason: 'invalid' | 'not_applicable_to_parameter_definitions',
details: string
}
},
success?: {
totalDuration: number,
durations: {
createLauncher?: number,
codeStartup?: number,
createInstantiatedModel?: number,
evaluate: number
},
executedOnLauncher: {
type: 'persistentLauncher',
persistentLauncherId: string,
spec: LauncherSpec
} | {
type: 'temporaryLauncher',
spec: LauncherSpec
},
output: DecthingsParameter[]
}
},
/** If failed */
error?: {
code: 'model_not_found' | 'evaluation_not_found' | 'bad_credentials' | 'too_many_requests' | 'payment_required' | 'unknown'
} | {
code: 'invalid_parameter',
parameterName: string,
reason: string
}
}
Where "DecthingsParameter" is defined as:
export type DecthingsParameter = {
name: string,
data: DecthingsTensor[]
}
Example
Following the installation guide to setup the Decthings API for TypeScript. Add your parameters to the following code and run it in Node.js, or in a browser by using a bundler.
The code reads your API key from file. Create an API key and save it to the file "auth.txt". Keep your key safe!
import * as fs from 'fs'
import { DecthingsClient } from '@decthings/api-client'
let apiKey = fs.readFileSync('./auth.txt').toString().trim()
let client = new DecthingsClient({ apiKey })
async function main() {
try {
let response = await client.model.getFinishedEvaluationResult({
modelId: /* Add modelId here */,
evaluationId: /* Add evaluationId here */
})
if (result.error) {
// Decthings sent us an error
console.log(response.error)
} else {
// Success!
console.log(response.result)
}
}
catch (e) {
// Client throws an error on connection issues. The function may or may not have succeded
console.log(e)
}
}
main()