当前位置: 首页>>代码示例>>Python>>正文


Python DVIDNodeService.custom_request方法代码示例

本文整理汇总了Python中libdvid.DVIDNodeService.custom_request方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.custom_request方法的具体用法?Python DVIDNodeService.custom_request怎么用?Python DVIDNodeService.custom_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libdvid.DVIDNodeService的用法示例。


在下文中一共展示了DVIDNodeService.custom_request方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write2dvid

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
                def write2dvid(yblocks):
                    from libdvid import DVIDNodeService, ConnectionMethod
                    import numpy
                    node_service = DVIDNodeService(str(server), str(uuid))
                    
                    # get block coordinates
                    zbindex = slice/blocksize 
                    ypos, blocks = yblocks
                    ybindex = ypos / blocksize
                    zsize,ysize,xsize = blocks.shape
                    xrun = xsize/blocksize
                    xbindex = 0 # assume x starts at 0!!

                    # retrieve blocks
                    blockbuffer = ""
                    for iterx in range(0, xsize, blocksize):
                        block = blocks[:,:,iterx:iterx+blocksize].copy()
                        blockbuffer += block.tostring() #numpy.getbuffer(block)

                    node_service.custom_request(str((grayname + "/blocks/0_%d_%d/%d") % (ybindex, zbindex, xrun)), blockbuffer, ConnectionMethod.POST) 
开发者ID:stuarteberg,项目名称:DVIDSparkServices,代码行数:22,代码来源:IngestGrayscale.py

示例2: set_sync

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
def set_sync(dvid_server, uuid, srcname, destname):
    """Sets a sync on srcname to point to destname.
    
    Note: only a limited number of syncs are possible.
    libdvid-cpp will throw an error if a sync is not possible.

    Args:
        dvid_server (str): location of dvid server
        uuid (str): version id
        srcname (str): data instance with new sync
        destname (str): data instance pointed to by new sync 
    
    Raises:
        DVIDExceptions are not caught in this function and will be
        transferred to the caller.
    """

    ns = DVIDNodeService(str(dvid_server), str(uuid))
    data = {"sync": destname}
    ns.custom_request(srcname + "/sync", json.dumps(data).encode('utf-8'), ConnectionMethod.POST)
开发者ID:janelia-flyem,项目名称:DVIDSparkServices,代码行数:22,代码来源:metadata.py

示例3: list

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
    # print "dvid_url " + dvid_get_annotated_bodies

    # response = urllib.urlopen(dvid_get_annotated_bodies, proxies=proxies).read()


    bodies_annot_data = list(response)

    group_synapses = []
    body_theshold = 0
    for key in bodies_annot_data:
        if key.isdigit():
            #print "key " + key
            # key is a bodyID
            # get synapses for bodyID like this http://emdata1.int.janelia.org:8500/api/node/44d42/mb6_synapses/label/10095139
            get_synapses_dvid = annotations_synapses + "/label/" + key
            response_syn = node_service.custom_request( get_synapses_dvid, "", ConnectionMethod.GET )
            # get_synapses_dvid = "http://" + dvid_server + "/api/node/" + dvid_uuid + "/" + annotations_synapses + "/label/" + key
            # print "get syn: " + get_synapses_dvid
            # response_syn = urllib.urlopen(get_synapses_dvid, proxies=proxies).read()
            if response_syn == 'null':
                print "No synapse data found for bodyID: " + key
            else:
                print "Found synapse data for bodyID: " + key
                body_synapses = {}
                #get_body_annot = "http://" + dvid_server + "/api/node/" + dvid_uuid + "/" + body_annotations_name + "/key/"+ key
                #response_bod_annot = urllib.urlopen(get_body_annot, proxies=proxies).read()
                #body_annot_data = json.loads(response_bod_annot)
                #print body_annot_data
                synapse_data = json.loads(response_syn)
                body_theshold += 1                
                syn_count = 0
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:33,代码来源:generate_body_synapses_dvid.py

