def repoAdd(): # Assign ranker2 repo instance repo = Ranker2Repo("http://192.168.2.19:6501/rank/repo") # Repo name repoid = 'repo1' # Do the repo add operation add_source = { "Context": {}, "Repo": { "Operation": 1, "RepoId": repoid, "Level": 3, "FeatureLen": 384, "Capacity": 11000, "Params": [{ "key": "GPUThreads", "value": "[1,1,1,1]" }] } } repo.addRepo(add_source)
def repoDelete(): # Assign ranker2 repo instance repo = Ranker2Repo("http://192.168.2.19:6501/rank/repo") # Do the repo delete operation delete_source = { "Context": {}, "Repo": { "Operation": 2, "RepoId": "repo1" } } repo.deleteRepo(delete_source)
def repoUpdate(): # Assign ranker2 repo instance repo = Ranker2Repo("http://192.168.2.19:6501/rank/repo") # Do the repo add operation update_source = { "Context": {}, "Repo": { "Operation": 3, "RepoId": "repo1", "Level": 3, "FeatureLen": 384, "Capacity": 11000000, "Params": [{ "key": "GPUThreads", "value": "[0,0,0,1]" }] } } repo.updateRepo(update_source)
#!/usr/bin/env python #!coding=utf-8 from repoRanker2 import Ranker2Repo from featureRanker2 import Ranker2Feature from featureCreate import featureCreate # Assign ranker2 repo and feature instance repoid = 'repo1' FeatureLen = 256 featureid = "4dd5b46a-b227-11e7-a604-408d5c1565b5" repo_url = "http://192.168.2.19:6501/rank/repo" feature_url = "http://192.168.2.19:6501/rank/feature" repo = Ranker2Repo(repo_url) fea = Ranker2Feature(feature_url) # Do the feature add operation print '::Do the feature update' feature = featureCreate(FeatureLen) update_source = { "Features": { "Operation": 3, "RepoId": repoid, "ObjectFeatures": [ { "Feature": feature, "Attributes": [ {"value": 43,"key": "k43"}], "Time": 1509480666000,
#!/usr/bin/env python #!coding=utf-8 ''' Created on 2017年12月18日 @author: Administrator ''' from repoRanker2 import Ranker2Repo # Assign ranker2 repo instance repo = Ranker2Repo("http://192.168.2.19:6501/rank/repo") # Do the repo add operation print '::Do the repo add' repoid = 'repo1' add_source = {"Context":{},"Repo":{"Operation":1,"RepoId":repoid,"Level":3,"FeatureLen":256,"Capacity":100,"Params":[{"key":"GPUThreads","value":"[0,0,0,1]"}]}} repo.addRepo(add_source) # Do the repo query operation print '\r::Do the repo query' query_source = {"Context":{},"Repo":{"Operation":4,"RepoId":repoid}} repo.queryRepo(query_source)
def repoQuery(): repo = Ranker2Repo("http://192.168.2.19:6501/rank/repo") query_source = {"Context": {}, "Repo": {"Operation": 4}} repo.queryRepo(query_source)