repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
bd808/python-iptools | iptools/ipv4.py | validate_netmask | def validate_netmask(s):
"""Validate that a dotted-quad ip address is a valid netmask.
>>> validate_netmask('0.0.0.0')
True
>>> validate_netmask('128.0.0.0')
True
>>> validate_netmask('255.0.0.0')
True
>>> validate_netmask('255.255.255.255')
True
>>> validate_netmask(BROADCAST)... | python | def validate_netmask(s):
"""Validate that a dotted-quad ip address is a valid netmask.
>>> validate_netmask('0.0.0.0')
True
>>> validate_netmask('128.0.0.0')
True
>>> validate_netmask('255.0.0.0')
True
>>> validate_netmask('255.255.255.255')
True
>>> validate_netmask(BROADCAST)... | [
"def",
"validate_netmask",
"(",
"s",
")",
":",
"if",
"validate_ip",
"(",
"s",
")",
":",
"# Convert to binary string, strip '0b' prefix, 0 pad to 32 bits",
"mask",
"=",
"bin",
"(",
"ip2network",
"(",
"s",
")",
")",
"[",
"2",
":",
"]",
".",
"zfill",
"(",
"32",... | Validate that a dotted-quad ip address is a valid netmask.
>>> validate_netmask('0.0.0.0')
True
>>> validate_netmask('128.0.0.0')
True
>>> validate_netmask('255.0.0.0')
True
>>> validate_netmask('255.255.255.255')
True
>>> validate_netmask(BROADCAST)
True
>>> validate_netma... | [
"Validate",
"that",
"a",
"dotted",
"-",
"quad",
"ip",
"address",
"is",
"a",
"valid",
"netmask",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L269-L309 |
bd808/python-iptools | iptools/ipv4.py | validate_subnet | def validate_subnet(s):
"""Validate a dotted-quad ip address including a netmask.
The string is considered a valid dotted-quad address with netmask if it
consists of one to four octets (0-255) seperated by periods (.) followed
by a forward slash (/) and a subnet bitmask which is expressed in
dotted... | python | def validate_subnet(s):
"""Validate a dotted-quad ip address including a netmask.
The string is considered a valid dotted-quad address with netmask if it
consists of one to four octets (0-255) seperated by periods (.) followed
by a forward slash (/) and a subnet bitmask which is expressed in
dotted... | [
"def",
"validate_subnet",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"basestring",
")",
":",
"if",
"'/'",
"in",
"s",
":",
"start",
",",
"mask",
"=",
"s",
".",
"split",
"(",
"'/'",
",",
"2",
")",
"return",
"validate_ip",
"(",
"start",
... | Validate a dotted-quad ip address including a netmask.
The string is considered a valid dotted-quad address with netmask if it
consists of one to four octets (0-255) seperated by periods (.) followed
by a forward slash (/) and a subnet bitmask which is expressed in
dotted-quad format.
>>> validat... | [
"Validate",
"a",
"dotted",
"-",
"quad",
"ip",
"address",
"including",
"a",
"netmask",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L313-L352 |
bd808/python-iptools | iptools/ipv4.py | ip2long | def ip2long(ip):
"""Convert a dotted-quad ip address to a network byte order 32-bit
integer.
>>> ip2long('127.0.0.1')
2130706433
>>> ip2long('127.1')
2130706433
>>> ip2long('127')
2130706432
>>> ip2long('127.0.0.256') is None
True
:param ip: Dotted-quad ip address (eg. '1... | python | def ip2long(ip):
"""Convert a dotted-quad ip address to a network byte order 32-bit
integer.
>>> ip2long('127.0.0.1')
2130706433
>>> ip2long('127.1')
2130706433
>>> ip2long('127')
2130706432
>>> ip2long('127.0.0.256') is None
True
:param ip: Dotted-quad ip address (eg. '1... | [
"def",
"ip2long",
"(",
"ip",
")",
":",
"if",
"not",
"validate_ip",
"(",
"ip",
")",
":",
"return",
"None",
"quads",
"=",
"ip",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"quads",
")",
"==",
"1",
":",
"# only a network quad",
"quads",
"=",
"qua... | Convert a dotted-quad ip address to a network byte order 32-bit
integer.
>>> ip2long('127.0.0.1')
2130706433
>>> ip2long('127.1')
2130706433
>>> ip2long('127')
2130706432
>>> ip2long('127.0.0.256') is None
True
:param ip: Dotted-quad ip address (eg. '127.0.0.1').
:type ip... | [
"Convert",
"a",
"dotted",
"-",
"quad",
"ip",
"address",
"to",
"a",
"network",
"byte",
"order",
"32",
"-",
"bit",
"integer",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L356-L389 |
bd808/python-iptools | iptools/ipv4.py | ip2network | def ip2network(ip):
"""Convert a dotted-quad ip to base network number.
This differs from :func:`ip2long` in that partial addresses as treated as
all network instead of network plus host (eg. '127.1' expands to
'127.1.0.0')
:param ip: dotted-quad ip address (eg. ‘127.0.0.1’).
:type ip: str
... | python | def ip2network(ip):
"""Convert a dotted-quad ip to base network number.
This differs from :func:`ip2long` in that partial addresses as treated as
all network instead of network plus host (eg. '127.1' expands to
'127.1.0.0')
:param ip: dotted-quad ip address (eg. ‘127.0.0.1’).
:type ip: str
... | [
"def",
"ip2network",
"(",
"ip",
")",
":",
"if",
"not",
"validate_ip",
"(",
"ip",
")",
":",
"return",
"None",
"quads",
"=",
"ip",
".",
"split",
"(",
"'.'",
")",
"netw",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"4",
")",
":",
"netw",
"=",
"(",
... | Convert a dotted-quad ip to base network number.
This differs from :func:`ip2long` in that partial addresses as treated as
all network instead of network plus host (eg. '127.1' expands to
'127.1.0.0')
:param ip: dotted-quad ip address (eg. ‘127.0.0.1’).
:type ip: str
:returns: Network byte ord... | [
"Convert",
"a",
"dotted",
"-",
"quad",
"ip",
"to",
"base",
"network",
"number",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L393-L410 |
bd808/python-iptools | iptools/ipv4.py | long2ip | def long2ip(l):
"""Convert a network byte order 32-bit integer to a dotted quad ip
address.
>>> long2ip(2130706433)
'127.0.0.1'
>>> long2ip(MIN_IP)
'0.0.0.0'
>>> long2ip(MAX_IP)
'255.255.255.255'
>>> long2ip(None) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call l... | python | def long2ip(l):
"""Convert a network byte order 32-bit integer to a dotted quad ip
address.
>>> long2ip(2130706433)
'127.0.0.1'
>>> long2ip(MIN_IP)
'0.0.0.0'
>>> long2ip(MAX_IP)
'255.255.255.255'
>>> long2ip(None) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call l... | [
"def",
"long2ip",
"(",
"l",
")",
":",
"if",
"MAX_IP",
"<",
"l",
"or",
"l",
"<",
"MIN_IP",
":",
"raise",
"TypeError",
"(",
"\"expected int between %d and %d inclusive\"",
"%",
"(",
"MIN_IP",
",",
"MAX_IP",
")",
")",
"return",
"'%d.%d.%d.%d'",
"%",
"(",
"l",... | Convert a network byte order 32-bit integer to a dotted quad ip
address.
>>> long2ip(2130706433)
'127.0.0.1'
>>> long2ip(MIN_IP)
'0.0.0.0'
>>> long2ip(MAX_IP)
'255.255.255.255'
>>> long2ip(None) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
T... | [
"Convert",
"a",
"network",
"byte",
"order",
"32",
"-",
"bit",
"integer",
"to",
"a",
"dotted",
"quad",
"ip",
"address",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L414-L452 |
bd808/python-iptools | iptools/ipv4.py | cidr2block | def cidr2block(cidr):
"""Convert a CIDR notation ip address into a tuple containing the network
block start and end addresses.
>>> cidr2block('127.0.0.1/32')
('127.0.0.1', '127.0.0.1')
>>> cidr2block('127/8')
('127.0.0.0', '127.255.255.255')
>>> cidr2block('127.0.1/16')
('127.0.0.0', '... | python | def cidr2block(cidr):
"""Convert a CIDR notation ip address into a tuple containing the network
block start and end addresses.
>>> cidr2block('127.0.0.1/32')
('127.0.0.1', '127.0.0.1')
>>> cidr2block('127/8')
('127.0.0.0', '127.255.255.255')
>>> cidr2block('127.0.1/16')
('127.0.0.0', '... | [
"def",
"cidr2block",
"(",
"cidr",
")",
":",
"if",
"not",
"validate_cidr",
"(",
"cidr",
")",
":",
"return",
"None",
"ip",
",",
"prefix",
"=",
"cidr",
".",
"split",
"(",
"'/'",
")",
"prefix",
"=",
"int",
"(",
"prefix",
")",
"# convert dotted-quad ip to bas... | Convert a CIDR notation ip address into a tuple containing the network
block start and end addresses.
>>> cidr2block('127.0.0.1/32')
('127.0.0.1', '127.0.0.1')
>>> cidr2block('127/8')
('127.0.0.0', '127.255.255.255')
>>> cidr2block('127.0.1/16')
('127.0.0.0', '127.0.255.255')
>>> cidr2... | [
"Convert",
"a",
"CIDR",
"notation",
"ip",
"address",
"into",
"a",
"tuple",
"containing",
"the",
"network",
"block",
"start",
"and",
"end",
"addresses",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L514-L547 |
bd808/python-iptools | iptools/ipv4.py | subnet2block | def subnet2block(subnet):
"""Convert a dotted-quad ip address including a netmask into a tuple
containing the network block start and end addresses.
>>> subnet2block('127.0.0.1/255.255.255.255')
('127.0.0.1', '127.0.0.1')
>>> subnet2block('127/255')
('127.0.0.0', '127.255.255.255')
>>> sub... | python | def subnet2block(subnet):
"""Convert a dotted-quad ip address including a netmask into a tuple
containing the network block start and end addresses.
>>> subnet2block('127.0.0.1/255.255.255.255')
('127.0.0.1', '127.0.0.1')
>>> subnet2block('127/255')
('127.0.0.0', '127.255.255.255')
>>> sub... | [
"def",
"subnet2block",
"(",
"subnet",
")",
":",
"if",
"not",
"validate_subnet",
"(",
"subnet",
")",
":",
"return",
"None",
"ip",
",",
"netmask",
"=",
"subnet",
".",
"split",
"(",
"'/'",
")",
"prefix",
"=",
"netmask2prefix",
"(",
"netmask",
")",
"# conver... | Convert a dotted-quad ip address including a netmask into a tuple
containing the network block start and end addresses.
>>> subnet2block('127.0.0.1/255.255.255.255')
('127.0.0.1', '127.0.0.1')
>>> subnet2block('127/255')
('127.0.0.0', '127.255.255.255')
>>> subnet2block('127.0.1/255.255')
... | [
"Convert",
"a",
"dotted",
"-",
"quad",
"ip",
"address",
"including",
"a",
"netmask",
"into",
"a",
"tuple",
"containing",
"the",
"network",
"block",
"start",
"and",
"end",
"addresses",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L579-L613 |
bd808/python-iptools | iptools/ipv4.py | _block_from_ip_and_prefix | def _block_from_ip_and_prefix(ip, prefix):
"""Create a tuple of (start, end) dotted-quad addresses from the given
ip address and prefix length.
:param ip: Ip address in block
:type ip: long
:param prefix: Prefix size for block
:type prefix: int
:returns: Tuple of block (start, end)
"""
... | python | def _block_from_ip_and_prefix(ip, prefix):
"""Create a tuple of (start, end) dotted-quad addresses from the given
ip address and prefix length.
:param ip: Ip address in block
:type ip: long
:param prefix: Prefix size for block
:type prefix: int
:returns: Tuple of block (start, end)
"""
... | [
"def",
"_block_from_ip_and_prefix",
"(",
"ip",
",",
"prefix",
")",
":",
"# keep left most prefix bits of ip",
"shift",
"=",
"32",
"-",
"prefix",
"block_start",
"=",
"ip",
">>",
"shift",
"<<",
"shift",
"# expand right most 32 - prefix bits to 1",
"mask",
"=",
"(",
"1... | Create a tuple of (start, end) dotted-quad addresses from the given
ip address and prefix length.
:param ip: Ip address in block
:type ip: long
:param prefix: Prefix size for block
:type prefix: int
:returns: Tuple of block (start, end) | [
"Create",
"a",
"tuple",
"of",
"(",
"start",
"end",
")",
"dotted",
"-",
"quad",
"addresses",
"from",
"the",
"given",
"ip",
"address",
"and",
"prefix",
"length",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/ipv4.py#L617-L634 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | download_shared_files | def download_shared_files(job, samples, config):
"""
Downloads files shared by all samples in the pipeline
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list of sample... | python | def download_shared_files(job, samples, config):
"""
Downloads files shared by all samples in the pipeline
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list of sample... | [
"def",
"download_shared_files",
"(",
"job",
",",
"samples",
",",
"config",
")",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Downloaded shared files'",
")",
"file_names",
"=",
"[",
"'reference'",
",",
"'phase'",
",",
"'mills'",
",",
"'dbsnp'",
",",... | Downloads files shared by all samples in the pipeline
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list of samples containing sample information | [
"Downloads",
"files",
"shared",
"by",
"all",
"samples",
"in",
"the",
"pipeline"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L29-L43 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | reference_preprocessing | def reference_preprocessing(job, samples, config):
"""
Spawn the jobs that create index and dict file for reference
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list ... | python | def reference_preprocessing(job, samples, config):
"""
Spawn the jobs that create index and dict file for reference
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list ... | [
"def",
"reference_preprocessing",
"(",
"job",
",",
"samples",
",",
"config",
")",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Processed reference files'",
")",
"config",
".",
"fai",
"=",
"job",
".",
"addChildJobFn",
"(",
"run_samtools_faidx",
",",
... | Spawn the jobs that create index and dict file for reference
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param list[list] samples: A nested list of samples containing sample information | [
"Spawn",
"the",
"jobs",
"that",
"create",
"index",
"and",
"dict",
"file",
"for",
"reference"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L46-L57 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | download_sample | def download_sample(job, sample, config):
"""
Download sample and store sample specific attributes
:param JobFunctionWrappingJob job: passed automatically by Toil
:param list sample: Contains uuid, normal URL, and tumor URL
:param Namespace config: Argparse Namespace object containing argument inpu... | python | def download_sample(job, sample, config):
"""
Download sample and store sample specific attributes
:param JobFunctionWrappingJob job: passed automatically by Toil
:param list sample: Contains uuid, normal URL, and tumor URL
:param Namespace config: Argparse Namespace object containing argument inpu... | [
"def",
"download_sample",
"(",
"job",
",",
"sample",
",",
"config",
")",
":",
"# Create copy of config that is sample specific",
"config",
"=",
"argparse",
".",
"Namespace",
"(",
"*",
"*",
"vars",
"(",
"config",
")",
")",
"uuid",
",",
"normal_url",
",",
"tumor... | Download sample and store sample specific attributes
:param JobFunctionWrappingJob job: passed automatically by Toil
:param list sample: Contains uuid, normal URL, and tumor URL
:param Namespace config: Argparse Namespace object containing argument inputs | [
"Download",
"sample",
"and",
"store",
"sample",
"specific",
"attributes"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L60-L82 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | index_bams | def index_bams(job, config):
"""
Convenience job for handling bam indexing to make the workflow declaration cleaner
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
"""
job.fileStore.logToMaster('Indexe... | python | def index_bams(job, config):
"""
Convenience job for handling bam indexing to make the workflow declaration cleaner
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
"""
job.fileStore.logToMaster('Indexe... | [
"def",
"index_bams",
"(",
"job",
",",
"config",
")",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Indexed sample BAMS: '",
"+",
"config",
".",
"uuid",
")",
"disk",
"=",
"'1G'",
"if",
"config",
".",
"ci_test",
"else",
"'20G'",
"config",
".",
"... | Convenience job for handling bam indexing to make the workflow declaration cleaner
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs | [
"Convenience",
"job",
"for",
"handling",
"bam",
"indexing",
"to",
"make",
"the",
"workflow",
"declaration",
"cleaner"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L85-L96 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | preprocessing_declaration | def preprocessing_declaration(job, config):
"""
Declare jobs related to preprocessing
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
"""
if config.preprocessing:
job.fileStore.logToMaster('Ran... | python | def preprocessing_declaration(job, config):
"""
Declare jobs related to preprocessing
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
"""
if config.preprocessing:
job.fileStore.logToMaster('Ran... | [
"def",
"preprocessing_declaration",
"(",
"job",
",",
"config",
")",
":",
"if",
"config",
".",
"preprocessing",
":",
"job",
".",
"fileStore",
".",
"logToMaster",
"(",
"'Ran preprocessing: '",
"+",
"config",
".",
"uuid",
")",
"disk",
"=",
"'1G'",
"if",
"config... | Declare jobs related to preprocessing
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs | [
"Declare",
"jobs",
"related",
"to",
"preprocessing"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L99-L123 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | static_workflow_declaration | def static_workflow_declaration(job, config, normal_bam, normal_bai, tumor_bam, tumor_bai):
"""
Statically declare workflow so sections can be modularly repurposed
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inpu... | python | def static_workflow_declaration(job, config, normal_bam, normal_bai, tumor_bam, tumor_bai):
"""
Statically declare workflow so sections can be modularly repurposed
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inpu... | [
"def",
"static_workflow_declaration",
"(",
"job",
",",
"config",
",",
"normal_bam",
",",
"normal_bai",
",",
"tumor_bam",
",",
"tumor_bai",
")",
":",
"# Mutation and indel tool wiring",
"memory",
"=",
"'1G'",
"if",
"config",
".",
"ci_test",
"else",
"'10G'",
"disk",... | Statically declare workflow so sections can be modularly repurposed
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param str normal_bam: Normal BAM FileStoreID
:param str normal_bai: Normal BAM index FileSto... | [
"Statically",
"declare",
"workflow",
"so",
"sections",
"can",
"be",
"modularly",
"repurposed"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L126-L155 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | consolidate_output | def consolidate_output(job, config, mutect, pindel, muse):
"""
Combine the contents of separate tarball outputs into one via streaming
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param str mutect: MuT... | python | def consolidate_output(job, config, mutect, pindel, muse):
"""
Combine the contents of separate tarball outputs into one via streaming
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param str mutect: MuT... | [
"def",
"consolidate_output",
"(",
"job",
",",
"config",
",",
"mutect",
",",
"pindel",
",",
"muse",
")",
":",
"work_dir",
"=",
"job",
".",
"fileStore",
".",
"getLocalTempDir",
"(",
")",
"mutect_tar",
",",
"pindel_tar",
",",
"muse_tar",
"=",
"None",
",",
"... | Combine the contents of separate tarball outputs into one via streaming
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace config: Argparse Namespace object containing argument inputs
:param str mutect: MuTect tarball FileStoreID
:param str pindel: Pindel tarball FileStore... | [
"Combine",
"the",
"contents",
"of",
"separate",
"tarball",
"outputs",
"into",
"one",
"via",
"streaming"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L158-L198 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | parse_manifest | def parse_manifest(path_to_manifest):
"""
Parses samples, specified in either a manifest or listed with --samples
:param str path_to_manifest: Path to configuration file
:return: Samples and their attributes as defined in the manifest
:rtype: list[list]
"""
samples = []
with open(path_t... | python | def parse_manifest(path_to_manifest):
"""
Parses samples, specified in either a manifest or listed with --samples
:param str path_to_manifest: Path to configuration file
:return: Samples and their attributes as defined in the manifest
:rtype: list[list]
"""
samples = []
with open(path_t... | [
"def",
"parse_manifest",
"(",
"path_to_manifest",
")",
":",
"samples",
"=",
"[",
"]",
"with",
"open",
"(",
"path_to_manifest",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
"if",
"not",
"line",
".",
"issp... | Parses samples, specified in either a manifest or listed with --samples
:param str path_to_manifest: Path to configuration file
:return: Samples and their attributes as defined in the manifest
:rtype: list[list] | [
"Parses",
"samples",
"specified",
"in",
"either",
"a",
"manifest",
"or",
"listed",
"with",
"--",
"samples"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L201-L220 |
BD2KGenomics/toil-scripts | src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py | main | def main():
"""
Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil exome pipeline
Perform variant / indel analysis given a pair of tumor/normal BAM files.
Samples are optionally preprocessed (indel realignment and base quality score recalibration)
The output of this pipeline is ... | python | def main():
"""
Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil exome pipeline
Perform variant / indel analysis given a pair of tumor/normal BAM files.
Samples are optionally preprocessed (indel realignment and base quality score recalibration)
The output of this pipeline is ... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"subparsers",
"=",
"parser",
".",
"add_subparsers",
"(",... | Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil exome pipeline
Perform variant / indel analysis given a pair of tumor/normal BAM files.
Samples are optionally preprocessed (indel realignment and base quality score recalibration)
The output of this pipeline is a tarball containing res... | [
"Computational",
"Genomics",
"Lab",
"Genomics",
"Institute",
"UC",
"Santa",
"Cruz",
"Toil",
"exome",
"pipeline"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/exome_variant_pipeline/exome_variant_pipeline.py#L303-L424 |
BD2KGenomics/toil-scripts | src/toil_scripts/bwa_alignment/bwa_alignment.py | download_reference_files | def download_reference_files(job, inputs, samples):
"""
Downloads shared files that are used by all samples for alignment, or generates them if they were not provided.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace inputs: Input arguments (see main)
:param list[lis... | python | def download_reference_files(job, inputs, samples):
"""
Downloads shared files that are used by all samples for alignment, or generates them if they were not provided.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace inputs: Input arguments (see main)
:param list[lis... | [
"def",
"download_reference_files",
"(",
"job",
",",
"inputs",
",",
"samples",
")",
":",
"# Create dictionary to store FileStoreIDs of shared input files",
"shared_ids",
"=",
"{",
"}",
"urls",
"=",
"[",
"(",
"'amb'",
",",
"inputs",
".",
"amb",
")",
",",
"(",
"'an... | Downloads shared files that are used by all samples for alignment, or generates them if they were not provided.
:param JobFunctionWrappingJob job: passed automatically by Toil
:param Namespace inputs: Input arguments (see main)
:param list[list[str, list[str, str]]] samples: Samples in the format [UUID, [U... | [
"Downloads",
"shared",
"files",
"that",
"are",
"used",
"by",
"all",
"samples",
"for",
"alignment",
"or",
"generates",
"them",
"if",
"they",
"were",
"not",
"provided",
"."
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/bwa_alignment.py#L21-L58 |
BD2KGenomics/toil-scripts | src/toil_scripts/bwa_alignment/bwa_alignment.py | download_sample_and_align | def download_sample_and_align(job, sample, inputs, ids):
"""
Downloads the sample and runs BWA-kit
:param JobFunctionWrappingJob job: Passed by Toil automatically
:param tuple(str, list) sample: UUID and URLS for sample
:param Namespace inputs: Contains input arguments
:param dict ids: FileStor... | python | def download_sample_and_align(job, sample, inputs, ids):
"""
Downloads the sample and runs BWA-kit
:param JobFunctionWrappingJob job: Passed by Toil automatically
:param tuple(str, list) sample: UUID and URLS for sample
:param Namespace inputs: Contains input arguments
:param dict ids: FileStor... | [
"def",
"download_sample_and_align",
"(",
"job",
",",
"sample",
",",
"inputs",
",",
"ids",
")",
":",
"uuid",
",",
"urls",
"=",
"sample",
"r1_url",
",",
"r2_url",
"=",
"urls",
"if",
"len",
"(",
"urls",
")",
"==",
"2",
"else",
"(",
"urls",
"[",
"0",
"... | Downloads the sample and runs BWA-kit
:param JobFunctionWrappingJob job: Passed by Toil automatically
:param tuple(str, list) sample: UUID and URLS for sample
:param Namespace inputs: Contains input arguments
:param dict ids: FileStore IDs for shared inputs | [
"Downloads",
"the",
"sample",
"and",
"runs",
"BWA",
"-",
"kit"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/bwa_alignment.py#L61-L96 |
BD2KGenomics/toil-scripts | src/toil_scripts/bwa_alignment/bwa_alignment.py | parse_manifest | def parse_manifest(manifest_path):
"""
Parse manifest file
:param str manifest_path: Path to manifest file
:return: samples
:rtype: list[str, list]
"""
samples = []
with open(manifest_path, 'r') as f:
for line in f:
if not line.isspace() and not line.startswith('#'):... | python | def parse_manifest(manifest_path):
"""
Parse manifest file
:param str manifest_path: Path to manifest file
:return: samples
:rtype: list[str, list]
"""
samples = []
with open(manifest_path, 'r') as f:
for line in f:
if not line.isspace() and not line.startswith('#'):... | [
"def",
"parse_manifest",
"(",
"manifest_path",
")",
":",
"samples",
"=",
"[",
"]",
"with",
"open",
"(",
"manifest_path",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"not",
"line",
".",
"isspace",
"(",
")",
"and",
"not",
"l... | Parse manifest file
:param str manifest_path: Path to manifest file
:return: samples
:rtype: list[str, list] | [
"Parse",
"manifest",
"file"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/bwa_alignment.py#L192-L212 |
BD2KGenomics/toil-scripts | src/toil_scripts/bwa_alignment/bwa_alignment.py | main | def main():
"""
Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil BWA pipeline
Alignment of fastq reads via BWA-kit
General usage:
1. Type "toil-bwa generate" to create an editable manifest and config in the current working directory.
2. Parameterize the pipeline by editin... | python | def main():
"""
Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil BWA pipeline
Alignment of fastq reads via BWA-kit
General usage:
1. Type "toil-bwa generate" to create an editable manifest and config in the current working directory.
2. Parameterize the pipeline by editin... | [
"def",
"main",
"(",
")",
":",
"# Define Parser object and add to Toil",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"subparsers",
"=",
... | Computational Genomics Lab, Genomics Institute, UC Santa Cruz
Toil BWA pipeline
Alignment of fastq reads via BWA-kit
General usage:
1. Type "toil-bwa generate" to create an editable manifest and config in the current working directory.
2. Parameterize the pipeline by editing the config.
3. Fil... | [
"Computational",
"Genomics",
"Lab",
"Genomics",
"Institute",
"UC",
"Santa",
"Cruz",
"Toil",
"BWA",
"pipeline"
] | train | https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/bwa_alignment/bwa_alignment.py#L215-L292 |
bd808/python-iptools | iptools/__init__.py | _address2long | def _address2long(address):
"""
Convert an address string to a long.
"""
parsed = ipv4.ip2long(address)
if parsed is None:
parsed = ipv6.ip2long(address)
return parsed | python | def _address2long(address):
"""
Convert an address string to a long.
"""
parsed = ipv4.ip2long(address)
if parsed is None:
parsed = ipv6.ip2long(address)
return parsed | [
"def",
"_address2long",
"(",
"address",
")",
":",
"parsed",
"=",
"ipv4",
".",
"ip2long",
"(",
"address",
")",
"if",
"parsed",
"is",
"None",
":",
"parsed",
"=",
"ipv6",
".",
"ip2long",
"(",
"address",
")",
"return",
"parsed"
] | Convert an address string to a long. | [
"Convert",
"an",
"address",
"string",
"to",
"a",
"long",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/__init__.py#L58-L65 |
bd808/python-iptools | iptools/__init__.py | IpRange.index | def index(self, item):
"""
Return the 0-based position of `item` in this IpRange.
>>> r = IpRange('127.0.0.1', '127.255.255.255')
>>> r.index('127.0.0.1')
0
>>> r.index('127.255.255.255')
16777214
>>> r.index('10.0.0.1')
Traceback (most recent ca... | python | def index(self, item):
"""
Return the 0-based position of `item` in this IpRange.
>>> r = IpRange('127.0.0.1', '127.255.255.255')
>>> r.index('127.0.0.1')
0
>>> r.index('127.255.255.255')
16777214
>>> r.index('10.0.0.1')
Traceback (most recent ca... | [
"def",
"index",
"(",
"self",
",",
"item",
")",
":",
"item",
"=",
"self",
".",
"_cast",
"(",
"item",
")",
"offset",
"=",
"item",
"-",
"self",
".",
"startIp",
"if",
"offset",
">=",
"0",
"and",
"offset",
"<",
"self",
".",
"_len",
":",
"return",
"off... | Return the 0-based position of `item` in this IpRange.
>>> r = IpRange('127.0.0.1', '127.255.255.255')
>>> r.index('127.0.0.1')
0
>>> r.index('127.255.255.255')
16777214
>>> r.index('10.0.0.1')
Traceback (most recent call last):
...
ValueErro... | [
"Return",
"the",
"0",
"-",
"based",
"position",
"of",
"item",
"in",
"this",
"IpRange",
"."
] | train | https://github.com/bd808/python-iptools/blob/5d3fae0056297540355bb7c6c112703cfaa4b6ce/iptools/__init__.py#L259-L283 |
torfsen/service | src/service/__init__.py | _detach_process | def _detach_process():
"""
Detach daemon process.
Forks the current process into a parent and a detached child. The
child process resides in its own process group, has no controlling
terminal attached and is cleaned up by the init process.
Returns ``True`` for the parent and ``False`` for the ... | python | def _detach_process():
"""
Detach daemon process.
Forks the current process into a parent and a detached child. The
child process resides in its own process group, has no controlling
terminal attached and is cleaned up by the init process.
Returns ``True`` for the parent and ``False`` for the ... | [
"def",
"_detach_process",
"(",
")",
":",
"# To detach from our process group we need to call ``setsid``. We",
"# can only do that if we aren't a process group leader. Therefore",
"# we fork once, which makes sure that the new child process is not",
"# a process group leader.",
"pid",
"=",
"os"... | Detach daemon process.
Forks the current process into a parent and a detached child. The
child process resides in its own process group, has no controlling
terminal attached and is cleaned up by the init process.
Returns ``True`` for the parent and ``False`` for the child. | [
"Detach",
"daemon",
"process",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L49-L78 |
torfsen/service | src/service/__init__.py | _block | def _block(predicate, timeout):
"""
Block until a predicate becomes true.
``predicate`` is a function taking no arguments. The call to
``_block`` blocks until ``predicate`` returns a true value. This
is done by polling ``predicate``.
``timeout`` is either ``True`` (block indefinitely) or a tim... | python | def _block(predicate, timeout):
"""
Block until a predicate becomes true.
``predicate`` is a function taking no arguments. The call to
``_block`` blocks until ``predicate`` returns a true value. This
is done by polling ``predicate``.
``timeout`` is either ``True`` (block indefinitely) or a tim... | [
"def",
"_block",
"(",
"predicate",
",",
"timeout",
")",
":",
"if",
"timeout",
":",
"if",
"timeout",
"is",
"True",
":",
"timeout",
"=",
"float",
"(",
"'Inf'",
")",
"timeout",
"=",
"time",
".",
"time",
"(",
")",
"+",
"timeout",
"while",
"not",
"predica... | Block until a predicate becomes true.
``predicate`` is a function taking no arguments. The call to
``_block`` blocks until ``predicate`` returns a true value. This
is done by polling ``predicate``.
``timeout`` is either ``True`` (block indefinitely) or a timeout
in seconds.
The return value i... | [
"Block",
"until",
"a",
"predicate",
"becomes",
"true",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L143-L163 |
torfsen/service | src/service/__init__.py | _PIDFile.read_pid | def read_pid(self):
"""
Return the PID of the process owning the lock.
Returns ``None`` if no lock is present.
"""
try:
with open(self._path, 'r') as f:
s = f.read().strip()
if not s:
return None
ret... | python | def read_pid(self):
"""
Return the PID of the process owning the lock.
Returns ``None`` if no lock is present.
"""
try:
with open(self._path, 'r') as f:
s = f.read().strip()
if not s:
return None
ret... | [
"def",
"read_pid",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_path",
",",
"'r'",
")",
"as",
"f",
":",
"s",
"=",
"f",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
"if",
"not",
"s",
":",
"return",
"None",
"return",... | Return the PID of the process owning the lock.
Returns ``None`` if no lock is present. | [
"Return",
"the",
"PID",
"of",
"the",
"process",
"owning",
"the",
"lock",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L109-L124 |
torfsen/service | src/service/__init__.py | Service._get_logger_file_handles | def _get_logger_file_handles(self):
"""
Find the file handles used by our logger's handlers.
"""
handles = []
for handler in self.logger.handlers:
# The following code works for logging's SysLogHandler,
# StreamHandler, SocketHandler, and their subclasses.... | python | def _get_logger_file_handles(self):
"""
Find the file handles used by our logger's handlers.
"""
handles = []
for handler in self.logger.handlers:
# The following code works for logging's SysLogHandler,
# StreamHandler, SocketHandler, and their subclasses.... | [
"def",
"_get_logger_file_handles",
"(",
"self",
")",
":",
"handles",
"=",
"[",
"]",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
":",
"# The following code works for logging's SysLogHandler,",
"# StreamHandler, SocketHandler, and their subclasses.",
"for"... | Find the file handles used by our logger's handlers. | [
"Find",
"the",
"file",
"handles",
"used",
"by",
"our",
"logger",
"s",
"handlers",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L221-L237 |
torfsen/service | src/service/__init__.py | Service.is_running | def is_running(self):
"""
Check if the daemon is running.
"""
pid = self.get_pid()
if pid is None:
return False
# The PID file may still exist even if the daemon isn't running,
# for example if it has crashed.
try:
os.kill(pid, 0)
... | python | def is_running(self):
"""
Check if the daemon is running.
"""
pid = self.get_pid()
if pid is None:
return False
# The PID file may still exist even if the daemon isn't running,
# for example if it has crashed.
try:
os.kill(pid, 0)
... | [
"def",
"is_running",
"(",
"self",
")",
":",
"pid",
"=",
"self",
".",
"get_pid",
"(",
")",
"if",
"pid",
"is",
"None",
":",
"return",
"False",
"# The PID file may still exist even if the daemon isn't running,",
"# for example if it has crashed.",
"try",
":",
"os",
"."... | Check if the daemon is running. | [
"Check",
"if",
"the",
"daemon",
"is",
"running",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L239-L259 |
torfsen/service | src/service/__init__.py | Service._get_signal_event | def _get_signal_event(self, s):
'''
Get the event for a signal.
Checks if the signal has been enabled and raises a
``ValueError`` if not.
'''
try:
return self._signal_events[int(s)]
except KeyError:
raise ValueError('Signal {} has not been... | python | def _get_signal_event(self, s):
'''
Get the event for a signal.
Checks if the signal has been enabled and raises a
``ValueError`` if not.
'''
try:
return self._signal_events[int(s)]
except KeyError:
raise ValueError('Signal {} has not been... | [
"def",
"_get_signal_event",
"(",
"self",
",",
"s",
")",
":",
"try",
":",
"return",
"self",
".",
"_signal_events",
"[",
"int",
"(",
"s",
")",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"'Signal {} has not been enabled'",
".",
"format",
"(",
... | Get the event for a signal.
Checks if the signal has been enabled and raises a
``ValueError`` if not. | [
"Get",
"the",
"event",
"for",
"a",
"signal",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L267-L277 |
torfsen/service | src/service/__init__.py | Service.send_signal | def send_signal(self, s):
"""
Send a signal to the daemon process.
The signal must have been enabled using the ``signals``
parameter of :py:meth:`Service.__init__`. Otherwise, a
``ValueError`` is raised.
"""
self._get_signal_event(s) # Check if signal has been e... | python | def send_signal(self, s):
"""
Send a signal to the daemon process.
The signal must have been enabled using the ``signals``
parameter of :py:meth:`Service.__init__`. Otherwise, a
``ValueError`` is raised.
"""
self._get_signal_event(s) # Check if signal has been e... | [
"def",
"send_signal",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"_get_signal_event",
"(",
"s",
")",
"# Check if signal has been enabled",
"pid",
"=",
"self",
".",
"get_pid",
"(",
")",
"if",
"not",
"pid",
":",
"raise",
"ValueError",
"(",
"'Daemon is not r... | Send a signal to the daemon process.
The signal must have been enabled using the ``signals``
parameter of :py:meth:`Service.__init__`. Otherwise, a
``ValueError`` is raised. | [
"Send",
"a",
"signal",
"to",
"the",
"daemon",
"process",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L279-L291 |
torfsen/service | src/service/__init__.py | Service.stop | def stop(self, block=False):
"""
Tell the daemon process to stop.
Sends the SIGTERM signal to the daemon process, requesting it
to terminate.
If ``block`` is true then the call blocks until the daemon
process has exited. This may take some time since the daemon
... | python | def stop(self, block=False):
"""
Tell the daemon process to stop.
Sends the SIGTERM signal to the daemon process, requesting it
to terminate.
If ``block`` is true then the call blocks until the daemon
process has exited. This may take some time since the daemon
... | [
"def",
"stop",
"(",
"self",
",",
"block",
"=",
"False",
")",
":",
"self",
".",
"send_signal",
"(",
"signal",
".",
"SIGTERM",
")",
"return",
"_block",
"(",
"lambda",
":",
"not",
"self",
".",
"is_running",
"(",
")",
",",
"block",
")"
] | Tell the daemon process to stop.
Sends the SIGTERM signal to the daemon process, requesting it
to terminate.
If ``block`` is true then the call blocks until the daemon
process has exited. This may take some time since the daemon
process will complete its on-going backup activit... | [
"Tell",
"the",
"daemon",
"process",
"to",
"stop",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L381-L401 |
torfsen/service | src/service/__init__.py | Service.kill | def kill(self, block=False):
"""
Kill the daemon process.
Sends the SIGKILL signal to the daemon process, killing it. You
probably want to try :py:meth:`stop` first.
If ``block`` is true then the call blocks until the daemon
process has exited. ``block`` can either be `... | python | def kill(self, block=False):
"""
Kill the daemon process.
Sends the SIGKILL signal to the daemon process, killing it. You
probably want to try :py:meth:`stop` first.
If ``block`` is true then the call blocks until the daemon
process has exited. ``block`` can either be `... | [
"def",
"kill",
"(",
"self",
",",
"block",
"=",
"False",
")",
":",
"pid",
"=",
"self",
".",
"get_pid",
"(",
")",
"if",
"not",
"pid",
":",
"raise",
"ValueError",
"(",
"'Daemon is not running.'",
")",
"try",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"s... | Kill the daemon process.
Sends the SIGKILL signal to the daemon process, killing it. You
probably want to try :py:meth:`stop` first.
If ``block`` is true then the call blocks until the daemon
process has exited. ``block`` can either be ``True`` (in which
case it blocks indefini... | [
"Kill",
"the",
"daemon",
"process",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L403-L437 |
torfsen/service | src/service/__init__.py | Service.start | def start(self, block=False):
"""
Start the daemon process.
The daemon process is started in the background and the calling
process returns.
Once the daemon process is initialized it calls the
:py:meth:`run` method.
If ``block`` is true then the call blocks unt... | python | def start(self, block=False):
"""
Start the daemon process.
The daemon process is started in the background and the calling
process returns.
Once the daemon process is initialized it calls the
:py:meth:`run` method.
If ``block`` is true then the call blocks unt... | [
"def",
"start",
"(",
"self",
",",
"block",
"=",
"False",
")",
":",
"pid",
"=",
"self",
".",
"get_pid",
"(",
")",
"if",
"pid",
":",
"raise",
"ValueError",
"(",
"'Daemon is already running at PID %d.'",
"%",
"pid",
")",
"# The default is to place the PID file into... | Start the daemon process.
The daemon process is started in the background and the calling
process returns.
Once the daemon process is initialized it calls the
:py:meth:`run` method.
If ``block`` is true then the call blocks until the daemon
process has started. ``block... | [
"Start",
"the",
"daemon",
"process",
"."
] | train | https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L439-L544 |
datacats/datacats | datacats/cli/create.py | create | def create(opts):
"""Create a new environment
Usage:
datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog]
[--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL]
[--no-init-db] ENVIRONMENT_DIR [PORT]
Options:
--address=IP Address to li... | python | def create(opts):
"""Create a new environment
Usage:
datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog]
[--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL]
[--no-init-db] ENVIRONMENT_DIR [PORT]
Options:
--address=IP Address to li... | [
"def",
"create",
"(",
"opts",
")",
":",
"if",
"opts",
"[",
"'--address'",
"]",
"and",
"is_boot2docker",
"(",
")",
":",
"raise",
"DatacatsError",
"(",
"'Cannot specify address on boot2docker.'",
")",
"return",
"create_environment",
"(",
"environment_dir",
"=",
"opt... | Create a new environment
Usage:
datacats create [-bin] [--interactive] [-s NAME] [--address=IP] [--syslog]
[--ckan=CKAN_VERSION] [--no-datapusher] [--site-url SITE_URL]
[--no-init-db] ENVIRONMENT_DIR [PORT]
Options:
--address=IP Address to listen on (Linux-only)
--... | [
"Create",
"a",
"new",
"environment"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L23-L63 |
datacats/datacats | datacats/cli/create.py | reset | def reset(environment, opts):
"""Resets a site to the default state. This will re-initialize the
database and recreate the administrator account.
Usage:
datacats reset [-iyn] [-s NAME] [ENVIRONMENT]
Options:
-i --interactive Don't detach from the web container
-s --site=NAME The site to rese... | python | def reset(environment, opts):
"""Resets a site to the default state. This will re-initialize the
database and recreate the administrator account.
Usage:
datacats reset [-iyn] [-s NAME] [ENVIRONMENT]
Options:
-i --interactive Don't detach from the web container
-s --site=NAME The site to rese... | [
"def",
"reset",
"(",
"environment",
",",
"opts",
")",
":",
"# pylint: disable=unused-argument",
"if",
"not",
"opts",
"[",
"'--yes'",
"]",
":",
"y_or_n_prompt",
"(",
"'Reset will remove all data related to the '",
"'site {} and recreate the database'",
".",
"format",
"(",
... | Resets a site to the default state. This will re-initialize the
database and recreate the administrator account.
Usage:
datacats reset [-iyn] [-s NAME] [ENVIRONMENT]
Options:
-i --interactive Don't detach from the web container
-s --site=NAME The site to reset [default: primary]
-y --yes ... | [
"Resets",
"a",
"site",
"to",
"the",
"default",
"state",
".",
"This",
"will",
"re",
"-",
"initialize",
"the",
"database",
"and",
"recreate",
"the",
"administrator",
"account",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L122-L157 |
datacats/datacats | datacats/cli/create.py | init | def init(opts, no_install=False, quiet=False):
"""Initialize a purged environment or copied environment directory
Usage:
datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive]
[--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db]
Options:
--address=IP Addres... | python | def init(opts, no_install=False, quiet=False):
"""Initialize a purged environment or copied environment directory
Usage:
datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive]
[--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db]
Options:
--address=IP Addres... | [
"def",
"init",
"(",
"opts",
",",
"no_install",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"if",
"opts",
"[",
"'--address'",
"]",
"and",
"is_boot2docker",
"(",
")",
":",
"raise",
"DatacatsError",
"(",
"'Cannot specify address on boot2docker.'",
")",
... | Initialize a purged environment or copied environment directory
Usage:
datacats init [-in] [--syslog] [-s NAME] [--address=IP] [--interactive]
[--site-url SITE_URL] [ENVIRONMENT_DIR [PORT]] [--no-init-db]
Options:
--address=IP Address to listen on (Linux-only)
--interactive ... | [
"Initialize",
"a",
"purged",
"environment",
"or",
"copied",
"environment",
"directory"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L160-L237 |
datacats/datacats | datacats/cli/create.py | finish_init | def finish_init(environment, start_web, create_sysadmin, log_syslog=False,
do_install=True, quiet=False, site_url=None, interactive=False,
init_db=True):
"""
Common parts of create and init: Install, init db, start site, sysadmin
"""
if not init_db:
start_web = Fa... | python | def finish_init(environment, start_web, create_sysadmin, log_syslog=False,
do_install=True, quiet=False, site_url=None, interactive=False,
init_db=True):
"""
Common parts of create and init: Install, init db, start site, sysadmin
"""
if not init_db:
start_web = Fa... | [
"def",
"finish_init",
"(",
"environment",
",",
"start_web",
",",
"create_sysadmin",
",",
"log_syslog",
"=",
"False",
",",
"do_install",
"=",
"True",
",",
"quiet",
"=",
"False",
",",
"site_url",
"=",
"None",
",",
"interactive",
"=",
"False",
",",
"init_db",
... | Common parts of create and init: Install, init db, start site, sysadmin | [
"Common",
"parts",
"of",
"create",
"and",
"init",
":",
"Install",
"init",
"db",
"start",
"site",
"sysadmin"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/create.py#L240-L283 |
datacats/datacats | datacats/userprofile.py | UserProfile.save | def save(self):
"""
Save profile settings into user profile directory
"""
config = self.profiledir + '/config'
if not isdir(self.profiledir):
makedirs(self.profiledir)
cp = SafeConfigParser()
cp.add_section('ssh')
cp.set('ssh', 'private_key',... | python | def save(self):
"""
Save profile settings into user profile directory
"""
config = self.profiledir + '/config'
if not isdir(self.profiledir):
makedirs(self.profiledir)
cp = SafeConfigParser()
cp.add_section('ssh')
cp.set('ssh', 'private_key',... | [
"def",
"save",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"profiledir",
"+",
"'/config'",
"if",
"not",
"isdir",
"(",
"self",
".",
"profiledir",
")",
":",
"makedirs",
"(",
"self",
".",
"profiledir",
")",
"cp",
"=",
"SafeConfigParser",
"(",
")",
... | Save profile settings into user profile directory | [
"Save",
"profile",
"settings",
"into",
"user",
"profile",
"directory"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L60-L75 |
datacats/datacats | datacats/userprofile.py | UserProfile.generate_ssh_key | def generate_ssh_key(self):
"""
Generate a new ssh private and public key
"""
web_command(
command=["ssh-keygen", "-q", "-t", "rsa", "-N", "", "-C",
"datacats generated {0}@{1}".format(
getuser(), gethostname()),
... | python | def generate_ssh_key(self):
"""
Generate a new ssh private and public key
"""
web_command(
command=["ssh-keygen", "-q", "-t", "rsa", "-N", "", "-C",
"datacats generated {0}@{1}".format(
getuser(), gethostname()),
... | [
"def",
"generate_ssh_key",
"(",
"self",
")",
":",
"web_command",
"(",
"command",
"=",
"[",
"\"ssh-keygen\"",
",",
"\"-q\"",
",",
"\"-t\"",
",",
"\"rsa\"",
",",
"\"-N\"",
",",
"\"\"",
",",
"\"-C\"",
",",
"\"datacats generated {0}@{1}\"",
".",
"format",
"(",
"... | Generate a new ssh private and public key | [
"Generate",
"a",
"new",
"ssh",
"private",
"and",
"public",
"key"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L77-L87 |
datacats/datacats | datacats/userprofile.py | UserProfile.create | def create(self, environment, target_name):
"""
Sends "create project" command to the remote server
"""
remote_server_command(
["ssh", environment.deploy_target, "create", target_name],
environment, self,
clean_up=True,
) | python | def create(self, environment, target_name):
"""
Sends "create project" command to the remote server
"""
remote_server_command(
["ssh", environment.deploy_target, "create", target_name],
environment, self,
clean_up=True,
) | [
"def",
"create",
"(",
"self",
",",
"environment",
",",
"target_name",
")",
":",
"remote_server_command",
"(",
"[",
"\"ssh\"",
",",
"environment",
".",
"deploy_target",
",",
"\"create\"",
",",
"target_name",
"]",
",",
"environment",
",",
"self",
",",
"clean_up"... | Sends "create project" command to the remote server | [
"Sends",
"create",
"project",
"command",
"to",
"the",
"remote",
"server"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L127-L135 |
datacats/datacats | datacats/userprofile.py | UserProfile.admin_password | def admin_password(self, environment, target_name, password):
"""
Return True if password was set successfully
"""
try:
remote_server_command(
["ssh", environment.deploy_target,
"admin_password", target_name, password],
envi... | python | def admin_password(self, environment, target_name, password):
"""
Return True if password was set successfully
"""
try:
remote_server_command(
["ssh", environment.deploy_target,
"admin_password", target_name, password],
envi... | [
"def",
"admin_password",
"(",
"self",
",",
"environment",
",",
"target_name",
",",
"password",
")",
":",
"try",
":",
"remote_server_command",
"(",
"[",
"\"ssh\"",
",",
"environment",
".",
"deploy_target",
",",
"\"admin_password\"",
",",
"target_name",
",",
"pass... | Return True if password was set successfully | [
"Return",
"True",
"if",
"password",
"was",
"set",
"successfully"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L137-L150 |
datacats/datacats | datacats/userprofile.py | UserProfile.deploy | def deploy(self, environment, target_name, stream_output=None):
"""
Return True if deployment was successful
"""
try:
remote_server_command(
[
"rsync", "-lrv", "--safe-links", "--munge-links",
"--delete", "--inplace", "-... | python | def deploy(self, environment, target_name, stream_output=None):
"""
Return True if deployment was successful
"""
try:
remote_server_command(
[
"rsync", "-lrv", "--safe-links", "--munge-links",
"--delete", "--inplace", "-... | [
"def",
"deploy",
"(",
"self",
",",
"environment",
",",
"target_name",
",",
"stream_output",
"=",
"None",
")",
":",
"try",
":",
"remote_server_command",
"(",
"[",
"\"rsync\"",
",",
"\"-lrv\"",
",",
"\"--safe-links\"",
",",
"\"--munge-links\"",
",",
"\"--delete\""... | Return True if deployment was successful | [
"Return",
"True",
"if",
"deployment",
"was",
"successful"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/userprofile.py#L152-L195 |
Britefury/batchup | batchup/sampling.py | num_batches | def num_batches(n, batch_size):
"""Compute the number of mini-batches required to cover a data set of
size `n` using batches of size `batch_size`.
Parameters
----------
n: int
the number of samples in the data set
batch_size: int
the mini-batch size
Returns
-------
... | python | def num_batches(n, batch_size):
"""Compute the number of mini-batches required to cover a data set of
size `n` using batches of size `batch_size`.
Parameters
----------
n: int
the number of samples in the data set
batch_size: int
the mini-batch size
Returns
-------
... | [
"def",
"num_batches",
"(",
"n",
",",
"batch_size",
")",
":",
"b",
"=",
"n",
"//",
"batch_size",
"if",
"n",
"%",
"batch_size",
">",
"0",
":",
"b",
"+=",
"1",
"return",
"b"
] | Compute the number of mini-batches required to cover a data set of
size `n` using batches of size `batch_size`.
Parameters
----------
n: int
the number of samples in the data set
batch_size: int
the mini-batch size
Returns
-------
int: the number of batches required | [
"Compute",
"the",
"number",
"of",
"mini",
"-",
"batches",
"required",
"to",
"cover",
"a",
"data",
"set",
"of",
"size",
"n",
"using",
"batches",
"of",
"size",
"batch_size",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L10-L28 |
Britefury/batchup | batchup/sampling.py | StandardSampler.num_indices_generated | def num_indices_generated(self):
"""
Get the number of indices that would be generated by this
sampler.
Returns
-------
int, `np.inf` or `None`.
An int if the number of samples is known, `np.inf` if it is
infinite or `None` if the number of sample... | python | def num_indices_generated(self):
"""
Get the number of indices that would be generated by this
sampler.
Returns
-------
int, `np.inf` or `None`.
An int if the number of samples is known, `np.inf` if it is
infinite or `None` if the number of sample... | [
"def",
"num_indices_generated",
"(",
"self",
")",
":",
"if",
"self",
".",
"repeats",
"==",
"-",
"1",
":",
"return",
"np",
".",
"inf",
"else",
":",
"return",
"self",
".",
"length",
"*",
"self",
".",
"repeats"
] | Get the number of indices that would be generated by this
sampler.
Returns
-------
int, `np.inf` or `None`.
An int if the number of samples is known, `np.inf` if it is
infinite or `None` if the number of samples is unknown. | [
"Get",
"the",
"number",
"of",
"indices",
"that",
"would",
"be",
"generated",
"by",
"this",
"sampler",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L137-L151 |
Britefury/batchup | batchup/sampling.py | StandardSampler.in_order_indices_batch_iterator | def in_order_indices_batch_iterator(self, batch_size):
"""
Create an iterator that generates in-order mini-batches of sample
indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
enough samples left to fi... | python | def in_order_indices_batch_iterator(self, batch_size):
"""
Create an iterator that generates in-order mini-batches of sample
indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
enough samples left to fi... | [
"def",
"in_order_indices_batch_iterator",
"(",
"self",
",",
"batch_size",
")",
":",
"if",
"self",
".",
"repeats",
"==",
"1",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"length",
",",
"batch_size",
")",
":",
"yield",
"np",
".",
"arange"... | Create an iterator that generates in-order mini-batches of sample
indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
enough samples left to fill it.
The generated mini-batches indices take the form of 1D NumP... | [
"Create",
"an",
"iterator",
"that",
"generates",
"in",
"-",
"order",
"mini",
"-",
"batches",
"of",
"sample",
"indices",
".",
"The",
"batches",
"will",
"have",
"batch_size",
"elements",
"with",
"the",
"exception",
"of",
"the",
"final",
"batch",
"which",
"will... | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L153-L225 |
Britefury/batchup | batchup/sampling.py | StandardSampler.shuffled_indices_batch_iterator | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
eno... | python | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
eno... | [
"def",
"shuffled_indices_batch_iterator",
"(",
"self",
",",
"batch_size",
",",
"shuffle_rng",
")",
":",
"if",
"self",
".",
"repeats",
"==",
"1",
":",
"indices",
"=",
"shuffle_rng",
".",
"permutation",
"(",
"self",
".",
"length",
")",
"for",
"i",
"in",
"ran... | Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements, with the
exception of the final batch which will have less if there are not
enough samples left to fill it.
The generated mini-batches indices take the form o... | [
"Create",
"an",
"iterator",
"that",
"generates",
"randomly",
"shuffled",
"mini",
"-",
"batches",
"of",
"sample",
"indices",
".",
"The",
"batches",
"will",
"have",
"batch_size",
"elements",
"with",
"the",
"exception",
"of",
"the",
"final",
"batch",
"which",
"wi... | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L227-L287 |
Britefury/batchup | batchup/sampling.py | WeightedSampler.shuffled_indices_batch_iterator | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
... | python | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
... | [
"def",
"shuffled_indices_batch_iterator",
"(",
"self",
",",
"batch_size",
",",
"shuffle_rng",
")",
":",
"while",
"True",
":",
"yield",
"shuffle_rng",
".",
"choice",
"(",
"len",
"(",
"self",
".",
"weights",
")",
",",
"size",
"=",
"(",
"batch_size",
",",
")"... | Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
Parameters
----------
batch_size: int
Mini-batch siz... | [
"Create",
"an",
"iterator",
"that",
"generates",
"randomly",
"shuffled",
"mini",
"-",
"batches",
"of",
"sample",
"indices",
".",
"The",
"batches",
"will",
"have",
"batch_size",
"elements",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L533-L556 |
Britefury/batchup | batchup/sampling.py | WeightedSampler.class_balancing_sample_weights | def class_balancing_sample_weights(y):
"""
Compute sample weight given an array of sample classes. The weights
are assigned on a per-class basis and the per-class weights are
inversely proportional to their frequency.
Parameters
----------
y: NumPy array, 1D dtyp... | python | def class_balancing_sample_weights(y):
"""
Compute sample weight given an array of sample classes. The weights
are assigned on a per-class basis and the per-class weights are
inversely proportional to their frequency.
Parameters
----------
y: NumPy array, 1D dtyp... | [
"def",
"class_balancing_sample_weights",
"(",
"y",
")",
":",
"h",
"=",
"np",
".",
"bincount",
"(",
"y",
")",
"cls_weight",
"=",
"1.0",
"/",
"(",
"h",
".",
"astype",
"(",
"float",
")",
"*",
"len",
"(",
"np",
".",
"nonzero",
"(",
"h",
")",
"[",
"0"... | Compute sample weight given an array of sample classes. The weights
are assigned on a per-class basis and the per-class weights are
inversely proportional to their frequency.
Parameters
----------
y: NumPy array, 1D dtype=int
sample classes, values must be 0 or posit... | [
"Compute",
"sample",
"weight",
"given",
"an",
"array",
"of",
"sample",
"classes",
".",
"The",
"weights",
"are",
"assigned",
"on",
"a",
"per",
"-",
"class",
"basis",
"and",
"the",
"per",
"-",
"class",
"weights",
"are",
"inversely",
"proportional",
"to",
"th... | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L559-L579 |
Britefury/batchup | batchup/sampling.py | WeightedSubsetSampler.shuffled_indices_batch_iterator | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
... | python | def shuffled_indices_batch_iterator(self, batch_size, shuffle_rng):
"""
Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
... | [
"def",
"shuffled_indices_batch_iterator",
"(",
"self",
",",
"batch_size",
",",
"shuffle_rng",
")",
":",
"while",
"True",
":",
"yield",
"shuffle_rng",
".",
"choice",
"(",
"self",
".",
"indices",
",",
"size",
"=",
"(",
"batch_size",
",",
")",
",",
"p",
"=",
... | Create an iterator that generates randomly shuffled mini-batches of
sample indices. The batches will have `batch_size` elements.
The generated mini-batches indices take the form of 1D NumPy integer
arrays.
Parameters
----------
batch_size: int
Mini-batch siz... | [
"Create",
"an",
"iterator",
"that",
"generates",
"randomly",
"shuffled",
"mini",
"-",
"batches",
"of",
"sample",
"indices",
".",
"The",
"batches",
"will",
"have",
"batch_size",
"elements",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L688-L711 |
Britefury/batchup | batchup/sampling.py | WeightedSubsetSampler.class_balancing_sampler | def class_balancing_sampler(y, indices):
"""
Construct a `WeightedSubsetSampler` that compensates for class
imbalance.
Parameters
----------
y: NumPy array, 1D dtype=int
sample classes, values must be 0 or positive
indices: NumPy array, 1D dtype=int
... | python | def class_balancing_sampler(y, indices):
"""
Construct a `WeightedSubsetSampler` that compensates for class
imbalance.
Parameters
----------
y: NumPy array, 1D dtype=int
sample classes, values must be 0 or positive
indices: NumPy array, 1D dtype=int
... | [
"def",
"class_balancing_sampler",
"(",
"y",
",",
"indices",
")",
":",
"weights",
"=",
"WeightedSampler",
".",
"class_balancing_sample_weights",
"(",
"y",
"[",
"indices",
"]",
")",
"return",
"WeightedSubsetSampler",
"(",
"weights",
",",
"indices",
"=",
"indices",
... | Construct a `WeightedSubsetSampler` that compensates for class
imbalance.
Parameters
----------
y: NumPy array, 1D dtype=int
sample classes, values must be 0 or positive
indices: NumPy array, 1D dtype=int
An array of indices that identify the subset of sa... | [
"Construct",
"a",
"WeightedSubsetSampler",
"that",
"compensates",
"for",
"class",
"imbalance",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/sampling.py#L714-L733 |
datacats/datacats | datacats/network.py | wait_for_service_available | def wait_for_service_available(container, url, timeout):
"""
Wait up to timeout seconds for service at host:port
to start.
Returns True if service becomes available, False if the
container stops or raises ServiceTimeout if timeout is
reached.
"""
start = time.time()
remaining = time... | python | def wait_for_service_available(container, url, timeout):
"""
Wait up to timeout seconds for service at host:port
to start.
Returns True if service becomes available, False if the
container stops or raises ServiceTimeout if timeout is
reached.
"""
start = time.time()
remaining = time... | [
"def",
"wait_for_service_available",
"(",
"container",
",",
"url",
",",
"timeout",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"remaining",
"=",
"timeout",
"while",
"True",
":",
"remaining",
"=",
"start",
"+",
"timeout",
"-",
"time",
".",
"tim... | Wait up to timeout seconds for service at host:port
to start.
Returns True if service becomes available, False if the
container stops or raises ServiceTimeout if timeout is
reached. | [
"Wait",
"up",
"to",
"timeout",
"seconds",
"for",
"service",
"at",
"host",
":",
"port",
"to",
"start",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/network.py#L21-L51 |
Britefury/batchup | batchup/config.py | get_data_path | def get_data_path(filename):
"""
Get the path of the given file within the batchup data directory
Parameters
----------
filename: str
The filename to locate within the batchup data directory
Returns
-------
str
The full path of the file
"""
if os.path.isabs(file... | python | def get_data_path(filename):
"""
Get the path of the given file within the batchup data directory
Parameters
----------
filename: str
The filename to locate within the batchup data directory
Returns
-------
str
The full path of the file
"""
if os.path.isabs(file... | [
"def",
"get_data_path",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"filename",
")",
":",
"return",
"filename",
"else",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"get_data_dir",
"(",
")",
",",
"filename",
")"
] | Get the path of the given file within the batchup data directory
Parameters
----------
filename: str
The filename to locate within the batchup data directory
Returns
-------
str
The full path of the file | [
"Get",
"the",
"path",
"of",
"the",
"given",
"file",
"within",
"the",
"batchup",
"data",
"directory"
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L68-L85 |
Britefury/batchup | batchup/config.py | download | def download(path, source_url):
"""
Download a file to a given path from a given URL, if it does not exist.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
source_url: str
The URL from which to download the file
Returns
-------... | python | def download(path, source_url):
"""
Download a file to a given path from a given URL, if it does not exist.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
source_url: str
The URL from which to download the file
Returns
-------... | [
"def",
"download",
"(",
"path",
",",
"source_url",
")",
":",
"dir_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir_path",
")",
":",
"os",
".",
"makedirs",
"(",
"dir_path",
")"... | Download a file to a given path from a given URL, if it does not exist.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
source_url: str
The URL from which to download the file
Returns
-------
str
The path of the file | [
"Download",
"a",
"file",
"to",
"a",
"given",
"path",
"from",
"a",
"given",
"URL",
"if",
"it",
"does",
"not",
"exist",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L88-L124 |
Britefury/batchup | batchup/config.py | compute_sha256 | def compute_sha256(path):
"""
Compute the SHA-256 hash of the file at the given path
Parameters
----------
path: str
The path of the file
Returns
-------
str
The SHA-256 HEX digest
"""
hasher = hashlib.sha256()
with open(path, 'rb') as f:
# 10MB chun... | python | def compute_sha256(path):
"""
Compute the SHA-256 hash of the file at the given path
Parameters
----------
path: str
The path of the file
Returns
-------
str
The SHA-256 HEX digest
"""
hasher = hashlib.sha256()
with open(path, 'rb') as f:
# 10MB chun... | [
"def",
"compute_sha256",
"(",
"path",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"# 10MB chunks",
"for",
"chunk",
"in",
"iter",
"(",
"lambda",
":",
"f",
".",
"read",
"... | Compute the SHA-256 hash of the file at the given path
Parameters
----------
path: str
The path of the file
Returns
-------
str
The SHA-256 HEX digest | [
"Compute",
"the",
"SHA",
"-",
"256",
"hash",
"of",
"the",
"file",
"at",
"the",
"given",
"path"
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L127-L146 |
Britefury/batchup | batchup/config.py | verify_file | def verify_file(path, sha256):
"""
Verify the integrity of a file by checking its SHA-256 hash.
If no digest is supplied, the digest is printed to the console.
Closely follows the code in `torchvision.datasets.utils.check_integrity`
Parameters
----------
path: str
The path of the f... | python | def verify_file(path, sha256):
"""
Verify the integrity of a file by checking its SHA-256 hash.
If no digest is supplied, the digest is printed to the console.
Closely follows the code in `torchvision.datasets.utils.check_integrity`
Parameters
----------
path: str
The path of the f... | [
"def",
"verify_file",
"(",
"path",
",",
"sha256",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"return",
"False",
"digest",
"=",
"compute_sha256",
"(",
"path",
")",
"if",
"sha256",
"is",
"None",
":",
"# No digest supp... | Verify the integrity of a file by checking its SHA-256 hash.
If no digest is supplied, the digest is printed to the console.
Closely follows the code in `torchvision.datasets.utils.check_integrity`
Parameters
----------
path: str
The path of the file to check
sha256: str
The ex... | [
"Verify",
"the",
"integrity",
"of",
"a",
"file",
"by",
"checking",
"its",
"SHA",
"-",
"256",
"hash",
".",
"If",
"no",
"digest",
"is",
"supplied",
"the",
"digest",
"is",
"printed",
"to",
"the",
"console",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L149-L180 |
Britefury/batchup | batchup/config.py | download_and_verify | def download_and_verify(path, source_url, sha256):
"""
Download a file to a given path from a given URL, if it does not exist.
After downloading it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesyst... | python | def download_and_verify(path, source_url, sha256):
"""
Download a file to a given path from a given URL, if it does not exist.
After downloading it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesyst... | [
"def",
"download_and_verify",
"(",
"path",
",",
"source_url",
",",
"sha256",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"# Already exists?",
"# Nothing to do, except print the SHA-256 if necessary",
"if",
"sha256",
"is",
"None",
":",
... | Download a file to a given path from a given URL, if it does not exist.
After downloading it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
source_url: str
The URL from which to download t... | [
"Download",
"a",
"file",
"to",
"a",
"given",
"path",
"from",
"a",
"given",
"URL",
"if",
"it",
"does",
"not",
"exist",
".",
"After",
"downloading",
"it",
"verify",
"it",
"integrity",
"by",
"checking",
"the",
"SHA",
"-",
"256",
"hash",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L183-L244 |
Britefury/batchup | batchup/config.py | copy_and_verify | def copy_and_verify(path, source_path, sha256):
"""
Copy a file to a given path from a given path, if it does not exist.
After copying it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
sou... | python | def copy_and_verify(path, source_path, sha256):
"""
Copy a file to a given path from a given path, if it does not exist.
After copying it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
sou... | [
"def",
"copy_and_verify",
"(",
"path",
",",
"source_path",
",",
"sha256",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"# Already exists?",
"# Nothing to do, except print the SHA-256 if necessary",
"if",
"sha256",
"is",
"None",
":",
"... | Copy a file to a given path from a given path, if it does not exist.
After copying it, verify it integrity by checking the SHA-256 hash.
Parameters
----------
path: str
The (destination) path of the file on the local filesystem
source_path: str
The path from which to copy the file
... | [
"Copy",
"a",
"file",
"to",
"a",
"given",
"path",
"from",
"a",
"given",
"path",
"if",
"it",
"does",
"not",
"exist",
".",
"After",
"copying",
"it",
"verify",
"it",
"integrity",
"by",
"checking",
"the",
"SHA",
"-",
"256",
"hash",
"."
] | train | https://github.com/Britefury/batchup/blob/3fc2304e629f813c05f9e7a85a18acef3581a536/batchup/config.py#L247-L298 |
datacats/datacats | datacats/template.py | ckan_extension_template | def ckan_extension_template(name, target):
"""
Create ckanext-(name) in target directory.
"""
setupdir = '{0}/ckanext-{1}theme'.format(target, name)
extdir = setupdir + '/ckanext/{0}theme'.format(name)
templatedir = extdir + '/templates/'
staticdir = extdir + '/static/datacats'
makedirs... | python | def ckan_extension_template(name, target):
"""
Create ckanext-(name) in target directory.
"""
setupdir = '{0}/ckanext-{1}theme'.format(target, name)
extdir = setupdir + '/ckanext/{0}theme'.format(name)
templatedir = extdir + '/templates/'
staticdir = extdir + '/static/datacats'
makedirs... | [
"def",
"ckan_extension_template",
"(",
"name",
",",
"target",
")",
":",
"setupdir",
"=",
"'{0}/ckanext-{1}theme'",
".",
"format",
"(",
"target",
",",
"name",
")",
"extdir",
"=",
"setupdir",
"+",
"'/ckanext/{0}theme'",
".",
"format",
"(",
"name",
")",
"template... | Create ckanext-(name) in target directory. | [
"Create",
"ckanext",
"-",
"(",
"name",
")",
"in",
"target",
"directory",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/template.py#L12-L41 |
datacats/datacats | datacats/cli/shell.py | shell | def shell(environment, opts):
"""Run a command or interactive shell within this environment
Usage:
datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]]
Options:
-d --detach Run the resulting container in the background
-s --site=NAME Specify a site to run the shell on [default: primary]
ENVIRON... | python | def shell(environment, opts):
"""Run a command or interactive shell within this environment
Usage:
datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]]
Options:
-d --detach Run the resulting container in the background
-s --site=NAME Specify a site to run the shell on [default: primary]
ENVIRON... | [
"def",
"shell",
"(",
"environment",
",",
"opts",
")",
":",
"environment",
".",
"require_data",
"(",
")",
"environment",
".",
"start_supporting_containers",
"(",
")",
"return",
"environment",
".",
"interactive_shell",
"(",
"opts",
"[",
"'COMMAND'",
"]",
",",
"d... | Run a command or interactive shell within this environment
Usage:
datacats [-d] [-s NAME] shell [ENVIRONMENT [COMMAND...]]
Options:
-d --detach Run the resulting container in the background
-s --site=NAME Specify a site to run the shell on [default: primary]
ENVIRONMENT may be an environment name or a ... | [
"Run",
"a",
"command",
"or",
"interactive",
"shell",
"within",
"this",
"environment"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/shell.py#L10-L28 |
datacats/datacats | datacats/cli/shell.py | paster | def paster(opts):
"""Run a paster command from the current directory
Usage:
datacats paster [-d] [-s NAME] [COMMAND...]
Options:
-s --site=NAME Specify a site to run this paster command on [default: primary]
-d --detach Run the resulting container in the background
You must be inside a datacats env... | python | def paster(opts):
"""Run a paster command from the current directory
Usage:
datacats paster [-d] [-s NAME] [COMMAND...]
Options:
-s --site=NAME Specify a site to run this paster command on [default: primary]
-d --detach Run the resulting container in the background
You must be inside a datacats env... | [
"def",
"paster",
"(",
"opts",
")",
":",
"environment",
"=",
"Environment",
".",
"load",
"(",
"'.'",
")",
"environment",
".",
"require_data",
"(",
")",
"environment",
".",
"start_supporting_containers",
"(",
")",
"if",
"not",
"opts",
"[",
"'COMMAND'",
"]",
... | Run a paster command from the current directory
Usage:
datacats paster [-d] [-s NAME] [COMMAND...]
Options:
-s --site=NAME Specify a site to run this paster command on [default: primary]
-d --detach Run the resulting container in the background
You must be inside a datacats environment to run this. The... | [
"Run",
"a",
"paster",
"command",
"from",
"the",
"current",
"directory"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/shell.py#L31-L57 |
datacats/datacats | datacats/task.py | save_new_site | def save_new_site(site_name, sitedir, srcdir, port, address, site_url,
passwords):
"""
Add a site's configuration to the source dir and site dir
"""
cp = ConfigParser.SafeConfigParser()
cp.read([srcdir + '/.datacats-environment'])
section_name = 'site_' + site_name
if not cp.has_se... | python | def save_new_site(site_name, sitedir, srcdir, port, address, site_url,
passwords):
"""
Add a site's configuration to the source dir and site dir
"""
cp = ConfigParser.SafeConfigParser()
cp.read([srcdir + '/.datacats-environment'])
section_name = 'site_' + site_name
if not cp.has_se... | [
"def",
"save_new_site",
"(",
"site_name",
",",
"sitedir",
",",
"srcdir",
",",
"port",
",",
"address",
",",
"site_url",
",",
"passwords",
")",
":",
"cp",
"=",
"ConfigParser",
".",
"SafeConfigParser",
"(",
")",
"cp",
".",
"read",
"(",
"[",
"srcdir",
"+",
... | Add a site's configuration to the source dir and site dir | [
"Add",
"a",
"site",
"s",
"configuration",
"to",
"the",
"source",
"dir",
"and",
"site",
"dir"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L44-L75 |
datacats/datacats | datacats/task.py | save_new_environment | def save_new_environment(name, datadir, srcdir, ckan_version,
deploy_target=None, always_prod=False):
"""
Save an environment's configuration to the source dir and data dir
"""
with open(datadir + '/.version', 'w') as f:
f.write('2')
cp = ConfigParser.SafeConfigParser()
cp.read... | python | def save_new_environment(name, datadir, srcdir, ckan_version,
deploy_target=None, always_prod=False):
"""
Save an environment's configuration to the source dir and data dir
"""
with open(datadir + '/.version', 'w') as f:
f.write('2')
cp = ConfigParser.SafeConfigParser()
cp.read... | [
"def",
"save_new_environment",
"(",
"name",
",",
"datadir",
",",
"srcdir",
",",
"ckan_version",
",",
"deploy_target",
"=",
"None",
",",
"always_prod",
"=",
"False",
")",
":",
"with",
"open",
"(",
"datadir",
"+",
"'/.version'",
",",
"'w'",
")",
"as",
"f",
... | Save an environment's configuration to the source dir and data dir | [
"Save",
"an",
"environment",
"s",
"configuration",
"to",
"the",
"source",
"dir",
"and",
"data",
"dir"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L78-L106 |
datacats/datacats | datacats/task.py | find_environment_dirs | def find_environment_dirs(environment_name=None, data_only=False):
"""
:param environment_name: exising environment name, path or None to
look in current or parent directories for project
returns (srcdir, extension_dir, datadir)
extension_dir is the name of extension directory user was in/ref... | python | def find_environment_dirs(environment_name=None, data_only=False):
"""
:param environment_name: exising environment name, path or None to
look in current or parent directories for project
returns (srcdir, extension_dir, datadir)
extension_dir is the name of extension directory user was in/ref... | [
"def",
"find_environment_dirs",
"(",
"environment_name",
"=",
"None",
",",
"data_only",
"=",
"False",
")",
":",
"docker",
".",
"require_images",
"(",
")",
"if",
"environment_name",
"is",
"None",
":",
"environment_name",
"=",
"'.'",
"extension_dir",
"=",
"'ckan'"... | :param environment_name: exising environment name, path or None to
look in current or parent directories for project
returns (srcdir, extension_dir, datadir)
extension_dir is the name of extension directory user was in/referenced,
default: 'ckan'. This value is used by the paster cli command.
... | [
":",
"param",
"environment_name",
":",
"exising",
"environment",
"name",
"path",
"or",
"None",
"to",
"look",
"in",
"current",
"or",
"parent",
"directories",
"for",
"project"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L118-L170 |
datacats/datacats | datacats/task.py | load_environment | def load_environment(srcdir, datadir=None, allow_old=False):
"""
Load configuration values for an environment
:param srcdir: environment source directory
:param datadir: environment data direcory, if None will be discovered
from srcdir
:param allow_old: Don't throw an exception ... | python | def load_environment(srcdir, datadir=None, allow_old=False):
"""
Load configuration values for an environment
:param srcdir: environment source directory
:param datadir: environment data direcory, if None will be discovered
from srcdir
:param allow_old: Don't throw an exception ... | [
"def",
"load_environment",
"(",
"srcdir",
",",
"datadir",
"=",
"None",
",",
"allow_old",
"=",
"False",
")",
":",
"cp",
"=",
"ConfigParser",
".",
"SafeConfigParser",
"(",
")",
"try",
":",
"cp",
".",
"read",
"(",
"[",
"srcdir",
"+",
"'/.datacats-environment'... | Load configuration values for an environment
:param srcdir: environment source directory
:param datadir: environment data direcory, if None will be discovered
from srcdir
:param allow_old: Don't throw an exception if this is an old site
This is only valid for sites... | [
"Load",
"configuration",
"values",
"for",
"an",
"environment"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L173-L247 |
datacats/datacats | datacats/task.py | load_site | def load_site(srcdir, datadir, site_name=None):
"""
Load configuration values for a site.
Returns (port, address, site_url, passwords)
"""
if site_name is None:
site_name = 'primary'
if not validate.valid_name(site_name):
raise DatacatsError('{} is not a valid site name.'.format... | python | def load_site(srcdir, datadir, site_name=None):
"""
Load configuration values for a site.
Returns (port, address, site_url, passwords)
"""
if site_name is None:
site_name = 'primary'
if not validate.valid_name(site_name):
raise DatacatsError('{} is not a valid site name.'.format... | [
"def",
"load_site",
"(",
"srcdir",
",",
"datadir",
",",
"site_name",
"=",
"None",
")",
":",
"if",
"site_name",
"is",
"None",
":",
"site_name",
"=",
"'primary'",
"if",
"not",
"validate",
".",
"valid_name",
"(",
"site_name",
")",
":",
"raise",
"DatacatsError... | Load configuration values for a site.
Returns (port, address, site_url, passwords) | [
"Load",
"configuration",
"values",
"for",
"a",
"site",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L250-L292 |
datacats/datacats | datacats/task.py | new_environment_check | def new_environment_check(srcpath, site_name, ckan_version):
"""
Check if a new environment or site can be created at the given path.
Returns (name, datadir, sitedir, srcdir) or raises DatacatsError
"""
docker.require_images()
workdir, name = path.split(path.abspath(path.expanduser(srcpath)))
... | python | def new_environment_check(srcpath, site_name, ckan_version):
"""
Check if a new environment or site can be created at the given path.
Returns (name, datadir, sitedir, srcdir) or raises DatacatsError
"""
docker.require_images()
workdir, name = path.split(path.abspath(path.expanduser(srcpath)))
... | [
"def",
"new_environment_check",
"(",
"srcpath",
",",
"site_name",
",",
"ckan_version",
")",
":",
"docker",
".",
"require_images",
"(",
")",
"workdir",
",",
"name",
"=",
"path",
".",
"split",
"(",
"path",
".",
"abspath",
"(",
"path",
".",
"expanduser",
"(",... | Check if a new environment or site can be created at the given path.
Returns (name, datadir, sitedir, srcdir) or raises DatacatsError | [
"Check",
"if",
"a",
"new",
"environment",
"or",
"site",
"can",
"be",
"created",
"at",
"the",
"given",
"path",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L298-L348 |
datacats/datacats | datacats/task.py | data_complete | def data_complete(datadir, sitedir, get_container_name):
"""
Return True if the directories and containers we're expecting
are present in datadir, sitedir and containers
"""
if any(not path.isdir(sitedir + x)
for x in ('/files', '/run', '/solr')):
return False
if docker.is_b... | python | def data_complete(datadir, sitedir, get_container_name):
"""
Return True if the directories and containers we're expecting
are present in datadir, sitedir and containers
"""
if any(not path.isdir(sitedir + x)
for x in ('/files', '/run', '/solr')):
return False
if docker.is_b... | [
"def",
"data_complete",
"(",
"datadir",
",",
"sitedir",
",",
"get_container_name",
")",
":",
"if",
"any",
"(",
"not",
"path",
".",
"isdir",
"(",
"sitedir",
"+",
"x",
")",
"for",
"x",
"in",
"(",
"'/files'",
",",
"'/run'",
",",
"'/solr'",
")",
")",
":"... | Return True if the directories and containers we're expecting
are present in datadir, sitedir and containers | [
"Return",
"True",
"if",
"the",
"directories",
"and",
"containers",
"we",
"re",
"expecting",
"are",
"present",
"in",
"datadir",
"sitedir",
"and",
"containers"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L351-L365 |
datacats/datacats | datacats/task.py | create_directories | def create_directories(datadir, sitedir, srcdir=None):
"""
Create expected directories in datadir, sitedir
and optionally srcdir
"""
# It's possible that the datadir already exists
# (we're making a secondary site)
if not path.isdir(datadir):
os.makedirs(datadir, mode=0o700)
try:... | python | def create_directories(datadir, sitedir, srcdir=None):
"""
Create expected directories in datadir, sitedir
and optionally srcdir
"""
# It's possible that the datadir already exists
# (we're making a secondary site)
if not path.isdir(datadir):
os.makedirs(datadir, mode=0o700)
try:... | [
"def",
"create_directories",
"(",
"datadir",
",",
"sitedir",
",",
"srcdir",
"=",
"None",
")",
":",
"# It's possible that the datadir already exists",
"# (we're making a secondary site)",
"if",
"not",
"path",
".",
"isdir",
"(",
"datadir",
")",
":",
"os",
".",
"makedi... | Create expected directories in datadir, sitedir
and optionally srcdir | [
"Create",
"expected",
"directories",
"in",
"datadir",
"sitedir",
"and",
"optionally",
"srcdir"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L377-L402 |
datacats/datacats | datacats/task.py | create_virtualenv | def create_virtualenv(srcdir, datadir, preload_image, get_container_name):
"""
Populate venv from preloaded image
"""
try:
if docker.is_boot2docker():
docker.data_only_container(
get_container_name('venv'),
['/usr/lib/ckan'],
)
... | python | def create_virtualenv(srcdir, datadir, preload_image, get_container_name):
"""
Populate venv from preloaded image
"""
try:
if docker.is_boot2docker():
docker.data_only_container(
get_container_name('venv'),
['/usr/lib/ckan'],
)
... | [
"def",
"create_virtualenv",
"(",
"srcdir",
",",
"datadir",
",",
"preload_image",
",",
"get_container_name",
")",
":",
"try",
":",
"if",
"docker",
".",
"is_boot2docker",
"(",
")",
":",
"docker",
".",
"data_only_container",
"(",
"get_container_name",
"(",
"'venv'"... | Populate venv from preloaded image | [
"Populate",
"venv",
"from",
"preloaded",
"image"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L405-L442 |
datacats/datacats | datacats/task.py | create_source | def create_source(srcdir, preload_image, datapusher=False):
"""
Copy ckan source, datapusher source (optional), who.ini and schema.xml
from preload image into srcdir
"""
try:
docker.web_command(
command='/bin/cp -a /project/ckan /project_target/ckan',
rw={srcdir: '/pr... | python | def create_source(srcdir, preload_image, datapusher=False):
"""
Copy ckan source, datapusher source (optional), who.ini and schema.xml
from preload image into srcdir
"""
try:
docker.web_command(
command='/bin/cp -a /project/ckan /project_target/ckan',
rw={srcdir: '/pr... | [
"def",
"create_source",
"(",
"srcdir",
",",
"preload_image",
",",
"datapusher",
"=",
"False",
")",
":",
"try",
":",
"docker",
".",
"web_command",
"(",
"command",
"=",
"'/bin/cp -a /project/ckan /project_target/ckan'",
",",
"rw",
"=",
"{",
"srcdir",
":",
"'/proje... | Copy ckan source, datapusher source (optional), who.ini and schema.xml
from preload image into srcdir | [
"Copy",
"ckan",
"source",
"datapusher",
"source",
"(",
"optional",
")",
"who",
".",
"ini",
"and",
"schema",
".",
"xml",
"from",
"preload",
"image",
"into",
"srcdir"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L445-L471 |
datacats/datacats | datacats/task.py | start_supporting_containers | def start_supporting_containers(sitedir, srcdir, passwords,
get_container_name, extra_containers, log_syslog=False):
"""
Start all supporting containers (containers required for CKAN to
operate) if they aren't already running, along with some extra
containers specified by the user
"""
if... | python | def start_supporting_containers(sitedir, srcdir, passwords,
get_container_name, extra_containers, log_syslog=False):
"""
Start all supporting containers (containers required for CKAN to
operate) if they aren't already running, along with some extra
containers specified by the user
"""
if... | [
"def",
"start_supporting_containers",
"(",
"sitedir",
",",
"srcdir",
",",
"passwords",
",",
"get_container_name",
",",
"extra_containers",
",",
"log_syslog",
"=",
"False",
")",
":",
"if",
"docker",
".",
"is_boot2docker",
"(",
")",
":",
"docker",
".",
"data_only_... | Start all supporting containers (containers required for CKAN to
operate) if they aren't already running, along with some extra
containers specified by the user | [
"Start",
"all",
"supporting",
"containers",
"(",
"containers",
"required",
"for",
"CKAN",
"to",
"operate",
")",
"if",
"they",
"aren",
"t",
"already",
"running",
"along",
"with",
"some",
"extra",
"containers",
"specified",
"by",
"the",
"user"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L478-L531 |
datacats/datacats | datacats/task.py | stop_supporting_containers | def stop_supporting_containers(get_container_name, extra_containers):
"""
Stop postgres and solr containers, along with any specified extra containers
"""
docker.remove_container(get_container_name('postgres'))
docker.remove_container(get_container_name('solr'))
for container in extra_containers... | python | def stop_supporting_containers(get_container_name, extra_containers):
"""
Stop postgres and solr containers, along with any specified extra containers
"""
docker.remove_container(get_container_name('postgres'))
docker.remove_container(get_container_name('solr'))
for container in extra_containers... | [
"def",
"stop_supporting_containers",
"(",
"get_container_name",
",",
"extra_containers",
")",
":",
"docker",
".",
"remove_container",
"(",
"get_container_name",
"(",
"'postgres'",
")",
")",
"docker",
".",
"remove_container",
"(",
"get_container_name",
"(",
"'solr'",
"... | Stop postgres and solr containers, along with any specified extra containers | [
"Stop",
"postgres",
"and",
"solr",
"containers",
"along",
"with",
"any",
"specified",
"extra",
"containers"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L534-L541 |
datacats/datacats | datacats/task.py | containers_running | def containers_running(get_container_name):
"""
Return a list of containers tracked by this environment that are running
"""
running = []
for n in ['web', 'postgres', 'solr', 'datapusher', 'redis']:
info = docker.inspect_container(get_container_name(n))
if info and not info['State'][... | python | def containers_running(get_container_name):
"""
Return a list of containers tracked by this environment that are running
"""
running = []
for n in ['web', 'postgres', 'solr', 'datapusher', 'redis']:
info = docker.inspect_container(get_container_name(n))
if info and not info['State'][... | [
"def",
"containers_running",
"(",
"get_container_name",
")",
":",
"running",
"=",
"[",
"]",
"for",
"n",
"in",
"[",
"'web'",
",",
"'postgres'",
",",
"'solr'",
",",
"'datapusher'",
",",
"'redis'",
"]",
":",
"info",
"=",
"docker",
".",
"inspect_container",
"(... | Return a list of containers tracked by this environment that are running | [
"Return",
"a",
"list",
"of",
"containers",
"tracked",
"by",
"this",
"environment",
"that",
"are",
"running"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/task.py#L544-L555 |
datacats/datacats | datacats/environment.py | Environment._load_sites | def _load_sites(self):
"""
Gets the names of all of the sites from the datadir and stores them
in self.sites. Also returns this list.
"""
if not self.sites:
self.sites = task.list_sites(self.datadir)
return self.sites | python | def _load_sites(self):
"""
Gets the names of all of the sites from the datadir and stores them
in self.sites. Also returns this list.
"""
if not self.sites:
self.sites = task.list_sites(self.datadir)
return self.sites | [
"def",
"_load_sites",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"sites",
":",
"self",
".",
"sites",
"=",
"task",
".",
"list_sites",
"(",
"self",
".",
"datadir",
")",
"return",
"self",
".",
"sites"
] | Gets the names of all of the sites from the datadir and stores them
in self.sites. Also returns this list. | [
"Gets",
"the",
"names",
"of",
"all",
"of",
"the",
"sites",
"from",
"the",
"datadir",
"and",
"stores",
"them",
"in",
"self",
".",
"sites",
".",
"Also",
"returns",
"this",
"list",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L73-L80 |
datacats/datacats | datacats/environment.py | Environment.save_site | def save_site(self, create=True):
"""
Save environment settings in the directory that need to be saved
even when creating only a new sub-site env.
"""
self._load_sites()
if create:
self.sites.append(self.site_name)
task.save_new_site(self.site_name, s... | python | def save_site(self, create=True):
"""
Save environment settings in the directory that need to be saved
even when creating only a new sub-site env.
"""
self._load_sites()
if create:
self.sites.append(self.site_name)
task.save_new_site(self.site_name, s... | [
"def",
"save_site",
"(",
"self",
",",
"create",
"=",
"True",
")",
":",
"self",
".",
"_load_sites",
"(",
")",
"if",
"create",
":",
"self",
".",
"sites",
".",
"append",
"(",
"self",
".",
"site_name",
")",
"task",
".",
"save_new_site",
"(",
"self",
".",... | Save environment settings in the directory that need to be saved
even when creating only a new sub-site env. | [
"Save",
"environment",
"settings",
"in",
"the",
"directory",
"that",
"need",
"to",
"be",
"saved",
"even",
"when",
"creating",
"only",
"a",
"new",
"sub",
"-",
"site",
"env",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L82-L92 |
datacats/datacats | datacats/environment.py | Environment.save | def save(self):
"""
Save environment settings into environment directory, overwriting
any existing configuration and discarding site config
"""
task.save_new_environment(self.name, self.datadir, self.target,
self.ckan_version, self.deploy_target, self.always_prod) | python | def save(self):
"""
Save environment settings into environment directory, overwriting
any existing configuration and discarding site config
"""
task.save_new_environment(self.name, self.datadir, self.target,
self.ckan_version, self.deploy_target, self.always_prod) | [
"def",
"save",
"(",
"self",
")",
":",
"task",
".",
"save_new_environment",
"(",
"self",
".",
"name",
",",
"self",
".",
"datadir",
",",
"self",
".",
"target",
",",
"self",
".",
"ckan_version",
",",
"self",
".",
"deploy_target",
",",
"self",
".",
"always... | Save environment settings into environment directory, overwriting
any existing configuration and discarding site config | [
"Save",
"environment",
"settings",
"into",
"environment",
"directory",
"overwriting",
"any",
"existing",
"configuration",
"and",
"discarding",
"site",
"config"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L94-L100 |
datacats/datacats | datacats/environment.py | Environment.new | def new(cls, path, ckan_version, site_name, **kwargs):
"""
Return a Environment object with settings for a new project.
No directories or containers are created by this call.
:params path: location for new project directory, may be relative
:params ckan_version: release of CKAN ... | python | def new(cls, path, ckan_version, site_name, **kwargs):
"""
Return a Environment object with settings for a new project.
No directories or containers are created by this call.
:params path: location for new project directory, may be relative
:params ckan_version: release of CKAN ... | [
"def",
"new",
"(",
"cls",
",",
"path",
",",
"ckan_version",
",",
"site_name",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ckan_version",
"==",
"'master'",
":",
"ckan_version",
"=",
"'latest'",
"name",
",",
"datadir",
",",
"srcdir",
"=",
"task",
".",
"new... | Return a Environment object with settings for a new project.
No directories or containers are created by this call.
:params path: location for new project directory, may be relative
:params ckan_version: release of CKAN to install
:params site_name: The name of the site to install datab... | [
"Return",
"a",
"Environment",
"object",
"with",
"settings",
"for",
"a",
"new",
"project",
".",
"No",
"directories",
"or",
"containers",
"are",
"created",
"by",
"this",
"call",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L103-L123 |
datacats/datacats | datacats/environment.py | Environment.load | def load(cls, environment_name=None, site_name='primary', data_only=False, allow_old=False):
"""
Return an Environment object based on an existing environnment+site.
:param environment_name: exising environment name, path or None to
look in current or parent directories for project
... | python | def load(cls, environment_name=None, site_name='primary', data_only=False, allow_old=False):
"""
Return an Environment object based on an existing environnment+site.
:param environment_name: exising environment name, path or None to
look in current or parent directories for project
... | [
"def",
"load",
"(",
"cls",
",",
"environment_name",
"=",
"None",
",",
"site_name",
"=",
"'primary'",
",",
"data_only",
"=",
"False",
",",
"allow_old",
"=",
"False",
")",
":",
"srcdir",
",",
"extension_dir",
",",
"datadir",
"=",
"task",
".",
"find_environme... | Return an Environment object based on an existing environnment+site.
:param environment_name: exising environment name, path or None to
look in current or parent directories for project
:param data_only: set to True to only load from data dir, not
the project dir; Used for purgi... | [
"Return",
"an",
"Environment",
"object",
"based",
"on",
"an",
"existing",
"environnment",
"+",
"site",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L126-L168 |
datacats/datacats | datacats/environment.py | Environment.data_complete | def data_complete(self):
"""
Return True if all the expected datadir files are present
"""
return task.data_complete(self.datadir, self.sitedir,
self._get_container_name) | python | def data_complete(self):
"""
Return True if all the expected datadir files are present
"""
return task.data_complete(self.datadir, self.sitedir,
self._get_container_name) | [
"def",
"data_complete",
"(",
"self",
")",
":",
"return",
"task",
".",
"data_complete",
"(",
"self",
".",
"datadir",
",",
"self",
".",
"sitedir",
",",
"self",
".",
"_get_container_name",
")"
] | Return True if all the expected datadir files are present | [
"Return",
"True",
"if",
"all",
"the",
"expected",
"datadir",
"files",
"are",
"present"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L182-L187 |
datacats/datacats | datacats/environment.py | Environment.require_data | def require_data(self):
"""
raise a DatacatsError if the datadir or volumes are missing or damaged
"""
files = task.source_missing(self.target)
if files:
raise DatacatsError('Missing files in source directory:\n' +
'\n'.join(files))
... | python | def require_data(self):
"""
raise a DatacatsError if the datadir or volumes are missing or damaged
"""
files = task.source_missing(self.target)
if files:
raise DatacatsError('Missing files in source directory:\n' +
'\n'.join(files))
... | [
"def",
"require_data",
"(",
"self",
")",
":",
"files",
"=",
"task",
".",
"source_missing",
"(",
"self",
".",
"target",
")",
"if",
"files",
":",
"raise",
"DatacatsError",
"(",
"'Missing files in source directory:\\n'",
"+",
"'\\n'",
".",
"join",
"(",
"files",
... | raise a DatacatsError if the datadir or volumes are missing or damaged | [
"raise",
"a",
"DatacatsError",
"if",
"the",
"datadir",
"or",
"volumes",
"are",
"missing",
"or",
"damaged"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L189-L204 |
datacats/datacats | datacats/environment.py | Environment.create_directories | def create_directories(self, create_project_dir=True):
"""
Call once for new projects to create the initial project directories.
"""
return task.create_directories(self.datadir, self.sitedir,
self.target if create_project_dir else None) | python | def create_directories(self, create_project_dir=True):
"""
Call once for new projects to create the initial project directories.
"""
return task.create_directories(self.datadir, self.sitedir,
self.target if create_project_dir else None) | [
"def",
"create_directories",
"(",
"self",
",",
"create_project_dir",
"=",
"True",
")",
":",
"return",
"task",
".",
"create_directories",
"(",
"self",
".",
"datadir",
",",
"self",
".",
"sitedir",
",",
"self",
".",
"target",
"if",
"create_project_dir",
"else",
... | Call once for new projects to create the initial project directories. | [
"Call",
"once",
"for",
"new",
"projects",
"to",
"create",
"the",
"initial",
"project",
"directories",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L206-L211 |
datacats/datacats | datacats/environment.py | Environment.create_virtualenv | def create_virtualenv(self):
"""
Populate venv from preloaded image
"""
return task.create_virtualenv(self.target, self.datadir,
self._preload_image(), self._get_container_name) | python | def create_virtualenv(self):
"""
Populate venv from preloaded image
"""
return task.create_virtualenv(self.target, self.datadir,
self._preload_image(), self._get_container_name) | [
"def",
"create_virtualenv",
"(",
"self",
")",
":",
"return",
"task",
".",
"create_virtualenv",
"(",
"self",
".",
"target",
",",
"self",
".",
"datadir",
",",
"self",
".",
"_preload_image",
"(",
")",
",",
"self",
".",
"_get_container_name",
")"
] | Populate venv from preloaded image | [
"Populate",
"venv",
"from",
"preloaded",
"image"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L228-L233 |
datacats/datacats | datacats/environment.py | Environment.clean_virtualenv | def clean_virtualenv(self):
"""
Empty our virtualenv so that new (or older) dependencies may be
installed
"""
self.user_run_script(
script=scripts.get_script_path('clean_virtualenv.sh'),
args=[],
rw_venv=True,
) | python | def clean_virtualenv(self):
"""
Empty our virtualenv so that new (or older) dependencies may be
installed
"""
self.user_run_script(
script=scripts.get_script_path('clean_virtualenv.sh'),
args=[],
rw_venv=True,
) | [
"def",
"clean_virtualenv",
"(",
"self",
")",
":",
"self",
".",
"user_run_script",
"(",
"script",
"=",
"scripts",
".",
"get_script_path",
"(",
"'clean_virtualenv.sh'",
")",
",",
"args",
"=",
"[",
"]",
",",
"rw_venv",
"=",
"True",
",",
")"
] | Empty our virtualenv so that new (or older) dependencies may be
installed | [
"Empty",
"our",
"virtualenv",
"so",
"that",
"new",
"(",
"or",
"older",
")",
"dependencies",
"may",
"be",
"installed"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L235-L244 |
datacats/datacats | datacats/environment.py | Environment.create_source | def create_source(self, datapusher=True):
"""
Populate ckan directory from preloaded image and copy
who.ini and schema.xml info conf directory
"""
task.create_source(self.target, self._preload_image(), datapusher) | python | def create_source(self, datapusher=True):
"""
Populate ckan directory from preloaded image and copy
who.ini and schema.xml info conf directory
"""
task.create_source(self.target, self._preload_image(), datapusher) | [
"def",
"create_source",
"(",
"self",
",",
"datapusher",
"=",
"True",
")",
":",
"task",
".",
"create_source",
"(",
"self",
".",
"target",
",",
"self",
".",
"_preload_image",
"(",
")",
",",
"datapusher",
")"
] | Populate ckan directory from preloaded image and copy
who.ini and schema.xml info conf directory | [
"Populate",
"ckan",
"directory",
"from",
"preloaded",
"image",
"and",
"copy",
"who",
".",
"ini",
"and",
"schema",
".",
"xml",
"info",
"conf",
"directory"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L253-L258 |
datacats/datacats | datacats/environment.py | Environment.start_supporting_containers | def start_supporting_containers(self, log_syslog=False):
"""
Start all supporting containers (containers required for CKAN to
operate) if they aren't already running.
:param log_syslog: A flag to redirect all container logs to host's syslog
"""
log_syslog = True if ... | python | def start_supporting_containers(self, log_syslog=False):
"""
Start all supporting containers (containers required for CKAN to
operate) if they aren't already running.
:param log_syslog: A flag to redirect all container logs to host's syslog
"""
log_syslog = True if ... | [
"def",
"start_supporting_containers",
"(",
"self",
",",
"log_syslog",
"=",
"False",
")",
":",
"log_syslog",
"=",
"True",
"if",
"self",
".",
"always_prod",
"else",
"log_syslog",
"# in production we always use log_syslog driver (to aggregate all the logs)",
"task",
".",
"st... | Start all supporting containers (containers required for CKAN to
operate) if they aren't already running.
:param log_syslog: A flag to redirect all container logs to host's syslog | [
"Start",
"all",
"supporting",
"containers",
"(",
"containers",
"required",
"for",
"CKAN",
"to",
"operate",
")",
"if",
"they",
"aren",
"t",
"already",
"running",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L260-L277 |
datacats/datacats | datacats/environment.py | Environment.create_ckan_ini | def create_ckan_ini(self):
"""
Use make-config to generate an initial development.ini file
"""
self.run_command(
command='/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'
' ckan /project/development.ini',
rw_project=True,
ro={s... | python | def create_ckan_ini(self):
"""
Use make-config to generate an initial development.ini file
"""
self.run_command(
command='/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'
' ckan /project/development.ini',
rw_project=True,
ro={s... | [
"def",
"create_ckan_ini",
"(",
"self",
")",
":",
"self",
".",
"run_command",
"(",
"command",
"=",
"'/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'",
"' ckan /project/development.ini'",
",",
"rw_project",
"=",
"True",
",",
"ro",
"=",
"{",
"scripts",
".",
... | Use make-config to generate an initial development.ini file | [
"Use",
"make",
"-",
"config",
"to",
"generate",
"an",
"initial",
"development",
".",
"ini",
"file"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L295-L304 |
datacats/datacats | datacats/environment.py | Environment.update_ckan_ini | def update_ckan_ini(self, skin=True):
"""
Use config-tool to update development.ini with our environment settings
:param skin: use environment template skin plugin True/False
"""
command = [
'/usr/lib/ckan/bin/paster', '--plugin=ckan', 'config-tool',
'/pr... | python | def update_ckan_ini(self, skin=True):
"""
Use config-tool to update development.ini with our environment settings
:param skin: use environment template skin plugin True/False
"""
command = [
'/usr/lib/ckan/bin/paster', '--plugin=ckan', 'config-tool',
'/pr... | [
"def",
"update_ckan_ini",
"(",
"self",
",",
"skin",
"=",
"True",
")",
":",
"command",
"=",
"[",
"'/usr/lib/ckan/bin/paster'",
",",
"'--plugin=ckan'",
",",
"'config-tool'",
",",
"'/project/development.ini'",
",",
"'-e'",
",",
"'sqlalchemy.url = postgresql://<hidden>'",
... | Use config-tool to update development.ini with our environment settings
:param skin: use environment template skin plugin True/False | [
"Use",
"config",
"-",
"tool",
"to",
"update",
"development",
".",
"ini",
"with",
"our",
"environment",
"settings"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L306-L329 |
datacats/datacats | datacats/environment.py | Environment.create_install_template_skin | def create_install_template_skin(self):
"""
Create an example ckan extension for this environment and install it
"""
ckan_extension_template(self.name, self.target)
self.install_package_develop('ckanext-' + self.name + 'theme') | python | def create_install_template_skin(self):
"""
Create an example ckan extension for this environment and install it
"""
ckan_extension_template(self.name, self.target)
self.install_package_develop('ckanext-' + self.name + 'theme') | [
"def",
"create_install_template_skin",
"(",
"self",
")",
":",
"ckan_extension_template",
"(",
"self",
".",
"name",
",",
"self",
".",
"target",
")",
"self",
".",
"install_package_develop",
"(",
"'ckanext-'",
"+",
"self",
".",
"name",
"+",
"'theme'",
")"
] | Create an example ckan extension for this environment and install it | [
"Create",
"an",
"example",
"ckan",
"extension",
"for",
"this",
"environment",
"and",
"install",
"it"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L331-L336 |
datacats/datacats | datacats/environment.py | Environment.ckan_db_init | def ckan_db_init(self, retry_seconds=DB_INIT_RETRY_SECONDS):
"""
Run db init to create all ckan tables
:param retry_seconds: how long to retry waiting for db to start
"""
# XXX workaround for not knowing how long we need to wait
# for postgres to be ready. fix this by ch... | python | def ckan_db_init(self, retry_seconds=DB_INIT_RETRY_SECONDS):
"""
Run db init to create all ckan tables
:param retry_seconds: how long to retry waiting for db to start
"""
# XXX workaround for not knowing how long we need to wait
# for postgres to be ready. fix this by ch... | [
"def",
"ckan_db_init",
"(",
"self",
",",
"retry_seconds",
"=",
"DB_INIT_RETRY_SECONDS",
")",
":",
"# XXX workaround for not knowing how long we need to wait",
"# for postgres to be ready. fix this by changing the postgres",
"# entrypoint, or possibly running once with command=/bin/true",
"... | Run db init to create all ckan tables
:param retry_seconds: how long to retry waiting for db to start | [
"Run",
"db",
"init",
"to",
"create",
"all",
"ckan",
"tables"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L338-L360 |
datacats/datacats | datacats/environment.py | Environment.start_ckan | def start_ckan(self, production=False, log_syslog=False, paster_reload=True,
interactive=False):
"""
Start the apache server or paster serve
:param log_syslog: A flag to redirect all container logs to host's syslog
:param production: True for apache, False for paster ... | python | def start_ckan(self, production=False, log_syslog=False, paster_reload=True,
interactive=False):
"""
Start the apache server or paster serve
:param log_syslog: A flag to redirect all container logs to host's syslog
:param production: True for apache, False for paster ... | [
"def",
"start_ckan",
"(",
"self",
",",
"production",
"=",
"False",
",",
"log_syslog",
"=",
"False",
",",
"paster_reload",
"=",
"True",
",",
"interactive",
"=",
"False",
")",
":",
"self",
".",
"stop_ckan",
"(",
")",
"address",
"=",
"self",
".",
"address",... | Start the apache server or paster serve
:param log_syslog: A flag to redirect all container logs to host's syslog
:param production: True for apache, False for paster serve + debug on
:param paster_reload: Instruct paster to watch for file changes | [
"Start",
"the",
"apache",
"server",
"or",
"paster",
"serve"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L391-L450 |
datacats/datacats | datacats/environment.py | Environment._create_run_ini | def _create_run_ini(self, port, production, output='development.ini',
source='development.ini', override_site_url=True):
"""
Create run/development.ini in datadir with debug and site_url overridden
and with correct db passwords inserted
"""
cp = SafeConfig... | python | def _create_run_ini(self, port, production, output='development.ini',
source='development.ini', override_site_url=True):
"""
Create run/development.ini in datadir with debug and site_url overridden
and with correct db passwords inserted
"""
cp = SafeConfig... | [
"def",
"_create_run_ini",
"(",
"self",
",",
"port",
",",
"production",
",",
"output",
"=",
"'development.ini'",
",",
"source",
"=",
"'development.ini'",
",",
"override_site_url",
"=",
"True",
")",
":",
"cp",
"=",
"SafeConfigParser",
"(",
")",
"try",
":",
"cp... | Create run/development.ini in datadir with debug and site_url overridden
and with correct db passwords inserted | [
"Create",
"run",
"/",
"development",
".",
"ini",
"in",
"datadir",
"with",
"debug",
"and",
"site_url",
"overridden",
"and",
"with",
"correct",
"db",
"passwords",
"inserted"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L452-L494 |
datacats/datacats | datacats/environment.py | Environment._run_web_container | def _run_web_container(self, port, command, address, log_syslog=False,
datapusher=True, interactive=False):
"""
Start web container on port with command
"""
if is_boot2docker():
ro = {}
volumes_from = self._get_container_name('venv')
... | python | def _run_web_container(self, port, command, address, log_syslog=False,
datapusher=True, interactive=False):
"""
Start web container on port with command
"""
if is_boot2docker():
ro = {}
volumes_from = self._get_container_name('venv')
... | [
"def",
"_run_web_container",
"(",
"self",
",",
"port",
",",
"command",
",",
"address",
",",
"log_syslog",
"=",
"False",
",",
"datapusher",
"=",
"True",
",",
"interactive",
"=",
"False",
")",
":",
"if",
"is_boot2docker",
"(",
")",
":",
"ro",
"=",
"{",
"... | Start web container on port with command | [
"Start",
"web",
"container",
"on",
"port",
"with",
"command"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L496-L566 |
datacats/datacats | datacats/environment.py | Environment.wait_for_web_available | def wait_for_web_available(self):
"""
Wait for the web server to become available or raise DatacatsError
if it fails to start.
"""
try:
if not wait_for_service_available(
self._get_container_name('web'),
self.web_address(),
... | python | def wait_for_web_available(self):
"""
Wait for the web server to become available or raise DatacatsError
if it fails to start.
"""
try:
if not wait_for_service_available(
self._get_container_name('web'),
self.web_address(),
... | [
"def",
"wait_for_web_available",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"wait_for_service_available",
"(",
"self",
".",
"_get_container_name",
"(",
"'web'",
")",
",",
"self",
".",
"web_address",
"(",
")",
",",
"WEB_START_TIMEOUT_SECONDS",
")",
":",
"r... | Wait for the web server to become available or raise DatacatsError
if it fails to start. | [
"Wait",
"for",
"the",
"web",
"server",
"to",
"become",
"available",
"or",
"raise",
"DatacatsError",
"if",
"it",
"fails",
"to",
"start",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L568-L583 |
datacats/datacats | datacats/environment.py | Environment._choose_port | def _choose_port(self):
"""
Return a port number from 5000-5999 based on the environment name
to be used as a default when the user hasn't selected one.
"""
# instead of random let's base it on the name chosen (and the site name)
return 5000 + unpack('Q',
... | python | def _choose_port(self):
"""
Return a port number from 5000-5999 based on the environment name
to be used as a default when the user hasn't selected one.
"""
# instead of random let's base it on the name chosen (and the site name)
return 5000 + unpack('Q',
... | [
"def",
"_choose_port",
"(",
"self",
")",
":",
"# instead of random let's base it on the name chosen (and the site name)",
"return",
"5000",
"+",
"unpack",
"(",
"'Q'",
",",
"sha",
"(",
"(",
"self",
".",
"name",
"+",
"self",
".",
"site_name",
")",
".",
"decode",
"... | Return a port number from 5000-5999 based on the environment name
to be used as a default when the user hasn't selected one. | [
"Return",
"a",
"port",
"number",
"from",
"5000",
"-",
"5999",
"based",
"on",
"the",
"environment",
"name",
"to",
"be",
"used",
"as",
"a",
"default",
"when",
"the",
"user",
"hasn",
"t",
"selected",
"one",
"."
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L585-L593 |
datacats/datacats | datacats/environment.py | Environment._next_port | def _next_port(self, port):
"""
Return another port from the 5000-5999 range
"""
port = 5000 + (port + 1) % 1000
if port == self.port:
raise DatacatsError('Too many instances running')
return port | python | def _next_port(self, port):
"""
Return another port from the 5000-5999 range
"""
port = 5000 + (port + 1) % 1000
if port == self.port:
raise DatacatsError('Too many instances running')
return port | [
"def",
"_next_port",
"(",
"self",
",",
"port",
")",
":",
"port",
"=",
"5000",
"+",
"(",
"port",
"+",
"1",
")",
"%",
"1000",
"if",
"port",
"==",
"self",
".",
"port",
":",
"raise",
"DatacatsError",
"(",
"'Too many instances running'",
")",
"return",
"por... | Return another port from the 5000-5999 range | [
"Return",
"another",
"port",
"from",
"the",
"5000",
"-",
"5999",
"range"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L595-L602 |
datacats/datacats | datacats/environment.py | Environment.stop_ckan | def stop_ckan(self):
"""
Stop and remove the web container
"""
remove_container(self._get_container_name('web'), force=True)
remove_container(self._get_container_name('datapusher'), force=True) | python | def stop_ckan(self):
"""
Stop and remove the web container
"""
remove_container(self._get_container_name('web'), force=True)
remove_container(self._get_container_name('datapusher'), force=True) | [
"def",
"stop_ckan",
"(",
"self",
")",
":",
"remove_container",
"(",
"self",
".",
"_get_container_name",
"(",
"'web'",
")",
",",
"force",
"=",
"True",
")",
"remove_container",
"(",
"self",
".",
"_get_container_name",
"(",
"'datapusher'",
")",
",",
"force",
"=... | Stop and remove the web container | [
"Stop",
"and",
"remove",
"the",
"web",
"container"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L604-L609 |
datacats/datacats | datacats/environment.py | Environment._current_web_port | def _current_web_port(self):
"""
return just the port number for the web container, or None if
not running
"""
info = inspect_container(self._get_container_name('web'))
if info is None:
return None
try:
if not info['State']['Running']:
... | python | def _current_web_port(self):
"""
return just the port number for the web container, or None if
not running
"""
info = inspect_container(self._get_container_name('web'))
if info is None:
return None
try:
if not info['State']['Running']:
... | [
"def",
"_current_web_port",
"(",
"self",
")",
":",
"info",
"=",
"inspect_container",
"(",
"self",
".",
"_get_container_name",
"(",
"'web'",
")",
")",
"if",
"info",
"is",
"None",
":",
"return",
"None",
"try",
":",
"if",
"not",
"info",
"[",
"'State'",
"]",... | return just the port number for the web container, or None if
not running | [
"return",
"just",
"the",
"port",
"number",
"for",
"the",
"web",
"container",
"or",
"None",
"if",
"not",
"running"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L611-L624 |
datacats/datacats | datacats/environment.py | Environment.add_extra_container | def add_extra_container(self, container, error_on_exists=False):
"""
Add a container as a 'extra'. These are running containers which are not necessary for
running default CKAN but are useful for certain extensions
:param container: The container name to add
:param error_on_exist... | python | def add_extra_container(self, container, error_on_exists=False):
"""
Add a container as a 'extra'. These are running containers which are not necessary for
running default CKAN but are useful for certain extensions
:param container: The container name to add
:param error_on_exist... | [
"def",
"add_extra_container",
"(",
"self",
",",
"container",
",",
"error_on_exists",
"=",
"False",
")",
":",
"if",
"container",
"in",
"self",
".",
"extra_containers",
":",
"if",
"error_on_exists",
":",
"raise",
"DatacatsError",
"(",
"'{} is already added as an extra... | Add a container as a 'extra'. These are running containers which are not necessary for
running default CKAN but are useful for certain extensions
:param container: The container name to add
:param error_on_exists: Raise a DatacatsError if the extra container already exists. | [
"Add",
"a",
"container",
"as",
"a",
"extra",
".",
"These",
"are",
"running",
"containers",
"which",
"are",
"not",
"necessary",
"for",
"running",
"default",
"CKAN",
"but",
"are",
"useful",
"for",
"certain",
"extensions",
":",
"param",
"container",
":",
"The",... | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L636-L657 |
datacats/datacats | datacats/environment.py | Environment.web_address | def web_address(self):
"""
Return the url of the web server or None if not running
"""
port = self._current_web_port()
address = self.address or '127.0.0.1'
if port is None:
return None
return 'http://{0}:{1}/'.format(
address if address an... | python | def web_address(self):
"""
Return the url of the web server or None if not running
"""
port = self._current_web_port()
address = self.address or '127.0.0.1'
if port is None:
return None
return 'http://{0}:{1}/'.format(
address if address an... | [
"def",
"web_address",
"(",
"self",
")",
":",
"port",
"=",
"self",
".",
"_current_web_port",
"(",
")",
"address",
"=",
"self",
".",
"address",
"or",
"'127.0.0.1'",
"if",
"port",
"is",
"None",
":",
"return",
"None",
"return",
"'http://{0}:{1}/'",
".",
"forma... | Return the url of the web server or None if not running | [
"Return",
"the",
"url",
"of",
"the",
"web",
"server",
"or",
"None",
"if",
"not",
"running"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L665-L675 |
datacats/datacats | datacats/environment.py | Environment.create_admin_set_password | def create_admin_set_password(self, password):
"""
create 'admin' account with given password
"""
with open(self.sitedir + '/run/admin.json', 'w') as out:
json.dump({
'name': 'admin',
'email': 'none',
'password': password,
... | python | def create_admin_set_password(self, password):
"""
create 'admin' account with given password
"""
with open(self.sitedir + '/run/admin.json', 'w') as out:
json.dump({
'name': 'admin',
'email': 'none',
'password': password,
... | [
"def",
"create_admin_set_password",
"(",
"self",
",",
"password",
")",
":",
"with",
"open",
"(",
"self",
".",
"sitedir",
"+",
"'/run/admin.json'",
",",
"'w'",
")",
"as",
"out",
":",
"json",
".",
"dump",
"(",
"{",
"'name'",
":",
"'admin'",
",",
"'email'",... | create 'admin' account with given password | [
"create",
"admin",
"account",
"with",
"given",
"password"
] | train | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L677-L696 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.