示例4: DVIDNodeService

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
        print "usage: dvid_server dvid_node_uuid synapse_datatype_name tagname outputfilename"
        sys.exit(1)

    dvid_server = sys.argv[1]
    dvid_uuid = sys.argv[2]
    datatype_name = sys.argv[3]
    tag_name = sys.argv[4]
    outputfilename = sys.argv[5]

    if dvid_server.endswith('/'):
        dvid_server = dvid_server[0:-1]
    http_dvid_server = "http://{0}".format(dvid_server)    
    node_service = DVIDNodeService(dvid_server, dvid_uuid, '[email protected]', 'export bookmarks')

    tag_endpoint = "{0}/tag/{1}".format(datatype_name, tag_name)
    response = node_service.custom_request( tag_endpoint, '', ConnectionMethod.GET )

    #print response
    bookmarkdata = json.loads(response)

    if not bookmarkdata:
	print "Error, no data for label: {0}".format(tag_name)
	exit(1)
    
    export_bookmarks = []
    
    for bookmark in bookmarkdata:
        #print "here " + synapse["Kind"] 
        pos = bookmark["Pos"]
        props = bookmark["Prop"]
        kind  = bookmark["Kind"]
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:33,代码来源:export_dvid_bookmarks.py

示例5: test_custom_request

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
 def test_custom_request(self):
     node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
     response_body = node_service.custom_request( "log", "", ConnectionMethod.GET )
     
     # This shouldn't raise an exception
     json_data = json.loads(response_body)
开发者ID:gnayuy,项目名称:libdvid-cpp,代码行数:8,代码来源:test_node_service.py

示例6: DVIDNodeService

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
    assign_type = sys.argv[8] # provide assignment type. most likely will all be body tracing assignments, I won't check for some standardize normenclature.
    
    lookup_bodyid = {}
    
    ## Do I comment out proxies?
    #proxies = {'http': 'http://' + dvid_server + '/'}    
    #dvid_get_body_synapse = "http://" + dvid_server + "/api/node/" + dvid_uuid + "/" + bodysyn_key_val + "/key/" + bodysyn_key
    #print "get body synapse " + dvid_get_body_synapse

    if dvid_server.endswith('/'):
        dvid_server = dvid_server[0:-1]
    http_dvid_server = "http://{0}".format(dvid_server)
    node_service = DVIDNodeService(dvid_server, dvid_uuid, '[email protected]', 'generate dvid assignment')
    dvid_get_body_synapse = bodysyn_key_val + "/key/" + bodysyn_key 
    
    response = node_service.custom_request( dvid_get_body_synapse, '', ConnectionMethod.GET )

    # need error check here for empty response
    
    body_synapse_data = json.loads(response)
    if type(body_synapse_data) is dict:
        print "Using body synapse format, dict"
        bk_data = body_synapse_data["data"]
    else:
        print "Using bookmark format, list"
        bk_data = body_synapse_data

    # check if it is from body_synapse
    #data_chk = body_synapse_data.get("data")
    #if data_chk:
    #    print "Using body synapse format"
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:33,代码来源:generate_dvid_assignment.py

示例7: DVIDNodeService

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
    dvid_server = sys.argv[1]
    dvid_uuid = sys.argv[2]
    synapse_datatype_name = sys.argv[3]
    label_id = sys.argv[4]
    labelblk = sys.argv[5]
    bodyannotations = sys.argv[6]
    outputfilename = sys.argv[7]

    # Libdvid has problems with trailing slashes in urls
    if dvid_server.endswith("/"):
        dvid_server = dvid_server[0:-1]
    http_dvid_server = "http://{0}".format(dvid_server)
    node_service = DVIDNodeService(dvid_server, dvid_uuid, "[email protected]", "export dvid synapses")
    dvid_request_synapses = "{0}/label/{1}".format(synapse_datatype_name, label_id)
    # print dvid_request_synapses
    response = node_service.custom_request(dvid_request_synapses, "", ConnectionMethod.GET)

    # print response

    if response == "null":
        print "No synapses found for " + dvid_request_synapses
        sys.exit(1)

    synapsedata = json.loads(response)

    export_synapse_tbars = {}
    export_synapses_psds = {}
    for synapse in synapsedata:
        # print "here " + synapse["Kind"]
        pos = synapse["Pos"]
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:32,代码来源:export_body_synapses.py

