Skip to content

Commit

Permalink
fix usecase model, fix db init, update makefile, others
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxos committed Oct 8, 2024
1 parent a0b98ae commit f23865c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 32 deletions.
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
MAKEFLAGS+=-j3
TASKS=rest web browse
MAKEFLAGS+=-j6
TASKS=ns mongo rest web browse scheduler

.PHONY: $(TASKS)
run: $(TASKS)


ns:
python3 -m Pyro5.nameserver --port 11001
mongo:
mkdir -p mongodb-tmp~ && /usr/bin/mongod --port 11002 --noauth --dbpath=./mongodb-tmp~ --logpath=/dev/stdout --logappend
rest:
cd mupifDB && FLASK_APP=mupifdbRestApi.py PYTHONPATH=.. python3 -m flask run --host 127.0.0.1 --port 5000
# MUPIFDB_DRY_RUN=1
sleep 2 && cd mupifDB/api && MUPIFDB_MONGODB_PORT=11002 MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIFDB_LOG_LEVEL=DEBUG MUPIFDB_RESTAPI_HOST=localhost MUPIFDB_RESTAPI_PORT=11003 python3 main.py
web:
cd webapi && MUPIFDB_REST_SERVER=http://127.0.0.1:5000 FLASK_APP=index.py PYTHONPATH=.. python3 -m flask run --host 127.0.0.1 --port 5555
sleep 7 && cd webapi && MUPIFDB_MONGODB_PORT=11002 MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIFDB_WEB_FAKE_AUTH=1 FLASK_APP=index.py PYTHONPATH=.. python3 -m flask run --host 127.0.0.1 --port 11004
browse:
sleep 2 && xdg-open http://127.0.0.1:5555
sleep 9 && xdg-open http://127.0.0.1:11004
scheduler:
sleep 7 && MUPIF_LOG_LEVEL=DEBUG MUPIFDB_REST_SERVER=http://127.0.0.1:11003 MUPIF_NS=localhost:11001 PYTHONPATH=.. python3 -c 'from mupifDB import workflowscheduler as ws; ws.LOOP_SLEEP_SEC=5; ws.schedulerStatFile="./sched-stat.json"; ws.main()'
1 change: 1 addition & 0 deletions mupifDB/api/client_mupif.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def createExecution(wid: str, version: int, ip: str, no_onto=False):

return response.json()

