Skip to content

Commit

Permalink
Changes gen_pg to return a JSONResponse.
Browse files Browse the repository at this point in the history
Corresponding update in main.js parses pgt string into Json object, before submitting to OOD endpoint.
  • Loading branch information
pritchardn committed Sep 14, 2022
1 parent bf18f65 commit ccc3eb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions daliuge-translator/dlg/dropmake/web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ async function restDeploy() {
// fetch the PGT from this server
console.log("sending request to ", pgt_url);
console.log("graph name:", pgtName);
const pgt = await fetch(pgt_url, {
let pgt = await fetch(pgt_url, {
method: 'GET',
})
.then(handleFetchErrors)
.then(response => response.json())
.catch(function (error) {
showMessageModal('Error', error + "\nGetting PGT unsuccessful: Unable to continue!");
});

pgt = JSON.parse(pgt);
// This is for a deferred start of daliuge, e.g. on SLURM
console.log("sending request to ", create_slurm_url);
var body = [pgtName, pgt]; // we send the name in the body with the pgt
Expand Down
14 changes: 7 additions & 7 deletions daliuge-translator/dlg/dropmake/web/translator_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ async def gen_pgt_post(
detail="Graph partition exception {1}: {0}".format(trace_msg, lg_name))


@app.get("/gen_pg", response_class=StreamingResponse, tags=["Original"])
@app.get("/gen_pg", response_class=JSONResponse, tags=["Original"])
def gen_pg(
request: Request,
pgt_id: str = Query(description="The pgt_id used to internally reference this graph"),
Expand Down Expand Up @@ -474,9 +474,7 @@ def gen_pg(

pg_spec = pgtp.to_pg_spec([], ret_str=False, tpl_nodes_len=nnodes)
pg_spec.append(reprodata)
response = StreamingResponse(json.dumps(pg_spec))
response.headers["Content-Disposition"] = "attachment; filename=%s" % pgt_id
return response
return JSONResponse(pg_spec)
try:
mgr_client = CompositeManagerClient(
host=mhost, port=mport, url_prefix=mprefix, timeout=30
Expand Down Expand Up @@ -505,9 +503,7 @@ def gen_pg(
mhost, mport, mprefix, ssid
))
else:
response = StreamingResponse(json.dumps(pg_spec))
response.headers["Content-Disposition"] = "attachment; filename=%s" % pgt_id
return response
return JSONResponse(pg_spec)
except restutils.RestClientException as re:
raise HTTPException(status_code=500,
detail="Failed to interact with DALiUGE Drop Manager: {0}".format(re))
Expand Down Expand Up @@ -900,3 +896,7 @@ def handler(*_args):
port=options.port,
debug=options.verbose
)


if __name__ == "__main__":
run(None, sys.argv[1:])

0 comments on commit ccc3eb1

Please sign in to comment.