#141: Made POC 99% there. Issue is multipart bug in python
This commit is contained in:
+100
-29
@@ -828,7 +828,6 @@ class AppBase:
|
|||||||
# - How can you download / stream a file?
|
# - How can you download / stream a file?
|
||||||
# - Can you decide if you want a stream or the files directly?
|
# - Can you decide if you want a stream or the files directly?
|
||||||
def get_files(full_execution, value):
|
def get_files(full_execution, value):
|
||||||
print("FULL EXEC: %s" % full_execution)
|
|
||||||
org_id = full_execution["workflow"]["execution_org"]["id"]
|
org_id = full_execution["workflow"]["execution_org"]["id"]
|
||||||
print("SHOULD GET FILES BASED ON ORG %s, workflow %s and value(s) %s" % (org_id, full_execution["workflow"]["id"], value))
|
print("SHOULD GET FILES BASED ON ORG %s, workflow %s and value(s) %s" % (org_id, full_execution["workflow"]["id"], value))
|
||||||
get_path = "/api/v1/files/%s/content?execution_id=%s" % (value, full_execution["execution_id"])
|
get_path = "/api/v1/files/%s/content?execution_id=%s" % (value, full_execution["execution_id"])
|
||||||
@@ -845,22 +844,72 @@ class AppBase:
|
|||||||
print("ERROR GETTING FILE: ")
|
print("ERROR GETTING FILE: ")
|
||||||
print("FILE RET CONTENT: %s" % ret.text)
|
print("FILE RET CONTENT: %s" % ret.text)
|
||||||
print("FILE RET CODE FILE: %d" % ret.status_code)
|
print("FILE RET CODE FILE: %d" % ret.status_code)
|
||||||
|
return "Error getting file(s). Status code %d" % ret.status_code
|
||||||
|
|
||||||
# Sets files in the backend
|
# Sets files in the backend
|
||||||
def set_files(full_execution, files[]):
|
def set_files(full_execution, infiles):
|
||||||
print("FULL EXEC: %s" % full_execution)
|
workflow_id = full_execution["workflow"]["id"]
|
||||||
org_id = full_execution["workflow"]["execution_org"]["id"]
|
org_id = full_execution["workflow"]["execution_org"]["id"]
|
||||||
print("SHOULD GET FILES BASED ON ORG %s, workflow %s and value(s) %s" % (org_id, full_execution["workflow"]["id"], value))
|
|
||||||
get_path = "/api/v1/files/%s/content?execution_id=%s" % (value, full_execution["execution_id"])
|
|
||||||
|
|
||||||
print("PATH: %s" % get_path)
|
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": "Bearer %s" % self.authorization
|
"Authorization": "Bearer %s" % self.authorization
|
||||||
}
|
}
|
||||||
ret = requests.get("%s%s" % (self.url, get_path), headers=headers)
|
|
||||||
print("RET CONTENT: %s" % ret.text)
|
create_path = "/api/v1/files/create?execution_id=%s" % full_execution["execution_id"]
|
||||||
print("RET CODE FILE: %d" % ret.status_code)
|
file_ids = []
|
||||||
|
for curfile in infiles:
|
||||||
|
filename = "unspecified"
|
||||||
|
data = {
|
||||||
|
"filename": filename,
|
||||||
|
"workflow_id": workflow_id,
|
||||||
|
"org_id": org_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data["filename"] = curfile["filename"]
|
||||||
|
filename = curfile["filename"]
|
||||||
|
except KeyError as e:
|
||||||
|
print("KeyError in file setup: %s" % e)
|
||||||
|
pass
|
||||||
|
|
||||||
|
ret = requests.post("%s%s" % (self.url, create_path), headers=headers, json=data)
|
||||||
|
print("Ret CREATE: %s" % ret.text)
|
||||||
|
cur_id = ""
|
||||||
|
if ret.status_code == 200:
|
||||||
|
print("RET: %s" % ret.text)
|
||||||
|
ret_json = ret.json()
|
||||||
|
if not ret_json["success"]:
|
||||||
|
print("Not success in file upload creation.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
print("Should handle ID %s" % ret_json["id"])
|
||||||
|
file_ids.append(ret_json["id"])
|
||||||
|
cur_id = ret_json["id"]
|
||||||
|
else:
|
||||||
|
print("Bad status code: %d" % ret.status_code)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(cur_id) == 0:
|
||||||
|
print("No file ID specified from backend")
|
||||||
|
continue
|
||||||
|
|
||||||
|
new_headers = {
|
||||||
|
"Content-Type": "multipart/form-data; charset=utf-8; boundary=\"test boundary Shuffle\"",
|
||||||
|
"Authorization": "Bearer %s" % self.authorization,
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_path = "/api/v1/files/%s/upload?execution_id=%s" % (cur_id, full_execution["execution_id"])
|
||||||
|
print("Create path: %s" % create_path)
|
||||||
|
#files={"shuffle_file": open(filename,'rb')}
|
||||||
|
files={"shuffle_file": (filename, curfile["data"])}
|
||||||
|
#open(filename,'rb')}
|
||||||
|
|
||||||
|
ret = requests.post("%s%s" % (self.url, upload_path), files=files, headers=new_headers)
|
||||||
|
print("Ret UPLOAD: %s" % ret.text)
|
||||||
|
print("Ret2 UPLOAD: %d" % ret.status_code)
|
||||||
|
|
||||||
|
print("IDS TO RETURN: %s" % file_ids)
|
||||||
|
return file_ids
|
||||||
|
|
||||||
# Checks whether conditions are met, otherwise set
|
# Checks whether conditions are met, otherwise set
|
||||||
branchcheck, tmpresult = check_branch_conditions(action, fullexecution)
|
branchcheck, tmpresult = check_branch_conditions(action, fullexecution)
|
||||||
@@ -929,19 +978,6 @@ class AppBase:
|
|||||||
multiexecution = False
|
multiexecution = False
|
||||||
multi_execution_lists = []
|
multi_execution_lists = []
|
||||||
for parameter in action["parameters"]:
|
for parameter in action["parameters"]:
|
||||||
|
|
||||||
# This code handles files.
|
|
||||||
is_file = False
|
|
||||||
try:
|
|
||||||
if parameter["schema"]["type"] == "file":
|
|
||||||
print("SHOULD HANDLE FILE. Get based on value %s" % parameter["value"])
|
|
||||||
get_files(fullexecution, parameter["value"])
|
|
||||||
is_file = True
|
|
||||||
except KeyError as e:
|
|
||||||
print("SCHEMA ERROR: %s" % e)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
check, value, is_loop = parse_params(action, fullexecution, parameter)
|
check, value, is_loop = parse_params(action, fullexecution, parameter)
|
||||||
if check:
|
if check:
|
||||||
raise "Value check error: %s" % Exception(check)
|
raise "Value check error: %s" % Exception(check)
|
||||||
@@ -1057,6 +1093,18 @@ class AppBase:
|
|||||||
params[parameter["name"]] = value
|
params[parameter["name"]] = value
|
||||||
multi_parameters[parameter["name"]] = value
|
multi_parameters[parameter["name"]] = value
|
||||||
|
|
||||||
|
# This code handles files.
|
||||||
|
try:
|
||||||
|
if parameter["schema"]["type"] == "file":
|
||||||
|
print("SHOULD HANDLE FILE. Get based on value %s" % parameter["value"])
|
||||||
|
file_value = get_files(fullexecution, value)
|
||||||
|
print("FILE VALUE: %s" % file_value)
|
||||||
|
|
||||||
|
params[parameter["name"]] = file_value
|
||||||
|
multi_parameters[parameter["name"]] = file_value
|
||||||
|
except KeyError as e:
|
||||||
|
print("SCHEMA ERROR IN FILE HANDLING: %s" % e)
|
||||||
|
|
||||||
# Fix lists here
|
# Fix lists here
|
||||||
print("CHECKING multi execution list!")
|
print("CHECKING multi execution list!")
|
||||||
if len(multi_execution_lists) > 0:
|
if len(multi_execution_lists) > 0:
|
||||||
@@ -1080,14 +1128,37 @@ class AppBase:
|
|||||||
|
|
||||||
print("New multi execution length: %d\n" % tmplength)
|
print("New multi execution length: %d\n" % tmplength)
|
||||||
|
|
||||||
# FIXME - this is horrible, but works for now
|
|
||||||
#for i in range(calltimes):
|
|
||||||
if not multiexecution:
|
if not multiexecution:
|
||||||
print("APP_SDK DONE: Starting NORMAL execution of function")
|
print("APP_SDK DONE: Starting NORMAL execution of function")
|
||||||
print("Running with params %s" % params)
|
print("Running with params (0): %s" % params)
|
||||||
newres = await func(**params)
|
newres = await func(**params)
|
||||||
print("Return from execution: %s" % newres)
|
print("Returned from execution.")
|
||||||
if isinstance(newres, str):
|
if isinstance(newres, tuple):
|
||||||
|
print("Handling return as tuple")
|
||||||
|
# Handles files.
|
||||||
|
filedata = ""
|
||||||
|
file_ids = []
|
||||||
|
print("TUPLE: %s" % newres[1])
|
||||||
|
if isinstance(newres[1], list):
|
||||||
|
print("HANDLING LIST FROM RET")
|
||||||
|
file_ids = set_files(fullexecution, newres[1])
|
||||||
|
elif isinstance(newres[1], object):
|
||||||
|
print("Handling JSON from ret")
|
||||||
|
file_ids = set_files(fullexecution, [newres[1]])
|
||||||
|
elif isinstance(newres[1], str):
|
||||||
|
print("Handling STRING from ret")
|
||||||
|
file_ids = set_files(fullexecution, [newres[1]])
|
||||||
|
else:
|
||||||
|
print("NO FILES TO HANDLE")
|
||||||
|
|
||||||
|
tmp_result = {
|
||||||
|
"result": newres[0],
|
||||||
|
"file_ids": file_ids
|
||||||
|
}
|
||||||
|
|
||||||
|
result = json.dumps(tmp_result)
|
||||||
|
elif isinstance(newres, str):
|
||||||
|
print("Handling return as string")
|
||||||
result += newres
|
result += newres
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@@ -1165,7 +1236,7 @@ class AppBase:
|
|||||||
print("KeyError: %s" % e)
|
print("KeyError: %s" % e)
|
||||||
baseparams[key] = "KeyError: %s" % e
|
baseparams[key] = "KeyError: %s" % e
|
||||||
|
|
||||||
print("Running with params %s" % baseparams)
|
print("Running with params %s (1)" % baseparams)
|
||||||
ret = await func(**baseparams)
|
ret = await func(**baseparams)
|
||||||
print("Return from execution: %s" % ret)
|
print("Return from execution: %s" % ret)
|
||||||
if isinstance(ret, dict) or isinstance(ret, list):
|
if isinstance(ret, dict) or isinstance(ret, list):
|
||||||
|
|||||||
@@ -2836,7 +2836,7 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
|
|||||||
|
|
||||||
var allEnvs []Environment
|
var allEnvs []Environment
|
||||||
if len(workflowExecution.ExecutionOrg) > 0 {
|
if len(workflowExecution.ExecutionOrg) > 0 {
|
||||||
log.Printf("Executing ORG: %s", workflowExecution.ExecutionOrg)
|
log.Printf("[INFO] Executing ORG: %s", workflowExecution.ExecutionOrg)
|
||||||
|
|
||||||
allEnvironments, err := getEnvironments(ctx, workflowExecution.ExecutionOrg)
|
allEnvironments, err := getEnvironments(ctx, workflowExecution.ExecutionOrg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2838,13 +2838,55 @@ const AngularWorkflow = (props) => {
|
|||||||
|
|
||||||
console.log(selectedActionParameters[count])
|
console.log(selectedActionParameters[count])
|
||||||
if (selectedActionParameters[count].schema !== undefined && selectedActionParameters[count].schema !== null && selectedActionParameters[count].schema.type === "file") {
|
if (selectedActionParameters[count].schema !== undefined && selectedActionParameters[count].schema !== null && selectedActionParameters[count].schema.type === "file") {
|
||||||
const fileId = "6daabec1-892b-469c-b603-c902e47223a9"
|
datafield =
|
||||||
datafield = `SHOW FILES FROM OTHER NODES? Filename: ${selectedActionParameters[count].value}`
|
<TextField
|
||||||
|
style={{backgroundColor: inputColor, borderRadius: borderRadius,}}
|
||||||
|
InputProps={{
|
||||||
|
style:{
|
||||||
|
color: "white",
|
||||||
|
minHeight: "50px",
|
||||||
|
marginLeft: "5px",
|
||||||
|
maxWidth: "95%",
|
||||||
|
fontSize: "1em",
|
||||||
|
},
|
||||||
|
endAdornment: (
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<Tooltip title="Autocomplete text" placement="top">
|
||||||
|
<AddCircleOutlineIcon style={{cursor: "pointer"}} onClick={(event) => {
|
||||||
|
setMenuPosition({
|
||||||
|
top: event.pageY,
|
||||||
|
left: event.pageX,
|
||||||
|
})
|
||||||
|
setShowDropdownNumber(count)
|
||||||
|
setShowDropdown(true)
|
||||||
|
setShowAutocomplete(true)
|
||||||
|
}}/>
|
||||||
|
</Tooltip>
|
||||||
|
</InputAdornment>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
multiline={multiline}
|
||||||
|
rows="5"
|
||||||
|
color="primary"
|
||||||
|
defaultValue={data.value}
|
||||||
|
type={"text"}
|
||||||
|
placeholder={"The file ID to get"}
|
||||||
|
onChange={(event) => {
|
||||||
|
changeActionParameter(event, count)
|
||||||
|
}}
|
||||||
|
onBlur={(event) => {
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
//const fileId = "6daabec1-892b-469c-b603-c902e47223a9"
|
||||||
|
//datafield = `SHOW FILES FROM OTHER NODES? Filename: ${selectedActionParameters[count].value}`
|
||||||
|
/*
|
||||||
if (selectedActionParameters[count].value != fileId) {
|
if (selectedActionParameters[count].value != fileId) {
|
||||||
changeActionParameter(fileId, count)
|
changeActionParameter(fileId, count)
|
||||||
setUpdate(Math.random())
|
setUpdate(Math.random())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} else if (selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0) {
|
} else if (selectedActionParameters[count].options !== undefined && selectedActionParameters[count].options !== null && selectedActionParameters[count].options.length > 0) {
|
||||||
if (selectedActionParameters[count].value === "" && selectedActionParameters[count].required) {
|
if (selectedActionParameters[count].value === "" && selectedActionParameters[count].required) {
|
||||||
// Rofl, dirty workaround :)
|
// Rofl, dirty workaround :)
|
||||||
|
|||||||
Reference in New Issue
Block a user