@pydantic.validate_call
def insertExecution(m: models.WorkflowExecution_Model):
response = rPost("executions/", data=m.model_dump_json())
return response.json()
Expand Down
2 changes: 1 addition & 1 deletion mupifDB/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def db_init():
if 'Settings' in db.list_collection_names(): return False
for coll,rec in [
('Settings',{'projectName':'TEST','projectLogo':'https://raw.githubusercontent.com/mupif/mupifDB/bd297a4a719336cd9672cfe73f31f7cbe2b4e029/webapi/static/images/mupif-logo.png'}),
('UseCases',{'projectName':'TEST','projectLogo':'https://raw.githubusercontent.com/mupif/mupifDB/bd297a4a719336cd9672cfe73f31f7cbe2b4e029/webapi/static/images/mupif-logo.png'}),
('UseCases',models.UseCase_Model(projectName='TEST',projectLogo='https://raw.githubusercontent.com/mupif/mupifDB/bd297a4a719336cd9672cfe73f31f7cbe2b4e029/webapi/static/images/mupif-logo.png',ucid='1',Description='Test usecase').model_dump()),
('Stat',{"scheduler": {"load": 0, "processedTasks": 0, "runningTasks": 0, "scheduledTasks": 0}}),
('Workflows',None),
('WorkflowsHistory',None),
Expand Down
6 changes: 4 additions & 2 deletions mupifDB/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class MongoObj_Model(pydantic.BaseModel):

class UseCase_Model(MongoObj_Model):
ucid: str
Description: str
projectName: str=''
projectLogo: str=''
Description: str=''


class EDMMappingIDs_Model(pydantic.BaseModel):
Expand All @@ -46,7 +48,7 @@ class InputOutputBase_Model(pydantic.BaseModel):
Name: str
Description: Optional[str]=None
Type: str
Type_ID: str = Field(...,alias=AliasChoices('Type_ID','TypeID')) # type: ignore[arg-type]
Type_ID: str = Field(...,alias=AliasChoices('Type_ID','TypeID')) # type: ignore[arg-type]
ValueType: Literal['Vector','Scalar','Tensor','VectorArray']='Scalar'
Units: str
ObjID: str|List[str] = Field([],alias=AliasChoices('ObjID','Obj_ID')) # type: ignore[arg-type]
Expand Down
2 changes: 1 addition & 1 deletion mupifDB/workflowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def mapInput(app, eid, name, obj_id, app_obj_id, object_type, data_id, linked_ou
f = open(full_path, 'wb')
f.write(pfile)
f.close()
field = mupif.Field.makeFromHdf5(full_path)[0]
field = mupif.Field.makeFromHdf5(fileName=full_path)[0]
app.set(field, app_obj_id)
else:
raise ValueError('Handling of io param of type %s is not implemented' % object_type)
Expand Down
37 changes: 15 additions & 22 deletions webapi/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,11 @@ def setExecutionInputs(weid):
msg = ""
c = 0
for i in execution_inputs:
if i.get(' EDMPath', None) is None:
name = i['Name']
objID = i['ObjID']
if i.EDMPath is None:
name = i.Name
objID = i.ObjID
value = request.form.get('Value_%d' % c, '')
units = i['Units']
units = i.Units

# set Link to output data
c_eid = request.form.get('c_eid_%d' % c, '')
Expand All @@ -775,20 +775,20 @@ def setExecutionInputs(weid):
restApiControl.setExecutionInputObject(weid, name, objID, {})
else:
restApiControl.setExecutionInputLink(weid, name, objID, '', '', '')
if i['Type'] == 'mupif.Property':
if i.Type == 'mupif.Property':
msg += 'Setting %s (ObjID %s) to %s [%s]</br>' % (name, objID, value, units)

object_dict = {
'ClassName': 'ConstantProperty',
'ValueType': i['ValueType'],
'ValueType': i.ValueType,
'DataID': i.TypeID.replace('mupif.DataID.', ''),
'Unit': i.Units,
'Value': literal_eval(value),
'Time': None
}
restApiControl.setExecutionInputObject(weid, name, objID, object_dict)

elif i['Type'] == 'mupif.String':
elif i.Type == 'mupif.String':
msg += 'Setting %s (ObjID %s) to %s</br>' % (name, objID, value)
valuetype = i.ValueType
strval = str(value)
Expand Down Expand Up @@ -876,7 +876,7 @@ def setExecutionInputs(weid):
for i in execution_inputs:
if i.EDMPath:
any_edm_path = True
if i.Link.ExecId or i.Link.Name or i.Link.ObjID:
if i.Link.ExecID or i.Link.Name or i.Link.ObjID:
any_execution_link = True

show_execution_links = any_execution_link or args.get('show_execution_links', False)
Expand Down Expand Up @@ -932,11 +932,7 @@ def setExecutionInputs(weid):
object_path = splitted[1]

# find base object info
info = {}
for ii in onto_base_objects:
if ii.Name == base_object_name:
info = ii

info = [i for i in onto_base_objects if i.Name == base_object_name][0]
# get the desired object
onto_data = restApiControl.getEDMData(info.DBName, info.EDMEntity, info.id, object_path)
if onto_data is not None and type(onto_data) is dict:
Expand All @@ -947,8 +943,8 @@ def setExecutionInputs(weid):
# form += str(value) + ' ' + str(unit)

else:
if i['Object'].get('Value', None) is not None:
form += str(i['Object']['Value'])
if i.Object.get('Value', None) is not None:
form += str(i.Object['Value'])
form += "</td>"

elif input_type == "mupif.String":
Expand Down Expand Up @@ -977,19 +973,16 @@ def setExecutionInputs(weid):
object_path = splitted[1]

# find base object info
info = {}
for ii in onto_base_objects:
if ii.Name == base_object_name:
info = ii
info = [i for i in onto_base_objects if i.Name == base_object_name][0]

# get the desired object
onto_data = restApiControl.getEDMData(info.DBName, info.EDMEntity, info.id, object_path)
if onto_data is not None and type(onto_data) is dict:
value = onto_data.value
value = onto_data['value']
if value is not None:
form += str(value)
else:
val = i.Object.Value
val = i.Object['Value']
if val is not None:
if i.ValueType == 'Vector':
form += str(list(val))
Expand All @@ -999,7 +992,7 @@ def setExecutionInputs(weid):
form += "</td>"

else:
form += '<td>' + str(i.Object.Value) + '</td>'
form += '<td>' + str(i.Object['Value']) + '</td>'

form += '<td>' + str(i.Units) + '</td>'
form += '<td>' + str(i.Name) + '</td>'
Expand Down

0 comments on commit f23865c

Please sign in to comment.