diff --git a/mupifDB/api/main.py b/mupifDB/api/main.py index be985c6..48cd2dd 100644 --- a/mupifDB/api/main.py +++ b/mupifDB/api/main.py @@ -1,3 +1,5 @@ +import time + from fastapi import FastAPI, UploadFile, Depends from fastapi.responses import FileResponse, StreamingResponse from fastapi.responses import HTMLResponse @@ -469,11 +471,6 @@ def get_file(uid: str, tdir=Depends(get_temp_dir)): wfile = io.BytesIO(foundfile.read()) fn = foundfile.filename return StreamingResponse(wfile, headers={"Content-Disposition": "attachment; filename=" + fn}) - # fullpath = tdir + '/' + fn - # with open(fullpath, "wb") as f: - # f.write(wfile.read()) - # f.close() - # return FileResponse(path=fullpath, media_type='application/octet-stream', headers={"Content-Disposition": "attachment; filename=" + fn}) @app.post("/file/", tags=["Files"]) @@ -506,7 +503,7 @@ def get_property_array_data(fid: str, i_start: int, i_count: int): @app.get("/field_as_vtu/{fid}", tags=["Additional"]) -def get_property_array_data(fid: str, tdir=Depends(get_temp_dir)): +def get_field_as_vtu(fid: str, tdir=Depends(get_temp_dir)): pfile, fn = mupifDB.restApiControl.getBinaryFileByID(fid) full_path = tdir + "/file.h5" f = open(full_path, 'wb') diff --git a/mupifDB/workflowmanager.py b/mupifDB/workflowmanager.py index 4a5a23a..cd70a3a 100644 --- a/mupifDB/workflowmanager.py +++ b/mupifDB/workflowmanager.py @@ -933,9 +933,20 @@ def mapOutput(app, eid, name, obj_id, data_id, time, object_type, onto_path=None else: raise ValueError('Handling of io param of type %s not implemented' % object_type) - # elif object_type == 'mupif.PyroFile': - # prop = app.get(mupif.DataID[data_id], time, obj_id) - # restApiControl.setExecutionOutputObject(eid, name, obj_id, prop.to_db_dict()) + elif object_type == 'mupif.PyroFile': + pf = app.get(mupif.DataID[data_id], time, obj_id) + with tempfile.TemporaryDirectory(dir="/tmp", prefix='mupifDB') as tempDir: + fn = pf.getBasename() + full_path = tempDir + "/" + fn + mupif.PyroFile.copy(pf, full_path) + fileID = None + with open(full_path, 'rb') as f: + fileID = restApiControl.uploadBinaryFile(f) + f.close() + if fileID is not None: + restApiControl.setExecutionOutputObject(eid, name, obj_id, {'FileID': fileID}) + else: + print("PyroFile file was not saved") elif object_type == 'mupif.HeavyStruct': hs = app.get(mupif.DataID[data_id], time, obj_id) diff --git a/webapi/index.py b/webapi/index.py index 93f15b5..6d62fc7 100644 --- a/webapi/index.py +++ b/webapi/index.py @@ -412,7 +412,7 @@ def executions(): if 'filter_status' in args: filter_status = str(args['filter_status']) - html = '

List of workflow executions:

' + html = '

List of workflow executions

' html += '
' html += 'WorkflowID: ' html += 'version: ' @@ -586,7 +586,7 @@ def setExecutionInputs(weid): if obo_id is not None: restApiControl.setExecutionOntoBaseObjectID(weid, name=obo.get('Name', ''), value=obo_id) - msg += "
Back to Execution record "+weid+"" + msg += "
Back to Execution detail" # return my_render_template("basic.html", body=Markup(msg)) execution_record = restApiControl.getExecutionRecord(weid) @@ -595,11 +595,18 @@ def setExecutionInputs(weid): workflow_record = restApiControl.getWorkflowRecord(wid) winprec = workflow_record["IOCard"]["Inputs"] # generate input form - form = "Back to Execution record "+weid+"
" + form = "Back to Execution detail
" - form += f"

Workflow: {wid}


" + # form += f"

Execution inputs: {wid}


" + + form += "" + form += "" + form += "" + form += "" + form += "" - form += "
Workflow_ID:" + form += str(wid) + form += "
" form += "" form += "" form += "
Task_ID:" @@ -643,8 +650,9 @@ def setExecutionInputs(weid): show_execution_links = any_execution_link or args.get('show_execution_links', False) - form += "
Input record for weid %s" % weid - form += "" + form += "

Execution inputs

