text
stringlengths 0
828
|
|---|
for bb in self.sample_scaled(scaled_image_shape):
|
# return the prediction and the bounding box, if the prediction is over threshold
|
prediction = cascade(bb)
|
if threshold is None or prediction > threshold:
|
yield prediction, bb.scale(1./scale)"
|
1207,"def pass_service(*names):
|
""""""Injects a service instance into the kwargs
|
""""""
|
def decorator(f):
|
@functools.wraps(f)
|
def wrapper(*args, **kwargs):
|
for name in names:
|
kwargs[name] = service_proxy(name)
|
return f(*args, **kwargs)
|
return wrapper
|
return decorator"
|
1208,"def get_conn():
|
""""""Return a connection to DynamoDB.""""""
|
if os.environ.get('DEBUG', False) or os.environ.get('travis', False):
|
# In DEBUG mode - use the local DynamoDB
|
# This also works for travis since we'll be running dynalite
|
conn = DynamoDBConnection(
|
host='localhost',
|
port=8000,
|
aws_access_key_id='TEST',
|
aws_secret_access_key='TEST',
|
is_secure=False
|
)
|
else:
|
# Regular old production
|
conn = DynamoDBConnection()
|
return conn"
|
1209,"def map_index_val(index_val):
|
""""""Xform index_val so that it can be stored/queried.""""""
|
if index_val is None:
|
return DynamoMappings.NONE_VAL
|
index_val = str(index_val)
|
if not index_val:
|
return DynamoMappings.EMPTY_STR_VAL
|
return index_val"
|
1210,"def table_schema_call(self, target, cls):
|
""""""Perform a table schema call.
|
We call the callable target with the args and keywords needed for the
|
table defined by cls. This is how we centralize the Table.create and
|
Table ctor calls.
|
""""""
|
index_defs = []
|
for name in cls.index_names() or []:
|
index_defs.append(GlobalIncludeIndex(
|
gsi_name(name),
|
parts=[HashKey(name)],
|
includes=['value']
|
))
|
return target(
|
cls.get_table_name(),
|
connection=get_conn(),
|
schema=[HashKey('id')],
|
global_indexes=index_defs or None
|
)"
|
1211,"def ensure_table(self, cls):
|
""""""Required functionality.""""""
|
exists = True
|
conn = get_conn()
|
try:
|
descrip = conn.describe_table(cls.get_table_name())
|
assert descrip is not None
|
except ResourceNotFoundException:
|
# Expected - this is what we get if there is no table
|
exists = False
|
except JSONResponseError:
|
# Also assuming no table
|
exists = False
|
if not exists:
|
table = self.table_schema_call(Table.create, cls)
|
assert table is not None"
|
1212,"def find_one(self, cls, id):
|
""""""Required functionality.""""""
|
try:
|
db_result = self.get_class_table(cls).lookup(id)
|
except ItemNotFound:
|
# according to docs, this shouldn't be required, but it IS
|
db_result = None
|
if not db_result:
|
return None
|
obj = cls.from_data(db_result['value'])
|
return obj"
|
1213,"def find_all(self, cls):
|
""""""Required functionality.""""""
|
final_results = []
|
table = self.get_class_table(cls)
|
for db_result in table.scan():
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.