def createCases(cls, host=defaulthost): print("in createcases") api = getRequest(host) call = api.concepts("testconcept").casebases("unittestCB").instances call.PUT(params={'cases': cls.casesJSON}) print("url: {} ".format(call._url))
def getRemoteConcepts(self): api = getRequest(self.host) call = api.concepts result = call.GET() concepts = result.json().get("concept") for elem in concepts: concepts.append(Concept(self.host,elem,get=True))
def createTestCaseBase(cls, host=defaulthost): print("in createTestCaseBase") api = getRequest(host) call = api.casebases result = call.PUT("unittestCB") print("url : {}".format(call._url)) print("result : {}".format(result))
def createAmalgamationFunction(self): print("in NEURAL createamal") api = getRequest(self.host) call = api.concepts(self.concept.name).neuralAmalgamationFunctions( self.name) jsonfilename = self.files["json"] h5filename = self.files["h5"] files = { "jsonfile": (jsonfilename, open(jsonfilename, 'rb'), { 'Expires': '0' }), "h5file": (h5filename, open(h5filename, 'rb'), { 'Expires': '0' }) } #requests.post('http://requestb.in/xucj9exu', files=(('foo', 'bar'), ('spam', 'eggs'))) #result = call.PUT('http://requestb.in/xucj9exu', files=(('foo', 'bar'), ('spam', 'eggs'))) print("in neural createamalgamationfunction url is: {}".format( call._url)) results = call.PUT( files={ "jsonfile": (jsonfilename, open(jsonfilename, 'rb'), { 'Expires': '0' }), "h5file": (h5filename, open(h5filename, 'rb'), { 'Expires': '0' }) }) #results = call.PUT(files=files) #results = call.PUT(params=files) print("results: {}".format(results)) self.created = True
def clearMyCBR(host): api = getRequest(host) call = api.concepts result = call.GET() concepts = result.json().get("concept") for elem in concepts: api.concepts(elem).DELETE()
def createAttributes(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept").attributes\ .PUT("wind_speed",params={"attributeJSON":cls.getAttributeParamterJSON(0,25)}) api.concepts("testconcept").attributes\ .PUT("wind_from_direction",params={"attributeJSON":cls.getAttributeParamterJSON(0,361)}) api.concepts("testconcept").attributes\ .PUT("wind_effect",params={"attributeJSON":cls.getAttributeParamterJSON(0,40)})
def createConcept(self, name): """ This is now working, it creates a concept. """ api = getRequest(self.host) call = api.concepts result = call.PUT(name) self.created = True
def createConcept(cls, host=defaulthost): """ This is now working, it creates a concept. """ print("in createconcept") api = getRequest(host) call = api.concepts result = call.PUT("testconcept") print("url : {}".format(call._url)) print("result : {}".format(result))
def createAmalgamationFunctions(cls, host=defaulthost): api = getRequest(host) call = api.concepts("testconcept").amalgamationFunctions( cls.amalgamationSimID) result = call.PUT( params={ "amalgamationFunctionType": "NEURAL_NETWORK_SOLUTION_DIRECTLY" }) print("add alg url {} result {}".format(call._url, result))
def getRemoteConcept(self): api = getRequest(self.host) #not needed as concept has no metainfo other than name getConceptCall = api.concepts(self.name) #this is needed though getAttributesCall = api.concepts(self.name).attributes attributesresults = getAttributesCall.GET() attributes = attributesresults.json().get("attributes") for elem in attributes: attributes.append(Attribute(self.host, elem["name"], self))
def getRemoteAttribute(self): api = getRequest(self.host) call = api.concepts(self.concept.name).attributes(self.name) result = call.GET() resultJson = result.json() self.attType = resultJson.get("type") if "Double" in self.attType: self.minvalue = resultJson.get("min") self.maxvalue = resultJson.get("max") print("created a double attribute with min: {} and max: {}".format( self.minvalue, self.maxvalue))
def deleteConcept(self, name): concept = None if name in self.concepts: concept = self.concepts[name] self.concepts.pop(name) else: return None concept.delete() api = getRequest(self.host) call = api.concepts(concept.name) result = call.DELETE()
def test_just_retrieval(self): casebasename = "mydefaultCB" conceptname = "opsitu" amalname = "neuralamal" api = getRequest(defaulthost) call = api.concepts(conceptname).casebases(casebasename)\ .amalgamationFunctions(amalname).retrievalByCaseID print(call) result = call.GET( params={"caseID": conceptname + "-" + casebasename + "1"}) print(result.json())
def addAmalagationFuntcion(host, concept): """This function adds a amalgation function to a concept :param host: hostname of the API server (e.g. epicmonolith.duckdns.org:8080) :param concept: the concept you want to add the amalgamationFunction to :returns: The added amalagation function or Null if not successfull. :rtype: amalgationFunction """ api = getRequest(host) payload = {'caseBase': 'CB_csv_Import', 'attribute': concept} api.concepts.concept(concept).amalagamationFuntcions.amalgationFuntcion( payload).PUT()
def getAmalgationFuntcions(host, concept): """This function get the list of amalgationfuntcions from a given concept. :param host: hostname of the API server (e.g. epicmonolith.duckdns.org:8080) :param concept: the concept you want to add the amalgamationFunction to :returns: The amalagation functions of the concept or Null if not successfull. :rtype: list of amalgationFunction """ api = getRequest(host) params = {'caseBase': 'CB_csv_Import', 'attribute': concept} amalgationFuntcions = api.concepts.concept( concept).amalgamationFunctions.GET() return amalgationFuntcions
def retrieval(self, filename, h5md5, jsonmd5): casebasename = "mydefaultCB" conceptname = "opsitu" amalname = "neuralamal" concepts = NeuralSimTest.uploadNeuralSim(filename, h5md5, jsonmd5, "opsitu", 20) concept = concepts.getConcept("opsitu") print(len(concept)) instances = concept.instanceList() firstincstance = instances[0] print(f"instance 0 params: {firstincstance.instance_parameters}") api = getRequest(defaulthost) call = api.concepts(conceptname).casebases(casebasename)\ .amalgamationFunctions(amalname).retrievalByCaseID print(call) result = call.GET( params={"caseID": conceptname + "-" + casebasename + "1"}) print(result.json())
def createAmalgamationFunction(self): print("in createamal") api = getRequest(self.host) call = api.concepts(self.concept.name).amalgamationFunctions(self.name) result = call.PUT(params=self.parameters) self.created = True
def destroyAmalgamationFunctions(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept")\ .amalgamationFunctions(cls.amalgamationSimID).DELETE()
def destroyLocalSimilarityFunctions(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept").attributes("wind_speed")\ .similarityfunction(cls.localSimID)\ .DELETE()
def destroyCases(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept").casebases("unittestCB").instances.DELETE()
def destroyTestCaseBase(cls, host=defaulthost): api = getRequest(host) api.casebases("unittestCB").DELETE()
def createCaseBase(self): api = getRequest(self.host) call = api.casebases call.PUT(self.name)
def createLocalSimilarityFunctions(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept").attributes("wind_speed")\ .similarityfunctions\ .PUT(cls.localSimJSON)
def destroyAttributes(cls, host=defaulthost): api = getRequest(host) api.concepts("testconcept").attributes("wind_speed").DELETE() api.concepts("testconcept").attributes("wind_from_direction").DELETE() api.concepts("testconcept").attributes("wind_effect").DELETE()
def createAttribute(self, name): api = getRequest(self.host) #print(f"in create attritube name: {name} and attribute parameters: {self.attribute_parameters}") result = api.concepts(self.concept.name).attributes.PUT( self.name, params={"attributeJSON": self.attribute_parameters})
def destroyConcept(cls, host=defaulthost): api = getRequest(host) call = api.concepts("testconcept") call.DELETE() print("in delete concept url is: {}".format(call._url))