示例#1
0
    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))
示例#2
0
 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))
示例#3
0
 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
示例#5
0
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()
示例#6
0
 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)})
示例#7
0
 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
示例#8
0
 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))
示例#9
0
    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))
示例#10
0
 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))
示例#11
0
 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))
示例#12
0
 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()
示例#13
0
 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
示例#16
0
 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
示例#18
0
 def destroyAmalgamationFunctions(cls, host=defaulthost):
     api = getRequest(host)
     api.concepts("testconcept")\
         .amalgamationFunctions(cls.amalgamationSimID).DELETE()
示例#19
0
 def destroyLocalSimilarityFunctions(cls, host=defaulthost):
     api = getRequest(host)
     api.concepts("testconcept").attributes("wind_speed")\
                                .similarityfunction(cls.localSimID)\
                                .DELETE()
示例#20
0
 def destroyCases(cls, host=defaulthost):
     api = getRequest(host)
     api.concepts("testconcept").casebases("unittestCB").instances.DELETE()
示例#21
0
 def destroyTestCaseBase(cls, host=defaulthost):
     api = getRequest(host)
     api.casebases("unittestCB").DELETE()
示例#22
0
 def createCaseBase(self):
     api = getRequest(self.host)
     call = api.casebases
     call.PUT(self.name)
示例#23
0
 def createLocalSimilarityFunctions(cls, host=defaulthost):
     api = getRequest(host)
     api.concepts("testconcept").attributes("wind_speed")\
                 .similarityfunctions\
                 .PUT(cls.localSimJSON)
示例#24
0
 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()
示例#25
0
 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})
示例#26
0
 def destroyConcept(cls, host=defaulthost):
     api = getRequest(host)
     call = api.concepts("testconcept")
     call.DELETE()
     print("in delete concept url is: {}".format(call._url))