ml4ai / ASKEM-TA1-DockerVM

Docker recipes demonstrating how to use our pipelines
3 stars 1 forks source link

[code2fn] example of gromet -> AMR in `end-to-end-rest` #6

Closed myedibleenso closed 1 year ago

myedibleenso commented 1 year ago

In coordination with @Free-Quarks , enhance or supplement end-to-end-rest example with AMR output.

We have a snippet we expect to work (to be added to code2amr.ipynb), but MORAE doesn't yet support our typical gromet:

from IPython.display import display, HTML, Image
from pathlib import Path
import requests
import json
import os

pp = lambda x: print(json.dumps(x, indent=2))

SKEMA_PA_SERVICE = os.environ.get("SKEMA_PA_ADDRESS", "http://skema-py:8000")
SKEMA_RS_SERVICE = os.environ.get("SKEMA_RS_ADDRESS", "http://skema-rs:8080")

filename = "CHIME_SIR.py"
with open(Path("/data") / "skema" / "code" / filename, "r") as infile:
    code = infile.read()

# display file contents
display(HTML(f"<code>{code}</code>"))

# API call and response

response = requests.post(f"{SKEMA_RS_SERVICE}/extract-comments", json={"language" : "Python", "code" : code})

r = requests.put(f"{BASE_URL}/models/PN", json=response.json())
r.json()

# NOTE: the put request cleans up after itself (from @Free-Quarks)
#requests.delete(f"{BASE_URL}/models/{MODEL_ID}").text
### Tasks
- [ ] https://github.com/ml4ai/skema/issues/278
myedibleenso commented 1 year ago

This now depends on a) addressing issues in gromet (wiring errors) and potentially b) updates to the amr side (i.e., expectations about what gromet properties are required).

myedibleenso commented 1 year ago

Completed during the hackathon.