本文整理汇总了Python中libdvid.DVIDNodeService.create_keyvalue方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.create_keyvalue方法的具体用法?Python DVIDNodeService.create_keyvalue怎么用?Python DVIDNodeService.create_keyvalue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.create_keyvalue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadFeaturesForFrame
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
def loadFeaturesForFrame(self, features, timeframe):
"""
loads feature data
"""
assert(self.server_address is not None)
assert(self.uuid is not None)
node_service = DVIDNodeService(self.server_address, self.uuid)
node_service.create_keyvalue(self.keyvalue_store)
return json.loads(node_service.get(self.keyvalue_store, "frame-{}".format(timeframe)))
示例2: storeFeaturesForFrame
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
def storeFeaturesForFrame(self, features, timeframe):
"""
Stores feature data
"""
assert(self.server_address is not None)
assert(self.uuid is not None)
node_service = DVIDNodeService(self.server_address, self.uuid)
node_service.create_keyvalue(self.keyvalue_store)
node_service.put(self.keyvalue_store, "frame-{}".format(timeframe), json.dumps(features))
示例3: test_keyvalue
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
def test_keyvalue(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_keyvalue("test_keyvalue")
node_service.put("test_keyvalue", "kkkk", "vvvv")
readback_value = node_service.get("test_keyvalue", "kkkk")
self.assertEqual(readback_value, "vvvv")
with self.assertRaises(RuntimeError):
node_service.put("test_keyvalue", "kkkk", 123) # 123 is not a buffer.
示例4: test_keyvalue
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
def test_keyvalue(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_keyvalue("keyvalue_test")
node_service.put("keyvalue_test", "key1", "val1")
readback_value = node_service.get("keyvalue_test", "key1")
self.assertEqual(readback_value, "val1")
node_service.put("keyvalue_test", "key2", "val2")
readback_value = node_service.get("keyvalue_test", "key2")
self.assertEqual(readback_value, "val2")
keys = node_service.get_keys("keyvalue_test")
assert isinstance(keys, collections.Iterable)
assert set(keys) == set(["key1", "key2"])
with self.assertRaises(ErrMsg):
node_service.put("keyvalue_test", "key1", 123) # 123 is not a buffer.
示例5: DVIDServerService
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
server_address = args.dvidAddress
server_service = DVIDServerService(server_address)
uuid = server_service.create_new_repo(args.datasetName, "description")
logging.info('UUID:\n{}'.format(uuid))
# get node service
node_service = DVIDNodeService(server_address, uuid)
# get dataset size and store in dvid
shape = image_provider.getImageShape(args.ilpFilename, args.labelImagePath)
time_range = image_provider.getTimeRange(args.ilpFilename, args.labelImagePath)
if args.timeRange is not None:
time_range = (max(time_range[0], args.timeRange[0]), min(time_range[1], args.timeRange[1]))
logging.info('Uploading time range {} to {}'.format(time_range, server_address))
keyvalue_store = "config"
node_service.create_keyvalue(keyvalue_store)
settings = { "shape": shape, "time_range": time_range }
node_service.put(keyvalue_store, "imageInfo", json.dumps(settings))
# upload all frames
for frame in range(time_range[0], time_range[1]):
logging.info("Uploading frame {}".format(frame))
label_image = image_provider.getLabelImageForFrame(args.ilpFilename, args.labelImagePath, frame)
raw_image = image_provider.getImageDataAtTimeFrame(args.rawFilename, args.rawPath, frame)
raw_name = "raw-{}".format(frame)
seg_name = "seg-{}".format(frame)
node_service.create_grayscale8(raw_name)
node_service.put_gray3D(raw_name, dataToBlock(raw_image, dtype=np.uint8), (0,0,0))
node_service.create_labelblk(seg_name)
node_service.put_labels3D(seg_name, dataToBlock(label_image, dtype=np.uint64), (0,0,0))
示例6: execute
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
#.........这里部分代码省略.........
Function preserves partitioner.
Args:
label_pairs (rdd): RDD is of (subvolume id, data)
Returns:
Original RDD including mappings for gt and the test seg.
"""
from DVIDSparkServices.reconutils.morpho import split_disconnected_bodies
from DVIDSparkServices.sparkdvid.CompressedNumpyArray import CompressedNumpyArray
subvolume, labelgtc, label2c = label_pairs
# extract numpy arrays
labelgt = labelgtc.deserialize()
label2 = label2c.deserialize()
# split bodies up
labelgt_split, labelgt_map = split_disconnected_bodies(labelgt)
label2_split, label2_map = split_disconnected_bodies(label2)
# compress results
return (subvolume, labelgt_map, label2_map,
CompressedNumpyArray(labelgt_split),
CompressedNumpyArray(label2_split))
# split bodies that are merged outside of the subvolume
# (preserves partitioner)
# => (key, (subvolume, seggt-split, seg2-split, seggt-map, seg2-map))
lpairs_split = lpairs.mapValues(_split_disjoint_labels)
# evaluation tool (support RAND, VI, per body, graph, and
# histogram stats over different sets of points)
evaluator = Evaluate.Evaluate(self.config_data)
### VOLUMETRIC ANALYSIS ###
# TODO: !! Grab number of intersecting disjoint faces
# (might need +1 border) for split edit distance
# grab volumetric body overlap ignoring boundaries as specified
# and generate overlap stats for substack (compute local)
# => (key, (subvolume, stats, seggt-split, seg2-split, seggt-map, seg2-map))
# (preserve partitioner)
lpairs_proc = evaluator.calcoverlap(lpairs_split, self.config_data["options"]["boundary-size"])
point_data = {}
### POINT ANALYSIS ###
for point_list_name in self.config_data["dvid-info"]["point-lists"]:
# grab point list from DVID
keyvalue = point_list_name.split('/')
if len(keyvalue) != 2:
raise Exception(str(point_list_name) + "point list key value not properly specified")
# is this too large to broadcast?? -- default lz4 should help quite a bit
# TODO: send only necessary data to each job through join might help
point_data[keyvalue[1]] = node_service.get_json(str(keyvalue[0]),
str(keyvalue[1]))
# Generate per substack and global stats for given points.
# Querying will just be done on the local labels stored.
# (preserve partitioner)
lpairs_proc = evaluator.calcoverlap_pts(lpairs_proc, keyvalue[1], point_data[keyvalue[1]])
# Extract stats by retrieving substacks and stats info and
# loading into data structures on the driver.
stats = evaluator.calculate_stats(lpairs_proc)
# none or false
debug = False
if "debug" in self.config_data:
debug = self.config_data["debug"]
if debug:
print "DEBUG:", json.dumps(stats)
# TODO: !! maybe generate a summary view from stats, write that back
# with simplify output, dump the more complicated file to keyvalue as well
# write stats and config back to DVID with time stamp
# (@ name + user name + time stamp)
# client should use '--' delimeter to parse name
stats["time-analyzed"] = \
datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
stats["config-file"] = self.config_data
current_time = int(time.time())
username = str(self.config_data["dvid-info"]["user-name"])
username = "__".join(username.split('.'))
location = str(self.config_data["dvid-info"]["stats-location"])
location = "__".join(location.split('.'))
fileloc = str(location + "--" + username + "--" + str(current_time))
node_service.create_keyvalue(self.writelocation)
node_service.put(self.writelocation, fileloc, json.dumps(stats))
示例7: createrepo
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_keyvalue [as 别名]
# create new repo for convenience
res, uuid = createrepo()
ns = DVIDNodeService(DVIDLOCATION, uuid)
ns.create_labelblk("labels")
# run tests on labelblk interface (will delete when finished)
volumetests(ns, uuid, "labels", labels)
print "************End Testing Labels**********\n\n\n"
# TODO run tests on labelk array interface
# Test key value
print "*************Testing KeyValue*************\n\n\n"
res, uuid = createrepo()
ns = DVIDNodeService(DVIDLOCATION, uuid)
name = "files"
ns.create_keyvalue(name)
# add files to master
ns.put(name, "m1", "data1")
ns.put(name, "m2", "data2")
ns.put(name, "m3", "data3")
# check keys and a value
@benchmark
def bench_checkmasterkv():
"""Checks whether a keyvalue at master matches what was posted.
"""
return check_keyvalue(ns, name, "m2", "data2")
bench_checkmasterkv()
@benchmark