Skip to content

Commit

Permalink
Update model to equations call (#2968)
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannParis authored Mar 11, 2024
1 parent 7c79cef commit 1d24acb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/client/hmi-client/src/services/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export async function generateModelCard(
}
}

// helper fucntion to get the model type, will always default to petrinet if the model is not found
// helper function to get the model type, will always default to petrinet if the model is not found
export function getModelType(model: Model | null | undefined): AMRSchemaNames {
const schemaName = model?.header?.schema_name?.toLowerCase();
if (schemaName === 'regnet') {
Expand All @@ -194,17 +194,19 @@ export function getModelType(model: Model | null | undefined): AMRSchemaNames {
}

// Converts a model into latex equation, either one of petrinet, stocknflow, or regnet;
export async function getModelEquation(model: Model) {
export async function getModelEquation(model: Model): Promise<string> {
const unSupportedFormats = ['decapodes'];
if (unSupportedFormats.includes(model.header.schema_name as string)) {
console.log(`getModelEquation: ${model.header.schema_name} not suported `);
console.warn(`getModelEquation: ${model.header.schema_name} not supported `);
return '';
}

const id = model.id;
const response = await API.get(`/transforms/model-to-latex/${id}`);
/* TODO - Replace the GET with the POST when the backend is ready,
* see PR https://github.com/DARPA-ASKEM/sciml-service/pull/167
*/
const response = await API.get(`/transforms/model-to-latex/${model.id}`);
// const response = await API.post(`/transforms/model-to-latex/`, model);
const latex = response.data.latex;
if (!latex) return '';

return latex;
}

0 comments on commit 1d24acb

Please sign in to comment.