repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bslatkin/dpxdt | dpxdt/server/work_queue.py | heartbeat | def heartbeat(queue_name, task_id, owner, message, index):
"""Sets the heartbeat status of the task and extends its lease.
The task's lease is extended by the same amount as its last lease to
ensure that any operations following the heartbeat will still hold the
lock for the original lock period.
... | python | def heartbeat(queue_name, task_id, owner, message, index):
"""Sets the heartbeat status of the task and extends its lease.
The task's lease is extended by the same amount as its last lease to
ensure that any operations following the heartbeat will still hold the
lock for the original lock period.
... | [
"def",
"heartbeat",
"(",
"queue_name",
",",
"task_id",
",",
"owner",
",",
"message",
",",
"index",
")",
":",
"task",
"=",
"_get_task_with_policy",
"(",
"queue_name",
",",
"task_id",
",",
"owner",
")",
"if",
"task",
".",
"heartbeat_number",
">",
"index",
":... | Sets the heartbeat status of the task and extends its lease.
The task's lease is extended by the same amount as its last lease to
ensure that any operations following the heartbeat will still hold the
lock for the original lock period.
Args:
queue_name: Name of the queue the work item is on.
... | [
"Sets",
"the",
"heartbeat",
"status",
"of",
"the",
"task",
"and",
"extends",
"its",
"lease",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L259-L303 | train |
bslatkin/dpxdt | dpxdt/server/work_queue.py | finish | def finish(queue_name, task_id, owner, error=False):
"""Marks a work item on a queue as finished.
Args:
queue_name: Name of the queue the work item is on.
task_id: ID of the task that is finished.
owner: Who or what has the current lease on the task.
error: Defaults to false. Tr... | python | def finish(queue_name, task_id, owner, error=False):
"""Marks a work item on a queue as finished.
Args:
queue_name: Name of the queue the work item is on.
task_id: ID of the task that is finished.
owner: Who or what has the current lease on the task.
error: Defaults to false. Tr... | [
"def",
"finish",
"(",
"queue_name",
",",
"task_id",
",",
"owner",
",",
"error",
"=",
"False",
")",
":",
"task",
"=",
"_get_task_with_policy",
"(",
"queue_name",
",",
"task_id",
",",
"owner",
")",
"if",
"not",
"task",
".",
"status",
"==",
"WorkQueue",
"."... | Marks a work item on a queue as finished.
Args:
queue_name: Name of the queue the work item is on.
task_id: ID of the task that is finished.
owner: Who or what has the current lease on the task.
error: Defaults to false. True if this task's final state is an error.
Returns:
... | [
"Marks",
"a",
"work",
"item",
"on",
"a",
"queue",
"as",
"finished",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L306-L342 | train |
bslatkin/dpxdt | dpxdt/server/work_queue.py | cancel | def cancel(**kwargs):
"""Cancels work items based on their criteria.
Args:
**kwargs: Same parameters as the query() method.
Returns:
The number of tasks that were canceled.
"""
task_list = _query(**kwargs)
for task in task_list:
task.status = WorkQueue.CANCELED
... | python | def cancel(**kwargs):
"""Cancels work items based on their criteria.
Args:
**kwargs: Same parameters as the query() method.
Returns:
The number of tasks that were canceled.
"""
task_list = _query(**kwargs)
for task in task_list:
task.status = WorkQueue.CANCELED
... | [
"def",
"cancel",
"(",
"**",
"kwargs",
")",
":",
"task_list",
"=",
"_query",
"(",
"**",
"kwargs",
")",
"for",
"task",
"in",
"task_list",
":",
"task",
".",
"status",
"=",
"WorkQueue",
".",
"CANCELED",
"task",
".",
"finished",
"=",
"datetime",
".",
"datet... | Cancels work items based on their criteria.
Args:
**kwargs: Same parameters as the query() method.
Returns:
The number of tasks that were canceled. | [
"Cancels",
"work",
"items",
"based",
"on",
"their",
"criteria",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L410-L424 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | handle_add | def handle_add(queue_name):
"""Adds a task to a queue."""
source = request.form.get('source', request.remote_addr, type=str)
try:
task_id = work_queue.add(
queue_name,
payload=request.form.get('payload', type=str),
content_type=request.form.get('content_type', typ... | python | def handle_add(queue_name):
"""Adds a task to a queue."""
source = request.form.get('source', request.remote_addr, type=str)
try:
task_id = work_queue.add(
queue_name,
payload=request.form.get('payload', type=str),
content_type=request.form.get('content_type', typ... | [
"def",
"handle_add",
"(",
"queue_name",
")",
":",
"source",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'source'",
",",
"request",
".",
"remote_addr",
",",
"type",
"=",
"str",
")",
"try",
":",
"task_id",
"=",
"work_queue",
".",
"add",
"(",
"queue_na... | Adds a task to a queue. | [
"Adds",
"a",
"task",
"to",
"a",
"queue",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L37-L53 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | handle_lease | def handle_lease(queue_name):
"""Leases a task from a queue."""
owner = request.form.get('owner', request.remote_addr, type=str)
try:
task_list = work_queue.lease(
queue_name,
owner,
request.form.get('count', 1, type=int),
request.form.get('timeout', 6... | python | def handle_lease(queue_name):
"""Leases a task from a queue."""
owner = request.form.get('owner', request.remote_addr, type=str)
try:
task_list = work_queue.lease(
queue_name,
owner,
request.form.get('count', 1, type=int),
request.form.get('timeout', 6... | [
"def",
"handle_lease",
"(",
"queue_name",
")",
":",
"owner",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'owner'",
",",
"request",
".",
"remote_addr",
",",
"type",
"=",
"str",
")",
"try",
":",
"task_list",
"=",
"work_queue",
".",
"lease",
"(",
"queu... | Leases a task from a queue. | [
"Leases",
"a",
"task",
"from",
"a",
"queue",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L59-L78 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | handle_heartbeat | def handle_heartbeat(queue_name):
"""Updates the heartbeat message for a task."""
task_id = request.form.get('task_id', type=str)
message = request.form.get('message', type=str)
index = request.form.get('index', type=int)
try:
work_queue.heartbeat(
queue_name,
task_id... | python | def handle_heartbeat(queue_name):
"""Updates the heartbeat message for a task."""
task_id = request.form.get('task_id', type=str)
message = request.form.get('message', type=str)
index = request.form.get('index', type=int)
try:
work_queue.heartbeat(
queue_name,
task_id... | [
"def",
"handle_heartbeat",
"(",
"queue_name",
")",
":",
"task_id",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'task_id'",
",",
"type",
"=",
"str",
")",
"message",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'message'",
",",
"type",
"=",
"str",
... | Updates the heartbeat message for a task. | [
"Updates",
"the",
"heartbeat",
"message",
"for",
"a",
"task",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L84-L102 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | handle_finish | def handle_finish(queue_name):
"""Marks a task on a queue as finished."""
task_id = request.form.get('task_id', type=str)
owner = request.form.get('owner', request.remote_addr, type=str)
error = request.form.get('error', type=str) is not None
try:
work_queue.finish(queue_name, task_id, owner... | python | def handle_finish(queue_name):
"""Marks a task on a queue as finished."""
task_id = request.form.get('task_id', type=str)
owner = request.form.get('owner', request.remote_addr, type=str)
error = request.form.get('error', type=str) is not None
try:
work_queue.finish(queue_name, task_id, owner... | [
"def",
"handle_finish",
"(",
"queue_name",
")",
":",
"task_id",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'task_id'",
",",
"type",
"=",
"str",
")",
"owner",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'owner'",
",",
"request",
".",
"remote_addr... | Marks a task on a queue as finished. | [
"Marks",
"a",
"task",
"on",
"a",
"queue",
"as",
"finished",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L108-L121 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | view_all_work_queues | def view_all_work_queues():
"""Page for viewing the index of all active work queues."""
count_list = list(
db.session.query(
work_queue.WorkQueue.queue_name,
work_queue.WorkQueue.status,
func.count(work_queue.WorkQueue.task_id))
.group_by(work_queue.WorkQueue.... | python | def view_all_work_queues():
"""Page for viewing the index of all active work queues."""
count_list = list(
db.session.query(
work_queue.WorkQueue.queue_name,
work_queue.WorkQueue.status,
func.count(work_queue.WorkQueue.task_id))
.group_by(work_queue.WorkQueue.... | [
"def",
"view_all_work_queues",
"(",
")",
":",
"count_list",
"=",
"list",
"(",
"db",
".",
"session",
".",
"query",
"(",
"work_queue",
".",
"WorkQueue",
".",
"queue_name",
",",
"work_queue",
".",
"WorkQueue",
".",
"status",
",",
"func",
".",
"count",
"(",
... | Page for viewing the index of all active work queues. | [
"Page",
"for",
"viewing",
"the",
"index",
"of",
"all",
"active",
"work",
"queues",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L126-L169 | train |
bslatkin/dpxdt | dpxdt/server/work_queue_handlers.py | manage_work_queue | def manage_work_queue(queue_name):
"""Page for viewing the contents of a work queue."""
modify_form = forms.ModifyWorkQueueTaskForm()
if modify_form.validate_on_submit():
primary_key = (modify_form.task_id.data, queue_name)
task = work_queue.WorkQueue.query.get(primary_key)
if task:
... | python | def manage_work_queue(queue_name):
"""Page for viewing the contents of a work queue."""
modify_form = forms.ModifyWorkQueueTaskForm()
if modify_form.validate_on_submit():
primary_key = (modify_form.task_id.data, queue_name)
task = work_queue.WorkQueue.query.get(primary_key)
if task:
... | [
"def",
"manage_work_queue",
"(",
"queue_name",
")",
":",
"modify_form",
"=",
"forms",
".",
"ModifyWorkQueueTaskForm",
"(",
")",
"if",
"modify_form",
".",
"validate_on_submit",
"(",
")",
":",
"primary_key",
"=",
"(",
"modify_form",
".",
"task_id",
".",
"data",
... | Page for viewing the contents of a work queue. | [
"Page",
"for",
"viewing",
"the",
"contents",
"of",
"a",
"work",
"queue",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue_handlers.py#L174-L220 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | retryable_transaction | def retryable_transaction(attempts=3, exceptions=(OperationalError,)):
"""Decorator retries a function when expected exceptions are raised."""
assert len(exceptions) > 0
assert attempts > 0
def wrapper(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
for i in xrange(att... | python | def retryable_transaction(attempts=3, exceptions=(OperationalError,)):
"""Decorator retries a function when expected exceptions are raised."""
assert len(exceptions) > 0
assert attempts > 0
def wrapper(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
for i in xrange(att... | [
"def",
"retryable_transaction",
"(",
"attempts",
"=",
"3",
",",
"exceptions",
"=",
"(",
"OperationalError",
",",
")",
")",
":",
"assert",
"len",
"(",
"exceptions",
")",
">",
"0",
"assert",
"attempts",
">",
"0",
"def",
"wrapper",
"(",
"f",
")",
":",
"@"... | Decorator retries a function when expected exceptions are raised. | [
"Decorator",
"retries",
"a",
"function",
"when",
"expected",
"exceptions",
"are",
"raised",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L37-L58 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | jsonify_assert | def jsonify_assert(asserted, message, status_code=400):
"""Asserts something is true, aborts the request if not."""
if asserted:
return
try:
raise AssertionError(message)
except AssertionError, e:
stack = traceback.extract_stack()
stack.pop()
logging.error('Assert... | python | def jsonify_assert(asserted, message, status_code=400):
"""Asserts something is true, aborts the request if not."""
if asserted:
return
try:
raise AssertionError(message)
except AssertionError, e:
stack = traceback.extract_stack()
stack.pop()
logging.error('Assert... | [
"def",
"jsonify_assert",
"(",
"asserted",
",",
"message",
",",
"status_code",
"=",
"400",
")",
":",
"if",
"asserted",
":",
"return",
"try",
":",
"raise",
"AssertionError",
"(",
"message",
")",
"except",
"AssertionError",
",",
"e",
":",
"stack",
"=",
"trace... | Asserts something is true, aborts the request if not. | [
"Asserts",
"something",
"is",
"true",
"aborts",
"the",
"request",
"if",
"not",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L61-L72 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | jsonify_error | def jsonify_error(message_or_exception, status_code=400):
"""Returns a JSON payload that indicates the request had an error."""
if isinstance(message_or_exception, Exception):
message = '%s: %s' % (
message_or_exception.__class__.__name__, message_or_exception)
else:
message = me... | python | def jsonify_error(message_or_exception, status_code=400):
"""Returns a JSON payload that indicates the request had an error."""
if isinstance(message_or_exception, Exception):
message = '%s: %s' % (
message_or_exception.__class__.__name__, message_or_exception)
else:
message = me... | [
"def",
"jsonify_error",
"(",
"message_or_exception",
",",
"status_code",
"=",
"400",
")",
":",
"if",
"isinstance",
"(",
"message_or_exception",
",",
"Exception",
")",
":",
"message",
"=",
"'%s: %s'",
"%",
"(",
"message_or_exception",
".",
"__class__",
".",
"__na... | Returns a JSON payload that indicates the request had an error. | [
"Returns",
"a",
"JSON",
"payload",
"that",
"indicates",
"the",
"request",
"had",
"an",
"error",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L75-L87 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | ignore_exceptions | def ignore_exceptions(f):
"""Decorator catches and ignores any exceptions raised by this function."""
@functools.wraps(f)
def wrapped(*args, **kwargs):
try:
return f(*args, **kwargs)
except:
logging.exception("Ignoring exception in %r", f)
return wrapped | python | def ignore_exceptions(f):
"""Decorator catches and ignores any exceptions raised by this function."""
@functools.wraps(f)
def wrapped(*args, **kwargs):
try:
return f(*args, **kwargs)
except:
logging.exception("Ignoring exception in %r", f)
return wrapped | [
"def",
"ignore_exceptions",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
":"... | Decorator catches and ignores any exceptions raised by this function. | [
"Decorator",
"catches",
"and",
"ignores",
"any",
"exceptions",
"raised",
"by",
"this",
"function",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L90-L98 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | timesince | def timesince(when):
"""Returns string representing "time since" or "time until".
Examples:
3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now.
"""
if not when:
return ''
now = datetime.datetime.utcnow()
if now > when:
diff = now - when
suffix = ... | python | def timesince(when):
"""Returns string representing "time since" or "time until".
Examples:
3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now.
"""
if not when:
return ''
now = datetime.datetime.utcnow()
if now > when:
diff = now - when
suffix = ... | [
"def",
"timesince",
"(",
"when",
")",
":",
"if",
"not",
"when",
":",
"return",
"''",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"now",
">",
"when",
":",
"diff",
"=",
"now",
"-",
"when",
"suffix",
"=",
"'ago'",
"else",
... | Returns string representing "time since" or "time until".
Examples:
3 days ago, 5 hours ago, 3 minutes from now, 5 hours from now, now. | [
"Returns",
"string",
"representing",
"time",
"since",
"or",
"time",
"until",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L103-L137 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | human_uuid | def human_uuid():
"""Returns a good UUID for using as a human readable string."""
return base64.b32encode(
hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=') | python | def human_uuid():
"""Returns a good UUID for using as a human readable string."""
return base64.b32encode(
hashlib.sha1(uuid.uuid4().bytes).digest()).lower().strip('=') | [
"def",
"human_uuid",
"(",
")",
":",
"return",
"base64",
".",
"b32encode",
"(",
"hashlib",
".",
"sha1",
"(",
"uuid",
".",
"uuid4",
"(",
")",
".",
"bytes",
")",
".",
"digest",
"(",
")",
")",
".",
"lower",
"(",
")",
".",
"strip",
"(",
"'='",
")"
] | Returns a good UUID for using as a human readable string. | [
"Returns",
"a",
"good",
"UUID",
"for",
"using",
"as",
"a",
"human",
"readable",
"string",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L140-L143 | train |
bslatkin/dpxdt | dpxdt/server/utils.py | get_deployment_timestamp | def get_deployment_timestamp():
"""Returns a unique string represeting the current deployment.
Used for busting caches.
"""
# TODO: Support other deployment situations.
if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
version_id = os.environ.get('CURRENT_VERSION_ID'... | python | def get_deployment_timestamp():
"""Returns a unique string represeting the current deployment.
Used for busting caches.
"""
# TODO: Support other deployment situations.
if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
version_id = os.environ.get('CURRENT_VERSION_ID'... | [
"def",
"get_deployment_timestamp",
"(",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'SERVER_SOFTWARE'",
",",
"''",
")",
".",
"startswith",
"(",
"'Google App Engine'",
")",
":",
"version_id",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'CURRENT... | Returns a unique string represeting the current deployment.
Used for busting caches. | [
"Returns",
"a",
"unique",
"string",
"represeting",
"the",
"current",
"deployment",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/utils.py#L163-L173 | train |
bslatkin/dpxdt | dpxdt/tools/url_pair_diff.py | real_main | def real_main(new_url=None,
baseline_url=None,
upload_build_id=None,
upload_release_name=None):
"""Runs the ur_pair_diff."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
item = UrlPairDiff(
new_url,
... | python | def real_main(new_url=None,
baseline_url=None,
upload_build_id=None,
upload_release_name=None):
"""Runs the ur_pair_diff."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
item = UrlPairDiff(
new_url,
... | [
"def",
"real_main",
"(",
"new_url",
"=",
"None",
",",
"baseline_url",
"=",
"None",
",",
"upload_build_id",
"=",
"None",
",",
"upload_release_name",
"=",
"None",
")",
":",
"coordinator",
"=",
"workers",
".",
"get_coordinator",
"(",
")",
"fetch_worker",
".",
"... | Runs the ur_pair_diff. | [
"Runs",
"the",
"ur_pair_diff",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/url_pair_diff.py#L132-L152 | train |
bslatkin/dpxdt | dpxdt/client/fetch_worker.py | fetch_internal | def fetch_internal(item, request):
"""Fetches the given request by using the local Flask context."""
# Break client dependence on Flask if internal fetches aren't being used.
from flask import make_response
from werkzeug.test import EnvironBuilder
# Break circular dependencies.
from dpxdt.server... | python | def fetch_internal(item, request):
"""Fetches the given request by using the local Flask context."""
# Break client dependence on Flask if internal fetches aren't being used.
from flask import make_response
from werkzeug.test import EnvironBuilder
# Break circular dependencies.
from dpxdt.server... | [
"def",
"fetch_internal",
"(",
"item",
",",
"request",
")",
":",
"from",
"flask",
"import",
"make_response",
"from",
"werkzeug",
".",
"test",
"import",
"EnvironBuilder",
"from",
"dpxdt",
".",
"server",
"import",
"app",
"environ_base",
"=",
"{",
"'REMOTE_ADDR'",
... | Fetches the given request by using the local Flask context. | [
"Fetches",
"the",
"given",
"request",
"by",
"using",
"the",
"local",
"Flask",
"context",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L118-L160 | train |
bslatkin/dpxdt | dpxdt/client/fetch_worker.py | fetch_normal | def fetch_normal(item, request):
"""Fetches the given request over HTTP."""
try:
conn = urllib2.urlopen(request, timeout=item.timeout_seconds)
except urllib2.HTTPError, e:
conn = e
except (urllib2.URLError, ssl.SSLError), e:
# TODO: Make this status more clear
item.status... | python | def fetch_normal(item, request):
"""Fetches the given request over HTTP."""
try:
conn = urllib2.urlopen(request, timeout=item.timeout_seconds)
except urllib2.HTTPError, e:
conn = e
except (urllib2.URLError, ssl.SSLError), e:
# TODO: Make this status more clear
item.status... | [
"def",
"fetch_normal",
"(",
"item",
",",
"request",
")",
":",
"try",
":",
"conn",
"=",
"urllib2",
".",
"urlopen",
"(",
"request",
",",
"timeout",
"=",
"item",
".",
"timeout_seconds",
")",
"except",
"urllib2",
".",
"HTTPError",
",",
"e",
":",
"conn",
"=... | Fetches the given request over HTTP. | [
"Fetches",
"the",
"given",
"request",
"over",
"HTTP",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L163-L189 | train |
bslatkin/dpxdt | dpxdt/client/fetch_worker.py | FetchItem.json | def json(self):
"""Returns de-JSONed data or None if it's a different content type."""
if self._data_json:
return self._data_json
if not self.data or self.content_type != 'application/json':
return None
self._data_json = json.loads(self.data)
return self... | python | def json(self):
"""Returns de-JSONed data or None if it's a different content type."""
if self._data_json:
return self._data_json
if not self.data or self.content_type != 'application/json':
return None
self._data_json = json.loads(self.data)
return self... | [
"def",
"json",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data_json",
":",
"return",
"self",
".",
"_data_json",
"if",
"not",
"self",
".",
"data",
"or",
"self",
".",
"content_type",
"!=",
"'application/json'",
":",
"return",
"None",
"self",
".",
"_data_j... | Returns de-JSONed data or None if it's a different content type. | [
"Returns",
"de",
"-",
"JSONed",
"data",
"or",
"None",
"if",
"it",
"s",
"a",
"different",
"content",
"type",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/fetch_worker.py#L106-L115 | train |
bslatkin/dpxdt | dpxdt/tools/local_pdiff.py | CaptureAndDiffWorkflowItem.maybe_imgur | def maybe_imgur(self, path):
'''Uploads a file to imgur if requested via command line flags.
Returns either "path" or "path url" depending on the course of action.
'''
if not FLAGS.imgur_client_id:
return path
im = pyimgur.Imgur(FLAGS.imgur_client_id)
upload... | python | def maybe_imgur(self, path):
'''Uploads a file to imgur if requested via command line flags.
Returns either "path" or "path url" depending on the course of action.
'''
if not FLAGS.imgur_client_id:
return path
im = pyimgur.Imgur(FLAGS.imgur_client_id)
upload... | [
"def",
"maybe_imgur",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"FLAGS",
".",
"imgur_client_id",
":",
"return",
"path",
"im",
"=",
"pyimgur",
".",
"Imgur",
"(",
"FLAGS",
".",
"imgur_client_id",
")",
"uploaded_image",
"=",
"im",
".",
"upload_image",
... | Uploads a file to imgur if requested via command line flags.
Returns either "path" or "path url" depending on the course of action. | [
"Uploads",
"a",
"file",
"to",
"imgur",
"if",
"requested",
"via",
"command",
"line",
"flags",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/local_pdiff.py#L254-L264 | train |
bslatkin/dpxdt | dpxdt/tools/diff_my_images.py | real_main | def real_main(release_url=None,
tests_json_path=None,
upload_build_id=None,
upload_release_name=None):
"""Runs diff_my_images."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
data = open(FLAGS.tests_json_pat... | python | def real_main(release_url=None,
tests_json_path=None,
upload_build_id=None,
upload_release_name=None):
"""Runs diff_my_images."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
data = open(FLAGS.tests_json_pat... | [
"def",
"real_main",
"(",
"release_url",
"=",
"None",
",",
"tests_json_path",
"=",
"None",
",",
"upload_build_id",
"=",
"None",
",",
"upload_release_name",
"=",
"None",
")",
":",
"coordinator",
"=",
"workers",
".",
"get_coordinator",
"(",
")",
"fetch_worker",
"... | Runs diff_my_images. | [
"Runs",
"diff_my_images",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/diff_my_images.py#L175-L198 | train |
bslatkin/dpxdt | dpxdt/tools/site_diff.py | clean_url | def clean_url(url, force_scheme=None):
"""Cleans the given URL."""
# URL should be ASCII according to RFC 3986
url = str(url)
# Collapse ../../ and related
url_parts = urlparse.urlparse(url)
path_parts = []
for part in url_parts.path.split('/'):
if part == '.':
continue
... | python | def clean_url(url, force_scheme=None):
"""Cleans the given URL."""
# URL should be ASCII according to RFC 3986
url = str(url)
# Collapse ../../ and related
url_parts = urlparse.urlparse(url)
path_parts = []
for part in url_parts.path.split('/'):
if part == '.':
continue
... | [
"def",
"clean_url",
"(",
"url",
",",
"force_scheme",
"=",
"None",
")",
":",
"url",
"=",
"str",
"(",
"url",
")",
"url_parts",
"=",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
"path_parts",
"=",
"[",
"]",
"for",
"part",
"in",
"url_parts",
".",
"path"... | Cleans the given URL. | [
"Cleans",
"the",
"given",
"URL",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L105-L135 | train |
bslatkin/dpxdt | dpxdt/tools/site_diff.py | extract_urls | def extract_urls(url, data, unescape=HTMLParser.HTMLParser().unescape):
"""Extracts the URLs from an HTML document."""
parts = urlparse.urlparse(url)
prefix = '%s://%s' % (parts.scheme, parts.netloc)
accessed_dir = os.path.dirname(parts.path)
if not accessed_dir.endswith('/'):
accessed_dir ... | python | def extract_urls(url, data, unescape=HTMLParser.HTMLParser().unescape):
"""Extracts the URLs from an HTML document."""
parts = urlparse.urlparse(url)
prefix = '%s://%s' % (parts.scheme, parts.netloc)
accessed_dir = os.path.dirname(parts.path)
if not accessed_dir.endswith('/'):
accessed_dir ... | [
"def",
"extract_urls",
"(",
"url",
",",
"data",
",",
"unescape",
"=",
"HTMLParser",
".",
"HTMLParser",
"(",
")",
".",
"unescape",
")",
":",
"parts",
"=",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
"prefix",
"=",
"'%s://%s'",
"%",
"(",
"parts",
".",
... | Extracts the URLs from an HTML document. | [
"Extracts",
"the",
"URLs",
"from",
"an",
"HTML",
"document",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L138-L162 | train |
bslatkin/dpxdt | dpxdt/tools/site_diff.py | prune_urls | def prune_urls(url_set, start_url, allowed_list, ignored_list):
"""Prunes URLs that should be ignored."""
result = set()
for url in url_set:
allowed = False
for allow_url in allowed_list:
if url.startswith(allow_url):
allowed = True
break
... | python | def prune_urls(url_set, start_url, allowed_list, ignored_list):
"""Prunes URLs that should be ignored."""
result = set()
for url in url_set:
allowed = False
for allow_url in allowed_list:
if url.startswith(allow_url):
allowed = True
break
... | [
"def",
"prune_urls",
"(",
"url_set",
",",
"start_url",
",",
"allowed_list",
",",
"ignored_list",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"url",
"in",
"url_set",
":",
"allowed",
"=",
"False",
"for",
"allow_url",
"in",
"allowed_list",
":",
"if",
"... | Prunes URLs that should be ignored. | [
"Prunes",
"URLs",
"that",
"should",
"be",
"ignored",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L169-L198 | train |
bslatkin/dpxdt | dpxdt/tools/site_diff.py | real_main | def real_main(start_url=None,
ignore_prefixes=None,
upload_build_id=None,
upload_release_name=None):
"""Runs the site_diff."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
item = SiteDiff(
start_url=... | python | def real_main(start_url=None,
ignore_prefixes=None,
upload_build_id=None,
upload_release_name=None):
"""Runs the site_diff."""
coordinator = workers.get_coordinator()
fetch_worker.register(coordinator)
coordinator.start()
item = SiteDiff(
start_url=... | [
"def",
"real_main",
"(",
"start_url",
"=",
"None",
",",
"ignore_prefixes",
"=",
"None",
",",
"upload_build_id",
"=",
"None",
",",
"upload_release_name",
"=",
"None",
")",
":",
"coordinator",
"=",
"workers",
".",
"get_coordinator",
"(",
")",
"fetch_worker",
"."... | Runs the site_diff. | [
"Runs",
"the",
"site_diff",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/tools/site_diff.py#L328-L348 | train |
bslatkin/dpxdt | dpxdt/server/emails.py | render_or_send | def render_or_send(func, message):
"""Renders an email message for debugging or actually sends it."""
if request.endpoint != func.func_name:
mail.send(message)
if (current_user.is_authenticated() and current_user.superuser):
return render_template('debug_email.html', message=message) | python | def render_or_send(func, message):
"""Renders an email message for debugging or actually sends it."""
if request.endpoint != func.func_name:
mail.send(message)
if (current_user.is_authenticated() and current_user.superuser):
return render_template('debug_email.html', message=message) | [
"def",
"render_or_send",
"(",
"func",
",",
"message",
")",
":",
"if",
"request",
".",
"endpoint",
"!=",
"func",
".",
"func_name",
":",
"mail",
".",
"send",
"(",
"message",
")",
"if",
"(",
"current_user",
".",
"is_authenticated",
"(",
")",
"and",
"current... | Renders an email message for debugging or actually sends it. | [
"Renders",
"an",
"email",
"message",
"for",
"debugging",
"or",
"actually",
"sends",
"it",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/emails.py#L33-L39 | train |
bslatkin/dpxdt | dpxdt/server/emails.py | send_ready_for_review | def send_ready_for_review(build_id, release_name, release_number):
"""Sends an email indicating that the release is ready for review."""
build = models.Build.query.get(build_id)
if not build.send_email:
logging.debug(
'Not sending ready for review email because build does not have '
... | python | def send_ready_for_review(build_id, release_name, release_number):
"""Sends an email indicating that the release is ready for review."""
build = models.Build.query.get(build_id)
if not build.send_email:
logging.debug(
'Not sending ready for review email because build does not have '
... | [
"def",
"send_ready_for_review",
"(",
"build_id",
",",
"release_name",
",",
"release_number",
")",
":",
"build",
"=",
"models",
".",
"Build",
".",
"query",
".",
"get",
"(",
"build_id",
")",
"if",
"not",
"build",
".",
"send_email",
":",
"logging",
".",
"debu... | Sends an email indicating that the release is ready for review. | [
"Sends",
"an",
"email",
"indicating",
"that",
"the",
"release",
"is",
"ready",
"for",
"review",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/emails.py#L45-L96 | train |
bslatkin/dpxdt | dpxdt/server/frontend.py | homepage | def homepage():
"""Renders the homepage."""
if current_user.is_authenticated():
if not login_fresh():
logging.debug('User needs a fresh token')
abort(login.needs_refresh())
auth.claim_invitations(current_user)
build_list = operations.UserOps(current_user.get_id()).g... | python | def homepage():
"""Renders the homepage."""
if current_user.is_authenticated():
if not login_fresh():
logging.debug('User needs a fresh token')
abort(login.needs_refresh())
auth.claim_invitations(current_user)
build_list = operations.UserOps(current_user.get_id()).g... | [
"def",
"homepage",
"(",
")",
":",
"if",
"current_user",
".",
"is_authenticated",
"(",
")",
":",
"if",
"not",
"login_fresh",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"'User needs a fresh token'",
")",
"abort",
"(",
"login",
".",
"needs_refresh",
"(",
")... | Renders the homepage. | [
"Renders",
"the",
"homepage",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L55-L68 | train |
bslatkin/dpxdt | dpxdt/server/frontend.py | new_build | def new_build():
"""Page for crediting or editing a build."""
form = forms.BuildForm()
if form.validate_on_submit():
build = models.Build()
form.populate_obj(build)
build.owners.append(current_user)
db.session.add(build)
db.session.flush()
auth.save_admin_lo... | python | def new_build():
"""Page for crediting or editing a build."""
form = forms.BuildForm()
if form.validate_on_submit():
build = models.Build()
form.populate_obj(build)
build.owners.append(current_user)
db.session.add(build)
db.session.flush()
auth.save_admin_lo... | [
"def",
"new_build",
"(",
")",
":",
"form",
"=",
"forms",
".",
"BuildForm",
"(",
")",
"if",
"form",
".",
"validate_on_submit",
"(",
")",
":",
"build",
"=",
"models",
".",
"Build",
"(",
")",
"form",
".",
"populate_obj",
"(",
"build",
")",
"build",
".",... | Page for crediting or editing a build. | [
"Page",
"for",
"crediting",
"or",
"editing",
"a",
"build",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L73-L96 | train |
bslatkin/dpxdt | dpxdt/server/frontend.py | view_build | def view_build():
"""Page for viewing all releases in a build."""
build = g.build
page_size = min(request.args.get('page_size', 10, type=int), 50)
offset = request.args.get('offset', 0, type=int)
ops = operations.BuildOps(build.id)
has_next_page, candidate_list, stats_counts = ops.get_candidate... | python | def view_build():
"""Page for viewing all releases in a build."""
build = g.build
page_size = min(request.args.get('page_size', 10, type=int), 50)
offset = request.args.get('offset', 0, type=int)
ops = operations.BuildOps(build.id)
has_next_page, candidate_list, stats_counts = ops.get_candidate... | [
"def",
"view_build",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"page_size",
"=",
"min",
"(",
"request",
".",
"args",
".",
"get",
"(",
"'page_size'",
",",
"10",
",",
"type",
"=",
"int",
")",
",",
"50",
")",
"offset",
"=",
"request",
".",
"ar... | Page for viewing all releases in a build. | [
"Page",
"for",
"viewing",
"all",
"releases",
"in",
"a",
"build",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L101-L154 | train |
bslatkin/dpxdt | dpxdt/server/frontend.py | view_release | def view_release():
"""Page for viewing all tests runs in a release."""
build = g.build
if request.method == 'POST':
form = forms.ReleaseForm(request.form)
else:
form = forms.ReleaseForm(request.args)
form.validate()
ops = operations.BuildOps(build.id)
release, run_list, st... | python | def view_release():
"""Page for viewing all tests runs in a release."""
build = g.build
if request.method == 'POST':
form = forms.ReleaseForm(request.form)
else:
form = forms.ReleaseForm(request.args)
form.validate()
ops = operations.BuildOps(build.id)
release, run_list, st... | [
"def",
"view_release",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"form",
"=",
"forms",
".",
"ReleaseForm",
"(",
"request",
".",
"form",
")",
"else",
":",
"form",
"=",
"forms",
".",
"ReleaseFo... | Page for viewing all tests runs in a release. | [
"Page",
"for",
"viewing",
"all",
"tests",
"runs",
"in",
"a",
"release",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L159-L221 | train |
bslatkin/dpxdt | dpxdt/server/frontend.py | _get_artifact_context | def _get_artifact_context(run, file_type):
"""Gets the artifact details for the given run and file_type."""
sha1sum = None
image_file = False
log_file = False
config_file = False
if request.path == '/image':
image_file = True
if file_type == 'before':
sha1sum = run.r... | python | def _get_artifact_context(run, file_type):
"""Gets the artifact details for the given run and file_type."""
sha1sum = None
image_file = False
log_file = False
config_file = False
if request.path == '/image':
image_file = True
if file_type == 'before':
sha1sum = run.r... | [
"def",
"_get_artifact_context",
"(",
"run",
",",
"file_type",
")",
":",
"sha1sum",
"=",
"None",
"image_file",
"=",
"False",
"log_file",
"=",
"False",
"config_file",
"=",
"False",
"if",
"request",
".",
"path",
"==",
"'/image'",
":",
"image_file",
"=",
"True",... | Gets the artifact details for the given run and file_type. | [
"Gets",
"the",
"artifact",
"details",
"for",
"the",
"given",
"run",
"and",
"file_type",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/frontend.py#L224-L260 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | get_coordinator | def get_coordinator():
"""Creates a coordinator and returns it."""
workflow_queue = Queue.Queue()
complete_queue = Queue.Queue()
coordinator = WorkflowThread(workflow_queue, complete_queue)
coordinator.register(WorkflowItem, workflow_queue)
return coordinator | python | def get_coordinator():
"""Creates a coordinator and returns it."""
workflow_queue = Queue.Queue()
complete_queue = Queue.Queue()
coordinator = WorkflowThread(workflow_queue, complete_queue)
coordinator.register(WorkflowItem, workflow_queue)
return coordinator | [
"def",
"get_coordinator",
"(",
")",
":",
"workflow_queue",
"=",
"Queue",
".",
"Queue",
"(",
")",
"complete_queue",
"=",
"Queue",
".",
"Queue",
"(",
")",
"coordinator",
"=",
"WorkflowThread",
"(",
"workflow_queue",
",",
"complete_queue",
")",
"coordinator",
"."... | Creates a coordinator and returns it. | [
"Creates",
"a",
"coordinator",
"and",
"returns",
"it",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L553-L559 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | WorkItem._print_repr | def _print_repr(self, depth):
"""Print this WorkItem to the given stack depth.
The depth parameter ensures that we can print WorkItems in
arbitrarily long chains without hitting the max stack depth.
This can happen with WaitForUrlWorkflowItems, which
create long chains of small ... | python | def _print_repr(self, depth):
"""Print this WorkItem to the given stack depth.
The depth parameter ensures that we can print WorkItems in
arbitrarily long chains without hitting the max stack depth.
This can happen with WaitForUrlWorkflowItems, which
create long chains of small ... | [
"def",
"_print_repr",
"(",
"self",
",",
"depth",
")",
":",
"if",
"depth",
"<=",
"0",
":",
"return",
"'%s.%s#%d'",
"%",
"(",
"self",
".",
"__class__",
".",
"__module__",
",",
"self",
".",
"__class__",
".",
"__name__",
",",
"id",
"(",
"self",
")",
")",... | Print this WorkItem to the given stack depth.
The depth parameter ensures that we can print WorkItems in
arbitrarily long chains without hitting the max stack depth.
This can happen with WaitForUrlWorkflowItems, which
create long chains of small waits. | [
"Print",
"this",
"WorkItem",
"to",
"the",
"given",
"stack",
"depth",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L74-L92 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | ResultList.error | def error(self):
"""Returns the error for this barrier and all work items, if any."""
# Copy the error from any failed item to be the error for the whole
# barrier. The first error seen "wins". Also handles the case where
# the WorkItems passed into the barrier have already completed and... | python | def error(self):
"""Returns the error for this barrier and all work items, if any."""
# Copy the error from any failed item to be the error for the whole
# barrier. The first error seen "wins". Also handles the case where
# the WorkItems passed into the barrier have already completed and... | [
"def",
"error",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
":",
"if",
"isinstance",
"(",
"item",
",",
"WorkItem",
")",
"and",
"item",
".",
"error",
":",
"return",
"item",
".",
"error",
"return",
"None"
] | Returns the error for this barrier and all work items, if any. | [
"Returns",
"the",
"error",
"for",
"this",
"barrier",
"and",
"all",
"work",
"items",
"if",
"any",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L227-L236 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | Barrier.outstanding | def outstanding(self):
"""Returns whether or not this barrier has pending work."""
# Allow the same WorkItem to be yielded multiple times but not
# count towards blocking the barrier.
done_count = 0
for item in self:
if not self.wait_any and item.fire_and_forget:
... | python | def outstanding(self):
"""Returns whether or not this barrier has pending work."""
# Allow the same WorkItem to be yielded multiple times but not
# count towards blocking the barrier.
done_count = 0
for item in self:
if not self.wait_any and item.fire_and_forget:
... | [
"def",
"outstanding",
"(",
"self",
")",
":",
"done_count",
"=",
"0",
"for",
"item",
"in",
"self",
":",
"if",
"not",
"self",
".",
"wait_any",
"and",
"item",
".",
"fire_and_forget",
":",
"done_count",
"+=",
"1",
"elif",
"item",
".",
"done",
":",
"done_co... | Returns whether or not this barrier has pending work. | [
"Returns",
"whether",
"or",
"not",
"this",
"barrier",
"has",
"pending",
"work",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L274-L295 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | Barrier.get_item | def get_item(self):
"""Returns the item to send back into the workflow generator."""
if self.was_list:
result = ResultList()
for item in self:
if isinstance(item, WorkflowItem):
if item.done and not item.error:
result.ap... | python | def get_item(self):
"""Returns the item to send back into the workflow generator."""
if self.was_list:
result = ResultList()
for item in self:
if isinstance(item, WorkflowItem):
if item.done and not item.error:
result.ap... | [
"def",
"get_item",
"(",
"self",
")",
":",
"if",
"self",
".",
"was_list",
":",
"result",
"=",
"ResultList",
"(",
")",
"for",
"item",
"in",
"self",
":",
"if",
"isinstance",
"(",
"item",
",",
"WorkflowItem",
")",
":",
"if",
"item",
".",
"done",
"and",
... | Returns the item to send back into the workflow generator. | [
"Returns",
"the",
"item",
"to",
"send",
"back",
"into",
"the",
"workflow",
"generator",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L297-L314 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | WorkflowThread.start | def start(self):
"""Starts the coordinator thread and all related worker threads."""
assert not self.interrupted
for thread in self.worker_threads:
thread.start()
WorkerThread.start(self) | python | def start(self):
"""Starts the coordinator thread and all related worker threads."""
assert not self.interrupted
for thread in self.worker_threads:
thread.start()
WorkerThread.start(self) | [
"def",
"start",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"interrupted",
"for",
"thread",
"in",
"self",
".",
"worker_threads",
":",
"thread",
".",
"start",
"(",
")",
"WorkerThread",
".",
"start",
"(",
"self",
")"
] | Starts the coordinator thread and all related worker threads. | [
"Starts",
"the",
"coordinator",
"thread",
"and",
"all",
"related",
"worker",
"threads",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L429-L434 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | WorkflowThread.stop | def stop(self):
"""Stops the coordinator thread and all related threads."""
if self.interrupted:
return
for thread in self.worker_threads:
thread.interrupted = True
self.interrupted = True | python | def stop(self):
"""Stops the coordinator thread and all related threads."""
if self.interrupted:
return
for thread in self.worker_threads:
thread.interrupted = True
self.interrupted = True | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"interrupted",
":",
"return",
"for",
"thread",
"in",
"self",
".",
"worker_threads",
":",
"thread",
".",
"interrupted",
"=",
"True",
"self",
".",
"interrupted",
"=",
"True"
] | Stops the coordinator thread and all related threads. | [
"Stops",
"the",
"coordinator",
"thread",
"and",
"all",
"related",
"threads",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L436-L442 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | WorkflowThread.join | def join(self):
"""Joins the coordinator thread and all worker threads."""
for thread in self.worker_threads:
thread.join()
WorkerThread.join(self) | python | def join(self):
"""Joins the coordinator thread and all worker threads."""
for thread in self.worker_threads:
thread.join()
WorkerThread.join(self) | [
"def",
"join",
"(",
"self",
")",
":",
"for",
"thread",
"in",
"self",
".",
"worker_threads",
":",
"thread",
".",
"join",
"(",
")",
"WorkerThread",
".",
"join",
"(",
"self",
")"
] | Joins the coordinator thread and all worker threads. | [
"Joins",
"the",
"coordinator",
"thread",
"and",
"all",
"worker",
"threads",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L444-L448 | train |
bslatkin/dpxdt | dpxdt/client/workers.py | WorkflowThread.wait_one | def wait_one(self):
"""Waits until this worker has finished one work item or died."""
while True:
try:
item = self.output_queue.get(True, self.polltime)
except Queue.Empty:
continue
except KeyboardInterrupt:
LOGGER.debug... | python | def wait_one(self):
"""Waits until this worker has finished one work item or died."""
while True:
try:
item = self.output_queue.get(True, self.polltime)
except Queue.Empty:
continue
except KeyboardInterrupt:
LOGGER.debug... | [
"def",
"wait_one",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"item",
"=",
"self",
".",
"output_queue",
".",
"get",
"(",
"True",
",",
"self",
".",
"polltime",
")",
"except",
"Queue",
".",
"Empty",
":",
"continue",
"except",
"KeyboardInter... | Waits until this worker has finished one work item or died. | [
"Waits",
"until",
"this",
"worker",
"has",
"finished",
"one",
"work",
"item",
"or",
"died",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/workers.py#L450-L462 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | superuser_required | def superuser_required(f):
"""Requires the requestor to be a super user."""
@functools.wraps(f)
@login_required
def wrapped(*args, **kwargs):
if not (current_user.is_authenticated() and current_user.superuser):
abort(403)
return f(*args, **kwargs)
return wrapped | python | def superuser_required(f):
"""Requires the requestor to be a super user."""
@functools.wraps(f)
@login_required
def wrapped(*args, **kwargs):
if not (current_user.is_authenticated() and current_user.superuser):
abort(403)
return f(*args, **kwargs)
return wrapped | [
"def",
"superuser_required",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"@",
"login_required",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"(",
"current_user",
".",
"is_authenticated",
"(",
")... | Requires the requestor to be a super user. | [
"Requires",
"the",
"requestor",
"to",
"be",
"a",
"super",
"user",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L174-L182 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | can_user_access_build | def can_user_access_build(param_name):
"""Determines if the current user can access the build ID in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
The build the user has access to.
... | python | def can_user_access_build(param_name):
"""Determines if the current user can access the build ID in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
The build the user has access to.
... | [
"def",
"can_user_access_build",
"(",
"param_name",
")",
":",
"build_id",
"=",
"(",
"request",
".",
"args",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"int",
")",
"or",
"request",
".",
"form",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"int"... | Determines if the current user can access the build ID in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
The build the user has access to. | [
"Determines",
"if",
"the",
"current",
"user",
"can",
"access",
"the",
"build",
"ID",
"in",
"the",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L185-L236 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | build_access_required | def build_access_required(function_or_param_name):
"""Decorator ensures user has access to the build ID in the request.
May be used in two ways:
@build_access_required
def my_func(build):
...
@build_access_required('custom_build_id_param')
def my_func(build):
... | python | def build_access_required(function_or_param_name):
"""Decorator ensures user has access to the build ID in the request.
May be used in two ways:
@build_access_required
def my_func(build):
...
@build_access_required('custom_build_id_param')
def my_func(build):
... | [
"def",
"build_access_required",
"(",
"function_or_param_name",
")",
":",
"def",
"get_wrapper",
"(",
"param_name",
",",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"g",
... | Decorator ensures user has access to the build ID in the request.
May be used in two ways:
@build_access_required
def my_func(build):
...
@build_access_required('custom_build_id_param')
def my_func(build):
...
Always calls the given function with the m... | [
"Decorator",
"ensures",
"user",
"has",
"access",
"to",
"the",
"build",
"ID",
"in",
"the",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L239-L268 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | _get_api_key_ops | def _get_api_key_ops():
"""Gets the operations.ApiKeyOps instance for the current request."""
auth_header = request.authorization
if not auth_header:
logging.debug('API request lacks authorization header')
abort(flask.Response(
'API key required', 401,
{'WWW-Authentic... | python | def _get_api_key_ops():
"""Gets the operations.ApiKeyOps instance for the current request."""
auth_header = request.authorization
if not auth_header:
logging.debug('API request lacks authorization header')
abort(flask.Response(
'API key required', 401,
{'WWW-Authentic... | [
"def",
"_get_api_key_ops",
"(",
")",
":",
"auth_header",
"=",
"request",
".",
"authorization",
"if",
"not",
"auth_header",
":",
"logging",
".",
"debug",
"(",
"'API request lacks authorization header'",
")",
"abort",
"(",
"flask",
".",
"Response",
"(",
"'API key re... | Gets the operations.ApiKeyOps instance for the current request. | [
"Gets",
"the",
"operations",
".",
"ApiKeyOps",
"instance",
"for",
"the",
"current",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L271-L280 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | current_api_key | def current_api_key():
"""Determines the API key for the current request.
Returns:
The ApiKey instance.
"""
if app.config.get('IGNORE_AUTH'):
return models.ApiKey(
id='anonymous_superuser',
secret='',
superuser=True)
ops = _get_api_key_ops()
... | python | def current_api_key():
"""Determines the API key for the current request.
Returns:
The ApiKey instance.
"""
if app.config.get('IGNORE_AUTH'):
return models.ApiKey(
id='anonymous_superuser',
secret='',
superuser=True)
ops = _get_api_key_ops()
... | [
"def",
"current_api_key",
"(",
")",
":",
"if",
"app",
".",
"config",
".",
"get",
"(",
"'IGNORE_AUTH'",
")",
":",
"return",
"models",
".",
"ApiKey",
"(",
"id",
"=",
"'anonymous_superuser'",
",",
"secret",
"=",
"''",
",",
"superuser",
"=",
"True",
")",
"... | Determines the API key for the current request.
Returns:
The ApiKey instance. | [
"Determines",
"the",
"API",
"key",
"for",
"the",
"current",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L283-L299 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | can_api_key_access_build | def can_api_key_access_build(param_name):
"""Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and... | python | def can_api_key_access_build(param_name):
"""Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and... | [
"def",
"can_api_key_access_build",
"(",
"param_name",
")",
":",
"build_id",
"=",
"(",
"request",
".",
"args",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"int",
")",
"or",
"request",
".",
"form",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"i... | Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to. | [
"Determines",
"if",
"the",
"current",
"API",
"key",
"can",
"access",
"the",
"build",
"in",
"the",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L302-L329 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | build_api_access_required | def build_api_access_required(f):
"""Decorator ensures API key has access to the build ID in the request.
Always calls the given function with the models.Build entity as the
first positional argument.
"""
@functools.wraps(f)
def wrapped(*args, **kwargs):
g.api_key, g.build = can_api_key... | python | def build_api_access_required(f):
"""Decorator ensures API key has access to the build ID in the request.
Always calls the given function with the models.Build entity as the
first positional argument.
"""
@functools.wraps(f)
def wrapped(*args, **kwargs):
g.api_key, g.build = can_api_key... | [
"def",
"build_api_access_required",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"g",
".",
"api_key",
",",
"g",
".",
"build",
"=",
"can_api_key_access_build",
"(",... | Decorator ensures API key has access to the build ID in the request.
Always calls the given function with the models.Build entity as the
first positional argument. | [
"Decorator",
"ensures",
"API",
"key",
"has",
"access",
"to",
"the",
"build",
"ID",
"in",
"the",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L332-L342 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | superuser_api_key_required | def superuser_api_key_required(f):
"""Decorator ensures only superuser API keys can request this function."""
@functools.wraps(f)
def wrapped(*args, **kwargs):
api_key = current_api_key()
g.api_key = api_key
utils.jsonify_assert(
api_key.superuser,
'API key=%... | python | def superuser_api_key_required(f):
"""Decorator ensures only superuser API keys can request this function."""
@functools.wraps(f)
def wrapped(*args, **kwargs):
api_key = current_api_key()
g.api_key = api_key
utils.jsonify_assert(
api_key.superuser,
'API key=%... | [
"def",
"superuser_api_key_required",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"api_key",
"=",
"current_api_key",
"(",
")",
"g",
".",
"api_key",
"=",
"api_key",... | Decorator ensures only superuser API keys can request this function. | [
"Decorator",
"ensures",
"only",
"superuser",
"API",
"keys",
"can",
"request",
"this",
"function",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L345-L359 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | manage_api_keys | def manage_api_keys():
"""Page for viewing and creating API keys."""
build = g.build
create_form = forms.CreateApiKeyForm()
if create_form.validate_on_submit():
api_key = models.ApiKey()
create_form.populate_obj(api_key)
api_key.id = utils.human_uuid()
api_key.secret = ut... | python | def manage_api_keys():
"""Page for viewing and creating API keys."""
build = g.build
create_form = forms.CreateApiKeyForm()
if create_form.validate_on_submit():
api_key = models.ApiKey()
create_form.populate_obj(api_key)
api_key.id = utils.human_uuid()
api_key.secret = ut... | [
"def",
"manage_api_keys",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"create_form",
"=",
"forms",
".",
"CreateApiKeyForm",
"(",
")",
"if",
"create_form",
".",
"validate_on_submit",
"(",
")",
":",
"api_key",
"=",
"models",
".",
"ApiKey",
"(",
")",
"c... | Page for viewing and creating API keys. | [
"Page",
"for",
"viewing",
"and",
"creating",
"API",
"keys",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L365-L404 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | revoke_api_key | def revoke_api_key():
"""Form submission handler for revoking API keys."""
build = g.build
form = forms.RevokeApiKeyForm()
if form.validate_on_submit():
api_key = models.ApiKey.query.get(form.id.data)
if api_key.build_id != build.id:
logging.debug('User does not have access t... | python | def revoke_api_key():
"""Form submission handler for revoking API keys."""
build = g.build
form = forms.RevokeApiKeyForm()
if form.validate_on_submit():
api_key = models.ApiKey.query.get(form.id.data)
if api_key.build_id != build.id:
logging.debug('User does not have access t... | [
"def",
"revoke_api_key",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"form",
"=",
"forms",
".",
"RevokeApiKeyForm",
"(",
")",
"if",
"form",
".",
"validate_on_submit",
"(",
")",
":",
"api_key",
"=",
"models",
".",
"ApiKey",
".",
"query",
".",
"get",... | Form submission handler for revoking API keys. | [
"Form",
"submission",
"handler",
"for",
"revoking",
"API",
"keys",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L410-L430 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | claim_invitations | def claim_invitations(user):
"""Claims any pending invitations for the given user's email address."""
# See if there are any build invitations present for the user with this
# email address. If so, replace all those invitations with the real user.
invitation_user_id = '%s:%s' % (
models.User.EMA... | python | def claim_invitations(user):
"""Claims any pending invitations for the given user's email address."""
# See if there are any build invitations present for the user with this
# email address. If so, replace all those invitations with the real user.
invitation_user_id = '%s:%s' % (
models.User.EMA... | [
"def",
"claim_invitations",
"(",
"user",
")",
":",
"invitation_user_id",
"=",
"'%s:%s'",
"%",
"(",
"models",
".",
"User",
".",
"EMAIL_INVITATION",
",",
"user",
".",
"email_address",
")",
"invitation_user",
"=",
"models",
".",
"User",
".",
"query",
".",
"get"... | Claims any pending invitations for the given user's email address. | [
"Claims",
"any",
"pending",
"invitations",
"for",
"the",
"given",
"user",
"s",
"email",
"address",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L433-L463 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | manage_admins | def manage_admins():
"""Page for viewing and managing build admins."""
build = g.build
# Do not show cached data
db.session.add(build)
db.session.refresh(build)
add_form = forms.AddAdminForm()
if add_form.validate_on_submit():
invitation_user_id = '%s:%s' % (
models.Us... | python | def manage_admins():
"""Page for viewing and managing build admins."""
build = g.build
# Do not show cached data
db.session.add(build)
db.session.refresh(build)
add_form = forms.AddAdminForm()
if add_form.validate_on_submit():
invitation_user_id = '%s:%s' % (
models.Us... | [
"def",
"manage_admins",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"db",
".",
"session",
".",
"add",
"(",
"build",
")",
"db",
".",
"session",
".",
"refresh",
"(",
"build",
")",
"add_form",
"=",
"forms",
".",
"AddAdminForm",
"(",
")",
"if",
"ad... | Page for viewing and managing build admins. | [
"Page",
"for",
"viewing",
"and",
"managing",
"build",
"admins",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L469-L518 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | revoke_admin | def revoke_admin():
"""Form submission handler for revoking admin access to a build."""
build = g.build
form = forms.RemoveAdminForm()
if form.validate_on_submit():
user = models.User.query.get(form.user_id.data)
if not user:
logging.debug('User being revoked admin access doe... | python | def revoke_admin():
"""Form submission handler for revoking admin access to a build."""
build = g.build
form = forms.RemoveAdminForm()
if form.validate_on_submit():
user = models.User.query.get(form.user_id.data)
if not user:
logging.debug('User being revoked admin access doe... | [
"def",
"revoke_admin",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"form",
"=",
"forms",
".",
"RemoveAdminForm",
"(",
")",
"if",
"form",
".",
"validate_on_submit",
"(",
")",
":",
"user",
"=",
"models",
".",
"User",
".",
"query",
".",
"get",
"(",
... | Form submission handler for revoking admin access to a build. | [
"Form",
"submission",
"handler",
"for",
"revoking",
"admin",
"access",
"to",
"a",
"build",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L524-L558 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | save_admin_log | def save_admin_log(build, **kwargs):
"""Saves an action to the admin log."""
message = kwargs.pop('message', None)
release = kwargs.pop('release', None)
run = kwargs.pop('run', None)
if not len(kwargs) == 1:
raise TypeError('Must specify a LOG_TYPE argument')
log_enum = kwargs.keys()[0... | python | def save_admin_log(build, **kwargs):
"""Saves an action to the admin log."""
message = kwargs.pop('message', None)
release = kwargs.pop('release', None)
run = kwargs.pop('run', None)
if not len(kwargs) == 1:
raise TypeError('Must specify a LOG_TYPE argument')
log_enum = kwargs.keys()[0... | [
"def",
"save_admin_log",
"(",
"build",
",",
"**",
"kwargs",
")",
":",
"message",
"=",
"kwargs",
".",
"pop",
"(",
"'message'",
",",
"None",
")",
"release",
"=",
"kwargs",
".",
"pop",
"(",
"'release'",
",",
"None",
")",
"run",
"=",
"kwargs",
".",
"pop"... | Saves an action to the admin log. | [
"Saves",
"an",
"action",
"to",
"the",
"admin",
"log",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L561-L593 | train |
bslatkin/dpxdt | dpxdt/server/auth.py | view_admin_log | def view_admin_log():
"""Page for viewing the log of admin activity."""
build = g.build
# TODO: Add paging
log_list = (
models.AdminLog.query
.filter_by(build_id=build.id)
.order_by(models.AdminLog.created.desc())
.all())
return render_template(
'view_admin... | python | def view_admin_log():
"""Page for viewing the log of admin activity."""
build = g.build
# TODO: Add paging
log_list = (
models.AdminLog.query
.filter_by(build_id=build.id)
.order_by(models.AdminLog.created.desc())
.all())
return render_template(
'view_admin... | [
"def",
"view_admin_log",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"log_list",
"=",
"(",
"models",
".",
"AdminLog",
".",
"query",
".",
"filter_by",
"(",
"build_id",
"=",
"build",
".",
"id",
")",
".",
"order_by",
"(",
"models",
".",
"AdminLog",
... | Page for viewing the log of admin activity. | [
"Page",
"for",
"viewing",
"the",
"log",
"of",
"admin",
"activity",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L599-L614 | train |
bslatkin/dpxdt | dpxdt/client/utils.py | verify_binary | def verify_binary(flag_name, process_args=None):
"""Exits the program if the binary from the given flag doesn't run.
Args:
flag_name: Name of the flag that should be the path to the binary.
process_args: Args to pass to the binary to do nothing but verify
that it's working correctly... | python | def verify_binary(flag_name, process_args=None):
"""Exits the program if the binary from the given flag doesn't run.
Args:
flag_name: Name of the flag that should be the path to the binary.
process_args: Args to pass to the binary to do nothing but verify
that it's working correctly... | [
"def",
"verify_binary",
"(",
"flag_name",
",",
"process_args",
"=",
"None",
")",
":",
"if",
"process_args",
"is",
"None",
":",
"process_args",
"=",
"[",
"]",
"path",
"=",
"getattr",
"(",
"FLAGS",
",",
"flag_name",
")",
"if",
"not",
"path",
":",
"logging"... | Exits the program if the binary from the given flag doesn't run.
Args:
flag_name: Name of the flag that should be the path to the binary.
process_args: Args to pass to the binary to do nothing but verify
that it's working correctly (something like "--version") is good.
Optio... | [
"Exits",
"the",
"program",
"if",
"the",
"binary",
"from",
"the",
"given",
"flag",
"doesn",
"t",
"run",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/utils.py#L28-L57 | train |
bslatkin/dpxdt | dpxdt/server/api.py | create_release | def create_release():
"""Creates a new release candidate for a build."""
build = g.build
release_name = request.form.get('release_name')
utils.jsonify_assert(release_name, 'release_name required')
url = request.form.get('url')
utils.jsonify_assert(release_name, 'url required')
release = mod... | python | def create_release():
"""Creates a new release candidate for a build."""
build = g.build
release_name = request.form.get('release_name')
utils.jsonify_assert(release_name, 'release_name required')
url = request.form.get('url')
utils.jsonify_assert(release_name, 'url required')
release = mod... | [
"def",
"create_release",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"release_name",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'release_name'",
")",
"utils",
".",
"jsonify_assert",
"(",
"release_name",
",",
"'release_name required'",
")",
"url",
"="... | Creates a new release candidate for a build. | [
"Creates",
"a",
"new",
"release",
"candidate",
"for",
"a",
"build",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L109-L154 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _check_release_done_processing | def _check_release_done_processing(release):
"""Moves a release candidate to reviewing if all runs are done."""
if release.status != models.Release.PROCESSING:
# NOTE: This statement also guards for situations where the user has
# prematurely specified that the release is good or bad. Once the u... | python | def _check_release_done_processing(release):
"""Moves a release candidate to reviewing if all runs are done."""
if release.status != models.Release.PROCESSING:
# NOTE: This statement also guards for situations where the user has
# prematurely specified that the release is good or bad. Once the u... | [
"def",
"_check_release_done_processing",
"(",
"release",
")",
":",
"if",
"release",
".",
"status",
"!=",
"models",
".",
"Release",
".",
"PROCESSING",
":",
"logging",
".",
"info",
"(",
"'Release not in processing state yet: build_id=%r, '",
"'name=%r, number=%d'",
",",
... | Moves a release candidate to reviewing if all runs are done. | [
"Moves",
"a",
"release",
"candidate",
"to",
"reviewing",
"if",
"all",
"runs",
"are",
"done",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L157-L197 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _get_release_params | def _get_release_params():
"""Gets the release params from the current request."""
release_name = request.form.get('release_name')
utils.jsonify_assert(release_name, 'release_name required')
release_number = request.form.get('release_number', type=int)
utils.jsonify_assert(release_number is not None... | python | def _get_release_params():
"""Gets the release params from the current request."""
release_name = request.form.get('release_name')
utils.jsonify_assert(release_name, 'release_name required')
release_number = request.form.get('release_number', type=int)
utils.jsonify_assert(release_number is not None... | [
"def",
"_get_release_params",
"(",
")",
":",
"release_name",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'release_name'",
")",
"utils",
".",
"jsonify_assert",
"(",
"release_name",
",",
"'release_name required'",
")",
"release_number",
"=",
"request",
".",
"fo... | Gets the release params from the current request. | [
"Gets",
"the",
"release",
"params",
"from",
"the",
"current",
"request",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L200-L206 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _find_last_good_run | def _find_last_good_run(build):
"""Finds the last good release and run for a build."""
run_name = request.form.get('run_name', type=str)
utils.jsonify_assert(run_name, 'run_name required')
last_good_release = (
models.Release.query
.filter_by(
build_id=build.id,
... | python | def _find_last_good_run(build):
"""Finds the last good release and run for a build."""
run_name = request.form.get('run_name', type=str)
utils.jsonify_assert(run_name, 'run_name required')
last_good_release = (
models.Release.query
.filter_by(
build_id=build.id,
... | [
"def",
"_find_last_good_run",
"(",
"build",
")",
":",
"run_name",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'run_name'",
",",
"type",
"=",
"str",
")",
"utils",
".",
"jsonify_assert",
"(",
"run_name",
",",
"'run_name required'",
")",
"last_good_release",
... | Finds the last good release and run for a build. | [
"Finds",
"the",
"last",
"good",
"release",
"and",
"run",
"for",
"a",
"build",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L209-L240 | train |
bslatkin/dpxdt | dpxdt/server/api.py | find_run | def find_run():
"""Finds the last good run of the given name for a release."""
build = g.build
last_good_release, last_good_run = _find_last_good_run(build)
if last_good_run:
return flask.jsonify(
success=True,
build_id=build.id,
release_name=last_good_releas... | python | def find_run():
"""Finds the last good run of the given name for a release."""
build = g.build
last_good_release, last_good_run = _find_last_good_run(build)
if last_good_run:
return flask.jsonify(
success=True,
build_id=build.id,
release_name=last_good_releas... | [
"def",
"find_run",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"last_good_release",
",",
"last_good_run",
"=",
"_find_last_good_run",
"(",
"build",
")",
"if",
"last_good_run",
":",
"return",
"flask",
".",
"jsonify",
"(",
"success",
"=",
"True",
",",
"b... | Finds the last good run of the given name for a release. | [
"Finds",
"the",
"last",
"good",
"run",
"of",
"the",
"given",
"name",
"for",
"a",
"release",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L245-L262 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _get_or_create_run | def _get_or_create_run(build):
"""Gets a run for a build or creates it if it does not exist."""
release_name, release_number = _get_release_params()
run_name = request.form.get('run_name', type=str)
utils.jsonify_assert(run_name, 'run_name required')
release = (
models.Release.query
... | python | def _get_or_create_run(build):
"""Gets a run for a build or creates it if it does not exist."""
release_name, release_number = _get_release_params()
run_name = request.form.get('run_name', type=str)
utils.jsonify_assert(run_name, 'run_name required')
release = (
models.Release.query
... | [
"def",
"_get_or_create_run",
"(",
"build",
")",
":",
"release_name",
",",
"release_number",
"=",
"_get_release_params",
"(",
")",
"run_name",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'run_name'",
",",
"type",
"=",
"str",
")",
"utils",
".",
"jsonify_ass... | Gets a run for a build or creates it if it does not exist. | [
"Gets",
"a",
"run",
"for",
"a",
"build",
"or",
"creates",
"it",
"if",
"it",
"does",
"not",
"exist",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L265-L293 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _enqueue_capture | def _enqueue_capture(build, release, run, url, config_data, baseline=False):
"""Enqueues a task to run a capture process."""
# Validate the JSON config parses.
try:
config_dict = json.loads(config_data)
except Exception, e:
abort(utils.jsonify_error(e))
# Rewrite the config JSON to ... | python | def _enqueue_capture(build, release, run, url, config_data, baseline=False):
"""Enqueues a task to run a capture process."""
# Validate the JSON config parses.
try:
config_dict = json.loads(config_data)
except Exception, e:
abort(utils.jsonify_error(e))
# Rewrite the config JSON to ... | [
"def",
"_enqueue_capture",
"(",
"build",
",",
"release",
",",
"run",
",",
"url",
",",
"config_data",
",",
"baseline",
"=",
"False",
")",
":",
"try",
":",
"config_dict",
"=",
"json",
".",
"loads",
"(",
"config_data",
")",
"except",
"Exception",
",",
"e",
... | Enqueues a task to run a capture process. | [
"Enqueues",
"a",
"task",
"to",
"run",
"a",
"capture",
"process",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L296-L344 | train |
bslatkin/dpxdt | dpxdt/server/api.py | request_run | def request_run():
"""Requests a new run for a release candidate."""
build = g.build
current_release, current_run = _get_or_create_run(build)
current_url = request.form.get('url', type=str)
config_data = request.form.get('config', default='{}', type=str)
utils.jsonify_assert(current_url, 'url t... | python | def request_run():
"""Requests a new run for a release candidate."""
build = g.build
current_release, current_run = _get_or_create_run(build)
current_url = request.form.get('url', type=str)
config_data = request.form.get('config', default='{}', type=str)
utils.jsonify_assert(current_url, 'url t... | [
"def",
"request_run",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"current_release",
",",
"current_run",
"=",
"_get_or_create_run",
"(",
"build",
")",
"current_url",
"=",
"request",
".",
"form",
".",
"get",
"(",
"'url'",
",",
"type",
"=",
"str",
")",... | Requests a new run for a release candidate. | [
"Requests",
"a",
"new",
"run",
"for",
"a",
"release",
"candidate",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L350-L396 | train |
bslatkin/dpxdt | dpxdt/server/api.py | runs_done | def runs_done():
"""Marks a release candidate as having all runs reported."""
build = g.build
release_name, release_number = _get_release_params()
release = (
models.Release.query
.filter_by(build_id=build.id, name=release_name, number=release_number)
.with_lockmode('update')
... | python | def runs_done():
"""Marks a release candidate as having all runs reported."""
build = g.build
release_name, release_number = _get_release_params()
release = (
models.Release.query
.filter_by(build_id=build.id, name=release_name, number=release_number)
.with_lockmode('update')
... | [
"def",
"runs_done",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"release_name",
",",
"release_number",
"=",
"_get_release_params",
"(",
")",
"release",
"=",
"(",
"models",
".",
"Release",
".",
"query",
".",
"filter_by",
"(",
"build_id",
"=",
"build",
... | Marks a release candidate as having all runs reported. | [
"Marks",
"a",
"release",
"candidate",
"as",
"having",
"all",
"runs",
"reported",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L531-L562 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _save_artifact | def _save_artifact(build, data, content_type):
"""Saves an artifact to the DB and returns it."""
sha1sum = hashlib.sha1(data).hexdigest()
artifact = models.Artifact.query.filter_by(id=sha1sum).first()
if artifact:
logging.debug('Upload already exists: artifact_id=%r', sha1sum)
else:
log... | python | def _save_artifact(build, data, content_type):
"""Saves an artifact to the DB and returns it."""
sha1sum = hashlib.sha1(data).hexdigest()
artifact = models.Artifact.query.filter_by(id=sha1sum).first()
if artifact:
logging.debug('Upload already exists: artifact_id=%r', sha1sum)
else:
log... | [
"def",
"_save_artifact",
"(",
"build",
",",
"data",
",",
"content_type",
")",
":",
"sha1sum",
"=",
"hashlib",
".",
"sha1",
"(",
"data",
")",
".",
"hexdigest",
"(",
")",
"artifact",
"=",
"models",
".",
"Artifact",
".",
"query",
".",
"filter_by",
"(",
"i... | Saves an artifact to the DB and returns it. | [
"Saves",
"an",
"artifact",
"to",
"the",
"DB",
"and",
"returns",
"it",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L575-L592 | train |
bslatkin/dpxdt | dpxdt/server/api.py | upload | def upload():
"""Uploads an artifact referenced by a run."""
build = g.build
utils.jsonify_assert(len(request.files) == 1,
'Need exactly one uploaded file')
file_storage = request.files.values()[0]
data = file_storage.read()
content_type, _ = mimetypes.guess_type(file_s... | python | def upload():
"""Uploads an artifact referenced by a run."""
build = g.build
utils.jsonify_assert(len(request.files) == 1,
'Need exactly one uploaded file')
file_storage = request.files.values()[0]
data = file_storage.read()
content_type, _ = mimetypes.guess_type(file_s... | [
"def",
"upload",
"(",
")",
":",
"build",
"=",
"g",
".",
"build",
"utils",
".",
"jsonify_assert",
"(",
"len",
"(",
"request",
".",
"files",
")",
"==",
"1",
",",
"'Need exactly one uploaded file'",
")",
"file_storage",
"=",
"request",
".",
"files",
".",
"v... | Uploads an artifact referenced by a run. | [
"Uploads",
"an",
"artifact",
"referenced",
"by",
"a",
"run",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L598-L617 | train |
bslatkin/dpxdt | dpxdt/server/api.py | _get_artifact_response | def _get_artifact_response(artifact):
"""Gets the response object for the given artifact.
This method may be overridden in environments that have a different way of
storing artifact files, such as on-disk or S3.
"""
response = flask.Response(
artifact.data,
mimetype=artifact.content... | python | def _get_artifact_response(artifact):
"""Gets the response object for the given artifact.
This method may be overridden in environments that have a different way of
storing artifact files, such as on-disk or S3.
"""
response = flask.Response(
artifact.data,
mimetype=artifact.content... | [
"def",
"_get_artifact_response",
"(",
"artifact",
")",
":",
"response",
"=",
"flask",
".",
"Response",
"(",
"artifact",
".",
"data",
",",
"mimetype",
"=",
"artifact",
".",
"content_type",
")",
"response",
".",
"cache_control",
".",
"public",
"=",
"True",
"re... | Gets the response object for the given artifact.
This method may be overridden in environments that have a different way of
storing artifact files, such as on-disk or S3. | [
"Gets",
"the",
"response",
"object",
"for",
"the",
"given",
"artifact",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L620-L632 | train |
bslatkin/dpxdt | dpxdt/server/api.py | download | def download():
"""Downloads an artifact by it's content hash."""
# Allow users with access to the build to download the file. Falls back
# to API keys with access to the build. Prefer user first for speed.
try:
build = auth.can_user_access_build('build_id')
except HTTPException:
log... | python | def download():
"""Downloads an artifact by it's content hash."""
# Allow users with access to the build to download the file. Falls back
# to API keys with access to the build. Prefer user first for speed.
try:
build = auth.can_user_access_build('build_id')
except HTTPException:
log... | [
"def",
"download",
"(",
")",
":",
"try",
":",
"build",
"=",
"auth",
".",
"can_user_access_build",
"(",
"'build_id'",
")",
"except",
"HTTPException",
":",
"logging",
".",
"debug",
"(",
"'User access to artifact failed. Trying API key.'",
")",
"_",
",",
"build",
"... | Downloads an artifact by it's content hash. | [
"Downloads",
"an",
"artifact",
"by",
"it",
"s",
"content",
"hash",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/api.py#L636-L682 | train |
bslatkin/dpxdt | dpxdt/server/operations.py | BaseOps.evict | def evict(self):
"""Evict all caches related to these operations."""
logging.debug('Evicting cache for %r', self.cache_key)
_clear_version_cache(self.cache_key)
# Cause the cache key to be refreshed next time any operation is
# run to make sure we don't act on old cached data.
... | python | def evict(self):
"""Evict all caches related to these operations."""
logging.debug('Evicting cache for %r', self.cache_key)
_clear_version_cache(self.cache_key)
# Cause the cache key to be refreshed next time any operation is
# run to make sure we don't act on old cached data.
... | [
"def",
"evict",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"'Evicting cache for %r'",
",",
"self",
".",
"cache_key",
")",
"_clear_version_cache",
"(",
"self",
".",
"cache_key",
")",
"self",
".",
"versioned_cache_key",
"=",
"None"
] | Evict all caches related to these operations. | [
"Evict",
"all",
"caches",
"related",
"to",
"these",
"operations",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/operations.py#L72-L78 | train |
bslatkin/dpxdt | dpxdt/server/operations.py | BuildOps.sort_run | def sort_run(run):
"""Sort function for runs within a release."""
# Sort errors first, then by name. Also show errors that were manually
# approved, so the paging sort order stays the same even after users
# approve a diff on the run page.
if run.status in models.Run.DIFF_NEEDED_... | python | def sort_run(run):
"""Sort function for runs within a release."""
# Sort errors first, then by name. Also show errors that were manually
# approved, so the paging sort order stays the same even after users
# approve a diff on the run page.
if run.status in models.Run.DIFF_NEEDED_... | [
"def",
"sort_run",
"(",
"run",
")",
":",
"if",
"run",
".",
"status",
"in",
"models",
".",
"Run",
".",
"DIFF_NEEDED_STATES",
":",
"return",
"(",
"0",
",",
"run",
".",
"name",
")",
"return",
"(",
"1",
",",
"run",
".",
"name",
")"
] | Sort function for runs within a release. | [
"Sort",
"function",
"for",
"runs",
"within",
"a",
"release",
"."
] | 9f860de1731021d99253670429e5f2157e1f6297 | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/operations.py#L170-L177 | train |
podio/valideer | valideer/base.py | parse | def parse(obj, required_properties=None, additional_properties=None,
ignore_optional_property_errors=None):
"""Try to parse the given ``obj`` as a validator instance.
:param obj: The object to be parsed. If it is a...:
- :py:class:`Validator` instance, return it.
- :py:class:`Validat... | python | def parse(obj, required_properties=None, additional_properties=None,
ignore_optional_property_errors=None):
"""Try to parse the given ``obj`` as a validator instance.
:param obj: The object to be parsed. If it is a...:
- :py:class:`Validator` instance, return it.
- :py:class:`Validat... | [
"def",
"parse",
"(",
"obj",
",",
"required_properties",
"=",
"None",
",",
"additional_properties",
"=",
"None",
",",
"ignore_optional_property_errors",
"=",
"None",
")",
":",
"if",
"not",
"(",
"required_properties",
"is",
"additional_properties",
"is",
"ignore_optio... | Try to parse the given ``obj`` as a validator instance.
:param obj: The object to be parsed. If it is a...:
- :py:class:`Validator` instance, return it.
- :py:class:`Validator` subclass, instantiate it without arguments and
return it.
- :py:attr:`~Validator.name` of a known :py:c... | [
"Try",
"to",
"parse",
"the",
"given",
"obj",
"as",
"a",
"validator",
"instance",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L60-L165 | train |
podio/valideer | valideer/base.py | parsing | def parsing(**kwargs):
"""
Context manager for overriding the default validator parsing rules for the
following code block.
"""
from .validators import Object
with _VALIDATOR_FACTORIES_LOCK:
old_values = {}
for key, value in iteritems(kwargs):
if value is not None:
... | python | def parsing(**kwargs):
"""
Context manager for overriding the default validator parsing rules for the
following code block.
"""
from .validators import Object
with _VALIDATOR_FACTORIES_LOCK:
old_values = {}
for key, value in iteritems(kwargs):
if value is not None:
... | [
"def",
"parsing",
"(",
"**",
"kwargs",
")",
":",
"from",
".",
"validators",
"import",
"Object",
"with",
"_VALIDATOR_FACTORIES_LOCK",
":",
"old_values",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"value",
... | Context manager for overriding the default validator parsing rules for the
following code block. | [
"Context",
"manager",
"for",
"overriding",
"the",
"default",
"validator",
"parsing",
"rules",
"for",
"the",
"following",
"code",
"block",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L169-L188 | train |
podio/valideer | valideer/base.py | register | def register(name, validator):
"""Register a validator instance under the given ``name``."""
if not isinstance(validator, Validator):
raise TypeError("Validator instance expected, %s given" % validator.__class__)
_NAMED_VALIDATORS[name] = validator | python | def register(name, validator):
"""Register a validator instance under the given ``name``."""
if not isinstance(validator, Validator):
raise TypeError("Validator instance expected, %s given" % validator.__class__)
_NAMED_VALIDATORS[name] = validator | [
"def",
"register",
"(",
"name",
",",
"validator",
")",
":",
"if",
"not",
"isinstance",
"(",
"validator",
",",
"Validator",
")",
":",
"raise",
"TypeError",
"(",
"\"Validator instance expected, %s given\"",
"%",
"validator",
".",
"__class__",
")",
"_NAMED_VALIDATORS... | Register a validator instance under the given ``name``. | [
"Register",
"a",
"validator",
"instance",
"under",
"the",
"given",
"name",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L191-L195 | train |
podio/valideer | valideer/base.py | accepts | def accepts(**schemas):
"""Create a decorator for validating function parameters.
Example::
@accepts(a="number", body={"+field_ids": [int], "is_ok": bool})
def f(a, body):
print (a, body["field_ids"], body.get("is_ok"))
:param schemas: The schema for validating a given paramet... | python | def accepts(**schemas):
"""Create a decorator for validating function parameters.
Example::
@accepts(a="number", body={"+field_ids": [int], "is_ok": bool})
def f(a, body):
print (a, body["field_ids"], body.get("is_ok"))
:param schemas: The schema for validating a given paramet... | [
"def",
"accepts",
"(",
"**",
"schemas",
")",
":",
"validate",
"=",
"parse",
"(",
"schemas",
")",
".",
"validate",
"@",
"decorator",
"def",
"validating",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"validate",
"(",
"inspect",
".",
"g... | Create a decorator for validating function parameters.
Example::
@accepts(a="number", body={"+field_ids": [int], "is_ok": bool})
def f(a, body):
print (a, body["field_ids"], body.get("is_ok"))
:param schemas: The schema for validating a given parameter. | [
"Create",
"a",
"decorator",
"for",
"validating",
"function",
"parameters",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L272-L289 | train |
podio/valideer | valideer/base.py | returns | def returns(schema):
"""Create a decorator for validating function return value.
Example::
@accepts(a=int, b=int)
@returns(int)
def f(a, b):
return a + b
:param schema: The schema for adapting a given parameter.
"""
validate = parse(schema).validate
@decora... | python | def returns(schema):
"""Create a decorator for validating function return value.
Example::
@accepts(a=int, b=int)
@returns(int)
def f(a, b):
return a + b
:param schema: The schema for adapting a given parameter.
"""
validate = parse(schema).validate
@decora... | [
"def",
"returns",
"(",
"schema",
")",
":",
"validate",
"=",
"parse",
"(",
"schema",
")",
".",
"validate",
"@",
"decorator",
"def",
"validating",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ret",
"=",
"func",
"(",
"*",
"args",
","... | Create a decorator for validating function return value.
Example::
@accepts(a=int, b=int)
@returns(int)
def f(a, b):
return a + b
:param schema: The schema for adapting a given parameter. | [
"Create",
"a",
"decorator",
"for",
"validating",
"function",
"return",
"value",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L292-L310 | train |
podio/valideer | valideer/base.py | adapts | def adapts(**schemas):
"""Create a decorator for validating and adapting function parameters.
Example::
@adapts(a="number", body={"+field_ids": [V.AdaptTo(int)], "is_ok": bool})
def f(a, body):
print (a, body.field_ids, body.is_ok)
:param schemas: The schema for adapting a giv... | python | def adapts(**schemas):
"""Create a decorator for validating and adapting function parameters.
Example::
@adapts(a="number", body={"+field_ids": [V.AdaptTo(int)], "is_ok": bool})
def f(a, body):
print (a, body.field_ids, body.is_ok)
:param schemas: The schema for adapting a giv... | [
"def",
"adapts",
"(",
"**",
"schemas",
")",
":",
"validate",
"=",
"parse",
"(",
"schemas",
")",
".",
"validate",
"@",
"decorator",
"def",
"adapting",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"adapted",
"=",
"validate",
"(",
"insp... | Create a decorator for validating and adapting function parameters.
Example::
@adapts(a="number", body={"+field_ids": [V.AdaptTo(int)], "is_ok": bool})
def f(a, body):
print (a, body.field_ids, body.is_ok)
:param schemas: The schema for adapting a given parameter. | [
"Create",
"a",
"decorator",
"for",
"validating",
"and",
"adapting",
"function",
"parameters",
"."
] | d35be173cb40c9fa1adb879673786b346b6841db | https://github.com/podio/valideer/blob/d35be173cb40c9fa1adb879673786b346b6841db/valideer/base.py#L313-L346 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/client_side_checksum_handler.py | ClientSideChecksumHandler.get_checksum_metadata_tag | def get_checksum_metadata_tag(self):
""" Returns a map of checksum values by the name of the hashing function that produced it."""
if not self._checksums:
print("Warning: No checksums have been computed for this file.")
return {str(_hash_name): str(_hash_value) for _hash_name, _hash_... | python | def get_checksum_metadata_tag(self):
""" Returns a map of checksum values by the name of the hashing function that produced it."""
if not self._checksums:
print("Warning: No checksums have been computed for this file.")
return {str(_hash_name): str(_hash_value) for _hash_name, _hash_... | [
"def",
"get_checksum_metadata_tag",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_checksums",
":",
"print",
"(",
"\"Warning: No checksums have been computed for this file.\"",
")",
"return",
"{",
"str",
"(",
"_hash_name",
")",
":",
"str",
"(",
"_hash_value",
... | Returns a map of checksum values by the name of the hashing function that produced it. | [
"Returns",
"a",
"map",
"of",
"checksum",
"values",
"by",
"the",
"name",
"of",
"the",
"hashing",
"function",
"that",
"produced",
"it",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/client_side_checksum_handler.py#L20-L24 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/client_side_checksum_handler.py | ClientSideChecksumHandler.compute_checksum | def compute_checksum(self):
""" Calculates checksums for a given file. """
if self._filename.startswith("s3://"):
print("Warning: Did not perform client-side checksumming for file in S3. To be implemented.")
pass
else:
checksumCalculator = self.ChecksumCalcula... | python | def compute_checksum(self):
""" Calculates checksums for a given file. """
if self._filename.startswith("s3://"):
print("Warning: Did not perform client-side checksumming for file in S3. To be implemented.")
pass
else:
checksumCalculator = self.ChecksumCalcula... | [
"def",
"compute_checksum",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filename",
".",
"startswith",
"(",
"\"s3://\"",
")",
":",
"print",
"(",
"\"Warning: Did not perform client-side checksumming for file in S3. To be implemented.\"",
")",
"pass",
"else",
":",
"checksum... | Calculates checksums for a given file. | [
"Calculates",
"checksums",
"for",
"a",
"given",
"file",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/client_side_checksum_handler.py#L26-L33 | train |
HumanCellAtlas/dcp-cli | hca/upload/upload_area.py | UploadArea.upload_files | def upload_files(self, file_paths, file_size_sum=0, dcp_type="data", target_filename=None,
use_transfer_acceleration=True, report_progress=False, sync=True):
"""
A function that takes in a list of file paths and other optional args for parallel file upload
"""
self._... | python | def upload_files(self, file_paths, file_size_sum=0, dcp_type="data", target_filename=None,
use_transfer_acceleration=True, report_progress=False, sync=True):
"""
A function that takes in a list of file paths and other optional args for parallel file upload
"""
self._... | [
"def",
"upload_files",
"(",
"self",
",",
"file_paths",
",",
"file_size_sum",
"=",
"0",
",",
"dcp_type",
"=",
"\"data\"",
",",
"target_filename",
"=",
"None",
",",
"use_transfer_acceleration",
"=",
"True",
",",
"report_progress",
"=",
"False",
",",
"sync",
"=",... | A function that takes in a list of file paths and other optional args for parallel file upload | [
"A",
"function",
"that",
"takes",
"in",
"a",
"list",
"of",
"file",
"paths",
"and",
"other",
"optional",
"args",
"for",
"parallel",
"file",
"upload"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/upload_area.py#L109-L138 | train |
HumanCellAtlas/dcp-cli | hca/upload/upload_area.py | UploadArea.validation_status | def validation_status(self, filename):
"""
Get status and results of latest validation job for a file.
:param str filename: The name of the file within the Upload Area
:return: a dict with validation information
:rtype: dict
:raises UploadApiException: if information cou... | python | def validation_status(self, filename):
"""
Get status and results of latest validation job for a file.
:param str filename: The name of the file within the Upload Area
:return: a dict with validation information
:rtype: dict
:raises UploadApiException: if information cou... | [
"def",
"validation_status",
"(",
"self",
",",
"filename",
")",
":",
"return",
"self",
".",
"upload_service",
".",
"api_client",
".",
"validation_status",
"(",
"area_uuid",
"=",
"self",
".",
"uuid",
",",
"filename",
"=",
"filename",
")"
] | Get status and results of latest validation job for a file.
:param str filename: The name of the file within the Upload Area
:return: a dict with validation information
:rtype: dict
:raises UploadApiException: if information could not be obtained | [
"Get",
"status",
"and",
"results",
"of",
"latest",
"validation",
"job",
"for",
"a",
"file",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/upload_area.py#L181-L190 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/s3_agent.py | S3Agent._item_exists_in_bucket | def _item_exists_in_bucket(self, bucket, key, checksums):
""" Returns true if the key already exists in the current bucket and the clientside checksum matches the
file's checksums, and false otherwise."""
try:
obj = self.target_s3.meta.client.head_object(Bucket=bucket, Key=key)
... | python | def _item_exists_in_bucket(self, bucket, key, checksums):
""" Returns true if the key already exists in the current bucket and the clientside checksum matches the
file's checksums, and false otherwise."""
try:
obj = self.target_s3.meta.client.head_object(Bucket=bucket, Key=key)
... | [
"def",
"_item_exists_in_bucket",
"(",
"self",
",",
"bucket",
",",
"key",
",",
"checksums",
")",
":",
"try",
":",
"obj",
"=",
"self",
".",
"target_s3",
".",
"meta",
".",
"client",
".",
"head_object",
"(",
"Bucket",
"=",
"bucket",
",",
"Key",
"=",
"key",... | Returns true if the key already exists in the current bucket and the clientside checksum matches the
file's checksums, and false otherwise. | [
"Returns",
"true",
"if",
"the",
"key",
"already",
"exists",
"in",
"the",
"current",
"bucket",
"and",
"the",
"clientside",
"checksum",
"matches",
"the",
"file",
"s",
"checksums",
"and",
"false",
"otherwise",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/s3_agent.py#L130-L141 | train |
HumanCellAtlas/dcp-cli | hca/dss/upload_to_cloud.py | upload_to_cloud | def upload_to_cloud(file_handles, staging_bucket, replica, from_cloud=False):
"""
Upload files to cloud.
:param file_handles: If from_cloud, file_handles is a aws s3 directory path to files with appropriate
metadata uploaded. Else, a list of binary file_handles to upload.
:para... | python | def upload_to_cloud(file_handles, staging_bucket, replica, from_cloud=False):
"""
Upload files to cloud.
:param file_handles: If from_cloud, file_handles is a aws s3 directory path to files with appropriate
metadata uploaded. Else, a list of binary file_handles to upload.
:para... | [
"def",
"upload_to_cloud",
"(",
"file_handles",
",",
"staging_bucket",
",",
"replica",
",",
"from_cloud",
"=",
"False",
")",
":",
"s3",
"=",
"boto3",
".",
"resource",
"(",
"\"s3\"",
")",
"file_uuids",
"=",
"[",
"]",
"key_names",
"=",
"[",
"]",
"abs_file_pat... | Upload files to cloud.
:param file_handles: If from_cloud, file_handles is a aws s3 directory path to files with appropriate
metadata uploaded. Else, a list of binary file_handles to upload.
:param staging_bucket: The aws bucket to upload the files to.
:param replica: The cloud rep... | [
"Upload",
"files",
"to",
"cloud",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/upload_to_cloud.py#L53-L102 | train |
HumanCellAtlas/dcp-cli | hca/dss/__init__.py | DSSClient.download | def download(self, bundle_uuid, replica, version="", download_dir="",
metadata_files=('*',), data_files=('*',),
num_retries=10, min_delay_seconds=0.25):
"""
Download a bundle and save it to the local filesystem as a directory.
:param str bundle_uuid: The uuid o... | python | def download(self, bundle_uuid, replica, version="", download_dir="",
metadata_files=('*',), data_files=('*',),
num_retries=10, min_delay_seconds=0.25):
"""
Download a bundle and save it to the local filesystem as a directory.
:param str bundle_uuid: The uuid o... | [
"def",
"download",
"(",
"self",
",",
"bundle_uuid",
",",
"replica",
",",
"version",
"=",
"\"\"",
",",
"download_dir",
"=",
"\"\"",
",",
"metadata_files",
"=",
"(",
"'*'",
",",
")",
",",
"data_files",
"=",
"(",
"'*'",
",",
")",
",",
"num_retries",
"=",
... | Download a bundle and save it to the local filesystem as a directory.
:param str bundle_uuid: The uuid of the bundle to download
:param str replica: the replica to download from. The supported replicas are: `aws` for Amazon Web Services, and
`gcp` for Google Cloud Platform. [aws, gcp]
... | [
"Download",
"a",
"bundle",
"and",
"save",
"it",
"to",
"the",
"local",
"filesystem",
"as",
"a",
"directory",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/__init__.py#L87-L140 | train |
HumanCellAtlas/dcp-cli | hca/dss/__init__.py | DSSClient._download_file | def _download_file(self, dss_file, dest_path, num_retries=10, min_delay_seconds=0.25):
"""
Attempt to download the data. If a retryable exception occurs, we wait a bit and retry again. The delay
increases each time we fail and decreases each time we successfully read a block. We set a quota f... | python | def _download_file(self, dss_file, dest_path, num_retries=10, min_delay_seconds=0.25):
"""
Attempt to download the data. If a retryable exception occurs, we wait a bit and retry again. The delay
increases each time we fail and decreases each time we successfully read a block. We set a quota f... | [
"def",
"_download_file",
"(",
"self",
",",
"dss_file",
",",
"dest_path",
",",
"num_retries",
"=",
"10",
",",
"min_delay_seconds",
"=",
"0.25",
")",
":",
"directory",
",",
"_",
"=",
"os",
".",
"path",
".",
"split",
"(",
"dest_path",
")",
"if",
"directory"... | Attempt to download the data. If a retryable exception occurs, we wait a bit and retry again. The delay
increases each time we fail and decreases each time we successfully read a block. We set a quota for the
number of failures that goes up with every successful block read and down with each failure.... | [
"Attempt",
"to",
"download",
"the",
"data",
".",
"If",
"a",
"retryable",
"exception",
"occurs",
"we",
"wait",
"a",
"bit",
"and",
"retry",
"again",
".",
"The",
"delay",
"increases",
"each",
"time",
"we",
"fail",
"and",
"decreases",
"each",
"time",
"we",
"... | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/__init__.py#L211-L237 | train |
HumanCellAtlas/dcp-cli | hca/dss/__init__.py | DSSClient._do_download_file | def _do_download_file(self, dss_file, fh, num_retries, min_delay_seconds):
"""
Abstracts away complications for downloading a file, handles retries and delays, and computes its hash
"""
hasher = hashlib.sha256()
delay = min_delay_seconds
retries_left = num_retries
... | python | def _do_download_file(self, dss_file, fh, num_retries, min_delay_seconds):
"""
Abstracts away complications for downloading a file, handles retries and delays, and computes its hash
"""
hasher = hashlib.sha256()
delay = min_delay_seconds
retries_left = num_retries
... | [
"def",
"_do_download_file",
"(",
"self",
",",
"dss_file",
",",
"fh",
",",
"num_retries",
",",
"min_delay_seconds",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"delay",
"=",
"min_delay_seconds",
"retries_left",
"=",
"num_retries",
"while",
"Tru... | Abstracts away complications for downloading a file, handles retries and delays, and computes its hash | [
"Abstracts",
"away",
"complications",
"for",
"downloading",
"a",
"file",
"handles",
"retries",
"and",
"delays",
"and",
"computes",
"its",
"hash"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/__init__.py#L239-L303 | train |
HumanCellAtlas/dcp-cli | hca/dss/__init__.py | DSSClient._write_output_manifest | def _write_output_manifest(self, manifest, filestore_root):
"""
Adds the file path column to the manifest and writes the copy to the current directory. If the original manifest
is in the current directory it is overwritten with a warning.
"""
output = os.path.basename(manifest)
... | python | def _write_output_manifest(self, manifest, filestore_root):
"""
Adds the file path column to the manifest and writes the copy to the current directory. If the original manifest
is in the current directory it is overwritten with a warning.
"""
output = os.path.basename(manifest)
... | [
"def",
"_write_output_manifest",
"(",
"self",
",",
"manifest",
",",
"filestore_root",
")",
":",
"output",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"manifest",
")",
"fieldnames",
",",
"source_manifest",
"=",
"self",
".",
"_parse_manifest",
"(",
"manifest",... | Adds the file path column to the manifest and writes the copy to the current directory. If the original manifest
is in the current directory it is overwritten with a warning. | [
"Adds",
"the",
"file",
"path",
"column",
"to",
"the",
"manifest",
"and",
"writes",
"the",
"copy",
"to",
"the",
"current",
"directory",
".",
"If",
"the",
"original",
"manifest",
"is",
"in",
"the",
"current",
"directory",
"it",
"is",
"overwritten",
"with",
"... | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/__init__.py#L332-L350 | train |
HumanCellAtlas/dcp-cli | hca/dss/util/__init__.py | hardlink | def hardlink(source, link_name):
"""
Create a hardlink in a portable way
The code for Windows support is adapted from:
https://github.com/sunshowers/ntfs/blob/master/ntfsutils/hardlink.py
"""
if sys.version_info < (3,) and platform.system() == 'Windows': # pragma: no cover
import ctype... | python | def hardlink(source, link_name):
"""
Create a hardlink in a portable way
The code for Windows support is adapted from:
https://github.com/sunshowers/ntfs/blob/master/ntfsutils/hardlink.py
"""
if sys.version_info < (3,) and platform.system() == 'Windows': # pragma: no cover
import ctype... | [
"def",
"hardlink",
"(",
"source",
",",
"link_name",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
")",
"and",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"import",
"ctypes",
"create_hard_link",
"=",
"ctypes",
".",
"wi... | Create a hardlink in a portable way
The code for Windows support is adapted from:
https://github.com/sunshowers/ntfs/blob/master/ntfsutils/hardlink.py | [
"Create",
"a",
"hardlink",
"in",
"a",
"portable",
"way"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/util/__init__.py#L40-L69 | train |
HumanCellAtlas/dcp-cli | hca/util/__init__.py | _ClientMethodFactory.request_with_retries_on_post_search | def request_with_retries_on_post_search(self, session, url, query, json_input, stream, headers):
"""
Submit a request and retry POST search requests specifically.
We don't currently retry on POST requests, and this is intended as a temporary fix until
the swagger is updated and changes ... | python | def request_with_retries_on_post_search(self, session, url, query, json_input, stream, headers):
"""
Submit a request and retry POST search requests specifically.
We don't currently retry on POST requests, and this is intended as a temporary fix until
the swagger is updated and changes ... | [
"def",
"request_with_retries_on_post_search",
"(",
"self",
",",
"session",
",",
"url",
",",
"query",
",",
"json_input",
",",
"stream",
",",
"headers",
")",
":",
"status_code",
"=",
"500",
"if",
"'/v1/search'",
"in",
"url",
":",
"retry_count",
"=",
"10",
"els... | Submit a request and retry POST search requests specifically.
We don't currently retry on POST requests, and this is intended as a temporary fix until
the swagger is updated and changes applied to prod. In the meantime, this function will add
retries specifically for POST search (and any other... | [
"Submit",
"a",
"request",
"and",
"retry",
"POST",
"search",
"requests",
"specifically",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/util/__init__.py#L143-L174 | train |
HumanCellAtlas/dcp-cli | hca/util/__init__.py | SwaggerClient.refresh_swagger | def refresh_swagger(self):
"""
Manually refresh the swagger document. This can help resolve errors communicate with the API.
"""
try:
os.remove(self._get_swagger_filename(self.swagger_url))
except EnvironmentError as e:
logger.warn(os.strerror(e.errno))
... | python | def refresh_swagger(self):
"""
Manually refresh the swagger document. This can help resolve errors communicate with the API.
"""
try:
os.remove(self._get_swagger_filename(self.swagger_url))
except EnvironmentError as e:
logger.warn(os.strerror(e.errno))
... | [
"def",
"refresh_swagger",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"_get_swagger_filename",
"(",
"self",
".",
"swagger_url",
")",
")",
"except",
"EnvironmentError",
"as",
"e",
":",
"logger",
".",
"warn",
"(",
"os",
".",
... | Manually refresh the swagger document. This can help resolve errors communicate with the API. | [
"Manually",
"refresh",
"the",
"swagger",
"document",
".",
"This",
"can",
"help",
"resolve",
"errors",
"communicate",
"with",
"the",
"API",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/util/__init__.py#L335-L344 | train |
HumanCellAtlas/dcp-cli | hca/upload/upload_config.py | UploadConfig.add_area | def add_area(self, uri):
"""
Record information about a new Upload Area
:param UploadAreaURI uri: An Upload Area URI.
"""
if uri.area_uuid not in self._config.upload.areas:
self._config.upload.areas[uri.area_uuid] = {'uri': uri.uri}
self.save() | python | def add_area(self, uri):
"""
Record information about a new Upload Area
:param UploadAreaURI uri: An Upload Area URI.
"""
if uri.area_uuid not in self._config.upload.areas:
self._config.upload.areas[uri.area_uuid] = {'uri': uri.uri}
self.save() | [
"def",
"add_area",
"(",
"self",
",",
"uri",
")",
":",
"if",
"uri",
".",
"area_uuid",
"not",
"in",
"self",
".",
"_config",
".",
"upload",
".",
"areas",
":",
"self",
".",
"_config",
".",
"upload",
".",
"areas",
"[",
"uri",
".",
"area_uuid",
"]",
"=",... | Record information about a new Upload Area
:param UploadAreaURI uri: An Upload Area URI. | [
"Record",
"information",
"about",
"a",
"new",
"Upload",
"Area"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/upload_config.py#L97-L105 | train |
HumanCellAtlas/dcp-cli | hca/upload/upload_config.py | UploadConfig.select_area | def select_area(self, area_uuid):
"""
Update the "current area" to be the area with this UUID.
:param str area_uuid: The RFC4122-compliant UUID of the Upload Area.
"""
self._config.upload.current_area = area_uuid
self.save() | python | def select_area(self, area_uuid):
"""
Update the "current area" to be the area with this UUID.
:param str area_uuid: The RFC4122-compliant UUID of the Upload Area.
"""
self._config.upload.current_area = area_uuid
self.save() | [
"def",
"select_area",
"(",
"self",
",",
"area_uuid",
")",
":",
"self",
".",
"_config",
".",
"upload",
".",
"current_area",
"=",
"area_uuid",
"self",
".",
"save",
"(",
")"
] | Update the "current area" to be the area with this UUID.
:param str area_uuid: The RFC4122-compliant UUID of the Upload Area. | [
"Update",
"the",
"current",
"area",
"to",
"be",
"the",
"area",
"with",
"this",
"UUID",
"."
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/upload_config.py#L107-L115 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.create_area | def create_area(self, area_uuid):
"""
Create an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict of the form { "uri": "s3://<bucket_name>/<upload-area-id>/" }
:rtype: dict
:raises UploadApiException: if the an Upload Area was n... | python | def create_area(self, area_uuid):
"""
Create an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict of the form { "uri": "s3://<bucket_name>/<upload-area-id>/" }
:rtype: dict
:raises UploadApiException: if the an Upload Area was n... | [
"def",
"create_area",
"(",
"self",
",",
"area_uuid",
")",
":",
"response",
"=",
"self",
".",
"_make_request",
"(",
"'post'",
",",
"path",
"=",
"\"/area/{id}\"",
".",
"format",
"(",
"id",
"=",
"area_uuid",
")",
",",
"headers",
"=",
"{",
"'Api-Key'",
":",
... | Create an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict of the form { "uri": "s3://<bucket_name>/<upload-area-id>/" }
:rtype: dict
:raises UploadApiException: if the an Upload Area was not created | [
"Create",
"an",
"Upload",
"Area"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L35-L47 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.area_exists | def area_exists(self, area_uuid):
"""
Check if an Upload Area exists
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True or False
:rtype: bool
"""
response = requests.head(self._url(path="/area/{id}".format(id=area_uuid)))
retur... | python | def area_exists(self, area_uuid):
"""
Check if an Upload Area exists
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True or False
:rtype: bool
"""
response = requests.head(self._url(path="/area/{id}".format(id=area_uuid)))
retur... | [
"def",
"area_exists",
"(",
"self",
",",
"area_uuid",
")",
":",
"response",
"=",
"requests",
".",
"head",
"(",
"self",
".",
"_url",
"(",
"path",
"=",
"\"/area/{id}\"",
".",
"format",
"(",
"id",
"=",
"area_uuid",
")",
")",
")",
"return",
"response",
".",... | Check if an Upload Area exists
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True or False
:rtype: bool | [
"Check",
"if",
"an",
"Upload",
"Area",
"exists"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L49-L58 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.delete_area | def delete_area(self, area_uuid):
"""
Delete an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True
:rtype: bool
:raises UploadApiException: if the an Upload Area was not deleted
"""
self._make_request('delete', path... | python | def delete_area(self, area_uuid):
"""
Delete an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True
:rtype: bool
:raises UploadApiException: if the an Upload Area was not deleted
"""
self._make_request('delete', path... | [
"def",
"delete_area",
"(",
"self",
",",
"area_uuid",
")",
":",
"self",
".",
"_make_request",
"(",
"'delete'",
",",
"path",
"=",
"\"/area/{id}\"",
".",
"format",
"(",
"id",
"=",
"area_uuid",
")",
",",
"headers",
"=",
"{",
"'Api-Key'",
":",
"self",
".",
... | Delete an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: True
:rtype: bool
:raises UploadApiException: if the an Upload Area was not deleted | [
"Delete",
"an",
"Upload",
"Area"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L60-L71 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.credentials | def credentials(self, area_uuid):
"""
Get AWS credentials required to directly upload files to Upload Area in S3
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict containing an AWS AccessKey, SecretKey and SessionToken
:rtype: dict
:raises ... | python | def credentials(self, area_uuid):
"""
Get AWS credentials required to directly upload files to Upload Area in S3
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict containing an AWS AccessKey, SecretKey and SessionToken
:rtype: dict
:raises ... | [
"def",
"credentials",
"(",
"self",
",",
"area_uuid",
")",
":",
"response",
"=",
"self",
".",
"_make_request",
"(",
"\"post\"",
",",
"path",
"=",
"\"/area/{uuid}/credentials\"",
".",
"format",
"(",
"uuid",
"=",
"area_uuid",
")",
")",
"return",
"response",
"."... | Get AWS credentials required to directly upload files to Upload Area in S3
:param str area_uuid: A RFC4122-compliant ID for the upload area
:return: a dict containing an AWS AccessKey, SecretKey and SessionToken
:rtype: dict
:raises UploadApiException: if credentials could not be obtain... | [
"Get",
"AWS",
"credentials",
"required",
"to",
"directly",
"upload",
"files",
"to",
"Upload",
"Area",
"in",
"S3"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L73-L83 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.file_upload_notification | def file_upload_notification(self, area_uuid, filename):
"""
Notify Upload Service that a file has been placed in an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param str filename: The name the file in the Upload Area
:return: True
:rtyp... | python | def file_upload_notification(self, area_uuid, filename):
"""
Notify Upload Service that a file has been placed in an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param str filename: The name the file in the Upload Area
:return: True
:rtyp... | [
"def",
"file_upload_notification",
"(",
"self",
",",
"area_uuid",
",",
"filename",
")",
":",
"url_safe_filename",
"=",
"urlparse",
".",
"quote",
"(",
"filename",
")",
"path",
"=",
"(",
"\"/area/{area_uuid}/{filename}\"",
".",
"format",
"(",
"area_uuid",
"=",
"ar... | Notify Upload Service that a file has been placed in an Upload Area
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param str filename: The name the file in the Upload Area
:return: True
:rtype: bool
:raises UploadApiException: if file could not be stored | [
"Notify",
"Upload",
"Service",
"that",
"a",
"file",
"has",
"been",
"placed",
"in",
"an",
"Upload",
"Area"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L111-L124 | train |
HumanCellAtlas/dcp-cli | hca/upload/lib/api_client.py | ApiClient.files_info | def files_info(self, area_uuid, file_list):
"""
Get information about files
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param list file_list: The names the files in the Upload Area about which we want information
:return: an array of file information dicts
... | python | def files_info(self, area_uuid, file_list):
"""
Get information about files
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param list file_list: The names the files in the Upload Area about which we want information
:return: an array of file information dicts
... | [
"def",
"files_info",
"(",
"self",
",",
"area_uuid",
",",
"file_list",
")",
":",
"path",
"=",
"\"/area/{uuid}/files_info\"",
".",
"format",
"(",
"uuid",
"=",
"area_uuid",
")",
"file_list",
"=",
"[",
"urlparse",
".",
"quote",
"(",
"filename",
")",
"for",
"fi... | Get information about files
:param str area_uuid: A RFC4122-compliant ID for the upload area
:param list file_list: The names the files in the Upload Area about which we want information
:return: an array of file information dicts
:rtype: list of dicts
:raises UploadApiException... | [
"Get",
"information",
"about",
"files"
] | cc70817bc4e50944c709eaae160de0bf7a19f0f3 | https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/lib/api_client.py#L126-L139 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.