How to use _set_path method in autotest

Best Python code snippet using autotest_python

system_classes.py

Source:system_classes.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Created on Fri Feb 12 18:56:07 20214@author: ilros5"""6import json7import copy8class GET_manager(object):9 def __init__(self, path):10 self.path=path11 12 def run(self):13 if self.path[0]=='sensors':14 _set_path="settings.json"15 with open(_set_path) as json_file:16 data=json.load(json_file)17 18 if self.path[1]=='house':19 #we need to send the basic setup for the sensors of the house20 resp = {21 "broker" : data["broker"],22 "port" : data["port"],23 "temperature" : data["meanAndVarSensorsHouse"]["temperature"],24 "humidity" : data["meanAndVarSensorsHouse"]["humidity"],25 "lumen" : data["meanAndVarSensorsHouse"]["lumen"]26 }27 28 return json.dumps(resp)29 30 31 elif self.path[1]=='house_list':32 resp = []33 34 if data["patientsList"]!=[]:35 for patient in data["patientsList"]:36 resp.append(patient["houseDevices"])37 38 return json.dumps(resp)39 #we need to get all the sensors from all the houses, publish on house-based topics40 41 elif self.path[1]=='bodydevices_list':42 resp = []43 44 if data["patientsList"]!=[]:45 for patient in data["patientsList"]:46 resp.append(patient["bodyDevices"])47 48 return json.dumps(resp)49 #we need to get all the sensors from all the houses, publish on house-based topics50 51 elif self.path[1]=='sim_values':52 53 resp = {}54 uniqueID = self.path[2]55 56 if data["patientsList"] != []:57 for patient in data["patientsList"]:58 if patient["uniqueID"] == uniqueID:59 resp = patient["bodySensorsSimulation"]60 61 return json.dumps(resp)62 63 64 elif self.path[1]=='patient':65 66 resp = {67 "broker" : data["broker"],68 "port" : data["port"],69 }70 71 return json.dumps(resp)72 73 elif self.path[0]=='thingspeak':74 _set_path="settings.json"75 with open(_set_path) as json_file:76 data=json.load(json_file)77 if self.path[1]=='settings':78 resp = {79 "broker" : data["broker"],80 "port" : data["port"],81 "url" : data["thinkspeakSettings"]["tsURL"],82 "key" : data["thinkspeakSettings"]["tsKEY"],83 "clearURL" : data["thinkspeakSettings"]["tsCLEARURL"],84 "field" : data["thinkspeakSettings"]["tsFields"]85 }86 return json.dumps(resp)87 if self.path[1]=='highlightedPatient':88 _set_path="settings.json"89 with open(_set_path) as json_file:90 data=json.load(json_file)91 92 resp = data["highlightedPatient"]93 94 return json.dumps(resp)95 elif self.path[1]=="highlighted":96 resp = ""97 uniqueID = self.path[2]98 99 if data["patientsList"] != []:100 for patient in data["patientsList"]:101 if patient["uniqueID"] == uniqueID:102 resp = patient["bodyDevices"][0]["topic"]103 104 return json.dumps(resp)105 elif self.path[0] == 'telegram':106 _set_path="settings.json"107 with open(_set_path) as json_file:108 data=json.load(json_file)109 110 111 112 if self.path[1]=='settings':113 resp={114 "TG_Token": data['TG_Token'],115 "broker" : data['broker'],116 "port" : data['port'],117 "topic_commands" : data['telegramTopics']['t_bot_topic'],118 "topic_alarms" : data['telegramTopics']['sim_bot_topic']119 }120 121 return json.dumps(resp)122 123 124 elif self.path[1] == 'get_pins':125 126 resp = {127 "Patient": [],128 "Doctor": [],129 "Caretaker": []130 }131 132 for patient in data["patientsList"]:133 resp["Patient"].append({"uniqueID":patient["uniqueID"], "pin":patient["pin"]})134 135 for doctor in data["doctorsList"]:136 resp["Doctor"].append({"uniqueID":doctor["uniqueID"], "pin":doctor["pin"]})137 138 for caretaker in data["caretakersList"]:139 resp["Caretaker"].append({"uniqueID":caretaker["uniqueID"], "pin":caretaker["pin"]})140 141 return json.dumps(resp)142 143 144 elif self.path[1]=="supported":145 resp = {146 "actuators" : {},147 "sensors" : {}148 }149 150 resp["actuators"] = data["supportedActuators"]151 resp["sensors"] = data["supportedSensors"]152 153 return json.dumps(resp)154 elif self.path[1]=="alarm_status":155 resp = []156 157 if data["patientsList"] != []:158 resp = data["patientsList"]159 160 return json.dumps(resp)161 162 elif self.path[1]=='getVals':163 164 uniqueID = self.path[2]165 166 resp = {167 "measUnit" : {},168 "sensValues": {}169 }170 171 resp["measUnit"] = data["correspondentUnits"]172 173 174 if data["patientsList"]!=[]:175 for patient in data["patientsList"]:176 if patient["uniqueID"] == uniqueID:177 if patient["bodyDevices"] != []:178 for sensor in patient["bodyDevices"]:179 resp["sensValues"].update({sensor["e"][0]["n"] : sensor["e"][0]["n"]})180 181 if patient["houseDevices"] != []:182 for sensor in patient["houseDevices"]:183 resp["sensValues"].update({sensor["e"][0]["n"] : sensor["e"][0]["n"]})184 185 if patient["actuatorsList"] != []:186 for actuator in patient["actuatorsList"]:187 resp["sensValues"].update({actuator["name"] : actuator["state"]})188 189 return json.dumps(resp)190 elif self.path[0] == 'controls':191 _set_path="settings.json"192 with open(_set_path) as json_file:193 data=json.load(json_file)194 195 if self.path[1] == 'settings':196 197 resp = {198 "broker" : data["broker"],199 "port" : data["port"]200 }201 202 return json.dumps(resp)203 204 elif self.path[1] == 'house_list':205 206 resp={207 "houses" : []208 }209 210 if data["patientsList"]!=[]:211 for patient in data["patientsList"]:212 resp["houses"].append({"houseDevices" : patient["houseDevices"], "actList" : patient["actuatorsList"]})213 214 215 return json.dumps(resp)216 217 else:218 return "Error 400 : The request cannot be fullfilled since the URL is wrong or it refers to something which does not exist"219 220class POST_manager():221 def __init__(self, path):222 self.path=path223 224 def run(self, data):225 if self.path[0]=='trained_modelsupdate':226 _set_path='data_comparison/trained_models.json'227 json.dump(data, open(_set_path,'w'), indent = 4)228 229 elif self.path[0] == 'regression_resultupdate':230 _set_path="settings.json"231 232 with open(_set_path) as json_in:233 sens_data=json.load(json_in)234 235 smt=dict(sens_data)236 smt["Regr_Values"]["Temp"] = data["Temp"]237 smt["Regr_Values"]["Weight"] = data["Weight"]238 smt["Regr_Values"]["HeartR"] = data["HeartR"]239 240 241 f = open(_set_path, 'w')242 json.dump(smt, f, indent = 4)243 f.close()244 245 246 247 elif self.path[0] == 'updateSens':248 _set_path="settings.json" 249 with open(_set_path) as json_in:250 all_data=json.load(json_in)251 252 if self.path[1] == 'body':253 254 uniqueID = self.path[2] 255 256 dev = data257 258 if all_data["patientsList"] != []:259 for patient in all_data["patientsList"]:260 if patient["uniqueID"] == uniqueID:261 if patient["bodyDevices"] != []:262 for sensor in patient["bodyDevices"]:263 if sensor["e"][0]["n"] == data["e"][0]["n"]:264 sensor["e"][0]["v"]=data["e"][0]["v"]265 266 f = open(_set_path, 'w')267 json.dump(all_data, f, indent = 4)268 f.close()269 270 271 elif self.path[1] == 'house':272 273 uniqueID = self.path[2] 274 275 dev = data276 277 if all_data["patientsList"] != []:278 for patient in all_data["patientsList"]:279 if patient["uniqueID"] == uniqueID:280 if patient["houseDevices"] != []:281 for sensor in patient["houseDevices"]:282 if sensor["e"][0]["n"] == data["e"][0]["n"]:283 sensor["e"][0]["v"]=data["e"][0]["v"]284 285 f = open(_set_path, 'w')286 json.dump(all_data, f, indent = 4)287 f.close()288 289 elif self.path[1] == 'actuator':290 291 uniqueID = self.path[2] 292 293 dev = data294 295 if all_data["patientsList"] != []:296 for patient in all_data["patientsList"]:297 if patient["uniqueID"] == uniqueID:298 if patient["actuatorsList"] != []:299 for actuator in patient["actuatorsList"]:300 if actuator["name"] == data["name"]:301 actuator["state"] = data["state"]302 303 f = open(_set_path, 'w')304 json.dump(all_data, f, indent = 4)305 f.close()306 307 308 elif self.path[0]=="telegram":309 _set_path="settings.json" 310 with open(_set_path) as json_in:311 all_data=json.load(json_in)312 if self.path[1]=="addPatient":313 found = False314 if all_data["patientsList"] != []:315 for patient in all_data["patientsList"]:316 if data["uniqueID"] == patient["uniqueID"]:317 found = True318 319 if not found:320 newPatient = copy.deepcopy(all_data["basePatient"])321 322 newPatient["name"] = data["name"]323 newPatient["age"] = data["age"]324 newPatient["weight"] = data["weight"]325 newPatient["uniqueID"] = data["uniqueID"]326 newPatient["disease"] = data["disease"]327 newPatient["bodySensorsSimulation"] = all_data["defaultSimValues"]328 if all_data["highlightedPatient"] == "":329 all_data["highlightedPatient"] = newPatient["uniqueID"]330 331 for sens in data["bodySensors"]:332 sens = sens.lower()333 newSensor = copy.deepcopy(all_data["baseSensor"])334 tresh = {335 sens+"Low" : data["thresholds"][sens+"Low"],336 sens+"High" : data["thresholds"][sens+"High"]337 }338 newSensor["simThresholds"] = tresh339 alarm = {340 sens+"Low" : data["alarms"][sens+"Low"],341 sens+"High" : data["alarms"][sens+"High"]342 }343 newSensor["alarmThresholds"] = alarm344 newSensor["topic"] = all_data["baseTopic"] + "/" + newPatient["uniqueID"] + "/body"345 newSensor["patientID"] = newPatient["uniqueID"]346 newSensor["bn"] = newPatient["uniqueID"] + "/body/" + sens347 newSensor["e"][0]["n"] = sens 348 newSensor["e"][0]["u"] = all_data["supportedSensors"][sens]349 350 newPatient["bodyDevices"].append(newSensor)351 newSensor = None352 353 354 for sens in data["houseSensors"]:355 sens = sens.lower()356 newSensor = copy.deepcopy(all_data["baseSensor"])357 358 newSensor["topic"] = all_data["baseTopic"] + "/" + newPatient["uniqueID"] + "/house"359 newSensor["patientID"] = newPatient["uniqueID"]360 newSensor["bn"] = newPatient["uniqueID"] + "/house/" + sens361 newSensor["e"][0]["n"] = sens 362 newSensor["e"][0]["u"] = all_data["supportedSensors"][sens]363 364 newPatient["houseDevices"].append(newSensor)365 newSensor = None366 367 for actuator in data["controlledActuators"]:368 actuator = actuator.lower()369 newActuator = copy.deepcopy(all_data["baseActuator"])370 371 newActuator["topic"] = all_data["baseTopic"] + "/" + newPatient["uniqueID"] + "/actuator"372 newActuator["patientID"] = newPatient["uniqueID"]373 newActuator["unit"] = all_data["supportedActuators"][actuator]374 newActuator["name"] = actuator375 newActuator["tresholds"].append(all_data["defaultActuatorValues"][actuator+"Low"]) 376 newActuator["tresholds"].append(all_data["defaultActuatorValues"][actuator+"High"])377 378 newPatient["actuatorsList"].append(newActuator)379 newActuator = None380 381 all_data["patientsList"].append(newPatient)382 383 f = open(_set_path, 'w')384 json.dump(all_data, f, indent = 4)385 f.close()386 387 elif self.path[1]=="addDoctor":388 389 newDoctor = all_data["baseDoctor"].copy()390 found = False391 392 if all_data["doctorsList"] != []:393 for doctor in all_data["doctorsList"]:394 if doctor["uniqueID"] == data["uniqueID"]:395 found = True396 397 if not found:398 newDoctor["age"] = data["age"]399 newDoctor["name"] = data["name"]400 newDoctor["patientsAssigned"] = data["patientsAssigned"]401 newDoctor["uniqueID"] = data["uniqueID"]402 403 all_data["doctorsList"].append(newDoctor)404 f = open(_set_path, 'w')405 json.dump(all_data, f, indent = 4)406 f.close()407 408 elif self.path[1]=="addCaretaker":409 410 newCaretaker = all_data["baseCaretaker"].copy()411 found = False412 413 if all_data["caretakersList"] != []:414 for caretaker in all_data["caretakersList"]:415 if caretaker["uniqueID"] == data["uniqueID"]:416 found = True417 418 if not found:419 420 newCaretaker["age"] = data["age"]421 newCaretaker["name"] = data["name"]422 newCaretaker["patientAssigned"] = data["patientAssigned"]423 newCaretaker["uniqueID"] = data["uniqueID"]424 425 all_data["caretakersList"].append(newCaretaker)426 427 f = open(_set_path, 'w')428 json.dump(all_data, f, indent = 4)429 f.close()430 431 432 433 434class PUT_manager():435 def __init__(self, path):436 self.path=path437 438 def run(self, data):439 _set_path = "settings.json"440 with open(_set_path) as json_in:441 all_data=json.load(json_in)442 443 if self.path[0] == "telegram":444 if self.path[1] == "updateAddress":445 if all_data["patientsList"] != []:446 for patient in all_data["patientsList"]:447 if patient["uniqueID"] == data["uniqueID"]:448 patient["address"] = data["address"]449 450 f = open(_set_path, 'w')451 json.dump(all_data, f, indent = 4)452 f.close()453 454 elif self.path[1] == "updateActuator":455 if all_data["patientsList"] != []:456 for patient in all_data["patientsList"]:457 if patient["uniqueID"] == data["uniqueID"]:458 actList = patient["actuatorsList"]459 for actuator in actList:460 if actuator["name"] == data["actName"]:461 actuator["tresholds"][0]=data["actLow"]462 actuator["tresholds"][1]=data["actHigh"]463 464 f = open(_set_path, 'w')465 json.dump(all_data, f, indent = 4)466 f.close()467 elif self.path[1] == "updateAlarms":468 if all_data["patientsList"] != []:469 for patient in all_data["patientsList"]:470 if patient["uniqueID"] == data["uniqueID"]:471 sensorList = patient["bodyDevices"]472 for alarm in sensorList:473 if alarm["e"][0]["n"] == data["sensorName"]:474 alarm["alarmThresholds"][alarm["e"][0]["n"]+"Low"]=data["alarmLow"]475 alarm["alarmThresholds"][alarm["e"][0]["n"]+"High"]=data["alarmHigh"]476 477 f = open(_set_path, 'w')478 json.dump(all_data, f, indent = 4)479 f.close()480 elif self.path[1] == "updateSimulation":481 if all_data["patientsList"] != []:482 for patient in all_data["patientsList"]:483 if patient["uniqueID"] == data["uniqueID"]:484 simsList = patient["bodySensorsSimulation"]485 for simulation in simsList:486 if simulation["sensorName"] == data["sensorName"]:487 simulation["typeSim"] = data["typeSim"]488 simulation["statusSim"] = data["statusSim"]489 490 f = open(_set_path, 'w')491 json.dump(all_data, f, indent = 4)492 f.close() 493 elif self.path[1] == "registerPatient":494 if all_data["patientsList"] != []:495 for patient in all_data["patientsList"]:496 if patient["uniqueID"] == data["userName"]:497 patient["pin"] = data["pin"]498 499 500 f = open(_set_path, 'w')501 json.dump(all_data, f, indent = 4)502 f.close()503 504 elif self.path[1] == "registerDoctor":505 if all_data["doctorsList"] != []:506 for doctor in all_data["doctorsList"]:507 if doctor["uniqueID"] == data["userName"]:508 doctor["pin"] = data["pin"]509 510 f = open(_set_path, 'w')511 json.dump(all_data, f, indent = 4)512 f.close()513 514 elif self.path[1] == "registerCaretaker":515 if all_data["caretakersList"] != []:516 for caretaker in all_data["caretakersList"]:517 if caretaker["uniqueID"] == data["userName"]:518 caretaker["pin"] = data["pin"]519 520 f = open(_set_path, 'w')521 json.dump(all_data, f, indent = 4)522 f.close()523 524 525 elif self.path[1] == "addSensor":526 uniqueID = data["uniqueID"]527 zone = data["zone"]528 sens_name = data["sensName"]529 530 531 sens = sens_name.lower()532 newSensor = copy.deepcopy(all_data["baseSensor"])533 534 newSensor["topic"] = all_data["baseTopic"] + "/" + uniqueID + "/house/"535 newSensor["patientID"] = uniqueID536 newSensor["bn"] = uniqueID + "/house/" + sens537 newSensor["e"][0]["n"] = sens 538 newSensor["e"][0]["u"] = all_data["supportedSensors"][sens]539 540 if all_data["patientsList"] != []:541 for patient in all_data["patientsList"]:542 if patient["uniqueID"] == uniqueID:543 patient[zone+"Devices"].append(newSensor)544 545 546 f = open(_set_path, 'w')547 json.dump(all_data, f, indent = 4)548 f.close()549 550 elif self.path[1] == "assignPatient":551 docID = data["docID"]552 patID = data["patID"]553 554 if all_data["doctorsList"]!=[]:555 for doctor in all_data["doctorsList"]:556 if doctor["uniqueID"] == docID:557 doctor["patientsAssigned"].append(patID)558 559 560 f = open(_set_path, 'w')561 json.dump(all_data, f, indent = 4)562 f.close()563 564 elif self.path[1] == "assignPatientCaretaker":565 careID = data["careID"]566 patID = data["patID"]567 568 if all_data["caretakersList"]!=[]:569 for caretaker in all_data["caretakersList"]:570 if caretaker["uniqueID"] == careID:571 caretaker["patientAssigned"] = patID572 573 574 f = open(_set_path, 'w')575 json.dump(all_data, f, indent = 4)576 f.close()577 578 elif self.path[1] == "updateHighlighted":579 upID = data["uniqueID"]580 581 all_data["highlightedPatient"] = upID582 583 f = open(_set_path, 'w')584 json.dump(all_data, f, indent = 4)585 f.close()586 587 elif self.path[0] == "sensors":588 if self.path[1] == "updateTimeVisited":589 590 uniqueID = self.path[2]591 sens_name = self.path[3]592 593 if all_data["patientsList"] != []:594 for patient in all_data["patientsList"]:595 if patient["bodyDevices"] != []:596 for device in patient["bodyDevices"]:597 if uniqueID == device["patientID"]:598 if device["e"][0]["n"] == sens_name:599 device["timesVisited"] = data["timesVisited"]600 601 f = open(_set_path, 'w')602 json.dump(all_data, f, indent = 4)603 f.close()604 605 elif self.path[1] == "alarm_patient":606 607 uniqueID = self.path[2]608 sens_name = self.path[3]609 610 if all_data["patientsList"] != []:611 for patient in all_data["patientsList"]:612 if patient["uniqueID"] == uniqueID:613 for key in data:614 if data[key]!="":615 patient["alarms_patient"] = key616 617 f = open(_set_path, 'w')618 json.dump(all_data, f, indent = 4)619 f.close()620 621 622class DELETE_manager():623 def __init__(self, path):624 self.path=path625 626 def run(self):627 _set_path = 'settings.json'628 with open(_set_path) as json_in:629 all_data=json.load(json_in)630 631 if self.path[0]=="telegram":632 if self.path[1]=="deletePatient":633 uniqueID = self.path[2]634 if all_data["patientsList"] != []:635 i = 0636 for patient in all_data["patientsList"]:637 if patient["uniqueID"] == uniqueID:638 all_data["patientsList"].pop(i)639 if patient["uniqueID"] == all_data["highlightedPatient"]:640 all_data["highlightedPatient"] = ""641 642 i+=1643 644 if all_data["doctorsList"] != []:645 i = 0646 for doctor in all_data["doctorsList"]:647 for patient_assigned in doctor["patientsAssigned"]:648 if patient_assigned["uniqueID"] == uniqueID:649 all_data["doctorsList"]["patientsAssigned"].pop(i)650 651 i+=1652 653 654 if all_data["caretakersList"] != []:655 i = 0656 for caretaker in all_data["caretakersList"]:657 if caretaker["patientAssigned"] == uniqueID:658 all_data["caretakersList"]["patientAssigned"] = ""659 660 i+=1661 662 f = open(_set_path, 'w')663 json.dump(all_data, f, indent = 4)664 f.close()665 666 667 elif self.path[1]=="deleteDoctor":668 uniqueID = self.path[2]669 if all_data["doctorsList"] != []:670 i = 0671 for doctor in all_data["doctorsList"]:672 if doctor["uniqueID"] == uniqueID:673 all_data["doctorsList"].pop(i)674 675 i+=1676 677 f = open(_set_path, 'w')678 json.dump(all_data, f, indent = 4)679 f.close()680 681 elif self.path[1]=="deleteCaretaker":682 uniqueID = self.path[2]683 if all_data["caretakersList"] != []:684 i = 0685 for caretaker in all_data["caretakersList"]:686 if caretaker["uniqueID"] == uniqueID:687 all_data["caretakersList"].pop(i)688 689 i+=1690 691 f = open(_set_path, 'w')692 json.dump(all_data, f, indent = 4)693 f.close()694 695 elif self.path[1] == "deleteSensor":696 uniqueID=self.path[2]697 zone = self.path[3]698 sens_name = self.path[4]699 700 if all_data["patientsList"] != []:701 for patient in all_data["patientsList"]:702 if patient["uniqueID"] == uniqueID:703 if patient[zone+"Devices"] != []:704 for sensor in patient[zone+"Devices"]:705 if sensor["e"][0]["n"]==sens_name:706 patient[zone+"Devices"].pop(patient[zone+"Devices"].index(sensor))707 708 f = open(_set_path, 'w')709 json.dump(all_data, f, indent = 4)...

Full Screen

Full Screen

namespace_model.py

Source:namespace_model.py Github

copy

Full Screen

...53 self.config_file = open(config_path)54 self.config = load(self.config_file, Loader=FullLoader)55 os.environ['CUDA_VISIBLE_DEVICES'] = str(self.config[_experiment].get(_gpu,-1))56 @staticmethod57 def _set_path(config_path, local_path):58 if os.path.isabs(local_path):59 return local_path60 else:61 if local_path.startswith(("./", "../")) or regexp.search(local_path):62 return f"{config_path}/{local_path}"63 else:64 return local_path65 def fill_base(self):66 # for path in self.config[_experiment][_data_paths].keys():67 # self.config[_experiment][_data_paths][path] = \68 # self.config[_experiment][_data_paths][path].format(self.config[_experiment][_dataset])69 self.config[_experiment][_recs] = self.config[_experiment]\70 .get(_recs, self._set_path(self._base_folder_path_config, "../results/{0}/recs/"))\71 .format(self.config[_experiment][_dataset])72 self.config[_experiment][_weights] = self.config[_experiment]\73 .get(_weights, self._set_path(self._base_folder_path_config, "../results/{0}/weights/")) \74 .format(self.config[_experiment][_dataset])75 self.config[_experiment][_performance] = self.config[_experiment]\76 .get(_performance, self._set_path(self._base_folder_path_config, "../results/{0}/performance/")) \77 .format(self.config[_experiment][_dataset])78 self.config[_experiment][_dataloader] = self.config[_experiment].get(_dataloader, "DataSetLoader")79 manage_directories(self.config[_experiment][_recs], self.config[_experiment][_weights],80 self.config[_experiment][_performance])81 for p in [_data_config, _weights, _recs, _dataset, _top_k, _performance, _logger_config,82 _log_folder, _dataloader, _splitting, _prefiltering, _evaluation, _external_models_path,83 _print_triplets, _config_test]:84 if p == _data_config:85 side_information = self.config[_experiment][p].get("side_information", {})86 side_information.update({k: self._set_path(self._base_folder_path_config,87 v.format(self.config[_experiment][_dataset]))88 for k, v in side_information.items() if isinstance(v, str)})89 side_information = SimpleNamespace(**side_information)90 self.config[_experiment][p].update({k: self._set_path(self._base_folder_path_config,91 v.format(self.config[_experiment][_dataset]))92 for k, v in self.config[_experiment][p].items() if93 isinstance(v, str)})94 self.config[_experiment][p]["side_information"] = side_information95 self.config[_experiment][p][_dataloader] = self.config[_experiment][p].get(_dataloader, "DataSetLoader")96 setattr(self.base_namespace, p, SimpleNamespace(**self.config[_experiment][p]))97 elif p == _splitting and self.config[_experiment].get(p, {}):98 self.config[_experiment][p].update({k: self._set_path(self._base_folder_path_config,99 v.format(self.config[_experiment][_dataset]))100 for k, v in self.config[_experiment][p].items() if101 isinstance(v, str)})102 test_splitting = self.config[_experiment][p].get("test_splitting", {})103 validation_splitting = self.config[_experiment][p].get("validation_splitting", {})104 if test_splitting:105 test_splitting = SimpleNamespace(**test_splitting)106 self.config[_experiment][p]["test_splitting"] = test_splitting107 if validation_splitting:108 validation_splitting = SimpleNamespace(**validation_splitting)109 self.config[_experiment][p]["validation_splitting"] = validation_splitting110 setattr(self.base_namespace, p, SimpleNamespace(**self.config[_experiment][p]))111 elif p == _prefiltering and self.config[_experiment].get(p, {}):112 preprocessing_strategy = SimpleNamespace(**self.config[_experiment][p])113 self.config[_experiment][p] = preprocessing_strategy114 setattr(self.base_namespace, p, self.config[_experiment][p])115 elif p == _evaluation and self.config[_experiment].get(p, {}):116 complex_metrics = self.config[_experiment][p].get("complex_metrics", {})117 paired_ttest = self.config[_experiment][p].get("paired_ttest", {})118 wilcoxon_test = self.config[_experiment][p].get("wilcoxon_test", {})119 for complex_metric in complex_metrics:120 complex_metric.update({k: self._set_path(self._base_folder_path_config,121 v.format(self.config[_experiment][_dataset]))122 for k, v in complex_metric.items() if isinstance(v, str)})123 self.config[_experiment][p]["complex_metrics"] = complex_metrics124 self.config[_experiment][p]["paired_ttest"] = paired_ttest125 self.config[_experiment][p]["wilcoxon_test"] = wilcoxon_test126 setattr(self.base_namespace, p, SimpleNamespace(**self.config[_experiment][p]))127 elif p == _logger_config and not self.config[_experiment].get(p, False):128 setattr(self.base_namespace, p, f"{self._base_folder_path_elliot}/config/logger_config.yml")129 elif p == _log_folder and not self.config[_experiment].get(p, False):130 setattr(self.base_namespace, p, f"{self._base_folder_path_elliot}/../log/")131 elif p == _external_models_path and self.config[_experiment].get(p, False):132 self.config[_experiment][p] = self._set_path(self._base_folder_path_config, self.config[_experiment][p])133 setattr(self.base_namespace, p, self.config[_experiment][p])134 elif p == _config_test:135 setattr(self.base_namespace, p, self.config[_experiment].get(p, False))136 else:137 if self.config[_experiment].get(p):138 setattr(self.base_namespace, p, self.config[_experiment][p])139 def fill_model(self):140 for key in self.config[_experiment][_models]:141 meta_model = self.config[_experiment][_models][key][_meta]142 model_name_space = SimpleNamespace(**self.config[_experiment][_models][key])143 setattr(model_name_space, _meta, SimpleNamespace(**meta_model))144 if any(isinstance(value, list) for value in self.config[_experiment][_models][key].values()):145 space_list = []146 for k, value in self.config[_experiment][_models][key].items():...

Full Screen

Full Screen

configuration.py

Source:configuration.py Github

copy

Full Screen

2class Conf(object):3 def __init__(self, args):4 self.args = args5 self.dataset = args.dataset6 def _set_path(self, dataset_type):7 if self.dataset == 'TIHM':8 return './{}/tihm15'.format(dataset_type)9 elif self.dataset == 'DRI':10 return './{}/tihmdri'.format(dataset_type)11 @property12 def raw_data(self):13 return self._set_path('raw_data')14 @property15 def csv_data(self):16 return self._set_path('csv_data')17 @property18 def npy_data(self):19 return self._set_path('npy_data')20 @property21 def data_path(self):22 data_path = {23 'env': self._set_path('csv_data') + '/env/data/',24 'flag': self._set_path('csv_data') + '/env/flag/',25 'clinical': self._set_path('csv_data') + '/clinical/data/',26 }27 return data_path28 def reading_settings(self, validation):29 validation = parser_bool(validation)30 return {31 'label': True if validation else False,32 'extend_label_range': 1 if validation else 1,33 'valid': True if validation else False,34 'uti_pre_post_range': 3 if validation else 3, # 10 days: 15,35 'extra_uti_range': 1 if validation else 1, # 10 days: 5,36 }37# Validated UTI, may not in the flags files38def validated_date():39 patient_data = {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful