diff --git a/skema/rest/schema.py b/skema/rest/schema.py index 571e279e367..5ab466b6655 100644 --- a/skema/rest/schema.py +++ b/skema/rest/schema.py @@ -81,7 +81,7 @@ class EquationsToAMRs(BaseModel): ]], ) model: Literal["regnet", "petrinet", "met", "gamr", "decapode"] = Field( - description="The model type", examples=[["gamr"], ["regnet"], ["petrinet"], ["met"], ["decapode"]] + description="The model type", examples=["gamr"] ) class MmlToAMR(BaseModel): diff --git a/skema/rest/workflows.py b/skema/rest/workflows.py index 4043b745f9a..8f4d97ad48a 100644 --- a/skema/rest/workflows.py +++ b/skema/rest/workflows.py @@ -9,6 +9,7 @@ from typing import List from pathlib import Path import httpx +import requests from fastapi import APIRouter, Depends, File, UploadFile, FastAPI, Request from starlette.responses import JSONResponse @@ -79,7 +80,7 @@ async def equation_to_amrs(data: schema.EquationsToAMRs, client: httpx.AsyncClie """ eqns = utils.parse_equations(data.equations) if data.model == "petrinet" or data.model == "regnet": - payload = {"mathml": data.equations, "model": data.model} + payload = {"mathml": eqns, "model": data.model} res = await client.put(f"{SKEMA_RS_ADDESS}/mathml/amr", json=payload) if res.status_code != 200: res_new = await client.put(f"{SKEMA_RS_ADDESS}/mathml/g-amr", json=eqns) diff --git a/skema/skema-rs/mathml/src/parsers/generic_mathml.rs b/skema/skema-rs/mathml/src/parsers/generic_mathml.rs index 79e25562d03..8fcc4602712 100644 --- a/skema/skema-rs/mathml/src/parsers/generic_mathml.rs +++ b/skema/skema-rs/mathml/src/parsers/generic_mathml.rs @@ -221,11 +221,30 @@ pub fn rparen(input: Span) -> IResult { Ok((s, op)) } +pub fn comma(input: Span) -> IResult { + let (s, op) = value(Operator::Comma, ws(tag(",")))(input)?; + Ok((s, op)) +} + +pub fn period(input: Span) -> IResult { + let (s, op) = value(Operator::Period, ws(tag(".")))(input)?; + Ok((s, op)) +} + pub fn mean(input: Span) -> IResult { let (s, op) = value(Operator::Mean, ws(tag("¯")))(input)?; Ok((s, op)) } +pub fn hat(input: Span) -> IResult { + let (s, op) = value(Operator::Hat, alt((ws(tag("^")), ws(tag("^")))))(input)?; + Ok((s, op)) +} + +pub fn grad(input: Span) -> IResult { + let (s, op) = value(Operator::Grad, alt((ws(tag("∇")), ws(tag("∇")))))(input)?; + Ok((s, op)) +} pub fn dot(input: Span) -> IResult { let (s, op) = value(Operator::Dot, alt((ws(tag("⋅")), ws(tag("⋅")))))(input)?; Ok((s, op)) @@ -236,12 +255,20 @@ pub fn cross(input: Span) -> IResult { Ok((s, op)) } -pub fn vector(input: Span) -> IResult { - let (s, op) = value(Operator::Vector, alt((ws(tag("→")), ws(tag("→")))))(input)?; +pub fn down_arrow(input: Span) -> IResult { + let (s, op) = value( + Operator::DownArrow, + alt((ws(tag("↓")), ws(tag("↓")))), + )(input)?; + Ok((s, op)) +} + +pub fn int(input: Span) -> IResult { + let (s, op) = value(Operator::Int, alt((ws(tag("∫")), ws(tag("∫")))))(input)?; Ok((s, op)) } -pub fn operator_other(input: Span) -> IResult { +fn operator_other(input: Span) -> IResult { let (s, consumed) = ws(recognize(not_line_ending))(input)?; let op = Operator::Other(consumed.to_string()); Ok((s, op)) @@ -255,11 +282,15 @@ pub fn operator(input: Span) -> IResult { lparen, rparen, mean, + hat, multiply, divide, + grad, dot, cross, - vector, + period, + down_arrow, + int, operator_other, ))(input)?; Ok((s, op))