partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | build_action | Build an Action object for a Pipeline request.
Args:
name (str): An optional name for the container.
image_uri (str): The URI to pull the container image from.
commands (List[str]): commands and arguments to run inside the container.
entrypoint (str): overrides the ENTRYPOINT specified in the contain... | dsub/providers/google_v2_pipelines.py | def build_action(name=None,
image_uri=None,
commands=None,
entrypoint=None,
environment=None,
pid_namespace=None,
flags=None,
port_mappings=None,
mounts=None,
labels=N... | def build_action(name=None,
image_uri=None,
commands=None,
entrypoint=None,
environment=None,
pid_namespace=None,
flags=None,
port_mappings=None,
mounts=None,
labels=N... | [
"Build",
"an",
"Action",
"object",
"for",
"a",
"Pipeline",
"request",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_pipelines.py#L135-L175 | [
"def",
"build_action",
"(",
"name",
"=",
"None",
",",
"image_uri",
"=",
"None",
",",
"commands",
"=",
"None",
",",
"entrypoint",
"=",
"None",
",",
"environment",
"=",
"None",
",",
"pid_namespace",
"=",
"None",
",",
"flags",
"=",
"None",
",",
"port_mappin... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | StubJobProvider.lookup_job_tasks | Return a list of operations. See base.py for additional detail. | dsub/providers/stub.py | def lookup_job_tasks(self,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
create... | def lookup_job_tasks(self,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
create... | [
"Return",
"a",
"list",
"of",
"operations",
".",
"See",
"base",
".",
"py",
"for",
"additional",
"detail",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/stub.py#L74-L109 | [
"def",
"lookup_job_tasks",
"(",
"self",
",",
"statuses",
",",
"user_ids",
"=",
"None",
",",
"job_ids",
"=",
"None",
",",
"job_names",
"=",
"None",
",",
"task_ids",
"=",
"None",
",",
"task_attempts",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"create_t... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_provider | Returns a provider for job submission requests. | dsub/providers/provider_base.py | def get_provider(args, resources):
"""Returns a provider for job submission requests."""
provider = getattr(args, 'provider', 'google')
if provider == 'google':
return google.GoogleJobProvider(
getattr(args, 'verbose', False),
getattr(args, 'dry_run', False), args.project)
elif provider ==... | def get_provider(args, resources):
"""Returns a provider for job submission requests."""
provider = getattr(args, 'provider', 'google')
if provider == 'google':
return google.GoogleJobProvider(
getattr(args, 'verbose', False),
getattr(args, 'dry_run', False), args.project)
elif provider ==... | [
"Returns",
"a",
"provider",
"for",
"job",
"submission",
"requests",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L36-L54 | [
"def",
"get_provider",
"(",
"args",
",",
"resources",
")",
":",
"provider",
"=",
"getattr",
"(",
"args",
",",
"'provider'",
",",
"'google'",
")",
"if",
"provider",
"==",
"'google'",
":",
"return",
"google",
".",
"GoogleJobProvider",
"(",
"getattr",
"(",
"a... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | create_parser | Create an argument parser, adding in the list of providers. | dsub/providers/provider_base.py | def create_parser(prog):
"""Create an argument parser, adding in the list of providers."""
parser = argparse.ArgumentParser(prog=prog, formatter_class=DsubHelpFormatter)
parser.add_argument(
'--provider',
default='google-v2',
choices=['local', 'google', 'google-v2', 'test-fails'],
help=""... | def create_parser(prog):
"""Create an argument parser, adding in the list of providers."""
parser = argparse.ArgumentParser(prog=prog, formatter_class=DsubHelpFormatter)
parser.add_argument(
'--provider',
default='google-v2',
choices=['local', 'google', 'google-v2', 'test-fails'],
help=""... | [
"Create",
"an",
"argument",
"parser",
"adding",
"in",
"the",
"list",
"of",
"providers",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L74-L87 | [
"def",
"create_parser",
"(",
"prog",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"prog",
",",
"formatter_class",
"=",
"DsubHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
"'--provider'",
",",
"default",
"=",
"'google-... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | parse_args | Add provider required arguments epilog message, parse, and validate. | dsub/providers/provider_base.py | def parse_args(parser, provider_required_args, argv):
"""Add provider required arguments epilog message, parse, and validate."""
# Add the provider required arguments epilog message
epilog = 'Provider-required arguments:\n'
for provider in provider_required_args:
epilog += ' %s: %s\n' % (provider, provide... | def parse_args(parser, provider_required_args, argv):
"""Add provider required arguments epilog message, parse, and validate."""
# Add the provider required arguments epilog message
epilog = 'Provider-required arguments:\n'
for provider in provider_required_args:
epilog += ' %s: %s\n' % (provider, provide... | [
"Add",
"provider",
"required",
"arguments",
"epilog",
"message",
"parse",
"and",
"validate",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L90-L107 | [
"def",
"parse_args",
"(",
"parser",
",",
"provider_required_args",
",",
"argv",
")",
":",
"# Add the provider required arguments epilog message",
"epilog",
"=",
"'Provider-required arguments:\\n'",
"for",
"provider",
"in",
"provider_required_args",
":",
"epilog",
"+=",
"' ... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_dstat_provider_args | A string with the arguments to point dstat to the same provider+project. | dsub/providers/provider_base.py | def get_dstat_provider_args(provider, project):
"""A string with the arguments to point dstat to the same provider+project."""
provider_name = get_provider_name(provider)
args = []
if provider_name == 'google':
args.append('--project %s' % project)
elif provider_name == 'google-v2':
args.append('--pr... | def get_dstat_provider_args(provider, project):
"""A string with the arguments to point dstat to the same provider+project."""
provider_name = get_provider_name(provider)
args = []
if provider_name == 'google':
args.append('--project %s' % project)
elif provider_name == 'google-v2':
args.append('--pr... | [
"A",
"string",
"with",
"the",
"arguments",
"to",
"point",
"dstat",
"to",
"the",
"same",
"provider",
"+",
"project",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L110-L128 | [
"def",
"get_dstat_provider_args",
"(",
"provider",
",",
"project",
")",
":",
"provider_name",
"=",
"get_provider_name",
"(",
"provider",
")",
"args",
"=",
"[",
"]",
"if",
"provider_name",
"==",
"'google'",
":",
"args",
".",
"append",
"(",
"'--project %s'",
"%"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _format_task_uri | Returns a URI with placeholders replaced by metadata values. | dsub/providers/provider_base.py | def _format_task_uri(fmt, job_metadata, task_metadata):
"""Returns a URI with placeholders replaced by metadata values."""
values = {
'job-id': None,
'task-id': 'task',
'job-name': None,
'user-id': None,
'task-attempt': None
}
for key in values:
values[key] = task_metadata.get... | def _format_task_uri(fmt, job_metadata, task_metadata):
"""Returns a URI with placeholders replaced by metadata values."""
values = {
'job-id': None,
'task-id': 'task',
'job-name': None,
'user-id': None,
'task-attempt': None
}
for key in values:
values[key] = task_metadata.get... | [
"Returns",
"a",
"URI",
"with",
"placeholders",
"replaced",
"by",
"metadata",
"values",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L151-L164 | [
"def",
"_format_task_uri",
"(",
"fmt",
",",
"job_metadata",
",",
"task_metadata",
")",
":",
"values",
"=",
"{",
"'job-id'",
":",
"None",
",",
"'task-id'",
":",
"'task'",
",",
"'job-name'",
":",
"None",
",",
"'user-id'",
":",
"None",
",",
"'task-attempt'",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | format_logging_uri | Inserts task metadata into the logging URI.
The core behavior is inspired by the Google Pipelines API:
(1) If a the uri ends in ".log", then that is the logging path.
(2) Otherwise, the uri is treated as "directory" for logs and a filename
needs to be automatically generated.
For (1), if the job i... | dsub/providers/provider_base.py | def format_logging_uri(uri, job_metadata, task_metadata):
"""Inserts task metadata into the logging URI.
The core behavior is inspired by the Google Pipelines API:
(1) If a the uri ends in ".log", then that is the logging path.
(2) Otherwise, the uri is treated as "directory" for logs and a filename
... | def format_logging_uri(uri, job_metadata, task_metadata):
"""Inserts task metadata into the logging URI.
The core behavior is inspired by the Google Pipelines API:
(1) If a the uri ends in ".log", then that is the logging path.
(2) Otherwise, the uri is treated as "directory" for logs and a filename
... | [
"Inserts",
"task",
"metadata",
"into",
"the",
"logging",
"URI",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/provider_base.py#L167-L217 | [
"def",
"format_logging_uri",
"(",
"uri",
",",
"job_metadata",
",",
"task_metadata",
")",
":",
"# If the user specifies any formatting (with curly braces), then use that",
"# as the format string unchanged.",
"fmt",
"=",
"str",
"(",
"uri",
")",
"if",
"'{'",
"not",
"in",
"f... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _google_v2_parse_arguments | Validated google-v2 arguments. | dsub/commands/dsub.py | def _google_v2_parse_arguments(args):
"""Validated google-v2 arguments."""
if (args.zones and args.regions) or (not args.zones and not args.regions):
raise ValueError('Exactly one of --regions and --zones must be specified')
if args.machine_type and (args.min_cores or args.min_ram):
raise ValueError(
... | def _google_v2_parse_arguments(args):
"""Validated google-v2 arguments."""
if (args.zones and args.regions) or (not args.zones and not args.regions):
raise ValueError('Exactly one of --regions and --zones must be specified')
if args.machine_type and (args.min_cores or args.min_ram):
raise ValueError(
... | [
"Validated",
"google",
"-",
"v2",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L185-L192 | [
"def",
"_google_v2_parse_arguments",
"(",
"args",
")",
":",
"if",
"(",
"args",
".",
"zones",
"and",
"args",
".",
"regions",
")",
"or",
"(",
"not",
"args",
".",
"zones",
"and",
"not",
"args",
".",
"regions",
")",
":",
"raise",
"ValueError",
"(",
"'Exact... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _parse_arguments | Parses command line arguments.
Args:
prog: The path of the program (dsub.py) or an alternate program name to
display in usage.
argv: The list of program arguments to parse.
Returns:
A Namespace of parsed arguments. | dsub/commands/dsub.py | def _parse_arguments(prog, argv):
"""Parses command line arguments.
Args:
prog: The path of the program (dsub.py) or an alternate program name to
display in usage.
argv: The list of program arguments to parse.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it... | def _parse_arguments(prog, argv):
"""Parses command line arguments.
Args:
prog: The path of the program (dsub.py) or an alternate program name to
display in usage.
argv: The list of program arguments to parse.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it... | [
"Parses",
"command",
"line",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L195-L515 | [
"def",
"_parse_arguments",
"(",
"prog",
",",
"argv",
")",
":",
"# Handle version flag and exit if it was passed.",
"param_util",
".",
"handle_version_flag",
"(",
")",
"parser",
"=",
"provider_base",
".",
"create_parser",
"(",
"prog",
")",
"# Add dsub core job submission a... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _get_job_resources | Extract job-global resources requirements from input args.
Args:
args: parsed command-line arguments
Returns:
Resources object containing the requested resources for the job | dsub/commands/dsub.py | def _get_job_resources(args):
"""Extract job-global resources requirements from input args.
Args:
args: parsed command-line arguments
Returns:
Resources object containing the requested resources for the job
"""
logging = param_util.build_logging_param(
args.logging) if args.logging else None
... | def _get_job_resources(args):
"""Extract job-global resources requirements from input args.
Args:
args: parsed command-line arguments
Returns:
Resources object containing the requested resources for the job
"""
logging = param_util.build_logging_param(
args.logging) if args.logging else None
... | [
"Extract",
"job",
"-",
"global",
"resources",
"requirements",
"from",
"input",
"args",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L518-L557 | [
"def",
"_get_job_resources",
"(",
"args",
")",
":",
"logging",
"=",
"param_util",
".",
"build_logging_param",
"(",
"args",
".",
"logging",
")",
"if",
"args",
".",
"logging",
"else",
"None",
"timeout",
"=",
"param_util",
".",
"timeout_in_seconds",
"(",
"args",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _get_job_metadata | Allow provider to extract job-specific metadata from command-line args.
Args:
provider: job service provider
user_id: user submitting the job
job_name: name for the job
script: the script to run
task_ids: a set of the task-ids for all tasks in the job
user_project: name of the project to be b... | dsub/commands/dsub.py | def _get_job_metadata(provider, user_id, job_name, script, task_ids,
user_project, unique_job_id):
"""Allow provider to extract job-specific metadata from command-line args.
Args:
provider: job service provider
user_id: user submitting the job
job_name: name for the job
script... | def _get_job_metadata(provider, user_id, job_name, script, task_ids,
user_project, unique_job_id):
"""Allow provider to extract job-specific metadata from command-line args.
Args:
provider: job service provider
user_id: user submitting the job
job_name: name for the job
script... | [
"Allow",
"provider",
"to",
"extract",
"job",
"-",
"specific",
"metadata",
"from",
"command",
"-",
"line",
"args",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L560-L589 | [
"def",
"_get_job_metadata",
"(",
"provider",
",",
"user_id",
",",
"job_name",
",",
"script",
",",
"task_ids",
",",
"user_project",
",",
"unique_job_id",
")",
":",
"create_time",
"=",
"dsub_util",
".",
"replace_timezone",
"(",
"datetime",
".",
"datetime",
".",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _resolve_task_logging | Resolve the logging path from job and task properties.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
job_resources: Resources specified such as ram, cpu, and logging path.
task_descriptors: Task metadata, parameters, and resources.
Resolve the logging path, which may have su... | dsub/commands/dsub.py | def _resolve_task_logging(job_metadata, job_resources, task_descriptors):
"""Resolve the logging path from job and task properties.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
job_resources: Resources specified such as ram, cpu, and logging path.
task_descriptors: Task meta... | def _resolve_task_logging(job_metadata, job_resources, task_descriptors):
"""Resolve the logging path from job and task properties.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
job_resources: Resources specified such as ram, cpu, and logging path.
task_descriptors: Task meta... | [
"Resolve",
"the",
"logging",
"path",
"from",
"job",
"and",
"task",
"properties",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L592-L617 | [
"def",
"_resolve_task_logging",
"(",
"job_metadata",
",",
"job_resources",
",",
"task_descriptors",
")",
":",
"if",
"not",
"job_resources",
".",
"logging",
":",
"return",
"for",
"task_descriptor",
"in",
"task_descriptors",
":",
"logging_uri",
"=",
"provider_base",
"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _wait_after | Print status info as we wait for those jobs.
Blocks until either all of the listed jobs succeed,
or one of them fails.
Args:
provider: job service provider
job_ids: a set of job IDs (string) to wait for
poll_interval: integer seconds to wait between iterations
stop_on_failure: whether to stop wa... | dsub/commands/dsub.py | def _wait_after(provider, job_ids, poll_interval, stop_on_failure):
"""Print status info as we wait for those jobs.
Blocks until either all of the listed jobs succeed,
or one of them fails.
Args:
provider: job service provider
job_ids: a set of job IDs (string) to wait for
poll_interval: integer s... | def _wait_after(provider, job_ids, poll_interval, stop_on_failure):
"""Print status info as we wait for those jobs.
Blocks until either all of the listed jobs succeed,
or one of them fails.
Args:
provider: job service provider
job_ids: a set of job IDs (string) to wait for
poll_interval: integer s... | [
"Print",
"status",
"info",
"as",
"we",
"wait",
"for",
"those",
"jobs",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L638-L701 | [
"def",
"_wait_after",
"(",
"provider",
",",
"job_ids",
",",
"poll_interval",
",",
"stop_on_failure",
")",
":",
"# Each time through the loop, the job_set is re-set to the jobs remaining to",
"# check. Jobs are removed from the list when they complete.",
"#",
"# We exit the loop when:",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _wait_and_retry | Wait for job and retry any tasks that fail.
Stops retrying an individual task when: it succeeds, is canceled, or has been
retried "retries" times.
This function exits when there are no tasks running and there are no tasks
eligible to be retried.
Args:
provider: job service provider
job_id: a single... | dsub/commands/dsub.py | def _wait_and_retry(provider, job_id, poll_interval, retries, job_descriptor):
"""Wait for job and retry any tasks that fail.
Stops retrying an individual task when: it succeeds, is canceled, or has been
retried "retries" times.
This function exits when there are no tasks running and there are no tasks
elig... | def _wait_and_retry(provider, job_id, poll_interval, retries, job_descriptor):
"""Wait for job and retry any tasks that fail.
Stops retrying an individual task when: it succeeds, is canceled, or has been
retried "retries" times.
This function exits when there are no tasks running and there are no tasks
elig... | [
"Wait",
"for",
"job",
"and",
"retry",
"any",
"tasks",
"that",
"fail",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L704-L786 | [
"def",
"_wait_and_retry",
"(",
"provider",
",",
"job_id",
",",
"poll_interval",
",",
"retries",
",",
"job_descriptor",
")",
":",
"while",
"True",
":",
"tasks",
"=",
"provider",
".",
"lookup_job_tasks",
"(",
"{",
"'*'",
"}",
",",
"job_ids",
"=",
"[",
"job_i... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _retry_task | Retry task_id (numeric id) assigning it task_attempt. | dsub/commands/dsub.py | def _retry_task(provider, job_descriptor, task_id, task_attempt):
"""Retry task_id (numeric id) assigning it task_attempt."""
td_orig = job_descriptor.find_task_descriptor(task_id)
new_task_descriptors = [
job_model.TaskDescriptor({
'task-id': task_id,
'task-attempt': task_attempt
... | def _retry_task(provider, job_descriptor, task_id, task_attempt):
"""Retry task_id (numeric id) assigning it task_attempt."""
td_orig = job_descriptor.find_task_descriptor(task_id)
new_task_descriptors = [
job_model.TaskDescriptor({
'task-id': task_id,
'task-attempt': task_attempt
... | [
"Retry",
"task_id",
"(",
"numeric",
"id",
")",
"assigning",
"it",
"task_attempt",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L789-L807 | [
"def",
"_retry_task",
"(",
"provider",
",",
"job_descriptor",
",",
"task_id",
",",
"task_attempt",
")",
":",
"td_orig",
"=",
"job_descriptor",
".",
"find_task_descriptor",
"(",
"task_id",
")",
"new_task_descriptors",
"=",
"[",
"job_model",
".",
"TaskDescriptor",
"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _dominant_task_for_jobs | A list with, for each job, its dominant task.
The dominant task is the one that exemplifies its job's
status. It is either:
- the first (FAILURE or CANCELED) task, or if none
- the first RUNNING task, or if none
- the first SUCCESS task.
Args:
tasks: a list of tasks to consider
Returns:
A list ... | dsub/commands/dsub.py | def _dominant_task_for_jobs(tasks):
"""A list with, for each job, its dominant task.
The dominant task is the one that exemplifies its job's
status. It is either:
- the first (FAILURE or CANCELED) task, or if none
- the first RUNNING task, or if none
- the first SUCCESS task.
Args:
tasks: a list of ... | def _dominant_task_for_jobs(tasks):
"""A list with, for each job, its dominant task.
The dominant task is the one that exemplifies its job's
status. It is either:
- the first (FAILURE or CANCELED) task, or if none
- the first RUNNING task, or if none
- the first SUCCESS task.
Args:
tasks: a list of ... | [
"A",
"list",
"with",
"for",
"each",
"job",
"its",
"dominant",
"task",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L810-L832 | [
"def",
"_dominant_task_for_jobs",
"(",
"tasks",
")",
":",
"per_job",
"=",
"_group_tasks_by_jobid",
"(",
"tasks",
")",
"ret",
"=",
"[",
"]",
"for",
"job_id",
"in",
"per_job",
".",
"keys",
"(",
")",
":",
"tasks_in_salience_order",
"=",
"sorted",
"(",
"per_job"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _group_tasks_by_jobid | A defaultdict with, for each job, a list of its tasks. | dsub/commands/dsub.py | def _group_tasks_by_jobid(tasks):
"""A defaultdict with, for each job, a list of its tasks."""
ret = collections.defaultdict(list)
for t in tasks:
ret[t.get_field('job-id')].append(t)
return ret | def _group_tasks_by_jobid(tasks):
"""A defaultdict with, for each job, a list of its tasks."""
ret = collections.defaultdict(list)
for t in tasks:
ret[t.get_field('job-id')].append(t)
return ret | [
"A",
"defaultdict",
"with",
"for",
"each",
"job",
"a",
"list",
"of",
"its",
"tasks",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L835-L840 | [
"def",
"_group_tasks_by_jobid",
"(",
"tasks",
")",
":",
"ret",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"t",
"in",
"tasks",
":",
"ret",
"[",
"t",
".",
"get_field",
"(",
"'job-id'",
")",
"]",
".",
"append",
"(",
"t",
")",
"retu... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _importance_of_task | Tuple (importance, end-time). Smaller values are more important. | dsub/commands/dsub.py | def _importance_of_task(task):
"""Tuple (importance, end-time). Smaller values are more important."""
# The status of a job is going to be determined by the roll-up of its tasks.
# A FAILURE or CANCELED task means the job has FAILED.
# If none, then any RUNNING task, the job is still RUNNING.
# If none, then ... | def _importance_of_task(task):
"""Tuple (importance, end-time). Smaller values are more important."""
# The status of a job is going to be determined by the roll-up of its tasks.
# A FAILURE or CANCELED task means the job has FAILED.
# If none, then any RUNNING task, the job is still RUNNING.
# If none, then ... | [
"Tuple",
"(",
"importance",
"end",
"-",
"time",
")",
".",
"Smaller",
"values",
"are",
"more",
"important",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L843-L858 | [
"def",
"_importance_of_task",
"(",
"task",
")",
":",
"# The status of a job is going to be determined by the roll-up of its tasks.",
"# A FAILURE or CANCELED task means the job has FAILED.",
"# If none, then any RUNNING task, the job is still RUNNING.",
"# If none, then the job status is SUCCESS."... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _wait_for_any_job | Waits until any of the listed jobs is not running.
In particular, if any of the jobs sees one of its tasks fail,
we count the whole job as failing (but do not terminate the remaining
tasks ourselves).
Args:
provider: job service provider
job_ids: a list of job IDs (string) to wait for
poll_interva... | dsub/commands/dsub.py | def _wait_for_any_job(provider, job_ids, poll_interval):
"""Waits until any of the listed jobs is not running.
In particular, if any of the jobs sees one of its tasks fail,
we count the whole job as failing (but do not terminate the remaining
tasks ourselves).
Args:
provider: job service provider
jo... | def _wait_for_any_job(provider, job_ids, poll_interval):
"""Waits until any of the listed jobs is not running.
In particular, if any of the jobs sees one of its tasks fail,
we count the whole job as failing (but do not terminate the remaining
tasks ourselves).
Args:
provider: job service provider
jo... | [
"Waits",
"until",
"any",
"of",
"the",
"listed",
"jobs",
"is",
"not",
"running",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L861-L892 | [
"def",
"_wait_for_any_job",
"(",
"provider",
",",
"job_ids",
",",
"poll_interval",
")",
":",
"if",
"not",
"job_ids",
":",
"return",
"while",
"True",
":",
"tasks",
"=",
"provider",
".",
"lookup_job_tasks",
"(",
"{",
"'*'",
"}",
",",
"job_ids",
"=",
"job_ids... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _validate_job_and_task_arguments | Validates that job and task argument names do not overlap. | dsub/commands/dsub.py | def _validate_job_and_task_arguments(job_params, task_descriptors):
"""Validates that job and task argument names do not overlap."""
if not task_descriptors:
return
task_params = task_descriptors[0].task_params
# The use case for specifying a label or env/input/output parameter on
# the command-line an... | def _validate_job_and_task_arguments(job_params, task_descriptors):
"""Validates that job and task argument names do not overlap."""
if not task_descriptors:
return
task_params = task_descriptors[0].task_params
# The use case for specifying a label or env/input/output parameter on
# the command-line an... | [
"Validates",
"that",
"job",
"and",
"task",
"argument",
"names",
"do",
"not",
"overlap",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L895-L934 | [
"def",
"_validate_job_and_task_arguments",
"(",
"job_params",
",",
"task_descriptors",
")",
":",
"if",
"not",
"task_descriptors",
":",
"return",
"task_params",
"=",
"task_descriptors",
"[",
"0",
"]",
".",
"task_params",
"# The use case for specifying a label or env/input/ou... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | run_main | Execute job/task submission from command-line arguments. | dsub/commands/dsub.py | def run_main(args):
"""Execute job/task submission from command-line arguments."""
if args.command and args.script:
raise ValueError('Cannot supply both a --command and --script flag')
provider_base.check_for_unsupported_flag(args)
# Set up job parameters and job data from a tasks file or flags.
input_... | def run_main(args):
"""Execute job/task submission from command-line arguments."""
if args.command and args.script:
raise ValueError('Cannot supply both a --command and --script flag')
provider_base.check_for_unsupported_flag(args)
# Set up job parameters and job data from a tasks file or flags.
input_... | [
"Execute",
"job",
"/",
"task",
"submission",
"from",
"command",
"-",
"line",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L969-L1028 | [
"def",
"run_main",
"(",
"args",
")",
":",
"if",
"args",
".",
"command",
"and",
"args",
".",
"script",
":",
"raise",
"ValueError",
"(",
"'Cannot supply both a --command and --script flag'",
")",
"provider_base",
".",
"check_for_unsupported_flag",
"(",
"args",
")",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | run | Actual dsub body, post-stdout-redirection. | dsub/commands/dsub.py | def run(provider,
job_resources,
job_params,
task_descriptors,
name=None,
dry_run=False,
command=None,
script=None,
user=None,
user_project=None,
wait=False,
retries=0,
poll_interval=10,
after=None,
skip=Fals... | def run(provider,
job_resources,
job_params,
task_descriptors,
name=None,
dry_run=False,
command=None,
script=None,
user=None,
user_project=None,
wait=False,
retries=0,
poll_interval=10,
after=None,
skip=Fals... | [
"Actual",
"dsub",
"body",
"post",
"-",
"stdout",
"-",
"redirection",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L1031-L1152 | [
"def",
"run",
"(",
"provider",
",",
"job_resources",
",",
"job_params",
",",
"task_descriptors",
",",
"name",
"=",
"None",
",",
"dry_run",
"=",
"False",
",",
"command",
"=",
"None",
",",
"script",
"=",
"None",
",",
"user",
"=",
"None",
",",
"user_project... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _name_for_command | r"""Craft a simple command name from the command.
The best command strings for this are going to be those where a simple
command was given; we will use the command to derive the name.
We won't always be able to figure something out and the caller should just
specify a "--name" on the command-line.
For exam... | dsub/commands/dsub.py | def _name_for_command(command):
r"""Craft a simple command name from the command.
The best command strings for this are going to be those where a simple
command was given; we will use the command to derive the name.
We won't always be able to figure something out and the caller should just
specify a "--name... | def _name_for_command(command):
r"""Craft a simple command name from the command.
The best command strings for this are going to be those where a simple
command was given; we will use the command to derive the name.
We won't always be able to figure something out and the caller should just
specify a "--name... | [
"r",
"Craft",
"a",
"simple",
"command",
"name",
"from",
"the",
"command",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dsub.py#L1155-L1193 | [
"def",
"_name_for_command",
"(",
"command",
")",
":",
"lines",
"=",
"command",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
"and",
"not",
"line",
".",
"startswith",
"(",
"'... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _local_uri_rewriter | Rewrite local file URIs as required by the rewrite_uris method.
Local file paths, unlike GCS paths, may have their raw URI simplified by
os.path.normpath which collapses extraneous indirect characters.
>>> _local_uri_rewriter('/tmp/a_path/../B_PATH/file.txt')
('/tmp/B_PATH/file.txt', 'file/tmp/B_PATH/file.txt... | dsub/lib/param_util.py | def _local_uri_rewriter(raw_uri):
"""Rewrite local file URIs as required by the rewrite_uris method.
Local file paths, unlike GCS paths, may have their raw URI simplified by
os.path.normpath which collapses extraneous indirect characters.
>>> _local_uri_rewriter('/tmp/a_path/../B_PATH/file.txt')
('/tmp/B_PA... | def _local_uri_rewriter(raw_uri):
"""Rewrite local file URIs as required by the rewrite_uris method.
Local file paths, unlike GCS paths, may have their raw URI simplified by
os.path.normpath which collapses extraneous indirect characters.
>>> _local_uri_rewriter('/tmp/a_path/../B_PATH/file.txt')
('/tmp/B_PA... | [
"Rewrite",
"local",
"file",
"URIs",
"as",
"required",
"by",
"the",
"rewrite_uris",
"method",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L308-L367 | [
"def",
"_local_uri_rewriter",
"(",
"raw_uri",
")",
":",
"# The path is split into components so that the filename is not rewritten.",
"raw_path",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"raw_uri",
")",
"# Generate the local path that can be resolved by files... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _get_filtered_mounts | Helper function to return an appropriate set of mount parameters. | dsub/lib/param_util.py | def _get_filtered_mounts(mounts, mount_param_type):
"""Helper function to return an appropriate set of mount parameters."""
return set([mount for mount in mounts if isinstance(mount, mount_param_type)]) | def _get_filtered_mounts(mounts, mount_param_type):
"""Helper function to return an appropriate set of mount parameters."""
return set([mount for mount in mounts if isinstance(mount, mount_param_type)]) | [
"Helper",
"function",
"to",
"return",
"an",
"appropriate",
"set",
"of",
"mount",
"parameters",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L385-L387 | [
"def",
"_get_filtered_mounts",
"(",
"mounts",
",",
"mount_param_type",
")",
":",
"return",
"set",
"(",
"[",
"mount",
"for",
"mount",
"in",
"mounts",
"if",
"isinstance",
"(",
"mount",
",",
"mount_param_type",
")",
"]",
")"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_logging_param | Convenience function simplifies construction of the logging uri. | dsub/lib/param_util.py | def build_logging_param(logging_uri, util_class=OutputFileParamUtil):
"""Convenience function simplifies construction of the logging uri."""
if not logging_uri:
return job_model.LoggingParam(None, None)
recursive = not logging_uri.endswith('.log')
oututil = util_class('')
_, uri, provider = oututil.parse_... | def build_logging_param(logging_uri, util_class=OutputFileParamUtil):
"""Convenience function simplifies construction of the logging uri."""
if not logging_uri:
return job_model.LoggingParam(None, None)
recursive = not logging_uri.endswith('.log')
oututil = util_class('')
_, uri, provider = oututil.parse_... | [
"Convenience",
"function",
"simplifies",
"construction",
"of",
"the",
"logging",
"uri",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L390-L399 | [
"def",
"build_logging_param",
"(",
"logging_uri",
",",
"util_class",
"=",
"OutputFileParamUtil",
")",
":",
"if",
"not",
"logging_uri",
":",
"return",
"job_model",
".",
"LoggingParam",
"(",
"None",
",",
"None",
")",
"recursive",
"=",
"not",
"logging_uri",
".",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | split_pair | Split a string into a pair, which can have one empty value.
Args:
pair_string: The string to be split.
separator: The separator to be used for splitting.
nullable_idx: The location to be set to null if the separator is not in the
input string. Should be either 0 or 1.
Returns:
A ... | dsub/lib/param_util.py | def split_pair(pair_string, separator, nullable_idx=1):
"""Split a string into a pair, which can have one empty value.
Args:
pair_string: The string to be split.
separator: The separator to be used for splitting.
nullable_idx: The location to be set to null if the separator is not in the
... | def split_pair(pair_string, separator, nullable_idx=1):
"""Split a string into a pair, which can have one empty value.
Args:
pair_string: The string to be split.
separator: The separator to be used for splitting.
nullable_idx: The location to be set to null if the separator is not in the
... | [
"Split",
"a",
"string",
"into",
"a",
"pair",
"which",
"can",
"have",
"one",
"empty",
"value",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L402-L427 | [
"def",
"split_pair",
"(",
"pair_string",
",",
"separator",
",",
"nullable_idx",
"=",
"1",
")",
":",
"pair",
"=",
"pair_string",
".",
"split",
"(",
"separator",
",",
"1",
")",
"if",
"len",
"(",
"pair",
")",
"==",
"1",
":",
"if",
"nullable_idx",
"==",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | parse_tasks_file_header | Parse the header from the tasks file into env, input, output definitions.
Elements are formatted similar to their equivalent command-line arguments,
but with associated values coming from the data rows.
Environment variables columns are headered as "--env <name>"
Inputs columns are headered as "--input <name>... | dsub/lib/param_util.py | def parse_tasks_file_header(header, input_file_param_util,
output_file_param_util):
"""Parse the header from the tasks file into env, input, output definitions.
Elements are formatted similar to their equivalent command-line arguments,
but with associated values coming from the data r... | def parse_tasks_file_header(header, input_file_param_util,
output_file_param_util):
"""Parse the header from the tasks file into env, input, output definitions.
Elements are formatted similar to their equivalent command-line arguments,
but with associated values coming from the data r... | [
"Parse",
"the",
"header",
"from",
"the",
"tasks",
"file",
"into",
"env",
"input",
"output",
"definitions",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L430-L488 | [
"def",
"parse_tasks_file_header",
"(",
"header",
",",
"input_file_param_util",
",",
"output_file_param_util",
")",
":",
"job_params",
"=",
"[",
"]",
"for",
"col",
"in",
"header",
":",
"# Reserve the \"-\" and \"--\" namespace.",
"# If the column has no leading \"-\", treat it... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | tasks_file_to_task_descriptors | Parses task parameters from a TSV.
Args:
tasks: Dict containing the path to a TSV file and task numbers to run
variables, input, and output parameters as column headings. Subsequent
lines specify parameter values, one row per job.
retries: Number of retries allowed.
input_file_param_util: Utility... | dsub/lib/param_util.py | def tasks_file_to_task_descriptors(tasks, retries, input_file_param_util,
output_file_param_util):
"""Parses task parameters from a TSV.
Args:
tasks: Dict containing the path to a TSV file and task numbers to run
variables, input, and output parameters as column headings.... | def tasks_file_to_task_descriptors(tasks, retries, input_file_param_util,
output_file_param_util):
"""Parses task parameters from a TSV.
Args:
tasks: Dict containing the path to a TSV file and task numbers to run
variables, input, and output parameters as column headings.... | [
"Parses",
"task",
"parameters",
"from",
"a",
"TSV",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L491-L578 | [
"def",
"tasks_file_to_task_descriptors",
"(",
"tasks",
",",
"retries",
",",
"input_file_param_util",
",",
"output_file_param_util",
")",
":",
"task_descriptors",
"=",
"[",
"]",
"path",
"=",
"tasks",
"[",
"'path'",
"]",
"task_min",
"=",
"tasks",
".",
"get",
"(",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | parse_pair_args | Parse flags of key=value pairs and return a list of argclass.
For pair variables, we need to:
* split the input into name=value pairs (value optional)
* Create the EnvParam object
Args:
labels: list of 'key' or 'key=value' strings.
argclass: Container class for args, must instantiate with argcla... | dsub/lib/param_util.py | def parse_pair_args(labels, argclass):
"""Parse flags of key=value pairs and return a list of argclass.
For pair variables, we need to:
* split the input into name=value pairs (value optional)
* Create the EnvParam object
Args:
labels: list of 'key' or 'key=value' strings.
argclass: Container ... | def parse_pair_args(labels, argclass):
"""Parse flags of key=value pairs and return a list of argclass.
For pair variables, we need to:
* split the input into name=value pairs (value optional)
* Create the EnvParam object
Args:
labels: list of 'key' or 'key=value' strings.
argclass: Container ... | [
"Parse",
"flags",
"of",
"key",
"=",
"value",
"pairs",
"and",
"return",
"a",
"list",
"of",
"argclass",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L581-L599 | [
"def",
"parse_pair_args",
"(",
"labels",
",",
"argclass",
")",
":",
"label_data",
"=",
"set",
"(",
")",
"for",
"arg",
"in",
"labels",
":",
"name",
",",
"value",
"=",
"split_pair",
"(",
"arg",
",",
"'='",
",",
"nullable_idx",
"=",
"1",
")",
"label_data"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | args_to_job_params | Parse env, input, and output parameters into a job parameters and data.
Passing arguments on the command-line allows for launching a single job.
The env, input, and output arguments encode both the definition of the
job as well as the single job's values.
Env arguments are simple name=value pairs.
Input and... | dsub/lib/param_util.py | def args_to_job_params(envs, labels, inputs, inputs_recursive, outputs,
outputs_recursive, mounts, input_file_param_util,
output_file_param_util, mount_param_util):
"""Parse env, input, and output parameters into a job parameters and data.
Passing arguments on the comm... | def args_to_job_params(envs, labels, inputs, inputs_recursive, outputs,
outputs_recursive, mounts, input_file_param_util,
output_file_param_util, mount_param_util):
"""Parse env, input, and output parameters into a job parameters and data.
Passing arguments on the comm... | [
"Parse",
"env",
"input",
"and",
"output",
"parameters",
"into",
"a",
"job",
"parameters",
"and",
"data",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L602-L678 | [
"def",
"args_to_job_params",
"(",
"envs",
",",
"labels",
",",
"inputs",
",",
"inputs_recursive",
",",
"outputs",
",",
"outputs_recursive",
",",
"mounts",
",",
"input_file_param_util",
",",
"output_file_param_util",
",",
"mount_param_util",
")",
":",
"# Parse environme... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | validate_submit_args_or_fail | Validate that arguments passed to submit_job have valid file providers.
This utility function takes resources and task data args from `submit_job`
in the base provider. This function will fail with a value error if any of the
parameters are not valid. See the following example;
>>> job_resources = type('', (o... | dsub/lib/param_util.py | def validate_submit_args_or_fail(job_descriptor, provider_name, input_providers,
output_providers, logging_providers):
"""Validate that arguments passed to submit_job have valid file providers.
This utility function takes resources and task data args from `submit_job`
in the base... | def validate_submit_args_or_fail(job_descriptor, provider_name, input_providers,
output_providers, logging_providers):
"""Validate that arguments passed to submit_job have valid file providers.
This utility function takes resources and task data args from `submit_job`
in the base... | [
"Validate",
"that",
"arguments",
"passed",
"to",
"submit_job",
"have",
"valid",
"file",
"providers",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L693-L762 | [
"def",
"validate_submit_args_or_fail",
"(",
"job_descriptor",
",",
"provider_name",
",",
"input_providers",
",",
"output_providers",
",",
"logging_providers",
")",
":",
"job_resources",
"=",
"job_descriptor",
".",
"job_resources",
"job_params",
"=",
"job_descriptor",
".",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | handle_version_flag | If the --version flag is passed, print version to stdout and exit.
Within dsub commands, --version should be the highest priority flag.
This function supplies a repeatable and DRY way of checking for the
version flag and printing the version. Callers still need to define a version
flag in the command's flags s... | dsub/lib/param_util.py | def handle_version_flag():
"""If the --version flag is passed, print version to stdout and exit.
Within dsub commands, --version should be the highest priority flag.
This function supplies a repeatable and DRY way of checking for the
version flag and printing the version. Callers still need to define a version... | def handle_version_flag():
"""If the --version flag is passed, print version to stdout and exit.
Within dsub commands, --version should be the highest priority flag.
This function supplies a repeatable and DRY way of checking for the
version flag and printing the version. Callers still need to define a version... | [
"If",
"the",
"--",
"version",
"flag",
"is",
"passed",
"print",
"version",
"to",
"stdout",
"and",
"exit",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L819-L833 | [
"def",
"handle_version_flag",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Version parser'",
",",
"add_help",
"=",
"False",
")",
"parser",
".",
"add_argument",
"(",
"'--version'",
",",
"'-v'",
",",
"dest",
"=",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | age_to_create_time | Compute the create time (UTC) for the list filter.
If the age is an integer value it is treated as a UTC date.
Otherwise the value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
age: A "<integer><unit>" string or integer value.
... | dsub/lib/param_util.py | def age_to_create_time(age, from_time=None):
"""Compute the create time (UTC) for the list filter.
If the age is an integer value it is treated as a UTC date.
Otherwise the value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
a... | def age_to_create_time(age, from_time=None):
"""Compute the create time (UTC) for the list filter.
If the age is an integer value it is treated as a UTC date.
Otherwise the value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
a... | [
"Compute",
"the",
"create",
"time",
"(",
"UTC",
")",
"for",
"the",
"list",
"filter",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L836-L877 | [
"def",
"age_to_create_time",
"(",
"age",
",",
"from_time",
"=",
"None",
")",
":",
"if",
"not",
"age",
":",
"return",
"None",
"if",
"not",
"from_time",
":",
"from_time",
"=",
"dsub_util",
".",
"replace_timezone",
"(",
"datetime",
".",
"datetime",
".",
"now"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _interval_to_seconds | Convert the timeout duration to seconds.
The value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
interval: A "<integer><unit>" string.
valid_units: A list of supported units.
Returns:
A string of the form "<integer>s" o... | dsub/lib/param_util.py | def _interval_to_seconds(interval, valid_units='smhdw'):
"""Convert the timeout duration to seconds.
The value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
interval: A "<integer><unit>" string.
valid_units: A list of suppor... | def _interval_to_seconds(interval, valid_units='smhdw'):
"""Convert the timeout duration to seconds.
The value must be of the form "<integer><unit>" where supported
units are s, m, h, d, w (seconds, minutes, hours, days, weeks).
Args:
interval: A "<integer><unit>" string.
valid_units: A list of suppor... | [
"Convert",
"the",
"timeout",
"duration",
"to",
"seconds",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L880-L914 | [
"def",
"_interval_to_seconds",
"(",
"interval",
",",
"valid_units",
"=",
"'smhdw'",
")",
":",
"if",
"not",
"interval",
":",
"return",
"None",
"try",
":",
"last_char",
"=",
"interval",
"[",
"-",
"1",
"]",
"if",
"last_char",
"==",
"'s'",
"and",
"'s'",
"in"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil.get_variable_name | Produce a default variable name if none is specified. | dsub/lib/param_util.py | def get_variable_name(self, name):
"""Produce a default variable name if none is specified."""
if not name:
name = '%s%s' % (self._auto_prefix, self._auto_index)
self._auto_index += 1
return name | def get_variable_name(self, name):
"""Produce a default variable name if none is specified."""
if not name:
name = '%s%s' % (self._auto_prefix, self._auto_index)
self._auto_index += 1
return name | [
"Produce",
"a",
"default",
"variable",
"name",
"if",
"none",
"is",
"specified",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L85-L90 | [
"def",
"get_variable_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"name",
"=",
"'%s%s'",
"%",
"(",
"self",
".",
"_auto_prefix",
",",
"self",
".",
"_auto_index",
")",
"self",
".",
"_auto_index",
"+=",
"1",
"return",
"name"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil.rewrite_uris | Accept a raw uri and return rewritten versions.
This function returns a normalized URI and a docker path. The normalized
URI may have minor alterations meant to disambiguate and prepare for use
by shell utilities that may require a specific format.
The docker rewriter makes substantial modifications t... | dsub/lib/param_util.py | def rewrite_uris(self, raw_uri, file_provider):
"""Accept a raw uri and return rewritten versions.
This function returns a normalized URI and a docker path. The normalized
URI may have minor alterations meant to disambiguate and prepare for use
by shell utilities that may require a specific format.
... | def rewrite_uris(self, raw_uri, file_provider):
"""Accept a raw uri and return rewritten versions.
This function returns a normalized URI and a docker path. The normalized
URI may have minor alterations meant to disambiguate and prepare for use
by shell utilities that may require a specific format.
... | [
"Accept",
"a",
"raw",
"uri",
"and",
"return",
"rewritten",
"versions",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L92-L144 | [
"def",
"rewrite_uris",
"(",
"self",
",",
"raw_uri",
",",
"file_provider",
")",
":",
"if",
"file_provider",
"==",
"job_model",
".",
"P_GCS",
":",
"normalized",
",",
"docker_path",
"=",
"_gcs_uri_rewriter",
"(",
"raw_uri",
")",
"elif",
"file_provider",
"==",
"jo... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil.parse_file_provider | Find the file provider for a URI. | dsub/lib/param_util.py | def parse_file_provider(uri):
"""Find the file provider for a URI."""
providers = {'gs': job_model.P_GCS, 'file': job_model.P_LOCAL}
# URI scheme detector uses a range up to 30 since none of the IANA
# registered schemes are longer than this.
provider_found = re.match(r'^([A-Za-z][A-Za-z0-9+.-]{0,29... | def parse_file_provider(uri):
"""Find the file provider for a URI."""
providers = {'gs': job_model.P_GCS, 'file': job_model.P_LOCAL}
# URI scheme detector uses a range up to 30 since none of the IANA
# registered schemes are longer than this.
provider_found = re.match(r'^([A-Za-z][A-Za-z0-9+.-]{0,29... | [
"Find",
"the",
"file",
"provider",
"for",
"a",
"URI",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L147-L163 | [
"def",
"parse_file_provider",
"(",
"uri",
")",
":",
"providers",
"=",
"{",
"'gs'",
":",
"job_model",
".",
"P_GCS",
",",
"'file'",
":",
"job_model",
".",
"P_LOCAL",
"}",
"# URI scheme detector uses a range up to 30 since none of the IANA",
"# registered schemes are longer ... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil._validate_paths_or_fail | Do basic validation of the uri, return the path and filename. | dsub/lib/param_util.py | def _validate_paths_or_fail(uri, recursive):
"""Do basic validation of the uri, return the path and filename."""
path, filename = os.path.split(uri)
# dsub could support character ranges ([0-9]) with some more work, but for
# now we assume that basic asterisk wildcards are sufficient. Reject any URI
... | def _validate_paths_or_fail(uri, recursive):
"""Do basic validation of the uri, return the path and filename."""
path, filename = os.path.split(uri)
# dsub could support character ranges ([0-9]) with some more work, but for
# now we assume that basic asterisk wildcards are sufficient. Reject any URI
... | [
"Do",
"basic",
"validation",
"of",
"the",
"uri",
"return",
"the",
"path",
"and",
"filename",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L166-L196 | [
"def",
"_validate_paths_or_fail",
"(",
"uri",
",",
"recursive",
")",
":",
"path",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"uri",
")",
"# dsub could support character ranges ([0-9]) with some more work, but for",
"# now we assume that basic asterisk wildc... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil.parse_uri | Return a valid docker_path, uri, and file provider from a flag value. | dsub/lib/param_util.py | def parse_uri(self, raw_uri, recursive):
"""Return a valid docker_path, uri, and file provider from a flag value."""
# Assume recursive URIs are directory paths.
if recursive:
raw_uri = directory_fmt(raw_uri)
# Get the file provider, validate the raw URI, and rewrite the path
# component of th... | def parse_uri(self, raw_uri, recursive):
"""Return a valid docker_path, uri, and file provider from a flag value."""
# Assume recursive URIs are directory paths.
if recursive:
raw_uri = directory_fmt(raw_uri)
# Get the file provider, validate the raw URI, and rewrite the path
# component of th... | [
"Return",
"a",
"valid",
"docker_path",
"uri",
"and",
"file",
"provider",
"from",
"a",
"flag",
"value",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L198-L210 | [
"def",
"parse_uri",
"(",
"self",
",",
"raw_uri",
",",
"recursive",
")",
":",
"# Assume recursive URIs are directory paths.",
"if",
"recursive",
":",
"raw_uri",
"=",
"directory_fmt",
"(",
"raw_uri",
")",
"# Get the file provider, validate the raw URI, and rewrite the path",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | FileParamUtil.make_param | Return a *FileParam given an input uri. | dsub/lib/param_util.py | def make_param(self, name, raw_uri, recursive):
"""Return a *FileParam given an input uri."""
if not raw_uri:
return self.param_class(name, None, None, None, recursive, None)
docker_path, uri_parts, provider = self.parse_uri(raw_uri, recursive)
return self.param_class(name, raw_uri, docker_path, u... | def make_param(self, name, raw_uri, recursive):
"""Return a *FileParam given an input uri."""
if not raw_uri:
return self.param_class(name, None, None, None, recursive, None)
docker_path, uri_parts, provider = self.parse_uri(raw_uri, recursive)
return self.param_class(name, raw_uri, docker_path, u... | [
"Return",
"a",
"*",
"FileParam",
"given",
"an",
"input",
"uri",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L212-L218 | [
"def",
"make_param",
"(",
"self",
",",
"name",
",",
"raw_uri",
",",
"recursive",
")",
":",
"if",
"not",
"raw_uri",
":",
"return",
"self",
".",
"param_class",
"(",
"name",
",",
"None",
",",
"None",
",",
"None",
",",
"recursive",
",",
"None",
")",
"doc... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | MountParamUtil._parse_image_uri | Return a valid docker_path from a Google Persistent Disk url. | dsub/lib/param_util.py | def _parse_image_uri(self, raw_uri):
"""Return a valid docker_path from a Google Persistent Disk url."""
# The string replace is so we don't have colons and double slashes in the
# mount path. The idea is the resulting mount path would look like:
# /mnt/data/mount/http/www.googleapis.com/compute/v1/proj... | def _parse_image_uri(self, raw_uri):
"""Return a valid docker_path from a Google Persistent Disk url."""
# The string replace is so we don't have colons and double slashes in the
# mount path. The idea is the resulting mount path would look like:
# /mnt/data/mount/http/www.googleapis.com/compute/v1/proj... | [
"Return",
"a",
"valid",
"docker_path",
"from",
"a",
"Google",
"Persistent",
"Disk",
"url",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L243-L250 | [
"def",
"_parse_image_uri",
"(",
"self",
",",
"raw_uri",
")",
":",
"# The string replace is so we don't have colons and double slashes in the",
"# mount path. The idea is the resulting mount path would look like:",
"# /mnt/data/mount/http/www.googleapis.com/compute/v1/projects/...",
"docker_uri... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | MountParamUtil._parse_local_mount_uri | Return a valid docker_path for a local file path. | dsub/lib/param_util.py | def _parse_local_mount_uri(self, raw_uri):
"""Return a valid docker_path for a local file path."""
raw_uri = directory_fmt(raw_uri)
_, docker_path = _local_uri_rewriter(raw_uri)
local_path = docker_path[len('file'):]
docker_uri = os.path.join(self._relative_path, docker_path)
return local_path, ... | def _parse_local_mount_uri(self, raw_uri):
"""Return a valid docker_path for a local file path."""
raw_uri = directory_fmt(raw_uri)
_, docker_path = _local_uri_rewriter(raw_uri)
local_path = docker_path[len('file'):]
docker_uri = os.path.join(self._relative_path, docker_path)
return local_path, ... | [
"Return",
"a",
"valid",
"docker_path",
"for",
"a",
"local",
"file",
"path",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L252-L258 | [
"def",
"_parse_local_mount_uri",
"(",
"self",
",",
"raw_uri",
")",
":",
"raw_uri",
"=",
"directory_fmt",
"(",
"raw_uri",
")",
"_",
",",
"docker_path",
"=",
"_local_uri_rewriter",
"(",
"raw_uri",
")",
"local_path",
"=",
"docker_path",
"[",
"len",
"(",
"'file'",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | MountParamUtil._parse_gcs_uri | Return a valid docker_path for a GCS bucket. | dsub/lib/param_util.py | def _parse_gcs_uri(self, raw_uri):
"""Return a valid docker_path for a GCS bucket."""
# Assume URI is a directory path.
raw_uri = directory_fmt(raw_uri)
_, docker_path = _gcs_uri_rewriter(raw_uri)
docker_uri = os.path.join(self._relative_path, docker_path)
return docker_uri | def _parse_gcs_uri(self, raw_uri):
"""Return a valid docker_path for a GCS bucket."""
# Assume URI is a directory path.
raw_uri = directory_fmt(raw_uri)
_, docker_path = _gcs_uri_rewriter(raw_uri)
docker_uri = os.path.join(self._relative_path, docker_path)
return docker_uri | [
"Return",
"a",
"valid",
"docker_path",
"for",
"a",
"GCS",
"bucket",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L260-L266 | [
"def",
"_parse_gcs_uri",
"(",
"self",
",",
"raw_uri",
")",
":",
"# Assume URI is a directory path.",
"raw_uri",
"=",
"directory_fmt",
"(",
"raw_uri",
")",
"_",
",",
"docker_path",
"=",
"_gcs_uri_rewriter",
"(",
"raw_uri",
")",
"docker_uri",
"=",
"os",
".",
"path... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | MountParamUtil.make_param | Return a MountParam given a GCS bucket, disk image or local path. | dsub/lib/param_util.py | def make_param(self, name, raw_uri, disk_size):
"""Return a MountParam given a GCS bucket, disk image or local path."""
if raw_uri.startswith('https://www.googleapis.com/compute'):
# Full Image URI should look something like:
# https://www.googleapis.com/compute/v1/projects/<project>/global/images/
... | def make_param(self, name, raw_uri, disk_size):
"""Return a MountParam given a GCS bucket, disk image or local path."""
if raw_uri.startswith('https://www.googleapis.com/compute'):
# Full Image URI should look something like:
# https://www.googleapis.com/compute/v1/projects/<project>/global/images/
... | [
"Return",
"a",
"MountParam",
"given",
"a",
"GCS",
"bucket",
"disk",
"image",
"or",
"local",
"path",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/param_util.py#L268-L286 | [
"def",
"make_param",
"(",
"self",
",",
"name",
",",
"raw_uri",
",",
"disk_size",
")",
":",
"if",
"raw_uri",
".",
"startswith",
"(",
"'https://www.googleapis.com/compute'",
")",
":",
"# Full Image URI should look something like:",
"# https://www.googleapis.com/compute/v1/pro... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | validate_param_name | Validate that the name follows posix conventions for env variables. | dsub/lib/job_model.py | def validate_param_name(name, param_type):
"""Validate that the name follows posix conventions for env variables."""
# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235
#
# 3.235 Name
# In the shell command language, a word consisting solely of underscores,
# digits, and alp... | def validate_param_name(name, param_type):
"""Validate that the name follows posix conventions for env variables."""
# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235
#
# 3.235 Name
# In the shell command language, a word consisting solely of underscores,
# digits, and alp... | [
"Validate",
"that",
"the",
"name",
"follows",
"posix",
"conventions",
"for",
"env",
"variables",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L105-L113 | [
"def",
"validate_param_name",
"(",
"name",
",",
"param_type",
")",
":",
"# http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235",
"#",
"# 3.235 Name",
"# In the shell command language, a word consisting solely of underscores,",
"# digits, and alphabetics from th... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | validate_bucket_name | Validate that the name is a valid GCS bucket. | dsub/lib/job_model.py | def validate_bucket_name(bucket):
"""Validate that the name is a valid GCS bucket."""
if not bucket.startswith('gs://'):
raise ValueError(
'Invalid bucket path "%s". Must start with "gs://".' % bucket)
bucket_name = bucket[len('gs://'):]
if not re.search(r'^\w[\w_\.-]{1,61}\w$', bucket_name):
ra... | def validate_bucket_name(bucket):
"""Validate that the name is a valid GCS bucket."""
if not bucket.startswith('gs://'):
raise ValueError(
'Invalid bucket path "%s". Must start with "gs://".' % bucket)
bucket_name = bucket[len('gs://'):]
if not re.search(r'^\w[\w_\.-]{1,61}\w$', bucket_name):
ra... | [
"Validate",
"that",
"the",
"name",
"is",
"a",
"valid",
"GCS",
"bucket",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L116-L123 | [
"def",
"validate_bucket_name",
"(",
"bucket",
")",
":",
"if",
"not",
"bucket",
".",
"startswith",
"(",
"'gs://'",
")",
":",
"raise",
"ValueError",
"(",
"'Invalid bucket path \"%s\". Must start with \"gs://\".'",
"%",
"bucket",
")",
"bucket_name",
"=",
"bucket",
"[",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | convert_to_label_chars | Turn the specified name and value into a valid Google label. | dsub/lib/job_model.py | def convert_to_label_chars(s):
"""Turn the specified name and value into a valid Google label."""
# We want the results to be user-friendly, not just functional.
# So we can't base-64 encode it.
# * If upper-case: lower-case it
# * If the char is not a standard letter or digit. make it a dash
# March ... | def convert_to_label_chars(s):
"""Turn the specified name and value into a valid Google label."""
# We want the results to be user-friendly, not just functional.
# So we can't base-64 encode it.
# * If upper-case: lower-case it
# * If the char is not a standard letter or digit. make it a dash
# March ... | [
"Turn",
"the",
"specified",
"name",
"and",
"value",
"into",
"a",
"valid",
"Google",
"label",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L184-L208 | [
"def",
"convert_to_label_chars",
"(",
"s",
")",
":",
"# We want the results to be user-friendly, not just functional.",
"# So we can't base-64 encode it.",
"# * If upper-case: lower-case it",
"# * If the char is not a standard letter or digit. make it a dash",
"# March 2019 note: underscores... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | ensure_task_params_are_complete | For each task, ensure that each task param entry is not None. | dsub/lib/job_model.py | def ensure_task_params_are_complete(task_descriptors):
"""For each task, ensure that each task param entry is not None."""
for task_desc in task_descriptors:
for param in [
'labels', 'envs', 'inputs', 'outputs', 'input-recursives',
'output-recursives'
]:
if not task_desc.task_params.ge... | def ensure_task_params_are_complete(task_descriptors):
"""For each task, ensure that each task param entry is not None."""
for task_desc in task_descriptors:
for param in [
'labels', 'envs', 'inputs', 'outputs', 'input-recursives',
'output-recursives'
]:
if not task_desc.task_params.ge... | [
"For",
"each",
"task",
"ensure",
"that",
"each",
"task",
"param",
"entry",
"is",
"not",
"None",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L494-L502 | [
"def",
"ensure_task_params_are_complete",
"(",
"task_descriptors",
")",
":",
"for",
"task_desc",
"in",
"task_descriptors",
":",
"for",
"param",
"in",
"[",
"'labels'",
",",
"'envs'",
",",
"'inputs'",
",",
"'outputs'",
",",
"'input-recursives'",
",",
"'output-recursiv... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _remove_empty_items | Return a new dict with any empty items removed.
Note that this is not a deep check. If d contains a dictionary which
itself contains empty items, those are never checked.
This method exists to make to_serializable() functions cleaner.
We could revisit this some day, but for now, the serialized objects are
s... | dsub/lib/job_model.py | def _remove_empty_items(d, required):
"""Return a new dict with any empty items removed.
Note that this is not a deep check. If d contains a dictionary which
itself contains empty items, those are never checked.
This method exists to make to_serializable() functions cleaner.
We could revisit this some day, ... | def _remove_empty_items(d, required):
"""Return a new dict with any empty items removed.
Note that this is not a deep check. If d contains a dictionary which
itself contains empty items, those are never checked.
This method exists to make to_serializable() functions cleaner.
We could revisit this some day, ... | [
"Return",
"a",
"new",
"dict",
"with",
"any",
"empty",
"items",
"removed",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L505-L532 | [
"def",
"_remove_empty_items",
"(",
"d",
",",
"required",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"required",
":",
"new_dict",
"[",
"k",
"]",
"=",
"v",
"elif",
"isinstance... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | task_view_generator | Generator that yields a task-specific view of the job.
This generator exists to make it easy for callers to iterate over the tasks
in a JobDescriptor. Each pass yields a new JobDescriptor with a single task.
Args:
job_descriptor: A JobDescriptor with 1 or more tasks.
Yields:
A JobDescriptor with a si... | dsub/lib/job_model.py | def task_view_generator(job_descriptor):
"""Generator that yields a task-specific view of the job.
This generator exists to make it easy for callers to iterate over the tasks
in a JobDescriptor. Each pass yields a new JobDescriptor with a single task.
Args:
job_descriptor: A JobDescriptor with 1 or more t... | def task_view_generator(job_descriptor):
"""Generator that yields a task-specific view of the job.
This generator exists to make it easy for callers to iterate over the tasks
in a JobDescriptor. Each pass yields a new JobDescriptor with a single task.
Args:
job_descriptor: A JobDescriptor with 1 or more t... | [
"Generator",
"that",
"yields",
"a",
"task",
"-",
"specific",
"view",
"of",
"the",
"job",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L927-L942 | [
"def",
"task_view_generator",
"(",
"job_descriptor",
")",
":",
"for",
"task_descriptor",
"in",
"job_descriptor",
".",
"task_descriptors",
":",
"jd",
"=",
"JobDescriptor",
"(",
"job_descriptor",
".",
"job_metadata",
",",
"job_descriptor",
".",
"job_params",
",",
"job... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | numeric_task_id | Converts a task-id to the numeric task-id.
Args:
task_id: task-id in either task-n or n format
Returns:
n | dsub/lib/job_model.py | def numeric_task_id(task_id):
"""Converts a task-id to the numeric task-id.
Args:
task_id: task-id in either task-n or n format
Returns:
n
"""
# This function exists to support the legacy "task-id" format in the "google"
# provider. Google labels originally could not be numeric. When the google
... | def numeric_task_id(task_id):
"""Converts a task-id to the numeric task-id.
Args:
task_id: task-id in either task-n or n format
Returns:
n
"""
# This function exists to support the legacy "task-id" format in the "google"
# provider. Google labels originally could not be numeric. When the google
... | [
"Converts",
"a",
"task",
"-",
"id",
"to",
"the",
"numeric",
"task",
"-",
"id",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L945-L964 | [
"def",
"numeric_task_id",
"(",
"task_id",
")",
":",
"# This function exists to support the legacy \"task-id\" format in the \"google\"",
"# provider. Google labels originally could not be numeric. When the google",
"# provider is completely replaced by the google-v2 provider, this function can",
"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | LabelParam._validate_label | Raise ValueError if the label is invalid. | dsub/lib/job_model.py | def _validate_label(cls, name, value):
"""Raise ValueError if the label is invalid."""
# Rules for labels are described in:
# https://cloud.google.com/compute/docs/labeling-resources#restrictions
# * Keys and values cannot be longer than 63 characters each.
# * Keys and values can only contain low... | def _validate_label(cls, name, value):
"""Raise ValueError if the label is invalid."""
# Rules for labels are described in:
# https://cloud.google.com/compute/docs/labeling-resources#restrictions
# * Keys and values cannot be longer than 63 characters each.
# * Keys and values can only contain low... | [
"Raise",
"ValueError",
"if",
"the",
"label",
"is",
"invalid",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L231-L249 | [
"def",
"_validate_label",
"(",
"cls",
",",
"name",
",",
"value",
")",
":",
"# Rules for labels are described in:",
"# https://cloud.google.com/compute/docs/labeling-resources#restrictions",
"# * Keys and values cannot be longer than 63 characters each.",
"# * Keys and values can only cont... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | TaskDescriptor.to_serializable | Return a dict populated for serialization (as YAML/JSON). | dsub/lib/job_model.py | def to_serializable(self):
"""Return a dict populated for serialization (as YAML/JSON)."""
task_metadata = self.task_metadata
task_params = self.task_params
task_resources = self.task_resources
# The only required field is the task-id, even if it is None
task_id = None
if task_metadata.get... | def to_serializable(self):
"""Return a dict populated for serialization (as YAML/JSON)."""
task_metadata = self.task_metadata
task_params = self.task_params
task_resources = self.task_resources
# The only required field is the task-id, even if it is None
task_id = None
if task_metadata.get... | [
"Return",
"a",
"dict",
"populated",
"for",
"serialization",
"(",
"as",
"YAML",
"/",
"JSON",
")",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L565-L609 | [
"def",
"to_serializable",
"(",
"self",
")",
":",
"task_metadata",
"=",
"self",
".",
"task_metadata",
"task_params",
"=",
"self",
".",
"task_params",
"task_resources",
"=",
"self",
".",
"task_resources",
"# The only required field is the task-id, even if it is None",
"task... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | JobDescriptor.to_serializable | Return a dict populated for serialization (as YAML/JSON). | dsub/lib/job_model.py | def to_serializable(self):
"""Return a dict populated for serialization (as YAML/JSON)."""
job_metadata = self.job_metadata
job_resources = self.job_resources
job_params = self.job_params
task_descriptors = self.task_descriptors
job = {
'job-id': job_metadata.get('job-id'),
'jo... | def to_serializable(self):
"""Return a dict populated for serialization (as YAML/JSON)."""
job_metadata = self.job_metadata
job_resources = self.job_resources
job_params = self.job_params
task_descriptors = self.task_descriptors
job = {
'job-id': job_metadata.get('job-id'),
'jo... | [
"Return",
"a",
"dict",
"populated",
"for",
"serialization",
"(",
"as",
"YAML",
"/",
"JSON",
")",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L645-L703 | [
"def",
"to_serializable",
"(",
"self",
")",
":",
"job_metadata",
"=",
"self",
".",
"job_metadata",
"job_resources",
"=",
"self",
".",
"job_resources",
"job_params",
"=",
"self",
".",
"job_params",
"task_descriptors",
"=",
"self",
".",
"task_descriptors",
"job",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | JobDescriptor._from_yaml_v0 | Populate a JobDescriptor from the local provider's original meta.yaml.
The local job provider had the first incarnation of a YAML file for each
task. That idea was extended here in the JobDescriptor and the local
provider adopted the JobDescriptor.to_yaml() call to write its meta.yaml.
The JobDescript... | dsub/lib/job_model.py | def _from_yaml_v0(cls, job):
"""Populate a JobDescriptor from the local provider's original meta.yaml.
The local job provider had the first incarnation of a YAML file for each
task. That idea was extended here in the JobDescriptor and the local
provider adopted the JobDescriptor.to_yaml() call to write... | def _from_yaml_v0(cls, job):
"""Populate a JobDescriptor from the local provider's original meta.yaml.
The local job provider had the first incarnation of a YAML file for each
task. That idea was extended here in the JobDescriptor and the local
provider adopted the JobDescriptor.to_yaml() call to write... | [
"Populate",
"a",
"JobDescriptor",
"from",
"the",
"local",
"provider",
"s",
"original",
"meta",
".",
"yaml",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L760-L837 | [
"def",
"_from_yaml_v0",
"(",
"cls",
",",
"job",
")",
":",
"# The v0 meta.yaml only contained:",
"# create-time, job-id, job-name, logging, task-id",
"# labels, envs, inputs, outputs",
"# It did NOT contain user-id.",
"# dsub-version might be there as a label.",
"job_metadata",
"=",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | JobDescriptor.from_yaml | Populate and return a JobDescriptor from a YAML string. | dsub/lib/job_model.py | def from_yaml(cls, yaml_string):
"""Populate and return a JobDescriptor from a YAML string."""
try:
job = yaml.full_load(yaml_string)
except AttributeError:
# For installations that cannot update their PyYAML version
job = yaml.load(yaml_string)
# If the YAML does not contain a top-le... | def from_yaml(cls, yaml_string):
"""Populate and return a JobDescriptor from a YAML string."""
try:
job = yaml.full_load(yaml_string)
except AttributeError:
# For installations that cannot update their PyYAML version
job = yaml.load(yaml_string)
# If the YAML does not contain a top-le... | [
"Populate",
"and",
"return",
"a",
"JobDescriptor",
"from",
"a",
"YAML",
"string",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L840-L914 | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_string",
")",
":",
"try",
":",
"job",
"=",
"yaml",
".",
"full_load",
"(",
"yaml_string",
")",
"except",
"AttributeError",
":",
"# For installations that cannot update their PyYAML version",
"job",
"=",
"yaml",
".",
"load"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | JobDescriptor.find_task_descriptor | Returns the task_descriptor corresponding to task_id. | dsub/lib/job_model.py | def find_task_descriptor(self, task_id):
"""Returns the task_descriptor corresponding to task_id."""
# It is not guaranteed that the index will be task_id - 1 when --tasks is
# used with a min/max range.
for task_descriptor in self.task_descriptors:
if task_descriptor.task_metadata.get('task-id')... | def find_task_descriptor(self, task_id):
"""Returns the task_descriptor corresponding to task_id."""
# It is not guaranteed that the index will be task_id - 1 when --tasks is
# used with a min/max range.
for task_descriptor in self.task_descriptors:
if task_descriptor.task_metadata.get('task-id')... | [
"Returns",
"the",
"task_descriptor",
"corresponding",
"to",
"task_id",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/job_model.py#L916-L924 | [
"def",
"find_task_descriptor",
"(",
"self",
",",
"task_id",
")",
":",
"# It is not guaranteed that the index will be task_id - 1 when --tasks is",
"# used with a min/max range.",
"for",
"task_descriptor",
"in",
"self",
".",
"task_descriptors",
":",
"if",
"task_descriptor",
".",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_file_environment_variables | Return a dictionary of environment variables for the user container. | dsub/lib/providers_util.py | def get_file_environment_variables(file_params):
"""Return a dictionary of environment variables for the user container."""
env = {}
for param in file_params:
# We have no cases where the environment variable provided to user
# scripts have a trailing slash, so be sure to always strip it.
# The case t... | def get_file_environment_variables(file_params):
"""Return a dictionary of environment variables for the user container."""
env = {}
for param in file_params:
# We have no cases where the environment variable provided to user
# scripts have a trailing slash, so be sure to always strip it.
# The case t... | [
"Return",
"a",
"dictionary",
"of",
"environment",
"variables",
"for",
"the",
"user",
"container",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L60-L70 | [
"def",
"get_file_environment_variables",
"(",
"file_params",
")",
":",
"env",
"=",
"{",
"}",
"for",
"param",
"in",
"file_params",
":",
"# We have no cases where the environment variable provided to user",
"# scripts have a trailing slash, so be sure to always strip it.",
"# The cas... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_recursive_localize_env | Return a multi-line string with export statements for the variables.
Arguments:
destination: Folder where the data will be put.
For example /mnt/data
inputs: a list of InputFileParam
Returns:
a multi-line string with a shell script that sets environment variables
corresponding to ... | dsub/lib/providers_util.py | def build_recursive_localize_env(destination, inputs):
"""Return a multi-line string with export statements for the variables.
Arguments:
destination: Folder where the data will be put.
For example /mnt/data
inputs: a list of InputFileParam
Returns:
a multi-line string with a shell ... | def build_recursive_localize_env(destination, inputs):
"""Return a multi-line string with export statements for the variables.
Arguments:
destination: Folder where the data will be put.
For example /mnt/data
inputs: a list of InputFileParam
Returns:
a multi-line string with a shell ... | [
"Return",
"a",
"multi",
"-",
"line",
"string",
"with",
"export",
"statements",
"for",
"the",
"variables",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L73-L91 | [
"def",
"build_recursive_localize_env",
"(",
"destination",
",",
"inputs",
")",
":",
"export_input_dirs",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"'export {0}={1}/{2}'",
".",
"format",
"(",
"var",
".",
"name",
",",
"destination",
".",
"rstrip",
"(",
"'/'",
")",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_recursive_localize_command | Return a multi-line string with a shell script to copy recursively.
Arguments:
destination: Folder where to put the data.
For example /mnt/data
inputs: a list of InputFileParam
file_provider: file provider string used to filter the output params; the
returned command wil... | dsub/lib/providers_util.py | def build_recursive_localize_command(destination, inputs, file_provider):
"""Return a multi-line string with a shell script to copy recursively.
Arguments:
destination: Folder where to put the data.
For example /mnt/data
inputs: a list of InputFileParam
file_provider: file provider str... | def build_recursive_localize_command(destination, inputs, file_provider):
"""Return a multi-line string with a shell script to copy recursively.
Arguments:
destination: Folder where to put the data.
For example /mnt/data
inputs: a list of InputFileParam
file_provider: file provider str... | [
"Return",
"a",
"multi",
"-",
"line",
"string",
"with",
"a",
"shell",
"script",
"to",
"copy",
"recursively",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L94-L133 | [
"def",
"build_recursive_localize_command",
"(",
"destination",
",",
"inputs",
",",
"file_provider",
")",
":",
"command",
"=",
"_LOCALIZE_COMMAND_MAP",
"[",
"file_provider",
"]",
"filtered_inputs",
"=",
"[",
"var",
"for",
"var",
"in",
"inputs",
"if",
"var",
".",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_recursive_gcs_delocalize_env | Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam
Returns:
a multi-line string with a shell script that sets environment variables
corresponding to the outputs. | dsub/lib/providers_util.py | def build_recursive_gcs_delocalize_env(source, outputs):
"""Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam
Returns:
a multi-line string with a shell script that sets en... | def build_recursive_gcs_delocalize_env(source, outputs):
"""Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam
Returns:
a multi-line string with a shell script that sets en... | [
"Return",
"a",
"multi",
"-",
"line",
"string",
"with",
"export",
"statements",
"for",
"the",
"variables",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L136-L157 | [
"def",
"build_recursive_gcs_delocalize_env",
"(",
"source",
",",
"outputs",
")",
":",
"filtered_outs",
"=",
"[",
"var",
"for",
"var",
"in",
"outputs",
"if",
"var",
".",
"recursive",
"and",
"var",
".",
"file_provider",
"==",
"job_model",
".",
"P_GCS",
"]",
"r... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_recursive_delocalize_command | Return a multi-line string with a shell script to copy recursively.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam.
file_provider: file provider string used to filter the output params; the
returned command will only apply ou... | dsub/lib/providers_util.py | def build_recursive_delocalize_command(source, outputs, file_provider):
"""Return a multi-line string with a shell script to copy recursively.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam.
file_provider: file provider string used to filte... | def build_recursive_delocalize_command(source, outputs, file_provider):
"""Return a multi-line string with a shell script to copy recursively.
Arguments:
source: Folder with the data.
For example /mnt/data
outputs: a list of OutputFileParam.
file_provider: file provider string used to filte... | [
"Return",
"a",
"multi",
"-",
"line",
"string",
"with",
"a",
"shell",
"script",
"to",
"copy",
"recursively",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L160-L196 | [
"def",
"build_recursive_delocalize_command",
"(",
"source",
",",
"outputs",
",",
"file_provider",
")",
":",
"command",
"=",
"_LOCALIZE_COMMAND_MAP",
"[",
"file_provider",
"]",
"filtered_outputs",
"=",
"[",
"var",
"for",
"var",
"in",
"outputs",
"if",
"var",
".",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_mount_env | Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data. For example /mnt/data
mounts: a list of MountParam
Returns:
a multi-line string with a shell script that sets environment variables
corresponding to the mounts. | dsub/lib/providers_util.py | def build_mount_env(source, mounts):
"""Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data. For example /mnt/data
mounts: a list of MountParam
Returns:
a multi-line string with a shell script that sets environment variables
corresponding ... | def build_mount_env(source, mounts):
"""Return a multi-line string with export statements for the variables.
Arguments:
source: Folder with the data. For example /mnt/data
mounts: a list of MountParam
Returns:
a multi-line string with a shell script that sets environment variables
corresponding ... | [
"Return",
"a",
"multi",
"-",
"line",
"string",
"with",
"export",
"statements",
"for",
"the",
"variables",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L207-L221 | [
"def",
"build_mount_env",
"(",
"source",
",",
"mounts",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"[",
"'export {0}={1}/{2}'",
".",
"format",
"(",
"var",
".",
"name",
",",
"source",
".",
"rstrip",
"(",
"'/'",
")",
",",
"var",
".",
"docker_path",
"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_job_and_task_param | Returns a dict combining the field for job and task params. | dsub/lib/providers_util.py | def get_job_and_task_param(job_params, task_params, field):
"""Returns a dict combining the field for job and task params."""
return job_params.get(field, set()) | task_params.get(field, set()) | def get_job_and_task_param(job_params, task_params, field):
"""Returns a dict combining the field for job and task params."""
return job_params.get(field, set()) | task_params.get(field, set()) | [
"Returns",
"a",
"dict",
"combining",
"the",
"field",
"for",
"job",
"and",
"task",
"params",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/lib/providers_util.py#L224-L226 | [
"def",
"get_job_and_task_param",
"(",
"job_params",
",",
"task_params",
",",
"field",
")",
":",
"return",
"job_params",
".",
"get",
"(",
"field",
",",
"set",
"(",
")",
")",
"|",
"task_params",
".",
"get",
"(",
"field",
",",
"set",
"(",
")",
")"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _parse_arguments | Parses command line arguments.
Returns:
A Namespace of parsed arguments. | dsub/commands/ddel.py | def _parse_arguments():
"""Parses command line arguments.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it was passed.
param_util.handle_version_flag()
parser = provider_base.create_parser(sys.argv[0])
parser.add_argument(
'--version', '-v', default=False, he... | def _parse_arguments():
"""Parses command line arguments.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it was passed.
param_util.handle_version_flag()
parser = provider_base.create_parser(sys.argv[0])
parser.add_argument(
'--version', '-v', default=False, he... | [
"Parses",
"command",
"line",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/ddel.py#L30-L90 | [
"def",
"_parse_arguments",
"(",
")",
":",
"# Handle version flag and exit if it was passed.",
"param_util",
".",
"handle_version_flag",
"(",
")",
"parser",
"=",
"provider_base",
".",
"create_parser",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
"parser",
".",
"add... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _emit_search_criteria | Print the filters used to delete tasks. Use raw flags as arguments. | dsub/commands/ddel.py | def _emit_search_criteria(user_ids, job_ids, task_ids, labels):
"""Print the filters used to delete tasks. Use raw flags as arguments."""
print('Delete running jobs:')
print(' user:')
print(' %s\n' % user_ids)
print(' job-id:')
print(' %s\n' % job_ids)
if task_ids:
print(' task-id:')
prin... | def _emit_search_criteria(user_ids, job_ids, task_ids, labels):
"""Print the filters used to delete tasks. Use raw flags as arguments."""
print('Delete running jobs:')
print(' user:')
print(' %s\n' % user_ids)
print(' job-id:')
print(' %s\n' % job_ids)
if task_ids:
print(' task-id:')
prin... | [
"Print",
"the",
"filters",
"used",
"to",
"delete",
"tasks",
".",
"Use",
"raw",
"flags",
"as",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/ddel.py#L93-L106 | [
"def",
"_emit_search_criteria",
"(",
"user_ids",
",",
"job_ids",
",",
"task_ids",
",",
"labels",
")",
":",
"print",
"(",
"'Delete running jobs:'",
")",
"print",
"(",
"' user:'",
")",
"print",
"(",
"' %s\\n'",
"%",
"user_ids",
")",
"print",
"(",
"' job-id:... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | ddel_tasks | Kill jobs or job tasks.
This function separates ddel logic from flag parsing and user output. Users
of ddel who intend to access the data programmatically should use this.
Args:
provider: an instantiated dsub provider.
user_ids: a set of user ids who "own" the job(s) to delete.
job_ids: a set of job... | dsub/commands/ddel.py | def ddel_tasks(provider,
user_ids=None,
job_ids=None,
task_ids=None,
labels=None,
create_time_min=None,
create_time_max=None):
"""Kill jobs or job tasks.
This function separates ddel logic from flag parsing and user output. U... | def ddel_tasks(provider,
user_ids=None,
job_ids=None,
task_ids=None,
labels=None,
create_time_min=None,
create_time_max=None):
"""Kill jobs or job tasks.
This function separates ddel logic from flag parsing and user output. U... | [
"Kill",
"jobs",
"or",
"job",
"tasks",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/ddel.py#L158-L192 | [
"def",
"ddel_tasks",
"(",
"provider",
",",
"user_ids",
"=",
"None",
",",
"job_ids",
"=",
"None",
",",
"task_ids",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"create_time_min",
"=",
"None",
",",
"create_time_max",
"=",
"None",
")",
":",
"# Delete the req... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_action_by_id | Return the operation's array of actions. | dsub/providers/google_v2_operations.py | def get_action_by_id(op, action_id):
"""Return the operation's array of actions."""
actions = get_actions(op)
if actions and 1 <= action_id < len(actions):
return actions[action_id - 1] | def get_action_by_id(op, action_id):
"""Return the operation's array of actions."""
actions = get_actions(op)
if actions and 1 <= action_id < len(actions):
return actions[action_id - 1] | [
"Return",
"the",
"operation",
"s",
"array",
"of",
"actions",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L101-L105 | [
"def",
"get_action_by_id",
"(",
"op",
",",
"action_id",
")",
":",
"actions",
"=",
"get_actions",
"(",
"op",
")",
"if",
"actions",
"and",
"1",
"<=",
"action_id",
"<",
"len",
"(",
"actions",
")",
":",
"return",
"actions",
"[",
"action_id",
"-",
"1",
"]"
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _get_action_by_name | Return the value for the specified action. | dsub/providers/google_v2_operations.py | def _get_action_by_name(op, name):
"""Return the value for the specified action."""
actions = get_actions(op)
for action in actions:
if action.get('name') == name:
return action | def _get_action_by_name(op, name):
"""Return the value for the specified action."""
actions = get_actions(op)
for action in actions:
if action.get('name') == name:
return action | [
"Return",
"the",
"value",
"for",
"the",
"specified",
"action",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L108-L113 | [
"def",
"_get_action_by_name",
"(",
"op",
",",
"name",
")",
":",
"actions",
"=",
"get_actions",
"(",
"op",
")",
"for",
"action",
"in",
"actions",
":",
"if",
"action",
".",
"get",
"(",
"'name'",
")",
"==",
"name",
":",
"return",
"action"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_action_environment | Return the environment for the operation. | dsub/providers/google_v2_operations.py | def get_action_environment(op, name):
"""Return the environment for the operation."""
action = _get_action_by_name(op, name)
if action:
return action.get('environment') | def get_action_environment(op, name):
"""Return the environment for the operation."""
action = _get_action_by_name(op, name)
if action:
return action.get('environment') | [
"Return",
"the",
"environment",
"for",
"the",
"operation",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L116-L120 | [
"def",
"get_action_environment",
"(",
"op",
",",
"name",
")",
":",
"action",
"=",
"_get_action_by_name",
"(",
"op",
",",
"name",
")",
"if",
"action",
":",
"return",
"action",
".",
"get",
"(",
"'environment'",
")"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_action_image | Return the image for the operation. | dsub/providers/google_v2_operations.py | def get_action_image(op, name):
"""Return the image for the operation."""
action = _get_action_by_name(op, name)
if action:
return action.get('imageUri') | def get_action_image(op, name):
"""Return the image for the operation."""
action = _get_action_by_name(op, name)
if action:
return action.get('imageUri') | [
"Return",
"the",
"image",
"for",
"the",
"operation",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L123-L127 | [
"def",
"get_action_image",
"(",
"op",
",",
"name",
")",
":",
"action",
"=",
"_get_action_by_name",
"(",
"op",
",",
"name",
")",
"if",
"action",
":",
"return",
"action",
".",
"get",
"(",
"'imageUri'",
")"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_failed_events | Return the events (if any) with a non-zero exitStatus. | dsub/providers/google_v2_operations.py | def get_failed_events(op):
"""Return the events (if any) with a non-zero exitStatus."""
events = get_events(op)
if events:
return [
e for e in events if int(e.get('details', {}).get('exitStatus', 0)) != 0
]
return None | def get_failed_events(op):
"""Return the events (if any) with a non-zero exitStatus."""
events = get_events(op)
if events:
return [
e for e in events if int(e.get('details', {}).get('exitStatus', 0)) != 0
]
return None | [
"Return",
"the",
"events",
"(",
"if",
"any",
")",
"with",
"a",
"non",
"-",
"zero",
"exitStatus",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L143-L150 | [
"def",
"get_failed_events",
"(",
"op",
")",
":",
"events",
"=",
"get_events",
"(",
"op",
")",
"if",
"events",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"events",
"if",
"int",
"(",
"e",
".",
"get",
"(",
"'details'",
",",
"{",
"}",
")",
".",
"get"... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_event_of_type | Return all events of a particular type. | dsub/providers/google_v2_operations.py | def get_event_of_type(op, event_type):
"""Return all events of a particular type."""
events = get_events(op)
if not events:
return None
return [e for e in events if e.get('details', {}).get('@type') == event_type] | def get_event_of_type(op, event_type):
"""Return all events of a particular type."""
events = get_events(op)
if not events:
return None
return [e for e in events if e.get('details', {}).get('@type') == event_type] | [
"Return",
"all",
"events",
"of",
"a",
"particular",
"type",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L153-L159 | [
"def",
"get_event_of_type",
"(",
"op",
",",
"event_type",
")",
":",
"events",
"=",
"get_events",
"(",
"op",
")",
"if",
"not",
"events",
":",
"return",
"None",
"return",
"[",
"e",
"for",
"e",
"in",
"events",
"if",
"e",
".",
"get",
"(",
"'details'",
",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_last_update | Return the most recent timestamp in the operation. | dsub/providers/google_v2_operations.py | def get_last_update(op):
"""Return the most recent timestamp in the operation."""
last_update = get_end_time(op)
if not last_update:
last_event = get_last_event(op)
if last_event:
last_update = last_event['timestamp']
if not last_update:
last_update = get_create_time(op)
return last_updat... | def get_last_update(op):
"""Return the most recent timestamp in the operation."""
last_update = get_end_time(op)
if not last_update:
last_event = get_last_event(op)
if last_event:
last_update = last_event['timestamp']
if not last_update:
last_update = get_create_time(op)
return last_updat... | [
"Return",
"the",
"most",
"recent",
"timestamp",
"in",
"the",
"operation",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L167-L179 | [
"def",
"get_last_update",
"(",
"op",
")",
":",
"last_update",
"=",
"get_end_time",
"(",
"op",
")",
"if",
"not",
"last_update",
":",
"last_event",
"=",
"get_last_event",
"(",
"op",
")",
"if",
"last_event",
":",
"last_update",
"=",
"last_event",
"[",
"'timesta... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | is_dsub_operation | Determine if a pipelines operation is a dsub request.
We don't have a rigorous way to identify an operation as being submitted
by dsub. Our best option is to check for certain fields that have always
been part of dsub operations.
- labels: job-id, job-name, and user-id have always existed. The dsub-version
... | dsub/providers/google_v2_operations.py | def is_dsub_operation(op):
"""Determine if a pipelines operation is a dsub request.
We don't have a rigorous way to identify an operation as being submitted
by dsub. Our best option is to check for certain fields that have always
been part of dsub operations.
- labels: job-id, job-name, and user-id have alw... | def is_dsub_operation(op):
"""Determine if a pipelines operation is a dsub request.
We don't have a rigorous way to identify an operation as being submitted
by dsub. Our best option is to check for certain fields that have always
been part of dsub operations.
- labels: job-id, job-name, and user-id have alw... | [
"Determine",
"if",
"a",
"pipelines",
"operation",
"is",
"a",
"dsub",
"request",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_v2_operations.py#L204-L227 | [
"def",
"is_dsub_operation",
"(",
"op",
")",
":",
"if",
"not",
"is_pipeline",
"(",
"op",
")",
":",
"return",
"False",
"for",
"name",
"in",
"[",
"'dsub-version'",
",",
"'job-id'",
",",
"'job-name'",
",",
"'user-id'",
"]",
":",
"if",
"not",
"get_label",
"("... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _prepare_summary_table | Create a new table that is a summary of the input rows.
All with the same (job-name or job-id, status) go together.
Args:
rows: the input rows, a list of dictionaries.
Returns:
A new row set of summary information. | dsub/commands/dstat.py | def _prepare_summary_table(rows):
"""Create a new table that is a summary of the input rows.
All with the same (job-name or job-id, status) go together.
Args:
rows: the input rows, a list of dictionaries.
Returns:
A new row set of summary information.
"""
if not rows:
return []
# We either ... | def _prepare_summary_table(rows):
"""Create a new table that is a summary of the input rows.
All with the same (job-name or job-id, status) go together.
Args:
rows: the input rows, a list of dictionaries.
Returns:
A new row set of summary information.
"""
if not rows:
return []
# We either ... | [
"Create",
"a",
"new",
"table",
"that",
"is",
"a",
"summary",
"of",
"the",
"input",
"rows",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L230-L273 | [
"def",
"_prepare_summary_table",
"(",
"rows",
")",
":",
"if",
"not",
"rows",
":",
"return",
"[",
"]",
"# We either group on the job-name (if present) or fall back to the job-id",
"key_field",
"=",
"'job-name'",
"if",
"key_field",
"not",
"in",
"rows",
"[",
"0",
"]",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _prepare_row | return a dict with the task's info (more if "full" is set). | dsub/commands/dstat.py | def _prepare_row(task, full, summary):
"""return a dict with the task's info (more if "full" is set)."""
# Would like to include the Job ID in the default set of columns, but
# it is a long value and would leave little room for status and update time.
row_spec = collections.namedtuple('row_spec',
... | def _prepare_row(task, full, summary):
"""return a dict with the task's info (more if "full" is set)."""
# Would like to include the Job ID in the default set of columns, but
# it is a long value and would leave little room for status and update time.
row_spec = collections.namedtuple('row_spec',
... | [
"return",
"a",
"dict",
"with",
"the",
"task",
"s",
"info",
"(",
"more",
"if",
"full",
"is",
"set",
")",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L276-L342 | [
"def",
"_prepare_row",
"(",
"task",
",",
"full",
",",
"summary",
")",
":",
"# Would like to include the Job ID in the default set of columns, but",
"# it is a long value and would leave little room for status and update time.",
"row_spec",
"=",
"collections",
".",
"namedtuple",
"("... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _parse_arguments | Parses command line arguments.
Returns:
A Namespace of parsed arguments. | dsub/commands/dstat.py | def _parse_arguments():
"""Parses command line arguments.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it was passed.
param_util.handle_version_flag()
parser = provider_base.create_parser(sys.argv[0])
parser.add_argument(
'--version', '-v', default=False, he... | def _parse_arguments():
"""Parses command line arguments.
Returns:
A Namespace of parsed arguments.
"""
# Handle version flag and exit if it was passed.
param_util.handle_version_flag()
parser = provider_base.create_parser(sys.argv[0])
parser.add_argument(
'--version', '-v', default=False, he... | [
"Parses",
"command",
"line",
"arguments",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L345-L450 | [
"def",
"_parse_arguments",
"(",
")",
":",
"# Handle version flag and exit if it was passed.",
"param_util",
".",
"handle_version_flag",
"(",
")",
"parser",
"=",
"provider_base",
".",
"create_parser",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
"parser",
".",
"add... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | dstat_job_producer | Generate jobs as lists of task dicts ready for formatting/output.
Args:
provider: an instantiated dsub provider.
statuses: a set of status strings that eligible jobs may match.
user_ids: a set of user strings that eligible jobs may match.
job_ids: a set of job-id strings eligible jobs may match.
... | dsub/commands/dstat.py | def dstat_job_producer(provider,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
... | def dstat_job_producer(provider,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
... | [
"Generate",
"jobs",
"as",
"lists",
"of",
"task",
"dicts",
"ready",
"for",
"formatting",
"/",
"output",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L520-L603 | [
"def",
"dstat_job_producer",
"(",
"provider",
",",
"statuses",
",",
"user_ids",
"=",
"None",
",",
"job_ids",
"=",
"None",
",",
"job_names",
"=",
"None",
",",
"task_ids",
"=",
"None",
",",
"task_attempts",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"cr... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | lookup_job_tasks | Generate formatted jobs individually, in order of create-time.
Args:
provider: an instantiated dsub provider.
statuses: a set of status strings that eligible jobs may match.
user_ids: a set of user strings that eligible jobs may match.
job_ids: a set of job-id strings eligible jobs may match.
job... | dsub/commands/dstat.py | def lookup_job_tasks(provider,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
create_time_min=No... | def lookup_job_tasks(provider,
statuses,
user_ids=None,
job_ids=None,
job_names=None,
task_ids=None,
task_attempts=None,
labels=None,
create_time_min=No... | [
"Generate",
"formatted",
"jobs",
"individually",
"in",
"order",
"of",
"create",
"-",
"time",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L606-L657 | [
"def",
"lookup_job_tasks",
"(",
"provider",
",",
"statuses",
",",
"user_ids",
"=",
"None",
",",
"job_ids",
"=",
"None",
",",
"job_names",
"=",
"None",
",",
"task_ids",
"=",
"None",
",",
"task_attempts",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"crea... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | OutputFormatter.prepare_output | Convert types of task fields. | dsub/commands/dstat.py | def prepare_output(self, row):
"""Convert types of task fields."""
date_fields = ['last-update', 'create-time', 'start-time', 'end-time']
int_fields = ['task-attempt']
for col in date_fields:
if col in row:
row[col] = self.default_format_date(row[col])
for col in int_fields:
if... | def prepare_output(self, row):
"""Convert types of task fields."""
date_fields = ['last-update', 'create-time', 'start-time', 'end-time']
int_fields = ['task-attempt']
for col in date_fields:
if col in row:
row[col] = self.default_format_date(row[col])
for col in int_fields:
if... | [
"Convert",
"types",
"of",
"task",
"fields",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L74-L87 | [
"def",
"prepare_output",
"(",
"self",
",",
"row",
")",
":",
"date_fields",
"=",
"[",
"'last-update'",
",",
"'create-time'",
",",
"'start-time'",
",",
"'end-time'",
"]",
"int_fields",
"=",
"[",
"'task-attempt'",
"]",
"for",
"col",
"in",
"date_fields",
":",
"i... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | TextOutput.trim_display_field | Return a value for display; if longer than max length, use ellipsis. | dsub/commands/dstat.py | def trim_display_field(self, value, max_length):
"""Return a value for display; if longer than max length, use ellipsis."""
if not value:
return ''
if len(value) > max_length:
return value[:max_length - 3] + '...'
return value | def trim_display_field(self, value, max_length):
"""Return a value for display; if longer than max length, use ellipsis."""
if not value:
return ''
if len(value) > max_length:
return value[:max_length - 3] + '...'
return value | [
"Return",
"a",
"value",
"for",
"display",
";",
"if",
"longer",
"than",
"max",
"length",
"use",
"ellipsis",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L102-L108 | [
"def",
"trim_display_field",
"(",
"self",
",",
"value",
",",
"max_length",
")",
":",
"if",
"not",
"value",
":",
"return",
"''",
"if",
"len",
"(",
"value",
")",
">",
"max_length",
":",
"return",
"value",
"[",
":",
"max_length",
"-",
"3",
"]",
"+",
"'.... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | TextOutput.format_pairs | Returns a string of comma-delimited key=value pairs. | dsub/commands/dstat.py | def format_pairs(self, values):
"""Returns a string of comma-delimited key=value pairs."""
return ', '.join(
'%s=%s' % (key, value) for key, value in sorted(values.items())) | def format_pairs(self, values):
"""Returns a string of comma-delimited key=value pairs."""
return ', '.join(
'%s=%s' % (key, value) for key, value in sorted(values.items())) | [
"Returns",
"a",
"string",
"of",
"comma",
"-",
"delimited",
"key",
"=",
"value",
"pairs",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L115-L118 | [
"def",
"format_pairs",
"(",
"self",
",",
"values",
")",
":",
"return",
"', '",
".",
"join",
"(",
"'%s=%s'",
"%",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"values",
".",
"items",
"(",
")",
")",
")"
] | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | YamlOutput.string_presenter | Presenter to force yaml.dump to use multi-line string style. | dsub/commands/dstat.py | def string_presenter(self, dumper, data):
"""Presenter to force yaml.dump to use multi-line string style."""
if '\n' in data:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
else:
return dumper.represent_scalar('tag:yaml.org,2002:str', data) | def string_presenter(self, dumper, data):
"""Presenter to force yaml.dump to use multi-line string style."""
if '\n' in data:
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
else:
return dumper.represent_scalar('tag:yaml.org,2002:str', data) | [
"Presenter",
"to",
"force",
"yaml",
".",
"dump",
"to",
"use",
"multi",
"-",
"line",
"string",
"style",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/commands/dstat.py#L192-L197 | [
"def",
"string_presenter",
"(",
"self",
",",
"dumper",
",",
"data",
")",
":",
"if",
"'\\n'",
"in",
"data",
":",
"return",
"dumper",
".",
"represent_scalar",
"(",
"'tag:yaml.org,2002:str'",
",",
"data",
",",
"style",
"=",
"'|'",
")",
"else",
":",
"return",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_zones | Returns a list of zones based on any wildcard input.
This function is intended to provide an easy method for producing a list
of desired zones for a pipeline to run in.
The Pipelines API default zone list is "any zone". The problem with
"any zone" is that it can lead to incurring Cloud Storage egress charges
... | dsub/providers/google_base.py | def get_zones(input_list):
"""Returns a list of zones based on any wildcard input.
This function is intended to provide an easy method for producing a list
of desired zones for a pipeline to run in.
The Pipelines API default zone list is "any zone". The problem with
"any zone" is that it can lead to incurri... | def get_zones(input_list):
"""Returns a list of zones based on any wildcard input.
This function is intended to provide an easy method for producing a list
of desired zones for a pipeline to run in.
The Pipelines API default zone list is "any zone". The problem with
"any zone" is that it can lead to incurri... | [
"Returns",
"a",
"list",
"of",
"zones",
"based",
"on",
"any",
"wildcard",
"input",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L155-L197 | [
"def",
"get_zones",
"(",
"input_list",
")",
":",
"if",
"not",
"input_list",
":",
"return",
"[",
"]",
"output_list",
"=",
"[",
"]",
"for",
"zone",
"in",
"input_list",
":",
"if",
"zone",
".",
"endswith",
"(",
"'*'",
")",
":",
"prefix",
"=",
"zone",
"["... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | build_pipeline_labels | Build a set() of standard job and task labels.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
task_metadata: Task metadata, such as the task-id.
task_id_pattern: A pattern for the task-id value, such as "task-%d"; the
original google label values could not be strictly nume... | dsub/providers/google_base.py | def build_pipeline_labels(job_metadata, task_metadata, task_id_pattern=None):
"""Build a set() of standard job and task labels.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
task_metadata: Task metadata, such as the task-id.
task_id_pattern: A pattern for the task-id value, s... | def build_pipeline_labels(job_metadata, task_metadata, task_id_pattern=None):
"""Build a set() of standard job and task labels.
Args:
job_metadata: Job metadata, such as job-id, job-name, and user-id.
task_metadata: Task metadata, such as the task-id.
task_id_pattern: A pattern for the task-id value, s... | [
"Build",
"a",
"set",
"()",
"of",
"standard",
"job",
"and",
"task",
"labels",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L211-L239 | [
"def",
"build_pipeline_labels",
"(",
"job_metadata",
",",
"task_metadata",
",",
"task_id_pattern",
"=",
"None",
")",
":",
"labels",
"=",
"{",
"Label",
"(",
"name",
",",
"job_metadata",
"[",
"name",
"]",
")",
"for",
"name",
"in",
"[",
"'job-name'",
",",
"'j... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | prepare_job_metadata | Returns a dictionary of metadata fields for the job. | dsub/providers/google_base.py | def prepare_job_metadata(script, job_name, user_id, create_time):
"""Returns a dictionary of metadata fields for the job."""
# The name of the pipeline gets set into the ephemeralPipeline.name as-is.
# The default name of the pipeline is the script name
# The name of the job is derived from the job_name and ge... | def prepare_job_metadata(script, job_name, user_id, create_time):
"""Returns a dictionary of metadata fields for the job."""
# The name of the pipeline gets set into the ephemeralPipeline.name as-is.
# The default name of the pipeline is the script name
# The name of the job is derived from the job_name and ge... | [
"Returns",
"a",
"dictionary",
"of",
"metadata",
"fields",
"for",
"the",
"job",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L242-L284 | [
"def",
"prepare_job_metadata",
"(",
"script",
",",
"job_name",
",",
"user_id",
",",
"create_time",
")",
":",
"# The name of the pipeline gets set into the ephemeralPipeline.name as-is.",
"# The default name of the pipeline is the script name",
"# The name of the job is derived from the j... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | parse_rfc3339_utc_string | Converts a datestamp from RFC3339 UTC to a datetime.
Args:
rfc3339_utc_string: a datetime string in RFC3339 UTC "Zulu" format
Returns:
A datetime. | dsub/providers/google_base.py | def parse_rfc3339_utc_string(rfc3339_utc_string):
"""Converts a datestamp from RFC3339 UTC to a datetime.
Args:
rfc3339_utc_string: a datetime string in RFC3339 UTC "Zulu" format
Returns:
A datetime.
"""
# The timestamp from the Google Operations are all in RFC3339 format, but
# they are sometime... | def parse_rfc3339_utc_string(rfc3339_utc_string):
"""Converts a datestamp from RFC3339 UTC to a datetime.
Args:
rfc3339_utc_string: a datetime string in RFC3339 UTC "Zulu" format
Returns:
A datetime.
"""
# The timestamp from the Google Operations are all in RFC3339 format, but
# they are sometime... | [
"Converts",
"a",
"datestamp",
"from",
"RFC3339",
"UTC",
"to",
"a",
"datetime",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L301-L357 | [
"def",
"parse_rfc3339_utc_string",
"(",
"rfc3339_utc_string",
")",
":",
"# The timestamp from the Google Operations are all in RFC3339 format, but",
"# they are sometimes formatted to millisconds, microseconds, sometimes",
"# nanoseconds, and sometimes only seconds:",
"# * 2016-11-14T23:05:56Z",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | get_operation_full_job_id | Returns the job-id or job-id.task-id for the operation. | dsub/providers/google_base.py | def get_operation_full_job_id(op):
"""Returns the job-id or job-id.task-id for the operation."""
job_id = op.get_field('job-id')
task_id = op.get_field('task-id')
if task_id:
return '%s.%s' % (job_id, task_id)
else:
return job_id | def get_operation_full_job_id(op):
"""Returns the job-id or job-id.task-id for the operation."""
job_id = op.get_field('job-id')
task_id = op.get_field('task-id')
if task_id:
return '%s.%s' % (job_id, task_id)
else:
return job_id | [
"Returns",
"the",
"job",
"-",
"id",
"or",
"job",
"-",
"id",
".",
"task",
"-",
"id",
"for",
"the",
"operation",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L360-L367 | [
"def",
"get_operation_full_job_id",
"(",
"op",
")",
":",
"job_id",
"=",
"op",
".",
"get_field",
"(",
"'job-id'",
")",
"task_id",
"=",
"op",
".",
"get_field",
"(",
"'task-id'",
")",
"if",
"task_id",
":",
"return",
"'%s.%s'",
"%",
"(",
"job_id",
",",
"task... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _cancel_batch | Cancel a batch of operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages. | dsub/providers/google_base.py | def _cancel_batch(batch_fn, cancel_fn, ops):
"""Cancel a batch of operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages.
"""
# We define an in... | def _cancel_batch(batch_fn, cancel_fn, ops):
"""Cancel a batch of operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages.
"""
# We define an in... | [
"Cancel",
"a",
"batch",
"of",
"operations",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L370-L436 | [
"def",
"_cancel_batch",
"(",
"batch_fn",
",",
"cancel_fn",
",",
"ops",
")",
":",
"# We define an inline callback which will populate a list of",
"# successfully canceled operations as well as a list of operations",
"# which were not successfully canceled.",
"canceled",
"=",
"[",
"]",... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | cancel | Cancel operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages. | dsub/providers/google_base.py | def cancel(batch_fn, cancel_fn, ops):
"""Cancel operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages.
"""
# Canceling many operations one-by-... | def cancel(batch_fn, cancel_fn, ops):
"""Cancel operations.
Args:
batch_fn: API-specific batch function.
cancel_fn: API-specific cancel function.
ops: A list of operations to cancel.
Returns:
A list of operations canceled and a list of error messages.
"""
# Canceling many operations one-by-... | [
"Cancel",
"operations",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L439-L466 | [
"def",
"cancel",
"(",
"batch_fn",
",",
"cancel_fn",
",",
"ops",
")",
":",
"# Canceling many operations one-by-one can be slow.",
"# The Pipelines API doesn't directly support a list of operations to cancel,",
"# but the requests can be performed in batch.",
"canceled_ops",
"=",
"[",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | retry_api_check | Return True if we should retry. False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise. | dsub/providers/google_base.py | def retry_api_check(exception):
"""Return True if we should retry. False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise.
"""
if isinstance(exception, apiclient.errors.HttpError):
if exception.resp.status in TRANSIENT_HTTP_ERROR_... | def retry_api_check(exception):
"""Return True if we should retry. False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise.
"""
if isinstance(exception, apiclient.errors.HttpError):
if exception.resp.status in TRANSIENT_HTTP_ERROR_... | [
"Return",
"True",
"if",
"we",
"should",
"retry",
".",
"False",
"otherwise",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L469-L504 | [
"def",
"retry_api_check",
"(",
"exception",
")",
":",
"if",
"isinstance",
"(",
"exception",
",",
"apiclient",
".",
"errors",
".",
"HttpError",
")",
":",
"if",
"exception",
".",
"resp",
".",
"status",
"in",
"TRANSIENT_HTTP_ERROR_CODES",
":",
"_print_error",
"("... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | retry_auth_check | Specific check for auth error codes.
Return True if we should retry.
False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise. | dsub/providers/google_base.py | def retry_auth_check(exception):
"""Specific check for auth error codes.
Return True if we should retry.
False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise.
"""
if isinstance(exception, apiclient.errors.HttpError):
if exc... | def retry_auth_check(exception):
"""Specific check for auth error codes.
Return True if we should retry.
False otherwise.
Args:
exception: An exception to test for transience.
Returns:
True if we should retry. False otherwise.
"""
if isinstance(exception, apiclient.errors.HttpError):
if exc... | [
"Specific",
"check",
"for",
"auth",
"error",
"codes",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L507-L524 | [
"def",
"retry_auth_check",
"(",
"exception",
")",
":",
"if",
"isinstance",
"(",
"exception",
",",
"apiclient",
".",
"errors",
".",
"HttpError",
")",
":",
"if",
"exception",
".",
"resp",
".",
"status",
"in",
"HTTP_AUTH_ERROR_CODES",
":",
"_print_error",
"(",
... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | setup_service | Configures genomics API client.
Args:
api_name: Name of the Google API (for example: "genomics")
api_version: Version of the API (for example: "v2alpha1")
credentials: Credentials to be used for the gcloud API calls.
Returns:
A configured Google Genomics API client with appropriate credentials. | dsub/providers/google_base.py | def setup_service(api_name, api_version, credentials=None):
"""Configures genomics API client.
Args:
api_name: Name of the Google API (for example: "genomics")
api_version: Version of the API (for example: "v2alpha1")
credentials: Credentials to be used for the gcloud API calls.
Returns:
A confi... | def setup_service(api_name, api_version, credentials=None):
"""Configures genomics API client.
Args:
api_name: Name of the Google API (for example: "genomics")
api_version: Version of the API (for example: "v2alpha1")
credentials: Credentials to be used for the gcloud API calls.
Returns:
A confi... | [
"Configures",
"genomics",
"API",
"client",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L541-L556 | [
"def",
"setup_service",
"(",
"api_name",
",",
"api_version",
",",
"credentials",
"=",
"None",
")",
":",
"if",
"not",
"credentials",
":",
"credentials",
"=",
"oauth2client",
".",
"client",
".",
"GoogleCredentials",
".",
"get_application_default",
"(",
")",
"retur... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | Api.execute | Executes operation.
Args:
api: The base API object
Returns:
A response body object | dsub/providers/google_base.py | def execute(api):
"""Executes operation.
Args:
api: The base API object
Returns:
A response body object
"""
try:
return api.execute()
except Exception as exception:
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
_print_error('%s: Exception %s: %s' % (now, ... | def execute(api):
"""Executes operation.
Args:
api: The base API object
Returns:
A response body object
"""
try:
return api.execute()
except Exception as exception:
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
_print_error('%s: Exception %s: %s' % (now, ... | [
"Executes",
"operation",
"."
] | DataBiosphere/dsub | python | https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L577-L593 | [
"def",
"execute",
"(",
"api",
")",
":",
"try",
":",
"return",
"api",
".",
"execute",
"(",
")",
"except",
"Exception",
"as",
"exception",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S.%f'",
")",
"_print_error... | 443ce31daa6023dc2fd65ef2051796e19d18d5a7 |
valid | _eval_arg_type | Returns a type from a snippit of python source. Should normally be
something just like 'str' or 'Object'.
arg_type the source to be evaluated
T the default type
arg context of where this type was extracted
sig ... | flask_jsonrpc/__init__.py | def _eval_arg_type(arg_type, T=Any, arg=None, sig=None):
"""Returns a type from a snippit of python source. Should normally be
something just like 'str' or 'Object'.
arg_type the source to be evaluated
T the default type
arg context... | def _eval_arg_type(arg_type, T=Any, arg=None, sig=None):
"""Returns a type from a snippit of python source. Should normally be
something just like 'str' or 'Object'.
arg_type the source to be evaluated
T the default type
arg context... | [
"Returns",
"a",
"type",
"from",
"a",
"snippit",
"of",
"python",
"source",
".",
"Should",
"normally",
"be",
"something",
"just",
"like",
"str",
"or",
"Object",
"."
] | cenobites/flask-jsonrpc | python | https://github.com/cenobites/flask-jsonrpc/blob/c7f8e049adda8cf4c5a62aea345eb42697f10eff/flask_jsonrpc/__init__.py#L74-L94 | [
"def",
"_eval_arg_type",
"(",
"arg_type",
",",
"T",
"=",
"Any",
",",
"arg",
"=",
"None",
",",
"sig",
"=",
"None",
")",
":",
"try",
":",
"T",
"=",
"eval",
"(",
"arg_type",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"ValueError",
"(",
"'The... | c7f8e049adda8cf4c5a62aea345eb42697f10eff |
valid | jsonify_status_code | Returns a jsonified response with the specified HTTP status code.
The positional and keyword arguments are passed directly to the
:func:`flask.jsonify` function which creates the response. | flask_jsonrpc/helpers.py | def jsonify_status_code(status_code, *args, **kw):
"""Returns a jsonified response with the specified HTTP status code.
The positional and keyword arguments are passed directly to the
:func:`flask.jsonify` function which creates the response.
"""
is_batch = kw.pop('is_batch', False)
if is_batch... | def jsonify_status_code(status_code, *args, **kw):
"""Returns a jsonified response with the specified HTTP status code.
The positional and keyword arguments are passed directly to the
:func:`flask.jsonify` function which creates the response.
"""
is_batch = kw.pop('is_batch', False)
if is_batch... | [
"Returns",
"a",
"jsonified",
"response",
"with",
"the",
"specified",
"HTTP",
"status",
"code",
"."
] | cenobites/flask-jsonrpc | python | https://github.com/cenobites/flask-jsonrpc/blob/c7f8e049adda8cf4c5a62aea345eb42697f10eff/flask_jsonrpc/helpers.py#L47-L61 | [
"def",
"jsonify_status_code",
"(",
"status_code",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"is_batch",
"=",
"kw",
".",
"pop",
"(",
"'is_batch'",
",",
"False",
")",
"if",
"is_batch",
":",
"response",
"=",
"flask_make_response",
"(",
"json",
".",
... | c7f8e049adda8cf4c5a62aea345eb42697f10eff |
valid | _Blueprint.register | Called by :meth:`Flask.register_blueprint` to register a blueprint
on the application. This can be overridden to customize the register
behavior. Keyword arguments from
:func:`~flask.Flask.register_blueprint` are directly forwarded to this
method in the `options` dictionary. | flask_jsonrpc/views/browse/__init__.py | def register(self, app, options, first_registration=False):
"""Called by :meth:`Flask.register_blueprint` to register a blueprint
on the application. This can be overridden to customize the register
behavior. Keyword arguments from
:func:`~flask.Flask.register_blueprint` are directly for... | def register(self, app, options, first_registration=False):
"""Called by :meth:`Flask.register_blueprint` to register a blueprint
on the application. This can be overridden to customize the register
behavior. Keyword arguments from
:func:`~flask.Flask.register_blueprint` are directly for... | [
"Called",
"by",
":",
"meth",
":",
"Flask",
".",
"register_blueprint",
"to",
"register",
"a",
"blueprint",
"on",
"the",
"application",
".",
"This",
"can",
"be",
"overridden",
"to",
"customize",
"the",
"register",
"behavior",
".",
"Keyword",
"arguments",
"from",... | cenobites/flask-jsonrpc | python | https://github.com/cenobites/flask-jsonrpc/blob/c7f8e049adda8cf4c5a62aea345eb42697f10eff/flask_jsonrpc/views/browse/__init__.py#L35-L51 | [
"def",
"register",
"(",
"self",
",",
"app",
",",
"options",
",",
"first_registration",
"=",
"False",
")",
":",
"self",
".",
"jsonrpc_site",
"=",
"options",
".",
"get",
"(",
"'jsonrpc_site'",
")",
"self",
".",
"_got_registered_once",
"=",
"True",
"state",
"... | c7f8e049adda8cf4c5a62aea345eb42697f10eff |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.