Skip to content

Commit

Permalink
EDM execution data endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav committed Oct 14, 2024
1 parent 4b875a1 commit 7257053
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions mupifDB/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,43 @@ def get_execution(uid: str):
return None


@app.get("/edm_executions/{uid}", tags=["Executions"])
@app.get("/edm_execution/{uid}", tags=["Executions"])
def get_edm_execution(uid: str):
res = db.WorkflowExecutions.find_one({"_id": bson.objectid.ObjectId(uid)})
if res:
e = table_structures.extendRecord(fix_id(res), table_structures.tableExecution)
mapping = e.get('EDMMapping', [])
for m in mapping:
if 'createFrom' in m or 'createNew' in m:
m['ioType'] = 'Output'
m['ioType'] = 'output'
else:
m['ioType'] = 'Input'
m['ioType'] = 'input'
return mapping
return None


@app.get("/edm_execution/{uid}/{entity}/{iotype}", tags=["Executions"])
def get_edm_execution(uid: str, entity: str, iotype: str):
res = db.WorkflowExecutions.find_one({"_id": bson.objectid.ObjectId(uid)})
if res:
e = table_structures.extendRecord(fix_id(res), table_structures.tableExecution)
mapping = e.get('EDMMapping', [])
for m in mapping:
if 'createFrom' in m or 'createNew' in m:
m['ioType'] = 'output'
else:
m['ioType'] = 'input'

for m in mapping:
if m['ioType'] == iotype and m['EDMEntity'] == entity:
if m.get('id', None):
return m['id']
elif m.get('ids', None):
return m['ids']
return None
return None


class M_WorkflowExecutionAddSpec(BaseModel):
wid: str
version: str
Expand Down

0 comments on commit 7257053

Please sign in to comment.