Here are the examples of the python api multivitamin.data.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Source : test_request.py
with Apache License 2.0
from gumgum
with Apache License 2.0
from gumgum
def test_r1():
req = Request(json.loads(r1))
assert (
req.url
== "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/A_blank_black_picture.jpg/1536px-A_blank_black_picture.jpg"
)
def test_r2():
0
Source : test_caffe_classifier.py
with Apache License 2.0
from gumgum
with Apache License 2.0
from gumgum
def test_process():
for message in messages:
request = Request(message)
response = Response(request=request)
response = cc.process(response)
log.info(json.dumps(response.dict, indent=2))
# def download_expected_response(path):
# s3 = boto3.client("s3")
# filelike = BytesIO()
# s3.download_fileobj(S3_BUCKET_NAME, S3_EXPECTED_PREV_RESPONSES+"/"+path, filelike)
# filelike.seek(0)
# expected_json = json.loads(filelike.read().decode())
# return expected_json
# def test_consistency1():
# # Just an image
# pass
# def test_consistency2():
# # Just a video
# expected_json = download_expected_response("classification_doc_without_prev_resp.json")
# message = {
# "url":expected_json["media_annotation"]["url"]
# }
# module_map ={}
# module_map['NHLPlacementDetector'] =60
# module_map['NHLLogoClassifier']=61
# module_map['NBAPlacementDetector'] =69
# module_map['NBALogoClassifier']=70
# module_map['NBALeagueDetector']=71
# sponsor_id_map_file= LOCAL_NET_DATA_DIR+"/idmap.txt"
# sponsor_map=load_idmap(sponsor_id_map_file)
# cc = CaffeClassifier("NHLLogoClassifier", "0.0.2", LOCAL_NET_DATA_DIR,prop_type="logo",prop_id_map=sponsor_map,module_id_map=module_map)
# cc.process(message)
# cc.update_response()
# j1 = json.dumps(expected_json, indent=2, sort_keys=True)
# j2 = json.dumps(cc.avro_api.doc, indent=2, sort_keys=True)
# j2 = j2.replace(cc.avro_api.doc["media_annotation"]["codes"][0]["date"], expected_json["media_annotation"]["codes"][0]["date"])
# j2 = j2.replace(cc.avro_api.doc["media_annotation"]["codes"][0]["id"], expected_json["media_annotation"]["codes"][0]["id"])
# assert(j1 == j2)
# assert(json.loads(j1) == json.loads(j2))
# def test_consistency3():
# # A video with previous response
# expected_json = download_expected_response("classification_doc_with_prev_resp.json")
# prev_resp = download_expected_response("detection_doc.json")
# message = {
# "url":expected_json["media_annotation"]["url"],
# "prev_response":json.dumps(prev_resp),
# "bin_decoding":False
# }
# module_map ={}
# module_map['NHLPlacementDetector'] =60
# module_map['NHLLogoClassifier']=61
# module_map['NBAPlacementDetector'] =69
# module_map['NBALogoClassifier']=70
# module_map['NBALeagueDetector']=71
# sponsor_id_map_file= LOCAL_NET_DATA_DIR+"/idmap.txt"
# sponsor_map=load_idmap(sponsor_id_map_file)
# p={}
# p['server']="NHLPlacementDetector"
# p['property_type']='placement'
# prev_pois=[p]
# cc = CaffeClassifier("NHLLogoClassifier", "0.0.2", LOCAL_NET_DATA_DIR,prop_type="logo",prop_id_map=sponsor_map,module_id_map=module_map)
# cc.set_prev_pois(prev_pois=prev_pois)
# cc.process(message)
# cc.update_response()
# j1 = json.dumps(expected_json, indent=2, sort_keys=True)
# j2 = json.dumps(cc.avro_api.doc, indent=2, sort_keys=True)
# #print(j2)
# j2 = j2.replace(cc.avro_api.doc["media_annotation"]["codes"][1]["date"], expected_json["media_annotation"]["codes"][1]["date"])
# j2 = j2.replace(cc.avro_api.doc["media_annotation"]["codes"][1]["id"], expected_json["media_annotation"]["codes"][1]["id"])
# assert(j1 == j2)
# assert(json.loads(j1) == json.loads(j2))
0
Source : test_detector_classifier_prev.py
with Apache License 2.0
from gumgum
with Apache License 2.0
from gumgum
def test_process():
# Test on short video
ssd, cc = load()
message = {
"url": "https://s3.amazonaws.com/video-ann-testing/short_flamesatblues.mp4",
"bin_encoding": "false",
"bin_decoding": "false",
}
request = Request(message)
response = load_response_from_request(request)
log.info("SSD DETECTOR")
response = ssd.process(request, response)
log.info("CAFFE CLASSIFIER")
cc.set_prev_props_of_interest(
[
{
"property_type": "placement",
"company": "gumgum",
"server": "TestSSDClassifier",
"value": "Static Dasherboard",
}
]
)
response = cc.process(request, response)
doc = response.dict
log.info(f"doc: {json.dumps(doc, indent=2)}")
with open("t.json", "w") as wf:
json.dump(doc, wf)
test_video = "https://s3.amazonaws.com/video-ann-testing/kitti-clip.mp4"
0
Source : test_request.py
with Apache License 2.0
from gumgum
with Apache License 2.0
from gumgum
def test_r3():
with pytest.raises(ValueError):
Request(json.loads(r3))