Skip to content

Commit

Permalink
Fixed mapping inputs from Granta
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislavsulc committed Dec 2, 2023
1 parent 92edf6d commit 1693d73
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions mupifDB/restApiControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def getWorkflowRecordGeneral(wid, version):
for gmd in gmds:
if gmd['name'] == 'muPIF metadata':
md = json.loads(fix_json(gmd['value']))
print(md)
# print(md)
workflow['metadata'] = md
workflow['classname'] = md['ClassName']
workflow['modulename'] = md['ModuleName']
Expand Down Expand Up @@ -289,10 +289,12 @@ def ObjIDIsIterable(val):
w_inputs = _getGrantaWorkflowMetadataFromDatabase(execution_record['WorkflowID']).get('Inputs', [])
units = ''
data_id = 'Unknown'
valueType = 'Unknown'
for w_i in w_inputs:
if w_i['Name'] == name:
units = w_i['Units']
data_id = w_i['Type_ID']
units = w_i.get('Units', 'Unknown')
data_id = w_i.get('Type_ID', 'Unknown')
valueType = w_i.get('ValueType', 'Scalar')
return {
'Compulsory': True,
'Description': '',
Expand All @@ -301,11 +303,11 @@ def ObjIDIsIterable(val):
'Type': 'mupif.Property',
'TypeID': data_id,
'Units': units, # todo
'ValueType': 'Scalar',
'ValueType': valueType,
'Link': {},
'Object': {
'ClassName': 'ConstantProperty',
'ValueType': 'Scalar',
'ValueType': valueType,
'DataID': data_id.replace('mupif.DataID.', ''),
'Unit': units, # todo
'Value': inp['value'],
Expand All @@ -318,34 +320,43 @@ def ObjIDIsIterable(val):
execution_record = getExecutionRecord(eid)
w_inputs = _getGrantaWorkflowMetadataFromDatabase(execution_record['WorkflowID']).get('Inputs', [])
units = ''
data_id = 'Unknown'
valueType = 'Unknown'
for w_i in w_inputs:
if w_i['Name'] == name:
units = w_i['Units']
units = w_i.get('Units', 'Unknown')
data_id = w_i.get('Type_ID', 'Unknown')
valueType = w_i.get('ValueType', 'Scalar')
return {
'Compulsory': True,
'Description': '',
'Name': inp['name'],
'ObjID': inp['name'],
'Type': 'mupif.String',
'TypeID': w_i['Type_ID'],
'TypeID': data_id,
'Units': units, # todo
'ValueType': 'Scalar',
'ValueType': valueType,
'Link': {},
'Object': {
'ClassName': 'String',
'DataID': w_i['Type_ID'].replace('mupif.DataID.', ''),
'Value': inp['value']
'DataID': data_id.replace('mupif.DataID.', ''),
'Value': inp['value'],
'ValueType': valueType
}
}

if inp['type'] == 'hyperlink':
execution_record = getExecutionRecord(eid)
w_inputs = _getGrantaWorkflowMetadataFromDatabase(execution_record['WorkflowID']).get('Inputs', [])
units = ''
data_id = 'Unknown'
valueType = 'Unknown'
obj_type = ''
for w_i in w_inputs:
if w_i['Name'] == name:
units = w_i['Units']
units = w_i.get('Units', 'Unknown')
data_id = w_i.get('Type_ID', 'Unknown')
valueType = w_i.get('ValueType', 'Scalar')
obj_type = w_i['Type']

if obj_type == 'mupif.HeavyStruct':
Expand All @@ -355,9 +366,9 @@ def ObjIDIsIterable(val):
'Name': inp['name'],
'ObjID': inp['name'],
'Type': 'mupif.HeavyStruct',
'TypeID': w_i['Type_ID'],
'TypeID': data_id,
'Units': '',
'ValueType': 'Scalar',
'ValueType': valueType,
'Link': {},
'Object': {
'FileID': inp['value']['url'].split('/')[-1]
Expand All @@ -371,9 +382,9 @@ def ObjIDIsIterable(val):
'Name': inp['name'],
'ObjID': inp['name'],
'Type': 'mupif.PyroFile',
'TypeID': w_i['Type_ID'],
'TypeID': data_id,
'Units': '',
'ValueType': 'Scalar',
'ValueType': valueType,
'Link': {},
'Object': {
'FileID': inp['value'].split('/')[-1]
Expand All @@ -387,9 +398,9 @@ def ObjIDIsIterable(val):
'Name': inp['name'],
'ObjID': inp['name'],
'Type': 'mupif.Field',
'TypeID': w_i['Type_ID'],
'TypeID': data_id,
'Units': '',
'ValueType': 'Scalar',
'ValueType': valueType,
'Link': {},
'Object': {
'FileID': inp['value'].split('/')[-1]
Expand Down

0 comments on commit 1693d73

Please sign in to comment.