repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
adaptive-learning/proso-apps
proso_models/views.py
to_practice_counts
def to_practice_counts(request): """ Get number of items available to practice. filters: -- use this or body json as in BODY language: language of the items BODY json in following format: { "#identifier": [] -- custom identifier (str) and filt...
python
def to_practice_counts(request): """ Get number of items available to practice. filters: -- use this or body json as in BODY language: language of the items BODY json in following format: { "#identifier": [] -- custom identifier (str) and filt...
[ "def", "to_practice_counts", "(", "request", ")", ":", "data", "=", "None", "if", "request", ".", "method", "==", "\"POST\"", ":", "data", "=", "json", ".", "loads", "(", "request", ".", "body", ".", "decode", "(", "\"utf-8\"", ")", ")", "[", "\"filter...
Get number of items available to practice. filters: -- use this or body json as in BODY language: language of the items BODY json in following format: { "#identifier": [] -- custom identifier (str) and filter ... }
[ "Get", "number", "of", "items", "available", "to", "practice", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/views.py#L89-L124
train
Returns a list of items available to practice.
adaptive-learning/proso-apps
proso_models/views.py
answer
def answer(request): """ Save the answer. GET parameters: html: turn on the HTML version of the API BODY json in following format: { "answer": #answer, -- for one answer "answers": [#answer, #answer, #answer ...] -- for multiple ans...
python
def answer(request): """ Save the answer. GET parameters: html: turn on the HTML version of the API BODY json in following format: { "answer": #answer, -- for one answer "answers": [#answer, #answer, #answer ...] -- for multiple ans...
[ "def", "answer", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'GET'", ":", "return", "render", "(", "request", ",", "'models_answer.html'", ",", "{", "}", ",", "help_text", "=", "answer", ".", "__doc__", ")", "elif", "request", ".", ...
Save the answer. GET parameters: html: turn on the HTML version of the API BODY json in following format: { "answer": #answer, -- for one answer "answers": [#answer, #answer, #answer ...] -- for multiple answers } answer = { ...
[ "Save", "the", "answer", "." ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/views.py#L245-L277
train
Save the answer.
adaptive-learning/proso-apps
proso_models/views.py
user_stats
def user_stats(request): """ Get user statistics for selected groups of items time: time in format '%Y-%m-%d_%H:%M:%S' used for practicing user: identifier of the user (only for stuff users) username: username of user (only for users with public profile) filters: ...
python
def user_stats(request): """ Get user statistics for selected groups of items time: time in format '%Y-%m-%d_%H:%M:%S' used for practicing user: identifier of the user (only for stuff users) username: username of user (only for users with public profile) filters: ...
[ "def", "user_stats", "(", "request", ")", ":", "timer", "(", "'user_stats'", ")", "response", "=", "{", "}", "data", "=", "None", "if", "request", ".", "method", "==", "\"POST\"", ":", "data", "=", "json", ".", "loads", "(", "request", ".", "body", "...
Get user statistics for selected groups of items time: time in format '%Y-%m-%d_%H:%M:%S' used for practicing user: identifier of the user (only for stuff users) username: username of user (only for users with public profile) filters: -- use this or body json as i...
[ "Get", "user", "statistics", "for", "selected", "groups", "of", "items" ]
8278c72e498d6ef8d392cc47b48473f4ec037142
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/views.py#L282-L347
train
Get user statistics for selected items in a single order.
Kortemme-Lab/klab
klab/rosetta/input_files.py
LoopsFile.parse_loops_file
def parse_loops_file(self, contents, ignore_whitespace = True, ignore_errors = False): '''This parser is forgiving and allows leading whitespace.''' for l in [l for l in contents.strip().split('\n') if l]: try: if ignore_whitespace: l = l.strip() ...
python
def parse_loops_file(self, contents, ignore_whitespace = True, ignore_errors = False): '''This parser is forgiving and allows leading whitespace.''' for l in [l for l in contents.strip().split('\n') if l]: try: if ignore_whitespace: l = l.strip() ...
[ "def", "parse_loops_file", "(", "self", ",", "contents", ",", "ignore_whitespace", "=", "True", ",", "ignore_errors", "=", "False", ")", ":", "for", "l", "in", "[", "l", "for", "l", "in", "contents", ".", "strip", "(", ")", ".", "split", "(", "'\\n'", ...
This parser is forgiving and allows leading whitespace.
[ "This", "parser", "is", "forgiving", "and", "allows", "leading", "whitespace", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/input_files.py#L66-L82
train
This parser is forgiving and allows leading whitespace.
Kortemme-Lab/klab
klab/rosetta/input_files.py
LoopsFile.add
def add(self, start, end, cut_point = None, skip_rate = None, extend_loop = None): '''Add a new loop definition.''' self.data.append(self.parse_loop_line(['LOOP', start, end, cut_point, skip_rate, extend_loop])) assert(start <= end)
python
def add(self, start, end, cut_point = None, skip_rate = None, extend_loop = None): '''Add a new loop definition.''' self.data.append(self.parse_loop_line(['LOOP', start, end, cut_point, skip_rate, extend_loop])) assert(start <= end)
[ "def", "add", "(", "self", ",", "start", ",", "end", ",", "cut_point", "=", "None", ",", "skip_rate", "=", "None", ",", "extend_loop", "=", "None", ")", ":", "self", ".", "data", ".", "append", "(", "self", ".", "parse_loop_line", "(", "[", "'LOOP'",...
Add a new loop definition.
[ "Add", "a", "new", "loop", "definition", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/input_files.py#L123-L126
train
Add a new loop definition.
Kortemme-Lab/klab
klab/rosetta/input_files.py
LoopsFile.get_distinct_segments
def get_distinct_segments(self, left_offset = 0, right_offset = 0, sequence_length = None): '''Returns a list of segments (pairs of start and end positions) based on the loop definitions. The returned segments merge overlapping loops e.g. if the loops file contains sections 32-40, 23-30, 28-33, and ...
python
def get_distinct_segments(self, left_offset = 0, right_offset = 0, sequence_length = None): '''Returns a list of segments (pairs of start and end positions) based on the loop definitions. The returned segments merge overlapping loops e.g. if the loops file contains sections 32-40, 23-30, 28-33, and ...
[ "def", "get_distinct_segments", "(", "self", ",", "left_offset", "=", "0", ",", "right_offset", "=", "0", ",", "sequence_length", "=", "None", ")", ":", "# Create a unique, sorted list of all loop terminus positions", "positions", "=", "set", "(", ")", "for", "l", ...
Returns a list of segments (pairs of start and end positions) based on the loop definitions. The returned segments merge overlapping loops e.g. if the loops file contains sections 32-40, 23-30, 28-33, and 43-46 then the returned segments will be [(23, 40), (43, 46)]. This may not be ...
[ "Returns", "a", "list", "of", "segments", "(", "pairs", "of", "start", "and", "end", "positions", ")", "based", "on", "the", "loop", "definitions", ".", "The", "returned", "segments", "merge", "overlapping", "loops", "e", ".", "g", ".", "if", "the", "loo...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/input_files.py#L129-L169
train
Returns a list of segments based on the loop definitions. The returned list is sorted by start and end positions.
Kortemme-Lab/klab
klab/rosetta/input_files.py
SecondaryStructureDefinition.parse_ss_def_file
def parse_ss_def_file(self, contents): '''This parser is forgiving and allows leading whitespace.''' mapping = {} for l in [l.strip() for l in contents.split('\n') if l.strip() and not(l.strip().startswith('#'))]: tokens = l.split() if len(tokens) != 2: ra...
python
def parse_ss_def_file(self, contents): '''This parser is forgiving and allows leading whitespace.''' mapping = {} for l in [l.strip() for l in contents.split('\n') if l.strip() and not(l.strip().startswith('#'))]: tokens = l.split() if len(tokens) != 2: ra...
[ "def", "parse_ss_def_file", "(", "self", ",", "contents", ")", ":", "mapping", "=", "{", "}", "for", "l", "in", "[", "l", ".", "strip", "(", ")", "for", "l", "in", "contents", ".", "split", "(", "'\\n'", ")", "if", "l", ".", "strip", "(", ")", ...
This parser is forgiving and allows leading whitespace.
[ "This", "parser", "is", "forgiving", "and", "allows", "leading", "whitespace", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/input_files.py#L198-L212
train
This parser is forgiving and allows leading whitespace.
berkeley-cocosci/Wallace
wallace/experiments.py
Experiment.log
def log(self, text, key="?????", force=False): """Print a string to the logs.""" if force or self.verbose: print ">>>> {} {}".format(key, text) sys.stdout.flush()
python
def log(self, text, key="?????", force=False): """Print a string to the logs.""" if force or self.verbose: print ">>>> {} {}".format(key, text) sys.stdout.flush()
[ "def", "log", "(", "self", ",", "text", ",", "key", "=", "\"?????\"", ",", "force", "=", "False", ")", ":", "if", "force", "or", "self", ".", "verbose", ":", "print", "\">>>> {} {}\"", ".", "format", "(", "key", ",", "text", ")", "sys", ".", "stdou...
Print a string to the logs.
[ "Print", "a", "string", "to", "the", "logs", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/experiments.py#L230-L234
train
Print a string to the logs.
Kortemme-Lab/klab
klab/view_commit_log.py
input_yes_no
def input_yes_no(msg=''): """ Simple helper function """ print '\n'+msg while(True): i=raw_input('Input yes or no: ') i=i.lower() if i=='y' or i=='yes': return True elif i=='n' or i=='no': return False else: print 'ERROR: Ba...
python
def input_yes_no(msg=''): """ Simple helper function """ print '\n'+msg while(True): i=raw_input('Input yes or no: ') i=i.lower() if i=='y' or i=='yes': return True elif i=='n' or i=='no': return False else: print 'ERROR: Ba...
[ "def", "input_yes_no", "(", "msg", "=", "''", ")", ":", "print", "'\\n'", "+", "msg", "while", "(", "True", ")", ":", "i", "=", "raw_input", "(", "'Input yes or no: '", ")", "i", "=", "i", ".", "lower", "(", ")", "if", "i", "==", "'y'", "or", "i"...
Simple helper function
[ "Simple", "helper", "function" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/view_commit_log.py#L120-L133
train
Simple helper function to input yes or no
TUNE-Archive/freight_forwarder
freight_forwarder/cli/deploy.py
DeployCommand._build_arguments
def _build_arguments(self): """ build arguments for command. """ # TODO: add tests to confirm deployments self._parser.add_argument( '-t', '--tag', required=False, type=six.text_type, default=None, help='This tag will ov...
python
def _build_arguments(self): """ build arguments for command. """ # TODO: add tests to confirm deployments self._parser.add_argument( '-t', '--tag', required=False, type=six.text_type, default=None, help='This tag will ov...
[ "def", "_build_arguments", "(", "self", ")", ":", "# TODO: add tests to confirm deployments", "self", ".", "_parser", ".", "add_argument", "(", "'-t'", ",", "'--tag'", ",", "required", "=", "False", ",", "type", "=", "six", ".", "text_type", ",", "default", "=...
build arguments for command.
[ "build", "arguments", "for", "command", "." ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/cli/deploy.py#L41-L61
train
Build command line arguments for the command.
TUNE-Archive/freight_forwarder
freight_forwarder/cli/deploy.py
DeployCommand.deploy
def deploy(self, args, **extra_args): """Deploy a docker container to a specific container ship (host) :param args: :type args: """ if not isinstance(args, argparse.Namespace): raise TypeError(logger.error("args should of an instance of argparse.Namespace")) ...
python
def deploy(self, args, **extra_args): """Deploy a docker container to a specific container ship (host) :param args: :type args: """ if not isinstance(args, argparse.Namespace): raise TypeError(logger.error("args should of an instance of argparse.Namespace")) ...
[ "def", "deploy", "(", "self", ",", "args", ",", "*", "*", "extra_args", ")", ":", "if", "not", "isinstance", "(", "args", ",", "argparse", ".", "Namespace", ")", ":", "raise", "TypeError", "(", "logger", ".", "error", "(", "\"args should of an instance of ...
Deploy a docker container to a specific container ship (host) :param args: :type args:
[ "Deploy", "a", "docker", "container", "to", "a", "specific", "container", "ship", "(", "host", ")" ]
6ea4a49f474ec04abb8bb81b175c774a16b5312f
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/cli/deploy.py#L63-L90
train
Deploy a docker container to a specific container ship
inveniosoftware/invenio-pidrelations
invenio_pidrelations/utils.py
resolve_relation_type_config
def resolve_relation_type_config(value): """Resolve the relation type to config object. Resolve relation type from string (e.g.: serialization) or int (db value) to the full config object. """ relation_types = current_app.config['PIDRELATIONS_RELATION_TYPES'] if isinstance(value, six.string_ty...
python
def resolve_relation_type_config(value): """Resolve the relation type to config object. Resolve relation type from string (e.g.: serialization) or int (db value) to the full config object. """ relation_types = current_app.config['PIDRELATIONS_RELATION_TYPES'] if isinstance(value, six.string_ty...
[ "def", "resolve_relation_type_config", "(", "value", ")", ":", "relation_types", "=", "current_app", ".", "config", "[", "'PIDRELATIONS_RELATION_TYPES'", "]", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "try", ":", "obj", "=", ...
Resolve the relation type to config object. Resolve relation type from string (e.g.: serialization) or int (db value) to the full config object.
[ "Resolve", "the", "relation", "type", "to", "config", "object", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/utils.py#L48-L73
train
Resolve the relation type to config object.
Kortemme-Lab/klab
klab/bio/alignment.py
match_pdb_chains
def match_pdb_chains(pdb1, pdb1_name, pdb2, pdb2_name, cut_off = 60.0, allow_multiple_matches = False, multiple_match_error_margin = 3.0, use_seqres_sequences_if_possible = True): '''Aligns two PDB files, returning a mapping from the chains in pdb1 to the chains of pdb2. If allow_multiple_matches is False, w...
python
def match_pdb_chains(pdb1, pdb1_name, pdb2, pdb2_name, cut_off = 60.0, allow_multiple_matches = False, multiple_match_error_margin = 3.0, use_seqres_sequences_if_possible = True): '''Aligns two PDB files, returning a mapping from the chains in pdb1 to the chains of pdb2. If allow_multiple_matches is False, w...
[ "def", "match_pdb_chains", "(", "pdb1", ",", "pdb1_name", ",", "pdb2", ",", "pdb2_name", ",", "cut_off", "=", "60.0", ",", "allow_multiple_matches", "=", "False", ",", "multiple_match_error_margin", "=", "3.0", ",", "use_seqres_sequences_if_possible", "=", "True", ...
Aligns two PDB files, returning a mapping from the chains in pdb1 to the chains of pdb2. If allow_multiple_matches is False, we return the best match for each chain in pdb1 if a match exists. The return value is a dict mapping chain_id_in_pdb1 -> None or a list with a single tuple (chain_id_i...
[ "Aligns", "two", "PDB", "files", "returning", "a", "mapping", "from", "the", "chains", "in", "pdb1", "to", "the", "chains", "of", "pdb2", ".", "If", "allow_multiple_matches", "is", "False", "we", "return", "the", "best", "match", "for", "each", "chain", "i...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L33-L136
train
Aligns two PDB files returning a mapping from the chains of pdb1 to the chains of pdb2.
Kortemme-Lab/klab
klab/bio/alignment.py
match_RCSB_pdb_chains
def match_RCSB_pdb_chains(pdb_id1, pdb_id2, cut_off = 60.0, allow_multiple_matches = False, multiple_match_error_margin = 3.0, use_seqres_sequences_if_possible = True, strict = True): '''A convenience function for match_pdb_chains. The required arguments are two PDB IDs from the RCSB.''' try: stage = pd...
python
def match_RCSB_pdb_chains(pdb_id1, pdb_id2, cut_off = 60.0, allow_multiple_matches = False, multiple_match_error_margin = 3.0, use_seqres_sequences_if_possible = True, strict = True): '''A convenience function for match_pdb_chains. The required arguments are two PDB IDs from the RCSB.''' try: stage = pd...
[ "def", "match_RCSB_pdb_chains", "(", "pdb_id1", ",", "pdb_id2", ",", "cut_off", "=", "60.0", ",", "allow_multiple_matches", "=", "False", ",", "multiple_match_error_margin", "=", "3.0", ",", "use_seqres_sequences_if_possible", "=", "True", ",", "strict", "=", "True"...
A convenience function for match_pdb_chains. The required arguments are two PDB IDs from the RCSB.
[ "A", "convenience", "function", "for", "match_pdb_chains", ".", "The", "required", "arguments", "are", "two", "PDB", "IDs", "from", "the", "RCSB", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L139-L149
train
A convenience function for match_pdb_chains. The required arguments are two PDB IDs from the RCSB. The required arguments are two PDB IDs from the RCSB.
Kortemme-Lab/klab
klab/bio/alignment.py
match_best_pdb_chains
def match_best_pdb_chains(pdb1, pdb1_name, pdb2, pdb2_name, cut_off = 60.0, use_seqres_sequences_if_possible = True): '''A wrapper function for match_pdb_chains. This function only takes the best match. The return value is a dict mapping chain_id_in_pdb1 -> None or a tuple (chain_id_in_pdb_2, pe...
python
def match_best_pdb_chains(pdb1, pdb1_name, pdb2, pdb2_name, cut_off = 60.0, use_seqres_sequences_if_possible = True): '''A wrapper function for match_pdb_chains. This function only takes the best match. The return value is a dict mapping chain_id_in_pdb1 -> None or a tuple (chain_id_in_pdb_2, pe...
[ "def", "match_best_pdb_chains", "(", "pdb1", ",", "pdb1_name", ",", "pdb2", ",", "pdb2_name", ",", "cut_off", "=", "60.0", ",", "use_seqres_sequences_if_possible", "=", "True", ")", ":", "d", "=", "match_pdb_chains", "(", "pdb1", ",", "pdb1_name", ",", "pdb2",...
A wrapper function for match_pdb_chains. This function only takes the best match. The return value is a dict mapping chain_id_in_pdb1 -> None or a tuple (chain_id_in_pdb_2, percentage_identity_score) where percentage_identity_score is a float. e.g. 'A' -> ('B', 100).
[ "A", "wrapper", "function", "for", "match_pdb_chains", ".", "This", "function", "only", "takes", "the", "best", "match", ".", "The", "return", "value", "is", "a", "dict", "mapping", "chain_id_in_pdb1", "-", ">", "None", "or", "a", "tuple", "(", "chain_id_in_...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L152-L161
train
A wrapper function for match_pdb_chains. This function only takes the best match. The return MimeType is a dict mapping chain_id_in_pdb1 -> None or a tuple mapping chain_id_in_pdb2 -> 100.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper._map_residues
def _map_residues(self): '''For each pair of equivalence classes, match the residues of a chain in the first class to the residues of appropriate chains in the second class. Note: we do a lot of repeated work here. Some of the lookups e.g. atom_sequences/seqres_sequences here could be cached.''' ...
python
def _map_residues(self): '''For each pair of equivalence classes, match the residues of a chain in the first class to the residues of appropriate chains in the second class. Note: we do a lot of repeated work here. Some of the lookups e.g. atom_sequences/seqres_sequences here could be cached.''' ...
[ "def", "_map_residues", "(", "self", ")", ":", "pdbs", "=", "self", ".", "pdbs", "pdb_names", "=", "self", ".", "pdb_names", "partition_by_sequence", "=", "self", ".", "partition_by_sequence", "representative_pdbs", "=", "self", ".", "representative_pdbs", "repres...
For each pair of equivalence classes, match the residues of a chain in the first class to the residues of appropriate chains in the second class. Note: we do a lot of repeated work here. Some of the lookups e.g. atom_sequences/seqres_sequences here could be cached.
[ "For", "each", "pair", "of", "equivalence", "classes", "match", "the", "residues", "of", "a", "chain", "in", "the", "first", "class", "to", "the", "residues", "of", "appropriate", "chains", "in", "the", "second", "class", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L590-L746
train
Map the residues of a single PDB file to the residues of the appropriate chains in the second class.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_representative_chain_mapping
def get_representative_chain_mapping(self, representative_id_1, representative_id_2): '''This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.''' d = {} for pdb1_chain_id, ma...
python
def get_representative_chain_mapping(self, representative_id_1, representative_id_2): '''This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.''' d = {} for pdb1_chain_id, ma...
[ "def", "get_representative_chain_mapping", "(", "self", ",", "representative_id_1", ",", "representative_id_2", ")", ":", "d", "=", "{", "}", "for", "pdb1_chain_id", ",", "matched_chain_list", "in", "self", ".", "chain_mapping", "[", "(", "representative_id_1", ",",...
This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.
[ "This", "replaces", "the", "old", "mapping", "member", "by", "constructing", "it", "from", "self", ".", "chain_mapping", ".", "This", "function", "returns", "a", "mapping", "from", "chain", "IDs", "in", "pdb_name1", "to", "chain", "IDs", "in", "pdb_name2", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L752-L758
train
This replaces the old mapping member by constructing it from self. chain_mapping. This function returns a mapping from pdb1_chain_id to pdb2_chain_id.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_chain_mapping
def get_chain_mapping(self, pdb_name1, pdb_name2): '''This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.''' raise Exception('Implement. Map pdb_namex to its equivalence class, cal...
python
def get_chain_mapping(self, pdb_name1, pdb_name2): '''This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.''' raise Exception('Implement. Map pdb_namex to its equivalence class, cal...
[ "def", "get_chain_mapping", "(", "self", ",", "pdb_name1", ",", "pdb_name2", ")", ":", "raise", "Exception", "(", "'Implement. Map pdb_namex to its equivalence class, call get_representative_chain_mapping, and something something.'", ")", "pprint", ".", "pprint", "(", "self", ...
This replaces the old mapping member by constructing it from self.chain_mapping. This function returns a mapping from chain IDs in pdb_name1 to chain IDs in pdb_name2.
[ "This", "replaces", "the", "old", "mapping", "member", "by", "constructing", "it", "from", "self", ".", "chain_mapping", ".", "This", "function", "returns", "a", "mapping", "from", "chain", "IDs", "in", "pdb_name1", "to", "chain", "IDs", "in", "pdb_name2", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L761-L770
train
This function returns a mapping from pdb_name1 to pdb_name2. This function replaces the old mapping member by constructing it from self. chain_mapping. This function returns a mapping from pdb_name1 to pdb_name2.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_differing_atom_residue_ids
def get_differing_atom_residue_ids(self, pdb_name, pdb_list = []): '''Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.''' # partition_by_sequence is a map pdb_name -> Int where two pdb names in the same equivalence class map to the same integer (...
python
def get_differing_atom_residue_ids(self, pdb_name, pdb_list = []): '''Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.''' # partition_by_sequence is a map pdb_name -> Int where two pdb names in the same equivalence class map to the same integer (...
[ "def", "get_differing_atom_residue_ids", "(", "self", ",", "pdb_name", ",", "pdb_list", "=", "[", "]", ")", ":", "# partition_by_sequence is a map pdb_name -> Int where two pdb names in the same equivalence class map to the same integer (i.e. it is a partition)", "# representative_pdbs i...
Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.
[ "Returns", "a", "list", "of", "residues", "in", "pdb_name", "which", "differ", "from", "the", "pdbs", "corresponding", "to", "the", "names", "in", "pdb_list", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L773-L809
train
Returns a list of residues in pdb_name which differ from the names in pdb_list.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_sequence_tooltips
def get_sequence_tooltips(self, pdb_object, pdb_sequence, pdb_sequence_type, pdb_name, pdb_chain, pdb_alignment_lines): '''pdb_sequence is a Sequence object. pdb_sequence_type is a type returned by PDB.get_annotated_chain_sequence_string, pdb_name is the name of the PDB used throughout this object e....
python
def get_sequence_tooltips(self, pdb_object, pdb_sequence, pdb_sequence_type, pdb_name, pdb_chain, pdb_alignment_lines): '''pdb_sequence is a Sequence object. pdb_sequence_type is a type returned by PDB.get_annotated_chain_sequence_string, pdb_name is the name of the PDB used throughout this object e....
[ "def", "get_sequence_tooltips", "(", "self", ",", "pdb_object", ",", "pdb_sequence", ",", "pdb_sequence_type", ",", "pdb_name", ",", "pdb_chain", ",", "pdb_alignment_lines", ")", ":", "raise", "Exception", "(", "'Re-implement using the equivalence classes.'", ")", "tool...
pdb_sequence is a Sequence object. pdb_sequence_type is a type returned by PDB.get_annotated_chain_sequence_string, pdb_name is the name of the PDB used throughout this object e.g. 'Scaffold', pdb_chain is the chain of interest, pdb_alignment_lines are the lines returned by SequenceAligner._get_al...
[ "pdb_sequence", "is", "a", "Sequence", "object", ".", "pdb_sequence_type", "is", "a", "type", "returned", "by", "PDB", ".", "get_annotated_chain_sequence_string", "pdb_name", "is", "the", "name", "of", "the", "PDB", "used", "throughout", "this", "object", "e", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L884-L929
train
This function returns a set of tooltips corresponding to the residues in the given PDB sequence.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_sequence_alignment_strings
def get_sequence_alignment_strings(self, pdb_list = [], reversed = True, width = 80, line_separator = '\n'): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments with cha...
python
def get_sequence_alignment_strings(self, pdb_list = [], reversed = True, width = 80, line_separator = '\n'): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments with cha...
[ "def", "get_sequence_alignment_strings", "(", "self", ",", "pdb_list", "=", "[", "]", ",", "reversed", "=", "True", ",", "width", "=", "80", ",", "line_separator", "=", "'\\n'", ")", ":", "raise", "Exception", "(", "'Re-implement using the equivalence classes.'", ...
Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments with chains in other members of the list. For simplicity, if a chain in the first PDB matches multiple chains in ano...
[ "Takes", "a", "list", "pdb_list", "of", "pdb", "names", "e", ".", "g", ".", "[", "Model", "Scaffold", "...", "]", "with", "which", "the", "object", "was", "created", ".", "Using", "the", "first", "element", "of", "this", "list", "as", "a", "base", "g...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L932-L951
train
Takes a list of pdb names e. g. Model Scaffold... Returns a list of strings each one containing the alignment for each chain mapping.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper.get_sequence_alignment_strings_as_html
def get_sequence_alignment_strings_as_html(self, pdb_list = [], reversed = False, width = 80, line_separator = '\n', extra_tooltip_class = ''): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, g...
python
def get_sequence_alignment_strings_as_html(self, pdb_list = [], reversed = False, width = 80, line_separator = '\n', extra_tooltip_class = ''): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, g...
[ "def", "get_sequence_alignment_strings_as_html", "(", "self", ",", "pdb_list", "=", "[", "]", ",", "reversed", "=", "False", ",", "width", "=", "80", ",", "line_separator", "=", "'\\n'", ",", "extra_tooltip_class", "=", "''", ")", ":", "raise", "Exception", ...
Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments with chains in other members of the list. For simplicity, if a chain in the first PDB matches multiple chains in ano...
[ "Takes", "a", "list", "pdb_list", "of", "pdb", "names", "e", ".", "g", ".", "[", "Model", "Scaffold", "...", "]", "with", "which", "the", "object", "was", "created", ".", "Using", "the", "first", "element", "of", "this", "list", "as", "a", "base", "g...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L954-L974
train
Takes a list of pdb names e. g. Model Scaffold... Returns an HTML string for the sequence alignments and an empty string.
Kortemme-Lab/klab
klab/bio/alignment.py
ScaffoldModelChainMapper.generate_pymol_session
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' b = BatchBuilder(pymol_executable = pymol_executable) structures_li...
python
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' b = BatchBuilder(pymol_executable = pymol_executable) structures_li...
[ "def", "generate_pymol_session", "(", "self", ",", "pymol_executable", "=", "'pymol'", ",", "settings", "=", "{", "}", ")", ":", "b", "=", "BatchBuilder", "(", "pymol_executable", "=", "pymol_executable", ")", "structures_list", "=", "[", "(", "self", ".", "...
Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.
[ "Generates", "the", "PyMOL", "session", "for", "the", "scaffold", "model", "and", "design", "structures", ".", "Returns", "this", "session", "and", "the", "script", "which", "generated", "it", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L1021-L1033
train
Generates the PyMOL session for the scaffold model and design structures. Returns this session and the script which generated it.
Kortemme-Lab/klab
klab/bio/alignment.py
ScaffoldModelDesignChainMapper.generate_pymol_session
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' b = BatchBuilder(pymol_executable = pymol_executable) if self.scaff...
python
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' b = BatchBuilder(pymol_executable = pymol_executable) if self.scaff...
[ "def", "generate_pymol_session", "(", "self", ",", "pymol_executable", "=", "'pymol'", ",", "settings", "=", "{", "}", ")", ":", "b", "=", "BatchBuilder", "(", "pymol_executable", "=", "pymol_executable", ")", "if", "self", ".", "scaffold_pdb", ":", "structure...
Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.
[ "Generates", "the", "PyMOL", "session", "for", "the", "scaffold", "model", "and", "design", "structures", ".", "Returns", "this", "session", "and", "the", "script", "which", "generated", "it", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L1102-L1121
train
Generates the PyMOL session for the scaffold model and design structures. Returns this session and the script which generated it.
Kortemme-Lab/klab
klab/bio/alignment.py
DecoyChainMapper.generate_pymol_session
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' if not self.fixed: self.fix() b = BatchBuilder(pymol_e...
python
def generate_pymol_session(self, pymol_executable = 'pymol', settings = {}): ''' Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.''' if not self.fixed: self.fix() b = BatchBuilder(pymol_e...
[ "def", "generate_pymol_session", "(", "self", ",", "pymol_executable", "=", "'pymol'", ",", "settings", "=", "{", "}", ")", ":", "if", "not", "self", ".", "fixed", ":", "self", ".", "fix", "(", ")", "b", "=", "BatchBuilder", "(", "pymol_executable", "=",...
Generates the PyMOL session for the scaffold, model, and design structures. Returns this session and the script which generated it.
[ "Generates", "the", "PyMOL", "session", "for", "the", "scaffold", "model", "and", "design", "structures", ".", "Returns", "this", "session", "and", "the", "script", "which", "generated", "it", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L1166-L1180
train
Generates the PyMOL session for the scaffold model and design structures. This method will automatically generate the PyMOL session for the scaffold model and design structures.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper_old.get_differing_atom_residue_ids
def get_differing_atom_residue_ids(self, pdb_name, pdb_list): '''Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.''' assert(pdb_name in self.pdb_names) assert(set(pdb_list).intersection(set(self.pdb_names)) == set(pdb_list)) # the names i...
python
def get_differing_atom_residue_ids(self, pdb_name, pdb_list): '''Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.''' assert(pdb_name in self.pdb_names) assert(set(pdb_list).intersection(set(self.pdb_names)) == set(pdb_list)) # the names i...
[ "def", "get_differing_atom_residue_ids", "(", "self", ",", "pdb_name", ",", "pdb_list", ")", ":", "assert", "(", "pdb_name", "in", "self", ".", "pdb_names", ")", "assert", "(", "set", "(", "pdb_list", ")", ".", "intersection", "(", "set", "(", "self", ".",...
Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.
[ "Returns", "a", "list", "of", "residues", "in", "pdb_name", "which", "differ", "from", "the", "pdbs", "corresponding", "to", "the", "names", "in", "pdb_list", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L1609-L1619
train
Returns a list of residues in pdb_name which differ from the pdbs corresponding to the names in pdb_list.
Kortemme-Lab/klab
klab/bio/alignment.py
PipelinePDBChainMapper_old.get_sequence_alignment_printer_objects
def get_sequence_alignment_printer_objects(self, pdb_list = [], reversed = True, width = 80, line_separator = '\n'): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments ...
python
def get_sequence_alignment_printer_objects(self, pdb_list = [], reversed = True, width = 80, line_separator = '\n'): '''Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments ...
[ "def", "get_sequence_alignment_printer_objects", "(", "self", ",", "pdb_list", "=", "[", "]", ",", "reversed", "=", "True", ",", "width", "=", "80", ",", "line_separator", "=", "'\\n'", ")", ":", "if", "not", "pdb_list", ":", "pdb_list", "=", "self", ".", ...
Takes a list, pdb_list, of pdb names e.g. ['Model', 'Scaffold', ...] with which the object was created. Using the first element of this list as a base, get the sequence alignments with chains in other members of the list. For simplicity, if a chain in the first PDB matches multiple chains in ano...
[ "Takes", "a", "list", "pdb_list", "of", "pdb", "names", "e", ".", "g", ".", "[", "Model", "Scaffold", "...", "]", "with", "which", "the", "object", "was", "created", ".", "Using", "the", "first", "element", "of", "this", "list", "as", "a", "base", "g...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/alignment.py#L1622-L1689
train
Takes a list of pdb names e. g. Model Scaffold... Returns a list of tuples each containing the ID of the sequence alignment object and each other containing the object s sequence alignment.
uogbuji/versa
tools/py/pipeline/main.py
materialize_entity
def materialize_entity(ctx, etype, unique=None): ''' Low-level routine for creating a BIBFRAME resource. Takes the entity (resource) type and a data mapping according to the resource type. Implements the Libhub Resource Hash Convention As a convenience, if a vocabulary base is provided in the context, c...
python
def materialize_entity(ctx, etype, unique=None): ''' Low-level routine for creating a BIBFRAME resource. Takes the entity (resource) type and a data mapping according to the resource type. Implements the Libhub Resource Hash Convention As a convenience, if a vocabulary base is provided in the context, c...
[ "def", "materialize_entity", "(", "ctx", ",", "etype", ",", "unique", "=", "None", ")", ":", "params", "=", "{", "}", "if", "ctx", ".", "base", ":", "etype", "=", "ctx", ".", "base", "+", "etype", "unique_computed", "=", "[", "]", "for", "k", ",", ...
Low-level routine for creating a BIBFRAME resource. Takes the entity (resource) type and a data mapping according to the resource type. Implements the Libhub Resource Hash Convention As a convenience, if a vocabulary base is provided in the context, concatenate it to etype and the data keys ctx - context i...
[ "Low", "-", "level", "routine", "for", "creating", "a", "BIBFRAME", "resource", ".", "Takes", "the", "entity", "(", "resource", ")", "type", "and", "a", "data", "mapping", "according", "to", "the", "resource", "type", ".", "Implements", "the", "Libhub", "R...
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/main.py#L75-L101
train
Materialize a resource into a new entity.
uogbuji/versa
tools/py/pipeline/main.py
create_resource
def create_resource(output_model, rtype, unique, links, existing_ids=None, id_helper=None): ''' General-purpose routine to create a new resource in the output model, based on data provided output_model - Versa connection to model to be updated rtype - Type IRI for the new resource, set wit...
python
def create_resource(output_model, rtype, unique, links, existing_ids=None, id_helper=None): ''' General-purpose routine to create a new resource in the output model, based on data provided output_model - Versa connection to model to be updated rtype - Type IRI for the new resource, set wit...
[ "def", "create_resource", "(", "output_model", ",", "rtype", ",", "unique", ",", "links", ",", "existing_ids", "=", "None", ",", "id_helper", "=", "None", ")", ":", "if", "isinstance", "(", "id_helper", ",", "str", ")", ":", "idg", "=", "idgen", "(", "...
General-purpose routine to create a new resource in the output model, based on data provided output_model - Versa connection to model to be updated rtype - Type IRI for the new resource, set with Versa type unique - list of key/value pairs for determining a unique hash for the new res...
[ "General", "-", "purpose", "routine", "to", "create", "a", "new", "resource", "in", "the", "output", "model", "based", "on", "data", "provided" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/main.py#L104-L133
train
This function creates a new resource in the output model based on data provided by the user.
fastmonkeys/pontus
pontus/amazon_s3_file_validator.py
AmazonS3FileValidator.validate
def validate(self): """ Validates the given Amazon S3 file with :attr:`validators`. If errors occur they are appended to :attr:`errors`. If the file is valid and a `AWS_UNVALIDATED_PREFIX` config is present, its value will be removed from the file key. :return: a boolean...
python
def validate(self): """ Validates the given Amazon S3 file with :attr:`validators`. If errors occur they are appended to :attr:`errors`. If the file is valid and a `AWS_UNVALIDATED_PREFIX` config is present, its value will be removed from the file key. :return: a boolean...
[ "def", "validate", "(", "self", ")", ":", "for", "validator", "in", "self", ".", "validators", ":", "try", ":", "validator", "(", "self", ".", "obj", ")", "except", "ValidationError", "as", "e", ":", "self", ".", "errors", ".", "append", "(", "e", "....
Validates the given Amazon S3 file with :attr:`validators`. If errors occur they are appended to :attr:`errors`. If the file is valid and a `AWS_UNVALIDATED_PREFIX` config is present, its value will be removed from the file key. :return: a boolean indicating if the file vas valid.
[ "Validates", "the", "given", "Amazon", "S3", "file", "with", ":", "attr", ":", "validators", ".", "If", "errors", "occur", "they", "are", "appended", "to", ":", "attr", ":", "errors", ".", "If", "the", "file", "is", "valid", "and", "a", "AWS_UNVALIDATED_...
cf02fb22c4558b899e2dcbe437a1a525321c4f12
https://github.com/fastmonkeys/pontus/blob/cf02fb22c4558b899e2dcbe437a1a525321c4f12/pontus/amazon_s3_file_validator.py#L91-L109
train
Validates the given Amazon S3 file with the given validator list.
berkeley-cocosci/Wallace
wallace/heroku/clock.py
check_db_for_missing_notifications
def check_db_for_missing_notifications(): """Check the database for missing notifications.""" aws_access_key_id = os.environ['aws_access_key_id'] aws_secret_access_key = os.environ['aws_secret_access_key'] if config.getboolean('Shell Parameters', 'launch_in_sandbox_mode'): conn = MTurkConnection...
python
def check_db_for_missing_notifications(): """Check the database for missing notifications.""" aws_access_key_id = os.environ['aws_access_key_id'] aws_secret_access_key = os.environ['aws_secret_access_key'] if config.getboolean('Shell Parameters', 'launch_in_sandbox_mode'): conn = MTurkConnection...
[ "def", "check_db_for_missing_notifications", "(", ")", ":", "aws_access_key_id", "=", "os", ".", "environ", "[", "'aws_access_key_id'", "]", "aws_secret_access_key", "=", "os", ".", "environ", "[", "'aws_secret_access_key'", "]", "if", "config", ".", "getboolean", "...
Check the database for missing notifications.
[ "Check", "the", "database", "for", "missing", "notifications", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/heroku/clock.py#L39-L254
train
Check the database for missing notifications.
brunato/lograptor
lograptor/core.py
LogRaptor._read_apps
def _read_apps(self): """ Read the configuration of applications returning a dictionary :return: A dictionary with application names as keys and configuration \ object as values. """ apps = {} for cfgfile in glob.iglob(os.path.join(self.confdir, '*.conf')): ...
python
def _read_apps(self): """ Read the configuration of applications returning a dictionary :return: A dictionary with application names as keys and configuration \ object as values. """ apps = {} for cfgfile in glob.iglob(os.path.join(self.confdir, '*.conf')): ...
[ "def", "_read_apps", "(", "self", ")", ":", "apps", "=", "{", "}", "for", "cfgfile", "in", "glob", ".", "iglob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "confdir", ",", "'*.conf'", ")", ")", ":", "name", "=", "os", ".", "path", "...
Read the configuration of applications returning a dictionary :return: A dictionary with application names as keys and configuration \ object as values.
[ "Read", "the", "configuration", "of", "applications", "returning", "a", "dictionary" ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L122-L142
train
Read the configuration of applications returning a dictionary with application names as keys and configuration \ objects as values.
brunato/lograptor
lograptor/core.py
LogRaptor.set_logger
def set_logger(self): """ Setup lograptor logger with an handler and a formatter. The logging level is defined by a [0..4] range, where an higher value means a more verbose logging. The loglevel value is mapped to correspondent logging module's value: LOG_CRIT=0 (syslog....
python
def set_logger(self): """ Setup lograptor logger with an handler and a formatter. The logging level is defined by a [0..4] range, where an higher value means a more verbose logging. The loglevel value is mapped to correspondent logging module's value: LOG_CRIT=0 (syslog....
[ "def", "set_logger", "(", "self", ")", ":", "# Higher or lesser argument values are also mapped to DEBUG or CRITICAL", "effective_level", "=", "max", "(", "logging", ".", "DEBUG", ",", "logging", ".", "CRITICAL", "-", "self", ".", "args", ".", "loglevel", "*", "10",...
Setup lograptor logger with an handler and a formatter. The logging level is defined by a [0..4] range, where an higher value means a more verbose logging. The loglevel value is mapped to correspondent logging module's value: LOG_CRIT=0 (syslog.h value is 2) ==> logging.CRITICAL ...
[ "Setup", "lograptor", "logger", "with", "an", "handler", "and", "a", "formatter", ".", "The", "logging", "level", "is", "defined", "by", "a", "[", "0", "..", "4", "]", "range", "where", "an", "higher", "value", "means", "a", "more", "verbose", "logging",...
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L182-L220
train
Setup lograptor logger with a handler and a formatter.
brunato/lograptor
lograptor/core.py
LogRaptor.patterns
def patterns(self): """ A tuple with re.RegexObject objects created from regex pattern arguments. """ # No explicit argument for patterns ==> consider the first source argument as pattern. if not self.args.patterns and not self.args.pattern_files: try: ...
python
def patterns(self): """ A tuple with re.RegexObject objects created from regex pattern arguments. """ # No explicit argument for patterns ==> consider the first source argument as pattern. if not self.args.patterns and not self.args.pattern_files: try: ...
[ "def", "patterns", "(", "self", ")", ":", "# No explicit argument for patterns ==> consider the first source argument as pattern.", "if", "not", "self", ".", "args", ".", "patterns", "and", "not", "self", ".", "args", ".", "pattern_files", ":", "try", ":", "self", "...
A tuple with re.RegexObject objects created from regex pattern arguments.
[ "A", "tuple", "with", "re", ".", "RegexObject", "objects", "created", "from", "regex", "pattern", "arguments", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L233-L263
train
Returns a tuple with re. RegexObject objects created from regex pattern arguments.
brunato/lograptor
lograptor/core.py
LogRaptor.files
def files(self): """ A list of input sources. Each item can be a file path, a glob path or URL. """ # If no files but a recursion option ==> use the current directory if not self.args.files and self.recursive: return ['.'] else: return self.args.fi...
python
def files(self): """ A list of input sources. Each item can be a file path, a glob path or URL. """ # If no files but a recursion option ==> use the current directory if not self.args.files and self.recursive: return ['.'] else: return self.args.fi...
[ "def", "files", "(", "self", ")", ":", "# If no files but a recursion option ==> use the current directory", "if", "not", "self", ".", "args", ".", "files", "and", "self", ".", "recursive", ":", "return", "[", "'.'", "]", "else", ":", "return", "self", ".", "a...
A list of input sources. Each item can be a file path, a glob path or URL.
[ "A", "list", "of", "input", "sources", ".", "Each", "item", "can", "be", "a", "file", "path", "a", "glob", "path", "or", "URL", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L266-L274
train
A list of input sources. Each item can be a file path a glob path or URL.
brunato/lograptor
lograptor/core.py
LogRaptor.matcher
def matcher(self): """ Matcher engine: ruled, unruled, unparsed. """ if self.args.matcher is None: return 'ruled' elif self.args.matcher.startswith('-'): matcher = self.args.matcher.strip('-').replace('-', '_') else: matcher = self.args...
python
def matcher(self): """ Matcher engine: ruled, unruled, unparsed. """ if self.args.matcher is None: return 'ruled' elif self.args.matcher.startswith('-'): matcher = self.args.matcher.strip('-').replace('-', '_') else: matcher = self.args...
[ "def", "matcher", "(", "self", ")", ":", "if", "self", ".", "args", ".", "matcher", "is", "None", ":", "return", "'ruled'", "elif", "self", ".", "args", ".", "matcher", ".", "startswith", "(", "'-'", ")", ":", "matcher", "=", "self", ".", "args", "...
Matcher engine: ruled, unruled, unparsed.
[ "Matcher", "engine", ":", "ruled", "unruled", "unparsed", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L289-L302
train
Returns the matcher engine for the log raptor.
brunato/lograptor
lograptor/core.py
LogRaptor.time_period
def time_period(self): """ Time period that is determined from the arguments --date and --last. It's a 2-tuple with (<start datetime>, <end_datetime>) items. An item is `None` if there isn't a limit. """ if self.args.time_period is None: if self.args.files or is_pipe(...
python
def time_period(self): """ Time period that is determined from the arguments --date and --last. It's a 2-tuple with (<start datetime>, <end_datetime>) items. An item is `None` if there isn't a limit. """ if self.args.time_period is None: if self.args.files or is_pipe(...
[ "def", "time_period", "(", "self", ")", ":", "if", "self", ".", "args", ".", "time_period", "is", "None", ":", "if", "self", ".", "args", ".", "files", "or", "is_pipe", "(", "STDIN_FILENO", ")", "or", "is_redirected", "(", "STDIN_FILENO", ")", ":", "ti...
Time period that is determined from the arguments --date and --last. It's a 2-tuple with (<start datetime>, <end_datetime>) items. An item is `None` if there isn't a limit.
[ "Time", "period", "that", "is", "determined", "from", "the", "arguments", "--", "date", "and", "--", "last", ".", "It", "s", "a", "2", "-", "tuple", "with", "(", "<start", "datetime", ">", "<end_datetime", ">", ")", "items", ".", "An", "item", "is", ...
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L318-L333
train
Return the time period that is determined from the arguments date and last.
brunato/lograptor
lograptor/core.py
LogRaptor.apps
def apps(self): """ Dictionary with loaded applications. """ logger.debug("initialize applications ...") enabled = None apps = self.args.apps or self._config_apps.keys() unknown = set(apps) - set(self._config_apps.keys()) if unknown: raise LogR...
python
def apps(self): """ Dictionary with loaded applications. """ logger.debug("initialize applications ...") enabled = None apps = self.args.apps or self._config_apps.keys() unknown = set(apps) - set(self._config_apps.keys()) if unknown: raise LogR...
[ "def", "apps", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"initialize applications ...\"", ")", "enabled", "=", "None", "apps", "=", "self", ".", "args", ".", "apps", "or", "self", ".", "_config_apps", ".", "keys", "(", ")", "unknown", "=", ...
Dictionary with loaded applications.
[ "Dictionary", "with", "loaded", "applications", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L350-L364
train
Dictionary with loaded applications.
brunato/lograptor
lograptor/core.py
LogRaptor.apptags
def apptags(self): """ Map from log app-name to an application. """ logger.debug("populate tags map ...") apps = self._apps.keys() unknown = set(apps) unknown.difference_update(self._config_apps.keys()) if unknown: raise ValueError("unknown app...
python
def apptags(self): """ Map from log app-name to an application. """ logger.debug("populate tags map ...") apps = self._apps.keys() unknown = set(apps) unknown.difference_update(self._config_apps.keys()) if unknown: raise ValueError("unknown app...
[ "def", "apptags", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"populate tags map ...\"", ")", "apps", "=", "self", ".", "_apps", ".", "keys", "(", ")", "unknown", "=", "set", "(", "apps", ")", "unknown", ".", "difference_update", "(", "self", ...
Map from log app-name to an application.
[ "Map", "from", "log", "app", "-", "name", "to", "an", "application", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L367-L388
train
Return a dictionary mapping from log app - name to application.
brunato/lograptor
lograptor/core.py
LogRaptor.channels
def channels(self): """Output channels""" try: return self._channels except AttributeError: logger.debug("initialize output channels ...") channels = self.args.channels config_channels = [sec.rpartition('_')[0] for sec in self.config.sections(suffix='_cha...
python
def channels(self): """Output channels""" try: return self._channels except AttributeError: logger.debug("initialize output channels ...") channels = self.args.channels config_channels = [sec.rpartition('_')[0] for sec in self.config.sections(suffix='_cha...
[ "def", "channels", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_channels", "except", "AttributeError", ":", "logger", ".", "debug", "(", "\"initialize output channels ...\"", ")", "channels", "=", "self", ".", "args", ".", "channels", "config_ch...
Output channels
[ "Output", "channels" ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L423-L447
train
Return a list of all available channels.
brunato/lograptor
lograptor/core.py
LogRaptor.create_dispatcher
def create_dispatcher(self): """ Return a dispatcher for configured channels. """ before_context = max(self.args.before_context, self.args.context) after_context = max(self.args.after_context, self.args.context) if self.args.files_with_match is not None or self.args.coun...
python
def create_dispatcher(self): """ Return a dispatcher for configured channels. """ before_context = max(self.args.before_context, self.args.context) after_context = max(self.args.after_context, self.args.context) if self.args.files_with_match is not None or self.args.coun...
[ "def", "create_dispatcher", "(", "self", ")", ":", "before_context", "=", "max", "(", "self", ".", "args", ".", "before_context", ",", "self", ".", "args", ".", "context", ")", "after_context", "=", "max", "(", "self", ".", "args", ".", "after_context", ...
Return a dispatcher for configured channels.
[ "Return", "a", "dispatcher", "for", "configured", "channels", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L562-L578
train
Create a dispatcher for configured channels.
brunato/lograptor
lograptor/core.py
LogRaptor.get_config
def get_config(self): """ Return a formatted text with main configuration parameters. """ # Create a dummy report object if necessary channels = [sect.rsplit('_')[0] for sect in self.config.sections(suffix='_channel')] channels.sort() disabled_apps = [app for app ...
python
def get_config(self): """ Return a formatted text with main configuration parameters. """ # Create a dummy report object if necessary channels = [sect.rsplit('_')[0] for sect in self.config.sections(suffix='_channel')] channels.sort() disabled_apps = [app for app ...
[ "def", "get_config", "(", "self", ")", ":", "# Create a dummy report object if necessary", "channels", "=", "[", "sect", ".", "rsplit", "(", "'_'", ")", "[", "0", "]", "for", "sect", "in", "self", ".", "config", ".", "sections", "(", "suffix", "=", "'_chan...
Return a formatted text with main configuration parameters.
[ "Return", "a", "formatted", "text", "with", "main", "configuration", "parameters", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L600-L620
train
Return a formatted text with main configuration parameters.
brunato/lograptor
lograptor/core.py
LogRaptor.get_run_summary
def get_run_summary(self, run_stats): """ Produce a text summary from run statistics. :param run_stats: A dictionary containing run stats :return: Formatted multiline string """ run_stats = run_stats.copy() run_stats['files'] = len(run_stats['files']) sum...
python
def get_run_summary(self, run_stats): """ Produce a text summary from run statistics. :param run_stats: A dictionary containing run stats :return: Formatted multiline string """ run_stats = run_stats.copy() run_stats['files'] = len(run_stats['files']) sum...
[ "def", "get_run_summary", "(", "self", ",", "run_stats", ")", ":", "run_stats", "=", "run_stats", ".", "copy", "(", ")", "run_stats", "[", "'files'", "]", "=", "len", "(", "run_stats", "[", "'files'", "]", ")", "summary", "=", "[", "u'\\n--- %s run summary...
Produce a text summary from run statistics. :param run_stats: A dictionary containing run stats :return: Formatted multiline string
[ "Produce", "a", "text", "summary", "from", "run", "statistics", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/core.py#L622-L647
train
Produce a text summary from run statistics.
peergradeio/flask-mongo-profiler
flask_mongo_profiler/helpers.py
add_template_dirs
def add_template_dirs(app): """Add flask_mongo_profiler's template directories. Parameters ---------- app : flask.Flask """ template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') app.jinja_loader = jinja2.ChoiceLoader( [app.jinja_loader, jinja2.FileSys...
python
def add_template_dirs(app): """Add flask_mongo_profiler's template directories. Parameters ---------- app : flask.Flask """ template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') app.jinja_loader = jinja2.ChoiceLoader( [app.jinja_loader, jinja2.FileSys...
[ "def", "add_template_dirs", "(", "app", ")", ":", "template_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'templates'", ")", "app", ".", "...
Add flask_mongo_profiler's template directories. Parameters ---------- app : flask.Flask
[ "Add", "flask_mongo_profiler", "s", "template", "directories", "." ]
a267eeb49fea07c9a24fb370bd9d7a90ed313ccf
https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/helpers.py#L7-L18
train
Add flask_mongo_profiler s template directories.
berkeley-cocosci/Wallace
wallace/command_line.py
setup
def setup(): """Walk the user though the Wallace setup.""" # Create the Wallace config file if it does not already exist. config_name = ".wallaceconfig" config_path = os.path.join(os.path.expanduser("~"), config_name) if os.path.isfile(config_path): log("Wallace config file already exists."...
python
def setup(): """Walk the user though the Wallace setup.""" # Create the Wallace config file if it does not already exist. config_name = ".wallaceconfig" config_path = os.path.join(os.path.expanduser("~"), config_name) if os.path.isfile(config_path): log("Wallace config file already exists."...
[ "def", "setup", "(", ")", ":", "# Create the Wallace config file if it does not already exist.", "config_name", "=", "\".wallaceconfig\"", "config_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "confi...
Walk the user though the Wallace setup.
[ "Walk", "the", "user", "though", "the", "Wallace", "setup", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L66-L80
train
Walk the user though the Wallace setup.
berkeley-cocosci/Wallace
wallace/command_line.py
setup_experiment
def setup_experiment(debug=True, verbose=False, app=None): """Check the app and, if it's compatible with Wallace, freeze its state.""" print_header() # Verify that the package is usable. log("Verifying that directory is compatible with Wallace...") if not verify_package(verbose=verbose): ra...
python
def setup_experiment(debug=True, verbose=False, app=None): """Check the app and, if it's compatible with Wallace, freeze its state.""" print_header() # Verify that the package is usable. log("Verifying that directory is compatible with Wallace...") if not verify_package(verbose=verbose): ra...
[ "def", "setup_experiment", "(", "debug", "=", "True", ",", "verbose", "=", "False", ",", "app", "=", "None", ")", ":", "print_header", "(", ")", "# Verify that the package is usable.", "log", "(", "\"Verifying that directory is compatible with Wallace...\"", ")", "if"...
Check the app and, if it's compatible with Wallace, freeze its state.
[ "Check", "the", "app", "and", "if", "it", "s", "compatible", "with", "Wallace", "freeze", "its", "state", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L83-L219
train
Setup the experiment.
berkeley-cocosci/Wallace
wallace/command_line.py
summary
def summary(app): """Print a summary of a deployed app's status.""" r = requests.get('https://{}.herokuapp.com/summary'.format(app)) summary = r.json()['summary'] click.echo("\nstatus \t| count") click.echo("----------------") for s in summary: click.echo("{}\t| {}".format(s[0], s[1])) ...
python
def summary(app): """Print a summary of a deployed app's status.""" r = requests.get('https://{}.herokuapp.com/summary'.format(app)) summary = r.json()['summary'] click.echo("\nstatus \t| count") click.echo("----------------") for s in summary: click.echo("{}\t| {}".format(s[0], s[1])) ...
[ "def", "summary", "(", "app", ")", ":", "r", "=", "requests", ".", "get", "(", "'https://{}.herokuapp.com/summary'", ".", "format", "(", "app", ")", ")", "summary", "=", "r", ".", "json", "(", ")", "[", "'summary'", "]", "click", ".", "echo", "(", "\...
Print a summary of a deployed app's status.
[ "Print", "a", "summary", "of", "a", "deployed", "app", "s", "status", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L224-L235
train
Print a summary of a deployed app s status.
berkeley-cocosci/Wallace
wallace/command_line.py
debug
def debug(verbose): """Run the experiment locally.""" (id, tmp) = setup_experiment(debug=True, verbose=verbose) # Drop all the tables from the database. db.init_db(drop_all=True) # Switch to the temporary directory. cwd = os.getcwd() os.chdir(tmp) # Load psiTurk configuration. con...
python
def debug(verbose): """Run the experiment locally.""" (id, tmp) = setup_experiment(debug=True, verbose=verbose) # Drop all the tables from the database. db.init_db(drop_all=True) # Switch to the temporary directory. cwd = os.getcwd() os.chdir(tmp) # Load psiTurk configuration. con...
[ "def", "debug", "(", "verbose", ")", ":", "(", "id", ",", "tmp", ")", "=", "setup_experiment", "(", "debug", "=", "True", ",", "verbose", "=", "verbose", ")", "# Drop all the tables from the database.", "db", ".", "init_db", "(", "drop_all", "=", "True", "...
Run the experiment locally.
[ "Run", "the", "experiment", "locally", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L240-L318
train
Run the experiment locally.
berkeley-cocosci/Wallace
wallace/command_line.py
scale_up_dynos
def scale_up_dynos(id): """Scale up the Heroku dynos.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() dyno_type = config.get('Server Parameters', 'dyno_type') num_dynos_web = config.get('Server Parameters', 'num_dynos_web') num_dynos_worker = config.get('Serve...
python
def scale_up_dynos(id): """Scale up the Heroku dynos.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() dyno_type = config.get('Server Parameters', 'dyno_type') num_dynos_web = config.get('Server Parameters', 'num_dynos_web') num_dynos_worker = config.get('Serve...
[ "def", "scale_up_dynos", "(", "id", ")", ":", "# Load psiTurk configuration.", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "(", ")", "dyno_type", "=", "config", ".", "get", "(", "'Server Parameters'", ",", "'dyno_type'", ")", "num_dyn...
Scale up the Heroku dynos.
[ "Scale", "up", "the", "Heroku", "dynos", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L321-L344
train
Scale up the Heroku dynos.
berkeley-cocosci/Wallace
wallace/command_line.py
deploy_sandbox_shared_setup
def deploy_sandbox_shared_setup(verbose=True, app=None, web_procs=1): """Set up Git, push to Heroku, and launch the app.""" if verbose: out = None else: out = open(os.devnull, 'w') (id, tmp) = setup_experiment(debug=False, verbose=verbose, app=app) # Log in to Heroku if we aren't a...
python
def deploy_sandbox_shared_setup(verbose=True, app=None, web_procs=1): """Set up Git, push to Heroku, and launch the app.""" if verbose: out = None else: out = open(os.devnull, 'w') (id, tmp) = setup_experiment(debug=False, verbose=verbose, app=app) # Log in to Heroku if we aren't a...
[ "def", "deploy_sandbox_shared_setup", "(", "verbose", "=", "True", ",", "app", "=", "None", ",", "web_procs", "=", "1", ")", ":", "if", "verbose", ":", "out", "=", "None", "else", ":", "out", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")", ...
Set up Git, push to Heroku, and launch the app.
[ "Set", "up", "Git", "push", "to", "Heroku", "and", "launch", "the", "app", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L347-L487
train
Deploy the sandbox to Heroku and launch the app.
berkeley-cocosci/Wallace
wallace/command_line.py
sandbox
def sandbox(verbose, app): """Deploy app using Heroku to the MTurk Sandbox.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() # Set the mode. config.set("Experiment Configuration", "mode", "sandbox") config.set("Server Parameters", "logfile", "-") # Ensure ...
python
def sandbox(verbose, app): """Deploy app using Heroku to the MTurk Sandbox.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() # Set the mode. config.set("Experiment Configuration", "mode", "sandbox") config.set("Server Parameters", "logfile", "-") # Ensure ...
[ "def", "sandbox", "(", "verbose", ",", "app", ")", ":", "# Load psiTurk configuration.", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "(", ")", "# Set the mode.", "config", ".", "set", "(", "\"Experiment Configuration\"", ",", "\"mode\""...
Deploy app using Heroku to the MTurk Sandbox.
[ "Deploy", "app", "using", "Heroku", "to", "the", "MTurk", "Sandbox", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L493-L507
train
Deploy app using Heroku to the MTurk Sandbox.
berkeley-cocosci/Wallace
wallace/command_line.py
deploy
def deploy(verbose, app): """Deploy app using Heroku to MTurk.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() # Set the mode. config.set("Experiment Configuration", "mode", "deploy") config.set("Server Parameters", "logfile", "-") # Ensure that psiTurk i...
python
def deploy(verbose, app): """Deploy app using Heroku to MTurk.""" # Load psiTurk configuration. config = PsiturkConfig() config.load_config() # Set the mode. config.set("Experiment Configuration", "mode", "deploy") config.set("Server Parameters", "logfile", "-") # Ensure that psiTurk i...
[ "def", "deploy", "(", "verbose", ",", "app", ")", ":", "# Load psiTurk configuration.", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "(", ")", "# Set the mode.", "config", ".", "set", "(", "\"Experiment Configuration\"", ",", "\"mode\"",...
Deploy app using Heroku to MTurk.
[ "Deploy", "app", "using", "Heroku", "to", "MTurk", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L513-L527
train
Deploy app using Heroku to MTurk.
berkeley-cocosci/Wallace
wallace/command_line.py
qualify
def qualify(qualification, value, worker): """Assign a qualification to a worker.""" # create connection to AWS from boto.mturk.connection import MTurkConnection config = PsiturkConfig() config.load_config() aws_access_key_id = config.get('AWS Access', 'aws_access_key_id') aws_secret_access_...
python
def qualify(qualification, value, worker): """Assign a qualification to a worker.""" # create connection to AWS from boto.mturk.connection import MTurkConnection config = PsiturkConfig() config.load_config() aws_access_key_id = config.get('AWS Access', 'aws_access_key_id') aws_secret_access_...
[ "def", "qualify", "(", "qualification", ",", "value", ",", "worker", ")", ":", "# create connection to AWS", "from", "boto", ".", "mturk", ".", "connection", "import", "MTurkConnection", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "("...
Assign a qualification to a worker.
[ "Assign", "a", "qualification", "to", "a", "worker", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L534-L593
train
Assign a qualification to a worker.
berkeley-cocosci/Wallace
wallace/command_line.py
dump_database
def dump_database(id): """Backup the Postgres database locally.""" log("Generating a backup of the database on Heroku...") dump_filename = "data.dump" data_directory = "data" dump_dir = os.path.join(data_directory, id) if not os.path.exists(dump_dir): os.makedirs(dump_dir) subproce...
python
def dump_database(id): """Backup the Postgres database locally.""" log("Generating a backup of the database on Heroku...") dump_filename = "data.dump" data_directory = "data" dump_dir = os.path.join(data_directory, id) if not os.path.exists(dump_dir): os.makedirs(dump_dir) subproce...
[ "def", "dump_database", "(", "id", ")", ":", "log", "(", "\"Generating a backup of the database on Heroku...\"", ")", "dump_filename", "=", "\"data.dump\"", "data_directory", "=", "\"data\"", "dump_dir", "=", "os", ".", "path", ".", "join", "(", "data_directory", ",...
Backup the Postgres database locally.
[ "Backup", "the", "Postgres", "database", "locally", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L596-L619
train
Backup the Postgres database locally.
berkeley-cocosci/Wallace
wallace/command_line.py
backup
def backup(app): """Dump the database.""" dump_path = dump_database(app) config = PsiturkConfig() config.load_config() conn = boto.connect_s3( config.get('AWS Access', 'aws_access_key_id'), config.get('AWS Access', 'aws_secret_access_key'), ) bucket = conn.create_bucket( ...
python
def backup(app): """Dump the database.""" dump_path = dump_database(app) config = PsiturkConfig() config.load_config() conn = boto.connect_s3( config.get('AWS Access', 'aws_access_key_id'), config.get('AWS Access', 'aws_secret_access_key'), ) bucket = conn.create_bucket( ...
[ "def", "backup", "(", "app", ")", ":", "dump_path", "=", "dump_database", "(", "app", ")", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "(", ")", "conn", "=", "boto", ".", "connect_s3", "(", "config", ".", "get", "(", "'AWS A...
Dump the database.
[ "Dump", "the", "database", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L622-L645
train
Dump the database.
berkeley-cocosci/Wallace
wallace/command_line.py
hibernate
def hibernate(app): """Pause an experiment and remove costly resources.""" backup(app) log("Scaling down the web servers...") subprocess.call("heroku ps:scale web=0" + " --app " + app, shell=True) subprocess.call("heroku ps:scale worker=0" + " --app " + app, shell=True) subprocess.call("heroku ...
python
def hibernate(app): """Pause an experiment and remove costly resources.""" backup(app) log("Scaling down the web servers...") subprocess.call("heroku ps:scale web=0" + " --app " + app, shell=True) subprocess.call("heroku ps:scale worker=0" + " --app " + app, shell=True) subprocess.call("heroku ...
[ "def", "hibernate", "(", "app", ")", ":", "backup", "(", "app", ")", "log", "(", "\"Scaling down the web servers...\"", ")", "subprocess", ".", "call", "(", "\"heroku ps:scale web=0\"", "+", "\" --app \"", "+", "app", ",", "shell", "=", "True", ")", "subproces...
Pause an experiment and remove costly resources.
[ "Pause", "an", "experiment", "and", "remove", "costly", "resources", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L650-L673
train
Pause an experiment and remove costly resources.
berkeley-cocosci/Wallace
wallace/command_line.py
awaken
def awaken(app, databaseurl): """Restore the database from a given url.""" config = PsiturkConfig() config.load_config() database_size = config.get('Database Parameters', 'database_size') subprocess.call( "heroku addons:create heroku-postgresql:{} --app {}".format( database_siz...
python
def awaken(app, databaseurl): """Restore the database from a given url.""" config = PsiturkConfig() config.load_config() database_size = config.get('Database Parameters', 'database_size') subprocess.call( "heroku addons:create heroku-postgresql:{} --app {}".format( database_siz...
[ "def", "awaken", "(", "app", ",", "databaseurl", ")", ":", "config", "=", "PsiturkConfig", "(", ")", "config", ".", "load_config", "(", ")", "database_size", "=", "config", ".", "get", "(", "'Database Parameters'", ",", "'database_size'", ")", "subprocess", ...
Restore the database from a given url.
[ "Restore", "the", "database", "from", "a", "given", "url", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L679-L717
train
Restore the database from a given url.
berkeley-cocosci/Wallace
wallace/command_line.py
export
def export(app, local): """Export the data.""" print_header() log("Preparing to export the data...") id = str(app) subdata_path = os.path.join("data", id, "data") # Create the data package os.makedirs(subdata_path) # Copy the experiment code into a code/ subdirectory try: ...
python
def export(app, local): """Export the data.""" print_header() log("Preparing to export the data...") id = str(app) subdata_path = os.path.join("data", id, "data") # Create the data package os.makedirs(subdata_path) # Copy the experiment code into a code/ subdirectory try: ...
[ "def", "export", "(", "app", ",", "local", ")", ":", "print_header", "(", ")", "log", "(", "\"Preparing to export the data...\"", ")", "id", "=", "str", "(", "app", ")", "subdata_path", "=", "os", ".", "path", ".", "join", "(", "\"data\"", ",", "id", "...
Export the data.
[ "Export", "the", "data", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L724-L799
train
Export the data.
berkeley-cocosci/Wallace
wallace/command_line.py
create
def create(example): """Create a copy of the given example.""" try: this_dir = os.path.dirname(os.path.realpath(__file__)) example_dir = os.path.join(this_dir, os.pardir, "examples", example) shutil.copytree(example_dir, os.path.join(os.getcwd(), example)) log("Example created.",...
python
def create(example): """Create a copy of the given example.""" try: this_dir = os.path.dirname(os.path.realpath(__file__)) example_dir = os.path.join(this_dir, os.pardir, "examples", example) shutil.copytree(example_dir, os.path.join(os.getcwd(), example)) log("Example created.",...
[ "def", "create", "(", "example", ")", ":", "try", ":", "this_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", "example_dir", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",",...
Create a copy of the given example.
[ "Create", "a", "copy", "of", "the", "given", "example", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L815-L825
train
Create a copy of the given example.
berkeley-cocosci/Wallace
wallace/command_line.py
verify_package
def verify_package(verbose=True): """Ensure the package has a config file and a valid experiment file.""" is_passing = True # Check the config file. if os.path.exists("config.txt"): log("✓ config.txt is OK", delay=0, chevrons=False, verbose=verbose) else: log("✗ config.t...
python
def verify_package(verbose=True): """Ensure the package has a config file and a valid experiment file.""" is_passing = True # Check the config file. if os.path.exists("config.txt"): log("✓ config.txt is OK", delay=0, chevrons=False, verbose=verbose) else: log("✗ config.t...
[ "def", "verify_package", "(", "verbose", "=", "True", ")", ":", "is_passing", "=", "True", "# Check the config file.", "if", "os", ".", "path", ".", "exists", "(", "\"config.txt\"", ")", ":", "log", "(", "\"✓ config.txt is OK\",", "", "delay", "=", "0", ",",...
Ensure the package has a config file and a valid experiment file.
[ "Ensure", "the", "package", "has", "a", "config", "file", "and", "a", "valid", "experiment", "file", "." ]
3650c0bc3b0804d0adb1d178c5eba9992babb1b0
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L834-L926
train
Verify that the package has a config file and a valid experiment file.
brunato/lograptor
lograptor/timedate.py
parse_last_period
def parse_last_period(last): """ Parse the --last value and return the time difference in seconds. """ wordmap = { 'hour': '1h', 'day': '1d', 'week': '1w', 'month': '1m' } # seconds multmap = { 'h': 3600, 'd': 86400, 'w': 604800, ...
python
def parse_last_period(last): """ Parse the --last value and return the time difference in seconds. """ wordmap = { 'hour': '1h', 'day': '1d', 'week': '1w', 'month': '1m' } # seconds multmap = { 'h': 3600, 'd': 86400, 'w': 604800, ...
[ "def", "parse_last_period", "(", "last", ")", ":", "wordmap", "=", "{", "'hour'", ":", "'1h'", ",", "'day'", ":", "'1d'", ",", "'week'", ":", "'1w'", ",", "'month'", ":", "'1m'", "}", "# seconds", "multmap", "=", "{", "'h'", ":", "3600", ",", "'d'", ...
Parse the --last value and return the time difference in seconds.
[ "Parse", "the", "--", "last", "value", "and", "return", "the", "time", "difference", "in", "seconds", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L45-L81
train
Parse the last value and return the time difference in seconds.
brunato/lograptor
lograptor/timedate.py
get_datetime_interval
def get_datetime_interval(timestamp, diff, offset=0): """ Returns datetime interval from timestamp backward in the past, computed using the milliseconds difference passed as argument. The final datetime is corrected with an optional offset. """ fin_datetime = datetime.datetime.fromtimestamp(time...
python
def get_datetime_interval(timestamp, diff, offset=0): """ Returns datetime interval from timestamp backward in the past, computed using the milliseconds difference passed as argument. The final datetime is corrected with an optional offset. """ fin_datetime = datetime.datetime.fromtimestamp(time...
[ "def", "get_datetime_interval", "(", "timestamp", ",", "diff", ",", "offset", "=", "0", ")", ":", "fin_datetime", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "timestamp", "+", "offset", ")", "ini_datetime", "=", "datetime", ".", "datetime", ...
Returns datetime interval from timestamp backward in the past, computed using the milliseconds difference passed as argument. The final datetime is corrected with an optional offset.
[ "Returns", "datetime", "interval", "from", "timestamp", "backward", "in", "the", "past", "computed", "using", "the", "milliseconds", "difference", "passed", "as", "argument", ".", "The", "final", "datetime", "is", "corrected", "with", "an", "optional", "offset", ...
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L84-L92
train
Returns datetime interval from timestamp backward in the past
brunato/lograptor
lograptor/timedate.py
parse_date_period
def parse_date_period(date): """ Parse the --date value and return a couple of datetime object. The format is [YYYY]MMDD[,[YYYY]MMDD]. """ import datetime now = datetime.datetime.today() date_len = len(date) if date_len == 4: date1 = str(now.year) + date date2 =...
python
def parse_date_period(date): """ Parse the --date value and return a couple of datetime object. The format is [YYYY]MMDD[,[YYYY]MMDD]. """ import datetime now = datetime.datetime.today() date_len = len(date) if date_len == 4: date1 = str(now.year) + date date2 =...
[ "def", "parse_date_period", "(", "date", ")", ":", "import", "datetime", "now", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "date_len", "=", "len", "(", "date", ")", "if", "date_len", "==", "4", ":", "date1", "=", "str", "(", "now", "."...
Parse the --date value and return a couple of datetime object. The format is [YYYY]MMDD[,[YYYY]MMDD].
[ "Parse", "the", "--", "date", "value", "and", "return", "a", "couple", "of", "datetime", "object", ".", "The", "format", "is", "[", "YYYY", "]", "MMDD", "[", "[", "YYYY", "]", "MMDD", "]", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L95-L141
train
Parse the date parameter and return a couple of datetime object.
brunato/lograptor
lograptor/timedate.py
strftimegen
def strftimegen(start_dt, end_dt): """ Return a generator function for datetime format strings. The generator produce a day-by-day sequence starting from the first datetime to the second datetime argument. """ if start_dt > end_dt: raise ValueError("the start datetime is after the end da...
python
def strftimegen(start_dt, end_dt): """ Return a generator function for datetime format strings. The generator produce a day-by-day sequence starting from the first datetime to the second datetime argument. """ if start_dt > end_dt: raise ValueError("the start datetime is after the end da...
[ "def", "strftimegen", "(", "start_dt", ",", "end_dt", ")", ":", "if", "start_dt", ">", "end_dt", ":", "raise", "ValueError", "(", "\"the start datetime is after the end datetime: (%r,%r)\"", "%", "(", "start_dt", ",", "end_dt", ")", ")", "def", "iterftime", "(", ...
Return a generator function for datetime format strings. The generator produce a day-by-day sequence starting from the first datetime to the second datetime argument.
[ "Return", "a", "generator", "function", "for", "datetime", "format", "strings", ".", "The", "generator", "produce", "a", "day", "-", "by", "-", "day", "sequence", "starting", "from", "the", "first", "datetime", "to", "the", "second", "datetime", "argument", ...
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L181-L203
train
Return a generator function for datetime format strings.
brunato/lograptor
lograptor/timedate.py
TimeRange.between
def between(self, time_): """ Compare if the parameter HH:MM is in the time range. """ hour = int(time_[0:2]) minute = int(time_[3:5]) return not ( hour < self.h1 or hour > self.h2 or (hour == self.h1 and minute < self.m1) or (hour == s...
python
def between(self, time_): """ Compare if the parameter HH:MM is in the time range. """ hour = int(time_[0:2]) minute = int(time_[3:5]) return not ( hour < self.h1 or hour > self.h2 or (hour == self.h1 and minute < self.m1) or (hour == s...
[ "def", "between", "(", "self", ",", "time_", ")", ":", "hour", "=", "int", "(", "time_", "[", "0", ":", "2", "]", ")", "minute", "=", "int", "(", "time_", "[", "3", ":", "5", "]", ")", "return", "not", "(", "hour", "<", "self", ".", "h1", "...
Compare if the parameter HH:MM is in the time range.
[ "Compare", "if", "the", "parameter", "HH", ":", "MM", "is", "in", "the", "time", "range", "." ]
b1f09fe1b429ed15110610092704ef12d253f3c9
https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L168-L178
train
Compare if the parameter HH : MM is in the time range.
Kortemme-Lab/klab
klab/bio/fragments/generate_fragments.py
setup_jobs
def setup_jobs(outpath, options, input_files): ''' This function sets up the jobs by creating the necessary input files as expected. - outpath is where the output is to be stored. - options is the optparse options object. - input_files is a list of paths to input files. ''' jo...
python
def setup_jobs(outpath, options, input_files): ''' This function sets up the jobs by creating the necessary input files as expected. - outpath is where the output is to be stored. - options is the optparse options object. - input_files is a list of paths to input files. ''' jo...
[ "def", "setup_jobs", "(", "outpath", ",", "options", ",", "input_files", ")", ":", "job_inputs", "=", "None", "reverse_mapping", "=", "None", "fasta_file_contents", "=", "{", "}", "# Generate FASTA files for PDB inputs", "# fasta_file_contents is a mapping from a file path ...
This function sets up the jobs by creating the necessary input files as expected. - outpath is where the output is to be stored. - options is the optparse options object. - input_files is a list of paths to input files.
[ "This", "function", "sets", "up", "the", "jobs", "by", "creating", "the", "necessary", "input", "files", "as", "expected", ".", "-", "outpath", "is", "where", "the", "output", "is", "to", "be", "stored", ".", "-", "options", "is", "the", "optparse", "opt...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/generate_fragments.py#L460-L520
train
This function creates the necessary input files as expected and then runs the appropriate jobs.
Kortemme-Lab/klab
klab/bio/fragments/generate_fragments.py
get_sequences
def get_sequences(options, fasta_file_contents): ''' This function returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the associated FASTA file contents. ''' errors = [] fa...
python
def get_sequences(options, fasta_file_contents): ''' This function returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the associated FASTA file contents. ''' errors = [] fa...
[ "def", "get_sequences", "(", "options", ",", "fasta_file_contents", ")", ":", "errors", "=", "[", "]", "fasta_files_str", "=", "\", \"", ".", "join", "(", "fasta_file_contents", ".", "keys", "(", ")", ")", "fasta_records", "=", "None", "reverse_mapping", "=", ...
This function returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the associated FASTA file contents.
[ "This", "function", "returns", "a", "dict", "mapping", "(", "pdbid", "chain", "file_name", ")", "tuples", "to", "sequences", ":", "-", "options", "is", "the", "OptionParser", "member", ";", "-", "fasta_file_contents", "is", "a", "map", "from", "input", "file...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/generate_fragments.py#L523-L545
train
This function returns a dict mapping PDBID chain file_name to sequence records.
Kortemme-Lab/klab
klab/bio/fragments/generate_fragments.py
parse_FASTA_files
def parse_FASTA_files(options, fasta_file_contents): ''' This function iterates through each filepath in fasta_file_contents and returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the ...
python
def parse_FASTA_files(options, fasta_file_contents): ''' This function iterates through each filepath in fasta_file_contents and returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the ...
[ "def", "parse_FASTA_files", "(", "options", ",", "fasta_file_contents", ")", ":", "records", "=", "{", "}", "reverse_mapping", "=", "{", "}", "original_segment_list", "=", "[", "]", "key_location", "=", "{", "}", "sequenceLine", "=", "re", ".", "compile", "(...
This function iterates through each filepath in fasta_file_contents and returns a dict mapping (pdbid, chain, file_name) tuples to sequences: - options is the OptionParser member; - fasta_file_contents is a map from input filenames to the associated FASTA file contents.
[ "This", "function", "iterates", "through", "each", "filepath", "in", "fasta_file_contents", "and", "returns", "a", "dict", "mapping", "(", "pdbid", "chain", "file_name", ")", "tuples", "to", "sequences", ":", "-", "options", "is", "the", "OptionParser", "member"...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/generate_fragments.py#L547-L721
train
This function parses the FASTA files and returns a dictionary mapping from PDB IDs to sequences.
Kortemme-Lab/klab
klab/bio/fragments/generate_fragments.py
reformat
def reformat(found_sequences): '''Truncate the FASTA headers so that the first field is a 4-character ID.''' for (pdb_id, chain, file_name), sequence in sorted(found_sequences.iteritems()): header = sequence[0] assert(header[0] == '>') tokens = header.split('|') tokens[0] = token...
python
def reformat(found_sequences): '''Truncate the FASTA headers so that the first field is a 4-character ID.''' for (pdb_id, chain, file_name), sequence in sorted(found_sequences.iteritems()): header = sequence[0] assert(header[0] == '>') tokens = header.split('|') tokens[0] = token...
[ "def", "reformat", "(", "found_sequences", ")", ":", "for", "(", "pdb_id", ",", "chain", ",", "file_name", ")", ",", "sequence", "in", "sorted", "(", "found_sequences", ".", "iteritems", "(", ")", ")", ":", "header", "=", "sequence", "[", "0", "]", "as...
Truncate the FASTA headers so that the first field is a 4-character ID.
[ "Truncate", "the", "FASTA", "headers", "so", "that", "the", "first", "field", "is", "a", "4", "-", "character", "ID", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/generate_fragments.py#L723-L731
train
Truncate the FASTA headers so that the first field is a 4 - character ID.
ronhanson/python-tbx
tbx/network.py
get_local_ip_address
def get_local_ip_address(target): """ Get the local ip address to access one specific target. """ ip_adr = '' try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((target, 8000)) ip_adr = s.getsockname()[0] s.close() except: pass return...
python
def get_local_ip_address(target): """ Get the local ip address to access one specific target. """ ip_adr = '' try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((target, 8000)) ip_adr = s.getsockname()[0] s.close() except: pass return...
[ "def", "get_local_ip_address", "(", "target", ")", ":", "ip_adr", "=", "''", "try", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "s", ".", "connect", "(", "(", "target", ",", "8000", ")...
Get the local ip address to access one specific target.
[ "Get", "the", "local", "ip", "address", "to", "access", "one", "specific", "target", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/network.py#L24-L37
train
Get the local ip address to access one specific target.
ronhanson/python-tbx
tbx/network.py
SocketClient.connect
def connect(self): """ Connect socket to server """ try: self.sock.connect((self.host, self.port)) return self.sock except socket.error as ex: logging.error('Exception while connecting socket on %s:%s - Error %s' % (self.host, self.port, ex)) ...
python
def connect(self): """ Connect socket to server """ try: self.sock.connect((self.host, self.port)) return self.sock except socket.error as ex: logging.error('Exception while connecting socket on %s:%s - Error %s' % (self.host, self.port, ex)) ...
[ "def", "connect", "(", "self", ")", ":", "try", ":", "self", ".", "sock", ".", "connect", "(", "(", "self", ".", "host", ",", "self", ".", "port", ")", ")", "return", "self", ".", "sock", "except", "socket", ".", "error", "as", "ex", ":", "loggin...
Connect socket to server
[ "Connect", "socket", "to", "server" ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/network.py#L97-L109
train
Connect to server and return the server s ID.
ronhanson/python-tbx
tbx/network.py
SocketClient.send_by_packet
def send_by_packet(self, data): """ Send data by packet on socket """ total_sent = 0 while total_sent < PACKET_SIZE: sent = self.sock.send(data[total_sent:]) if sent == 0: raise RuntimeError("socket connection broken") total_sen...
python
def send_by_packet(self, data): """ Send data by packet on socket """ total_sent = 0 while total_sent < PACKET_SIZE: sent = self.sock.send(data[total_sent:]) if sent == 0: raise RuntimeError("socket connection broken") total_sen...
[ "def", "send_by_packet", "(", "self", ",", "data", ")", ":", "total_sent", "=", "0", "while", "total_sent", "<", "PACKET_SIZE", ":", "sent", "=", "self", ".", "sock", ".", "send", "(", "data", "[", "total_sent", ":", "]", ")", "if", "sent", "==", "0"...
Send data by packet on socket
[ "Send", "data", "by", "packet", "on", "socket" ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/network.py#L111-L121
train
Send data by packet on socket.
ronhanson/python-tbx
tbx/network.py
SocketClient.receive
def receive(self, siz): """ Receive a known length of bytes from a socket """ result = bytearray() data = 'x' while len(data) > 0: data = self.sock.recv(siz - len(result)) result += data if len(result) == siz: return res...
python
def receive(self, siz): """ Receive a known length of bytes from a socket """ result = bytearray() data = 'x' while len(data) > 0: data = self.sock.recv(siz - len(result)) result += data if len(result) == siz: return res...
[ "def", "receive", "(", "self", ",", "siz", ")", ":", "result", "=", "bytearray", "(", ")", "data", "=", "'x'", "while", "len", "(", "data", ")", ">", "0", ":", "data", "=", "self", ".", "sock", ".", "recv", "(", "siz", "-", "len", "(", "result"...
Receive a known length of bytes from a socket
[ "Receive", "a", "known", "length", "of", "bytes", "from", "a", "socket" ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/network.py#L136-L149
train
Receive a known length of bytes from a socket.
assamite/creamas
creamas/mp.py
spawn_container
def spawn_container(addr, env_cls=Environment, mgr_cls=EnvManager, set_seed=True, *args, **kwargs): """Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <htt...
python
def spawn_container(addr, env_cls=Environment, mgr_cls=EnvManager, set_seed=True, *args, **kwargs): """Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <htt...
[ "def", "spawn_container", "(", "addr", ",", "env_cls", "=", "Environment", ",", "mgr_cls", "=", "EnvManager", ",", "set_seed", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Try setting the process name to easily recognize the spawned", "# en...
Spawn a new environment in a given address as a coroutine. Arguments and keyword arguments are passed down to the created environment at initialization time. If `setproctitle <https://pypi.python.org/pypi/setproctitle>`_ is installed, this function renames the title of the process to start with 'c...
[ "Spawn", "a", "new", "environment", "in", "a", "given", "address", "as", "a", "coroutine", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L886-L915
train
Spawn a new environment in a given address as a coroutine.
assamite/creamas
creamas/mp.py
spawn_containers
def spawn_containers(addrs, env_cls=Environment, env_params=None, mgr_cls=EnvManager, *args, **kwargs): """Spawn environments in a multiprocessing :class:`multiprocessing.Pool`. Arguments and keyword arguments are passed down to the created environments at initiali...
python
def spawn_containers(addrs, env_cls=Environment, env_params=None, mgr_cls=EnvManager, *args, **kwargs): """Spawn environments in a multiprocessing :class:`multiprocessing.Pool`. Arguments and keyword arguments are passed down to the created environments at initiali...
[ "def", "spawn_containers", "(", "addrs", ",", "env_cls", "=", "Environment", ",", "env_params", "=", "None", ",", "mgr_cls", "=", "EnvManager", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "len", ...
Spawn environments in a multiprocessing :class:`multiprocessing.Pool`. Arguments and keyword arguments are passed down to the created environments at initialization time if *env_params* is None. If *env_params* is not None, then it is assumed to contain individual initialization parameters for each env...
[ "Spawn", "environments", "in", "a", "multiprocessing", ":", "class", ":", "multiprocessing", ".", "Pool", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L918-L965
train
Spawn environments in a multiprocessing. Pool.
assamite/creamas
creamas/mp.py
start
async def start(addr, env_cls, mgr_cls, *env_args, **env_kwargs): """`Coroutine <https://docs.python.org/3/library/asyncio-task.html#coroutine>`_ that starts an environment with :class:`mgr_cls` manager agent. The agent will connect to *addr* ``('host', port)`` and wait for commands to spawn new ag...
python
async def start(addr, env_cls, mgr_cls, *env_args, **env_kwargs): """`Coroutine <https://docs.python.org/3/library/asyncio-task.html#coroutine>`_ that starts an environment with :class:`mgr_cls` manager agent. The agent will connect to *addr* ``('host', port)`` and wait for commands to spawn new ag...
[ "async", "def", "start", "(", "addr", ",", "env_cls", ",", "mgr_cls", ",", "*", "env_args", ",", "*", "*", "env_kwargs", ")", ":", "env_kwargs", ".", "update", "(", "as_coro", "=", "True", ")", "log_folder", "=", "env_kwargs", ".", "get", "(", "'log_fo...
`Coroutine <https://docs.python.org/3/library/asyncio-task.html#coroutine>`_ that starts an environment with :class:`mgr_cls` manager agent. The agent will connect to *addr* ``('host', port)`` and wait for commands to spawn new agents within its environment. The *env_args* and *env_kwargs* will be...
[ "Coroutine", "<https", ":", "//", "docs", ".", "python", ".", "org", "/", "3", "/", "library", "/", "asyncio", "-", "task", ".", "html#coroutine", ">", "_", "that", "starts", "an", "environment", "with", ":", "class", ":", "mgr_cls", "manager", "agent", ...
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L968-L1004
train
Coroutine that starts an environment with the given manager agent.
assamite/creamas
creamas/mp.py
_set_random_seeds
def _set_random_seeds(): """Set new random seeds for the process. """ try: import numpy as np np.random.seed() except: pass try: import scipy as sp sp.random.seed() except: pass import random random.seed()
python
def _set_random_seeds(): """Set new random seeds for the process. """ try: import numpy as np np.random.seed() except: pass try: import scipy as sp sp.random.seed() except: pass import random random.seed()
[ "def", "_set_random_seeds", "(", ")", ":", "try", ":", "import", "numpy", "as", "np", "np", ".", "random", ".", "seed", "(", ")", "except", ":", "pass", "try", ":", "import", "scipy", "as", "sp", "sp", ".", "random", ".", "seed", "(", ")", "except"...
Set new random seeds for the process.
[ "Set", "new", "random", "seeds", "for", "the", "process", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L1007-L1023
train
Set new random seeds for the process.
assamite/creamas
creamas/mp.py
EnvManager.report
async def report(self, msg, timeout=5): """Report message to the host manager. """ try: host_manager = await self.env.connect(self.host_manager, timeout=timeout) except: raise ConnectionError("Could not reach host ...
python
async def report(self, msg, timeout=5): """Report message to the host manager. """ try: host_manager = await self.env.connect(self.host_manager, timeout=timeout) except: raise ConnectionError("Could not reach host ...
[ "async", "def", "report", "(", "self", ",", "msg", ",", "timeout", "=", "5", ")", ":", "try", ":", "host_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "self", ".", "host_manager", ",", "timeout", "=", "timeout", ")", "except", ":",...
Report message to the host manager.
[ "Report", "message", "to", "the", "host", "manager", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L77-L87
train
Report a message to the host manager.
assamite/creamas
creamas/mp.py
EnvManager.get_agents
def get_agents(self, addr=True, agent_cls=None, as_coro=False): """Get agents from the managed environment. This is a managing function for the :py:meth:`~creamas.environment.Environment.get_agents`. Returned agent list excludes the environment's manager agent (this agent) by de...
python
def get_agents(self, addr=True, agent_cls=None, as_coro=False): """Get agents from the managed environment. This is a managing function for the :py:meth:`~creamas.environment.Environment.get_agents`. Returned agent list excludes the environment's manager agent (this agent) by de...
[ "def", "get_agents", "(", "self", ",", "addr", "=", "True", ",", "agent_cls", "=", "None", ",", "as_coro", "=", "False", ")", ":", "return", "self", ".", "env", ".", "get_agents", "(", "addr", "=", "addr", ",", "agent_cls", "=", "agent_cls", ")" ]
Get agents from the managed environment. This is a managing function for the :py:meth:`~creamas.environment.Environment.get_agents`. Returned agent list excludes the environment's manager agent (this agent) by design.
[ "Get", "agents", "from", "the", "managed", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L96-L104
train
Get agents from the environment.
assamite/creamas
creamas/mp.py
EnvManager.get_artifacts
async def get_artifacts(self): """Get all artifacts from the host environment. :returns: All the artifacts in the environment. """ host_manager = await self.env.connect(self._host_manager, timeout=TIMEOUT) artifacts = await host_mana...
python
async def get_artifacts(self): """Get all artifacts from the host environment. :returns: All the artifacts in the environment. """ host_manager = await self.env.connect(self._host_manager, timeout=TIMEOUT) artifacts = await host_mana...
[ "async", "def", "get_artifacts", "(", "self", ")", ":", "host_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "self", ".", "_host_manager", ",", "timeout", "=", "TIMEOUT", ")", "artifacts", "=", "await", "host_manager", ".", "get_artifacts",...
Get all artifacts from the host environment. :returns: All the artifacts in the environment.
[ "Get", "all", "artifacts", "from", "the", "host", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L135-L143
train
Get all the artifacts from the host environment.
assamite/creamas
creamas/mp.py
MultiEnvManager.spawn
async def spawn(self, agent_cls, *args, addr=None, **kwargs): """Spawn an agent to the environment. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle (re)serializa...
python
async def spawn(self, agent_cls, *args, addr=None, **kwargs): """Spawn an agent to the environment. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle (re)serializa...
[ "async", "def", "spawn", "(", "self", ",", "agent_cls", ",", "*", "args", ",", "addr", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_", ",", "addr", "=", "await", "self", ".", "menv", ".", "spawn", "(", "agent_cls", ",", "*", "args", ",", "...
Spawn an agent to the environment. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle (re)serialization, only the address of the spawned agent is returned.
[ "Spawn", "an", "agent", "to", "the", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L218-L231
train
Spawn an agent to the environment.
assamite/creamas
creamas/mp.py
MultiEnvManager.spawn_n
async def spawn_n(self, agent_cls, n, *args, addr=None, **kwargs): """Same as :meth:`~creamas.mp.MultiEnvManager.spawn`, but spawn :attr:`n` agents with same initialization parameters. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn_n`. .. note:: ...
python
async def spawn_n(self, agent_cls, n, *args, addr=None, **kwargs): """Same as :meth:`~creamas.mp.MultiEnvManager.spawn`, but spawn :attr:`n` agents with same initialization parameters. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn_n`. .. note:: ...
[ "async", "def", "spawn_n", "(", "self", ",", "agent_cls", ",", "n", ",", "*", "args", ",", "addr", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "await", "self", ".", "menv", ".", "spawn_n", "(", "agent_cls", ",", "n", ",", "*", "...
Same as :meth:`~creamas.mp.MultiEnvManager.spawn`, but spawn :attr:`n` agents with same initialization parameters. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.spawn_n`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle ...
[ "Same", "as", ":", "meth", ":", "~creamas", ".", "mp", ".", "MultiEnvManager", ".", "spawn", "but", "spawn", ":", "attr", ":", "n", "agents", "with", "same", "initialization", "parameters", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L234-L248
train
Spawn agents with same initialization parameters.
assamite/creamas
creamas/mp.py
MultiEnvManager.get_agents
async def get_agents(self, addr=True, agent_cls=None): """Get addresses of all agents in all the slave environments. This is a managing function for :meth:`creamas.mp.MultiEnvironment.get_agents`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle ...
python
async def get_agents(self, addr=True, agent_cls=None): """Get addresses of all agents in all the slave environments. This is a managing function for :meth:`creamas.mp.MultiEnvironment.get_agents`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle ...
[ "async", "def", "get_agents", "(", "self", ",", "addr", "=", "True", ",", "agent_cls", "=", "None", ")", ":", "return", "await", "self", ".", "menv", ".", "get_agents", "(", "addr", "=", "True", ",", "agent_cls", "=", "None", ",", "as_coro", "=", "Tr...
Get addresses of all agents in all the slave environments. This is a managing function for :meth:`creamas.mp.MultiEnvironment.get_agents`. .. note:: Since :class:`aiomas.rpc.Proxy` objects do not seem to handle (re)serialization, ``addr`` and ``agent_cls`` parameters a...
[ "Get", "addresses", "of", "all", "agents", "in", "all", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L251-L269
train
Get all agents in all the slave environments.
assamite/creamas
creamas/mp.py
MultiEnvManager.get_connections
async def get_connections(self, data=True): """Return connections for all the agents in the slave environments. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.get_connections`. """ return await self.menv.get_connections(data=data, as_coro=True)
python
async def get_connections(self, data=True): """Return connections for all the agents in the slave environments. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.get_connections`. """ return await self.menv.get_connections(data=data, as_coro=True)
[ "async", "def", "get_connections", "(", "self", ",", "data", "=", "True", ")", ":", "return", "await", "self", ".", "menv", ".", "get_connections", "(", "data", "=", "data", ",", "as_coro", "=", "True", ")" ]
Return connections for all the agents in the slave environments. This is a managing function for :meth:`~creamas.mp.MultiEnvironment.get_connections`.
[ "Return", "connections", "for", "all", "the", "agents", "in", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L281-L287
train
Return all the agents in the slave environments.
assamite/creamas
creamas/mp.py
MultiEnvManager.set_as_host_manager
async def set_as_host_manager(self, addr, timeout=5): """Set the this manager as a host manager for the manager in *addr*. This is a managing function for :py:meth:`~creamas.mp.MultiEnvironment.set_host_manager`. """ return await self.menv.set_host_manager(addr, timeout=timeout)
python
async def set_as_host_manager(self, addr, timeout=5): """Set the this manager as a host manager for the manager in *addr*. This is a managing function for :py:meth:`~creamas.mp.MultiEnvironment.set_host_manager`. """ return await self.menv.set_host_manager(addr, timeout=timeout)
[ "async", "def", "set_as_host_manager", "(", "self", ",", "addr", ",", "timeout", "=", "5", ")", ":", "return", "await", "self", ".", "menv", ".", "set_host_manager", "(", "addr", ",", "timeout", "=", "timeout", ")" ]
Set the this manager as a host manager for the manager in *addr*. This is a managing function for :py:meth:`~creamas.mp.MultiEnvironment.set_host_manager`.
[ "Set", "the", "this", "manager", "as", "a", "host", "manager", "for", "the", "manager", "in", "*", "addr", "*", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L296-L302
train
Set this manager as a host manager for the manager in addr.
assamite/creamas
creamas/mp.py
MultiEnvironment.get_agents
def get_agents(self, addr=True, agent_cls=None, as_coro=False): """Get agents from the slave environments. :param bool addr: If ``True``, returns only addresses of the agents, otherwise returns a :class:`Proxy` object for each agent. :param agent_cls: If spe...
python
def get_agents(self, addr=True, agent_cls=None, as_coro=False): """Get agents from the slave environments. :param bool addr: If ``True``, returns only addresses of the agents, otherwise returns a :class:`Proxy` object for each agent. :param agent_cls: If spe...
[ "def", "get_agents", "(", "self", ",", "addr", "=", "True", ",", "agent_cls", "=", "None", ",", "as_coro", "=", "False", ")", ":", "async", "def", "slave_task", "(", "mgr_addr", ",", "addr", "=", "True", ",", "agent_cls", "=", "None", ")", ":", "r_ma...
Get agents from the slave environments. :param bool addr: If ``True``, returns only addresses of the agents, otherwise returns a :class:`Proxy` object for each agent. :param agent_cls: If specified, returns only agents that are members of that particular...
[ "Get", "agents", "from", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L446-L481
train
Get agents from the slave environments.
assamite/creamas
creamas/mp.py
MultiEnvironment.is_ready
async def is_ready(self): """Check if the multi-environment has been fully initialized. This calls each slave environment managers' :py:meth:`is_ready` and checks if the multi-environment itself is ready by calling :py:meth:`~creamas.mp.MultiEnvironment.check_ready`. .. seealso...
python
async def is_ready(self): """Check if the multi-environment has been fully initialized. This calls each slave environment managers' :py:meth:`is_ready` and checks if the multi-environment itself is ready by calling :py:meth:`~creamas.mp.MultiEnvironment.check_ready`. .. seealso...
[ "async", "def", "is_ready", "(", "self", ")", ":", "async", "def", "slave_task", "(", "addr", ",", "timeout", ")", ":", "try", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ",", "timeout", "=", "timeout", ")", "read...
Check if the multi-environment has been fully initialized. This calls each slave environment managers' :py:meth:`is_ready` and checks if the multi-environment itself is ready by calling :py:meth:`~creamas.mp.MultiEnvironment.check_ready`. .. seealso:: :py:meth:`creamas.cor...
[ "Check", "if", "the", "multi", "-", "environment", "has", "been", "fully", "initialized", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L526-L554
train
Check if the multi - environment is fully initialized.
assamite/creamas
creamas/mp.py
MultiEnvironment.spawn_slaves
async def spawn_slaves(self, slave_addrs, slave_env_cls, slave_mgr_cls, slave_kwargs=None): """Spawn slave environments. :param slave_addrs: List of (HOST, PORT) addresses for the slave-environments. :param slave_env_cls: Class for the slave environments....
python
async def spawn_slaves(self, slave_addrs, slave_env_cls, slave_mgr_cls, slave_kwargs=None): """Spawn slave environments. :param slave_addrs: List of (HOST, PORT) addresses for the slave-environments. :param slave_env_cls: Class for the slave environments....
[ "async", "def", "spawn_slaves", "(", "self", ",", "slave_addrs", ",", "slave_env_cls", ",", "slave_mgr_cls", ",", "slave_kwargs", "=", "None", ")", ":", "pool", ",", "r", "=", "spawn_containers", "(", "slave_addrs", ",", "env_cls", "=", "slave_env_cls", ",", ...
Spawn slave environments. :param slave_addrs: List of (HOST, PORT) addresses for the slave-environments. :param slave_env_cls: Class for the slave environments. :param slave_kwargs: If not None, must be a list of the same size as *addrs*. Each item in the l...
[ "Spawn", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L556-L578
train
Spawn all the slaves.
assamite/creamas
creamas/mp.py
MultiEnvironment.wait_slaves
async def wait_slaves(self, timeout, check_ready=False): """Wait until all slaves are online (their managers accept connections) or timeout expires. :param int timeout: Timeout (in seconds) after which the method will return even though all the slaves are not online yet....
python
async def wait_slaves(self, timeout, check_ready=False): """Wait until all slaves are online (their managers accept connections) or timeout expires. :param int timeout: Timeout (in seconds) after which the method will return even though all the slaves are not online yet....
[ "async", "def", "wait_slaves", "(", "self", ",", "timeout", ",", "check_ready", "=", "False", ")", ":", "status", "=", "'ready'", "if", "check_ready", "else", "'online'", "self", ".", "_log", "(", "logging", ".", "DEBUG", ",", "\"Waiting for slaves to become {...
Wait until all slaves are online (their managers accept connections) or timeout expires. :param int timeout: Timeout (in seconds) after which the method will return even though all the slaves are not online yet. :param bool check_ready: If ``True`` also chec...
[ "Wait", "until", "all", "slaves", "are", "online", "(", "their", "managers", "accept", "connections", ")", "or", "timeout", "expires", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L580-L629
train
Wait until all slaves are online.
assamite/creamas
creamas/mp.py
MultiEnvironment.set_host_manager
async def set_host_manager(self, addr, timeout=TIMEOUT): """Set this multi-environment's manager as the host manager for a manager agent in *addr* """ r_manager = await self.env.connect(addr, timeout=timeout) return await r_manager.set_host_manager(self.manager.addr)
python
async def set_host_manager(self, addr, timeout=TIMEOUT): """Set this multi-environment's manager as the host manager for a manager agent in *addr* """ r_manager = await self.env.connect(addr, timeout=timeout) return await r_manager.set_host_manager(self.manager.addr)
[ "async", "def", "set_host_manager", "(", "self", ",", "addr", ",", "timeout", "=", "TIMEOUT", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ",", "timeout", "=", "timeout", ")", "return", "await", "r_manager", ".", ...
Set this multi-environment's manager as the host manager for a manager agent in *addr*
[ "Set", "this", "multi", "-", "environment", "s", "manager", "as", "the", "host", "manager", "for", "a", "manager", "agent", "in", "*", "addr", "*" ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L640-L645
train
Set this multi - environment s manager as the host manager for the manager agent in addr
assamite/creamas
creamas/mp.py
MultiEnvironment.trigger_act
async def trigger_act(self, addr): """Trigger agent in :attr:`addr` to act. This method is quite inefficient if used repeatedly for a large number of agents. .. seealso:: :py:meth:`creamas.mp.MultiEnvironment.trigger_all` """ r_agent = await self.env.connec...
python
async def trigger_act(self, addr): """Trigger agent in :attr:`addr` to act. This method is quite inefficient if used repeatedly for a large number of agents. .. seealso:: :py:meth:`creamas.mp.MultiEnvironment.trigger_all` """ r_agent = await self.env.connec...
[ "async", "def", "trigger_act", "(", "self", ",", "addr", ")", ":", "r_agent", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ",", "timeout", "=", "TIMEOUT", ")", "return", "await", "r_agent", ".", "act", "(", ")" ]
Trigger agent in :attr:`addr` to act. This method is quite inefficient if used repeatedly for a large number of agents. .. seealso:: :py:meth:`creamas.mp.MultiEnvironment.trigger_all`
[ "Trigger", "agent", "in", ":", "attr", ":", "addr", "to", "act", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L661-L672
train
Trigger an agent in addr to act.
assamite/creamas
creamas/mp.py
MultiEnvironment.trigger_all
async def trigger_all(self, *args, **kwargs): """Trigger all agents in all the slave environments to :meth:`act` asynchronously. Given arguments and keyword arguments are passed down to each agent's :meth:`creamas.core.agent.CreativeAgent.act`. .. note:: By design,...
python
async def trigger_all(self, *args, **kwargs): """Trigger all agents in all the slave environments to :meth:`act` asynchronously. Given arguments and keyword arguments are passed down to each agent's :meth:`creamas.core.agent.CreativeAgent.act`. .. note:: By design,...
[ "async", "def", "trigger_all", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "async", "def", "slave_task", "(", "addr", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "...
Trigger all agents in all the slave environments to :meth:`act` asynchronously. Given arguments and keyword arguments are passed down to each agent's :meth:`creamas.core.agent.CreativeAgent.act`. .. note:: By design, the manager agents in each slave environment, i.e. ...
[ "Trigger", "all", "agents", "in", "all", "the", "slave", "environments", "to", ":", "meth", ":", "act", "asynchronously", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L674-L690
train
Trigger all agents in all the slave environments to act asynchronously.
assamite/creamas
creamas/mp.py
MultiEnvironment._get_smallest_env
async def _get_smallest_env(self): """Get address of the slave environment manager with the smallest number of agents. """ async def slave_task(mgr_addr): r_manager = await self.env.connect(mgr_addr, timeout=TIMEOUT) ret = await r_manager.get_agents(addr=True) ...
python
async def _get_smallest_env(self): """Get address of the slave environment manager with the smallest number of agents. """ async def slave_task(mgr_addr): r_manager = await self.env.connect(mgr_addr, timeout=TIMEOUT) ret = await r_manager.get_agents(addr=True) ...
[ "async", "def", "_get_smallest_env", "(", "self", ")", ":", "async", "def", "slave_task", "(", "mgr_addr", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "mgr_addr", ",", "timeout", "=", "TIMEOUT", ")", "ret", "=", "await",...
Get address of the slave environment manager with the smallest number of agents.
[ "Get", "address", "of", "the", "slave", "environment", "manager", "with", "the", "smallest", "number", "of", "agents", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L692-L702
train
Get the address of the slave environment manager with the smallest number of agents.
assamite/creamas
creamas/mp.py
MultiEnvironment.spawn
async def spawn(self, agent_cls, *args, addr=None, **kwargs): """Spawn a new agent in a slave environment. :param str agent_cls: `qualname`` of the agent class. That is, the name should be in the form ``pkg.mod:cls``, e.g. ``creamas.core.agent:CreativeAgent``. ...
python
async def spawn(self, agent_cls, *args, addr=None, **kwargs): """Spawn a new agent in a slave environment. :param str agent_cls: `qualname`` of the agent class. That is, the name should be in the form ``pkg.mod:cls``, e.g. ``creamas.core.agent:CreativeAgent``. ...
[ "async", "def", "spawn", "(", "self", ",", "agent_cls", ",", "*", "args", ",", "addr", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "addr", "is", "None", ":", "addr", "=", "await", "self", ".", "_get_smallest_env", "(", ")", "r_manager", "...
Spawn a new agent in a slave environment. :param str agent_cls: `qualname`` of the agent class. That is, the name should be in the form ``pkg.mod:cls``, e.g. ``creamas.core.agent:CreativeAgent``. :param str addr: Optional. Address for the slave enviroment...
[ "Spawn", "a", "new", "agent", "in", "a", "slave", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L704-L729
train
Spawns a new agent in a slave environment.
assamite/creamas
creamas/mp.py
MultiEnvironment.spawn_n
async def spawn_n(self, agent_cls, n, *args, addr=None, **kwargs): """Same as :meth:`~creamas.mp.MultiEnvironment.spawn`, but allows spawning multiple agents with the same initialization parameters simultaneously into **one** slave environment. :param str agent_cls: ``qualna...
python
async def spawn_n(self, agent_cls, n, *args, addr=None, **kwargs): """Same as :meth:`~creamas.mp.MultiEnvironment.spawn`, but allows spawning multiple agents with the same initialization parameters simultaneously into **one** slave environment. :param str agent_cls: ``qualna...
[ "async", "def", "spawn_n", "(", "self", ",", "agent_cls", ",", "n", ",", "*", "args", ",", "addr", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "addr", "is", "None", ":", "addr", "=", "await", "self", ".", "_get_smallest_env", "(", ")", ...
Same as :meth:`~creamas.mp.MultiEnvironment.spawn`, but allows spawning multiple agents with the same initialization parameters simultaneously into **one** slave environment. :param str agent_cls: ``qualname`` of the agent class. That is, the name should be in the form o...
[ "Same", "as", ":", "meth", ":", "~creamas", ".", "mp", ".", "MultiEnvironment", ".", "spawn", "but", "allows", "spawning", "multiple", "agents", "with", "the", "same", "initialization", "parameters", "simultaneously", "into", "**", "one", "**", "slave", "envir...
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L731-L755
train
Spawns agents in the slave environment with the given agent class and number of agents.
assamite/creamas
creamas/mp.py
MultiEnvironment.get_connections
def get_connections(self, data=True, as_coro=False): """Return connections from all the agents in the slave environments. :param bool data: If ``True``, returns also the data stored for each connection. :param bool as_coro: If ``True`` returns a coroutine, otherwise run...
python
def get_connections(self, data=True, as_coro=False): """Return connections from all the agents in the slave environments. :param bool data: If ``True``, returns also the data stored for each connection. :param bool as_coro: If ``True`` returns a coroutine, otherwise run...
[ "def", "get_connections", "(", "self", ",", "data", "=", "True", ",", "as_coro", "=", "False", ")", ":", "async", "def", "slave_task", "(", "addr", ",", "data", ")", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")"...
Return connections from all the agents in the slave environments. :param bool data: If ``True``, returns also the data stored for each connection. :param bool as_coro: If ``True`` returns a coroutine, otherwise runs the asynchronous calls to the slave environment ma...
[ "Return", "connections", "from", "all", "the", "agents", "in", "the", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L780-L799
train
Return connections from all the agents in the slave environments.
assamite/creamas
creamas/mp.py
MultiEnvironment.get_artifacts
def get_artifacts(self, agent_name=None): """Get all artifacts or all artifacts published by a specific agent. :param str agent_name: Optional. Name of the agent which artifacts are returned. :returns: All artifacts or all artifacts published by the agent. :rtype: list ...
python
def get_artifacts(self, agent_name=None): """Get all artifacts or all artifacts published by a specific agent. :param str agent_name: Optional. Name of the agent which artifacts are returned. :returns: All artifacts or all artifacts published by the agent. :rtype: list ...
[ "def", "get_artifacts", "(", "self", ",", "agent_name", "=", "None", ")", ":", "if", "agent_name", "is", "not", "None", ":", "return", "[", "a", "for", "a", "in", "self", ".", "artifacts", "if", "agent_name", "==", "a", ".", "creator", "]", "return", ...
Get all artifacts or all artifacts published by a specific agent. :param str agent_name: Optional. Name of the agent which artifacts are returned. :returns: All artifacts or all artifacts published by the agent. :rtype: list
[ "Get", "all", "artifacts", "or", "all", "artifacts", "published", "by", "a", "specific", "agent", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L825-L836
train
Get all artifacts or all artifacts published by a specific agent.
assamite/creamas
creamas/mp.py
MultiEnvironment.stop_slaves
async def stop_slaves(self, timeout=1): """Stop all the slaves by sending a stop-message to their managers. :param int timeout: Timeout for connecting to each manager. If a connection can not be made before the timeout expires, the resulting error for that particular...
python
async def stop_slaves(self, timeout=1): """Stop all the slaves by sending a stop-message to their managers. :param int timeout: Timeout for connecting to each manager. If a connection can not be made before the timeout expires, the resulting error for that particular...
[ "async", "def", "stop_slaves", "(", "self", ",", "timeout", "=", "1", ")", ":", "for", "addr", "in", "self", ".", "addrs", ":", "try", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ",", "timeout", "=", "timeout", ...
Stop all the slaves by sending a stop-message to their managers. :param int timeout: Timeout for connecting to each manager. If a connection can not be made before the timeout expires, the resulting error for that particular manager is logged, but the stopping of other manag...
[ "Stop", "all", "the", "slaves", "by", "sending", "a", "stop", "-", "message", "to", "their", "managers", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L852-L866
train
Stop all the slaves by sending a stop - message to each manager.
assamite/creamas
creamas/mp.py
MultiEnvironment.destroy
def destroy(self, folder=None, as_coro=False): """Destroy the multiprocessing environment and its slave environments. """ async def _destroy(folder): ret = self.save_info(folder) await self.stop_slaves() # Terminate and join the process pool when we are destro...
python
def destroy(self, folder=None, as_coro=False): """Destroy the multiprocessing environment and its slave environments. """ async def _destroy(folder): ret = self.save_info(folder) await self.stop_slaves() # Terminate and join the process pool when we are destro...
[ "def", "destroy", "(", "self", ",", "folder", "=", "None", ",", "as_coro", "=", "False", ")", ":", "async", "def", "_destroy", "(", "folder", ")", ":", "ret", "=", "self", ".", "save_info", "(", "folder", ")", "await", "self", ".", "stop_slaves", "("...
Destroy the multiprocessing environment and its slave environments.
[ "Destroy", "the", "multiprocessing", "environment", "and", "its", "slave", "environments", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/mp.py#L868-L883
train
Destroy the multiprocessing environment and its slave environments.
inveniosoftware/invenio-pidrelations
invenio_pidrelations/serializers/schemas.py
RelationSchema.dump_next
def dump_next(self, obj): """Dump the parent of a PID.""" if self._is_child(obj) and not obj.is_last_child(self.context['pid']): return self._dump_relative(obj.next_child(self.context['pid']))
python
def dump_next(self, obj): """Dump the parent of a PID.""" if self._is_child(obj) and not obj.is_last_child(self.context['pid']): return self._dump_relative(obj.next_child(self.context['pid']))
[ "def", "dump_next", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "_is_child", "(", "obj", ")", "and", "not", "obj", ".", "is_last_child", "(", "self", ".", "context", "[", "'pid'", "]", ")", ":", "return", "self", ".", "_dump_relative", "(",...
Dump the parent of a PID.
[ "Dump", "the", "parent", "of", "a", "PID", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/schemas.py#L63-L66
train
Dump the next child of a PID.