示例8: DVIDNodeService

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
	parser.add_argument('--dvid', dest='dvid', action='store', default='', required=True, help='Which DVID server to use')
	parser.add_argument('--key-name', dest='key_name', action='store', default='dashboard', help='Name of key to store data under in DVID')
	parser.add_argument('--key-value-store', dest='key_value_store', action='store', default='external_dashboard', help='Name of keyvalue data instance to put key-values under')
	parser.add_argument('--input', dest='input', action='store', default='',  required=True, help='Path to input JSON')
	parser.add_argument('--user', dest='user', action='store', default='anon', help='User name for dvid tracking purposes')


	args = parser.parse_args()
	#connect to DVID
	node_service = DVIDNodeService(args.dvid, args.uuid, args.user, "Load Extrernal Dashboard Data")

	
	#If key doesn't exist create it
	key_info_url = '/{kv_name}/info'.format(kv_name=args.key_value_store)
	try:
		node_service.custom_request(key_info_url, '', ConnectionMethod.GET)
	except DVIDException:
		if args.insert:
			create_datatype_endpoint = "{}api/repo/{}/instance".format(args.dvid, args.uuid)
			print create_datatype_endpoint
			payload = json.dumps({
				"typename": 'keyvalue', 
				"dataname": args.key_value_store,
				"versioned": "0",
			})
			u = urllib2.urlopen(create_datatype_endpoint, payload)
			#node_service.custom_request(create_datatype, payload, ConnectionMethod.POST)

	# Read in data
	with open(args.input) as fi:
		data = json.load(fi)
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:33,代码来源:DVIDLoad.py

示例9: DVIDNodeService

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
    dvid_server_exp = sys.argv[1]
    dvid_uuid_exp = sys.argv[2]
    annot_datatype_exp = sys.argv[3]
    offsett_coord = sys.argv[4]
    size = sys.argv[5]
    dvid_server_imp = sys.argv[6]
    dvid_uuid_imp = sys.argv[7]
    annot_datatype_imp = sys.argv[8]

    if dvid_server_exp.endswith('/'):
        dvid_server_exp = dvid_server[0:-1]
    http_dvid_server = "http://{0}".format(dvid_server_exp)
    node_service = DVIDNodeService(http_dvid_server, dvid_uuid_exp, '[email protected]', 'dvid annotation migration')
    dvid_request_annot_exp = annot_datatype_exp + "/elements/" + size + "/" + offsett_coord

    response = node_service.custom_request( dvid_request_annot_exp, "", ConnectionMethod.GET )

    if response == 'null':
        print "No elements found in offset " + offsett_coord + " to " + size
        sys.exit(1)

    
    annot_data = json.loads(response)    
    write_count = offsett_coord

    #if len(annot_data) > 0:
    load_dvid_annotations(annot_data, node_service, annot_datatype_imp, write_count)
    #else:
    #    print "No elements found in offset " + offsett_coord + " to " + size

    sys.exit(1)
开发者ID:janelia-flyem,项目名称:DVIDScripts,代码行数:33,代码来源:dvid_annotation_migration.py

示例10: check_keyvalue

# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import custom_request [as 别名]
    """Checks whether a keyvalue at master matches what was posted.
    """
    return check_keyvalue(ns, name, "m2", "data2")
bench_checkmasterkv()

@benchmark
def bench_checkmasterkeys():
    """Checks master range query.
    """
    keys = ["m1", "m2", "m3"]
    keys.sort()
    return check_keys(uuid, name, keys)
bench_checkmasterkeys()

# commit node, create new version
ns.custom_request("/commit", json.dumps({"note": "committed"}), ConnectionMethod.POST)
res = ns.custom_request("/newversion", "", ConnectionMethod.POST)
uuid2 = str(json.loads(res)["child"])
ns2 = DVIDNodeService(DVIDLOCATION, uuid2)

# add files to version
ns2.put(name, "v1", "vdata1")
ns2.put(name, "v2", "vdata2")
ns2.put(name, "m2", "vovewrite")

# check keys and a value
@benchmark
def bench_checkversionkeys():
    """Checks version range query.
    """
    keys = ["m1", "m2", "m3", "v1", "v2"]
开发者ID:janelia-flyem,项目名称:dvid,代码行数:33,代码来源:testGbucket.py


注:本文中的libdvid.DVIDNodeService.custom_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。