def updatePassword(oldPassword, newPassword): parameter = '' data = { "OldPassword": oldPassword, "NewPassword": newPassword, "ConfirmPassword": newPassword } postInAPI(token, '/api/Account/ChangePassword', parameter, data) return 0
def runExecution(idStudy, idServer, idQueue, spotInstanceType, executionMode, infeasibilityHandling, maxRestarts): parameter = '' if idServer == 0: if spotInstanceType == '': prospecStudy = getInfoFromStudy(idStudy) listOfDecks = prospecStudy['Decks'] containsNEWAVE = False for deck in listOfDecks: if deck['Model'] == 'NEWAVE': containsNEWAVE = True break if containsNEWAVE: data = { "SpotInstanceType": 'c5.9xlarge', "ExecutionMode": executionMode, "InfeasibilityHandling": infeasibilityHandling, "MaxTreatmentRestarts": maxRestarts } else: data = { "SpotInstanceType": 'm5.4xlarge', "ExecutionMode": executionMode, "InfeasibilityHandling": infeasibilityHandling, "MaxTreatmentRestarts": maxRestarts } else: data = { "SpotInstanceType": spotInstanceType, "ExecutionMode": executionMode, "InfeasibilityHandling": infeasibilityHandling, "MaxTreatmentRestarts": maxRestarts } elif idQueue == 0: data = { "ServerId": int(idServer), "ExecutionMode": executionMode, "InfeasibilityHandling": infeasibilityHandling, "MaxTreatmentRestarts": maxRestarts } else: data = { "ServerId": int(idServer), "QueueId": int(idQueue), "ExecutionMode": executionMode, "InfeasibilityHandling": infeasibilityHandling, "MaxTreatmentRestarts": maxRestarts } print( "A seguinte configuracao sera usada para iniciar a execucao o estudo: ", str(idStudy)) print(data) response = postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Run', parameter, data)
def abortExecution(idStudy): parameter = '' data = '' response = postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Stop', parameter, data) print(response)
def completeStudyDecks(idStudy, fileName, tags): listOfTags = [] for tag in tags: tagsConfiguration = {} tagsConfiguration['Text'] = tag listOfTags.append(tagsConfiguration) parameter = '' data = {"Tags": listOfTags, "FileName": fileName} print("Usando a seguinte configuracao para o estudo: ", str(idStudy)) print(data) postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Complete', parameter, data)
def generateStudyDecks(idStudy, initialYear, initialMonth, duration, month, year, multipleStages, multipleRevision, firstNewaveFile, otherNewaveFiles, decompFile, spreadsheetFile, tags): listOfDeckConfiguration = [] listOfTags = [] i = 0 for deck in month: deckConfiguration = {} deckConfiguration['Year'] = year[i] deckConfiguration['Month'] = month[i] deckConfiguration['MultipleStages'] = multipleStages[i] deckConfiguration['MultipleRevisions'] = multipleRevision[i] if (i > 0): if (otherNewaveFiles[i] != ''): deckConfiguration['NewaveUploaded'] = otherNewaveFiles[i] listOfDeckConfiguration.append(deckConfiguration) i = i + 1 for tag in tags: tagsConfiguration = {} tagsConfiguration['Text'] = tag listOfTags.append(tagsConfiguration) parameter = '' data = { "InitialYear": initialYear, "InitialMonth": initialMonth, "Duration": duration, "DeckCreationConfigurations": listOfDeckConfiguration, "Tags": listOfTags, "InitialFiles": { "NewaveFileName": firstNewaveFile, "DecompFileName": decompFile, "SpreadsheetFileName": spreadsheetFile } } print("Gerando decks com as seguintes configuracoes para o estudo: ", str(idStudy)) print(data) postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Generate', parameter, data)
def cutAssociation(idStudy, destinationIds, sourceStudyId): listOfAssociation = [] for deck in destinationIds: associationConfiguration = {} associationConfiguration['DestinationDeckId'] = deck associationConfiguration['SourceStudyId'] = sourceStudyId listOfAssociation.append(associationConfiguration) parameter = '' data = { "cortesAssociation": listOfAssociation, } print("Usando a seguinte configuracao do estudo: ", str(idStudy)) print(data) postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Associate', parameter, data)
def volumeAssociation(idStudy, destinationIds, previsouStage, sourceStudyId): listOfAssociation = [] i = 0 for deck in destinationIds: associationConfiguration = {} associationConfiguration['DestinationDeckId'] = deck associationConfiguration['SourceStudyId'] = sourceStudyId if (len(previsouStage) > i): associationConfiguration['PreviousStage'] = previsouStage[i] listOfAssociation.append(associationConfiguration) i = i + 1 parameter = '' data = { "volumeAssociation": listOfAssociation, } print("Usando a seguinte configuracao do estudo: ", str(idStudy)) print(data) postInAPI(token, '/api/prospectiveStudies/' + str(idStudy) + '/Associate', parameter, data)
def createStudy(title, description, idDecomp, idNewave): parameter = '' data = { "Title": title, "Description": description, "DecompVersionId": int(idDecomp), "NewaveVersionId": int(idNewave) } print("Creating study with the following configuration:") print(data) prospecStudyId = postInAPI(token, '/api/prospectiveStudies', parameter, data) return prospecStudyId
def duplicateStudy(idStudy, title, description, tags, vazoesDat, vazoesRvx, prevsCondition): listOfTags = [] for tag in tags: tagsConfiguration = {} tagsConfiguration['Text'] = tag listOfTags.append(tagsConfiguration) parameter = '' data = { "Title": title, "Description": description, "Tags": listOfTags, "VazoesDatCondition": vazoesDat, "VazoesRvxCondition": vazoesRvx, "PrevsCondition": prevsCondition } # VazoesDatCondition(integer) # 0 - padrão, não faz nenhuma mudança no decks. # 1 - exclui todos os vazoes.dat de todos os decks DECOMP do estudo. # 2 - exclui os vazoes.dat do segundo deck DECOMP em diante. # VazoesRvxCondition(integer) # 0 - Modo padrão # 1 - exclui todos os vazoes.rvX de todos os decks DECOMP do estudo. # 2 - exclui os vazoes.rvX do segundo deck DECOMP em diante. # PrevsCondition(integer) # 0 - Modo padrão # 1 - exclui todos os prevs, inclusive sensibilidade, de todos os decks DECOMP do estudo. # 2 - exclui somente os prevs sensibilidade do primeiro deck DECOMP e dos demais decks exclui todos os prevs, inclusive sensibilidade print("Usando a seguinte configuracao para o estudo: ", str(idStudy)) print(data) prospecStudyId = postInAPI( token, '/api/prospectiveStudies/' + str(idStudy) + '/Duplicate', parameter, data) return prospecStudyId