" + form += "
NameTypeValueTypeDataIDDescriptionObjIDValueUnits
" + form += "" if show_execution_links: form += "" if any_edm_path: @@ -669,14 +677,12 @@ def setExecutionInputs(weid): required = "" form += '' + form += '' + form += '' + form += '' if input_type == "mupif.Property": - form += '' - form += '' - form += '' - form += '' - form += '' - form += '' + form += '" - form += '' elif input_type == "mupif.String": - form += '' - form += '' - form += '' - form += '' - form += '' - form += '' form += '" - form += '' else: - form += '' - form += '' - form += '' - form += '' - form += '' - form += '' form += '' - form += '' + + form += '' + form += '' + + form += '' + form += '' if show_execution_links: if execution_record["Status"] == "Created" and i.get('EDMPath', None) is None: @@ -864,10 +862,11 @@ def getExecutionOutputs(weid): # generate result table form - form = "Back to Execution record " + weid + "" + form = "Back to Execution detail" - form += f"

Workflow: {wid}

Output record for weid {weid}
TypeValueTypeDataIDValueUnitsNameDescriptionObjIDLink_EIDLink_NameLink_ObjID
' + str(i['Type']).replace('mupif.', '') + '' + str(i.get('ValueType', '')) + '' + str(i.get('TypeID', '[unknown]')).replace('mupif.DataID.', '') + '' + str(i['Name']) + '' + str(i['Type']) + '' + str(i.get('ValueType', '')) + '' + str(i.get('TypeID', '[unknown]')).replace('mupif.DataID.', '') + '' + str(description) + '' + str(i['ObjID']) + '' if execution_record["Status"] == "Created" and i.get('EDMPath', None) is None: try: @@ -706,21 +712,15 @@ def setExecutionInputs(weid): value = onto_data.get('value', None) unit = onto_data.get('unit', '') if value is not None: - form += str(value) + ' ' + str(unit) + form += "" % (c, str(value), required) + # form += str(value) + ' ' + str(unit) else: if i['Object'].get('Value', None) is not None: form += str(i['Object']['Value']) form += "' + str(i.get('Units')) + '' + str(i['Name']) + '' + str(i['Type']) + '' + str(i.get('ValueType', '')) + '' + str(i.get('TypeID', '[unknown]')).replace('mupif.DataID.', '') + '' + str(description) + '' + str(i['ObjID']) + '' if execution_record["Status"] == "Created" and i.get('EDMPath', None) is None: try: @@ -766,17 +766,15 @@ def setExecutionInputs(weid): form += str(val) form += "' + str(i.get('Units')) + '' + str(i['Name']) + '' + str(i['Type']) + '' + str(i.get('ValueType', '')) + '' + str(i.get('TypeID', '[unknown]')).replace('mupif.DataID.', '') + '' + str(description) + '' + str(i['ObjID']) + '' + str(i.get('Object', {}).get('Value', '')) + '' + str(i.get('Units')) + '' + str(i.get('Units')) + '' + str(i['Name']) + '' + str(description) + '' + str(i['ObjID']) + '
" - form += "" + form += "

Execution outputs

" + form += "
NameTypeValueTypeDataIDObjIDValueUnitsEDMPath
" + form += "" for i in execution_outputs: val = '' @@ -903,6 +902,9 @@ def getExecutionOutputs(weid): except: pass + if i['Type'] == 'mupif.TemporalProperty': + val = '[...]' + if i['Type'] == 'mupif.String': if i.get('EDMPath', None) is not None: onto_path = i.get('EDMPath') @@ -938,14 +940,21 @@ def getExecutionOutputs(weid): except: pass + if i['Type'] == 'mupif.PyroFile': + try: + if i['Object'].get('FileID') is not None and i['Object'].get('FileID') != '': + val = 'download' + except: + pass + form += '' - form += '' form += '' form += '' form += '' - form += '' form += '' form += '' + form += '' + form += '' form += '' form += "
TypeValueTypeDataIDValueUnitsNameObjIDEDMPath
' + str(i['Name']) + '' + str(i['Type']) + '' + str(i.get('ValueType', '')) + '' + str(i.get('TypeID', '[unknown]')).replace('mupif.DataID.', '') + '' + str(i['ObjID']) + '' + str(val) + '' + str(escape(i.get('Units'))) + '' + str(i['Name']) + '' + str(i['ObjID']) + '' + str(i.get('EDMPath', '')) + '
" diff --git a/webapi/static/images/project-logo.png b/webapi/static/images/project-logo.png deleted file mode 100644 index 1bddae3..0000000 Binary files a/webapi/static/images/project-logo.png and /dev/null differ diff --git a/webapi/templates/layout.html b/webapi/templates/layout.html index c435fc4..48068c6 100644 --- a/webapi/templates/layout.html +++ b/webapi/templates/layout.html @@ -21,7 +21,7 @@ diff --git a/webapi/templates/workflows.html b/webapi/templates/workflows.html index 7dfbe94..d8e9e14 100644 --- a/webapi/templates/workflows.html +++ b/webapi/templates/workflows.html @@ -1,8 +1,9 @@ {% extends "layout.html" %} {% block title %} {{ title }} {% endblock %} -{% block content %} +{% block content %} +

List of workflows

- + {% for item in items %}
WIDUseCaseIDDescriptionDetails
WorkflowIDUseCaseIDDescriptionDetail
{{item.wid}}