repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
CitrineInformatics/pypif-sdk
pypif_sdk/readview/core.py
add_child_ambig
def add_child_ambig(child_ambig, child_unambig, ambig, unambig): """ Add information about decodings of a child object :param child_ambig: ambiguous set from child :param child_unambig: unambiguous set from child :param ambig: set of keys storing ambig decodings :param unambig: dictionary stori...
python
def add_child_ambig(child_ambig, child_unambig, ambig, unambig): """ Add information about decodings of a child object :param child_ambig: ambiguous set from child :param child_unambig: unambiguous set from child :param ambig: set of keys storing ambig decodings :param unambig: dictionary stori...
[ "def", "add_child_ambig", "(", "child_ambig", ",", "child_unambig", ",", "ambig", ",", "unambig", ")", ":", "for", "k", "in", "child_ambig", ":", "ambig", ".", "add", "(", "k", ")", "if", "k", "in", "unambig", ":", "del", "unambig", "[", "k", "]", "f...
Add information about decodings of a child object :param child_ambig: ambiguous set from child :param child_unambig: unambiguous set from child :param ambig: set of keys storing ambig decodings :param unambig: dictionary storing unambiguous decodings :return:
[ "Add", "information", "about", "decodings", "of", "a", "child", "object" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/readview/core.py#L39-L57
CitrineInformatics/pypif-sdk
pypif_sdk/util/citrination.py
get_client
def get_client(site=None): """Get a citrination client""" if 'CITRINATION_API_KEY' not in environ: raise ValueError("'CITRINATION_API_KEY' is not set as an environment variable") if not site: site = environ.get("CITRINATION_SITE", "https://citrination.com") return CitrinationClient(envir...
python
def get_client(site=None): """Get a citrination client""" if 'CITRINATION_API_KEY' not in environ: raise ValueError("'CITRINATION_API_KEY' is not set as an environment variable") if not site: site = environ.get("CITRINATION_SITE", "https://citrination.com") return CitrinationClient(envir...
[ "def", "get_client", "(", "site", "=", "None", ")", ":", "if", "'CITRINATION_API_KEY'", "not", "in", "environ", ":", "raise", "ValueError", "(", "\"'CITRINATION_API_KEY' is not set as an environment variable\"", ")", "if", "not", "site", ":", "site", "=", "environ",...
Get a citrination client
[ "Get", "a", "citrination", "client" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/util/citrination.py#L6-L12
CitrineInformatics/pypif-sdk
pypif_sdk/util/citrination.py
set_uids
def set_uids(pifs, uids=None): """ Set the uids in a PIF, explicitly if the list of UIDs is passed in :param pifs: to set UIDs in :param uids: to set; defaults to a hash of the object :return: """ if not uids: uids = [str(hash(dumps(x))) for x in pifs] for pif, uid in zip(pifs, u...
python
def set_uids(pifs, uids=None): """ Set the uids in a PIF, explicitly if the list of UIDs is passed in :param pifs: to set UIDs in :param uids: to set; defaults to a hash of the object :return: """ if not uids: uids = [str(hash(dumps(x))) for x in pifs] for pif, uid in zip(pifs, u...
[ "def", "set_uids", "(", "pifs", ",", "uids", "=", "None", ")", ":", "if", "not", "uids", ":", "uids", "=", "[", "str", "(", "hash", "(", "dumps", "(", "x", ")", ")", ")", "for", "x", "in", "pifs", "]", "for", "pif", ",", "uid", "in", "zip", ...
Set the uids in a PIF, explicitly if the list of UIDs is passed in :param pifs: to set UIDs in :param uids: to set; defaults to a hash of the object :return:
[ "Set", "the", "uids", "in", "a", "PIF", "explicitly", "if", "the", "list", "of", "UIDs", "is", "passed", "in", ":", "param", "pifs", ":", "to", "set", "UIDs", "in", ":", "param", "uids", ":", "to", "set", ";", "defaults", "to", "a", "hash", "of", ...
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/util/citrination.py#L15-L26
CitrineInformatics/pypif-sdk
pypif_sdk/util/citrination.py
get_url
def get_url(pif, dataset, version=1, site="https://citrination.com"): """ Construct the URL of a PIF on a site :param pif: to construct URL for :param dataset: the pif will belong to :param version: of the PIF (default: 1) :param site: for the dataset (default: https://citrination.com) :retu...
python
def get_url(pif, dataset, version=1, site="https://citrination.com"): """ Construct the URL of a PIF on a site :param pif: to construct URL for :param dataset: the pif will belong to :param version: of the PIF (default: 1) :param site: for the dataset (default: https://citrination.com) :retu...
[ "def", "get_url", "(", "pif", ",", "dataset", ",", "version", "=", "1", ",", "site", "=", "\"https://citrination.com\"", ")", ":", "return", "\"{site}/datasets/{dataset}/version/{version}/pif/{uid}\"", ".", "format", "(", "uid", "=", "pif", ".", "uid", ",", "ver...
Construct the URL of a PIF on a site :param pif: to construct URL for :param dataset: the pif will belong to :param version: of the PIF (default: 1) :param site: for the dataset (default: https://citrination.com) :return: the URL as a string
[ "Construct", "the", "URL", "of", "a", "PIF", "on", "a", "site", ":", "param", "pif", ":", "to", "construct", "URL", "for", ":", "param", "dataset", ":", "the", "pif", "will", "belong", "to", ":", "param", "version", ":", "of", "the", "PIF", "(", "d...
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/util/citrination.py#L29-L40
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
calculate_ideal_atomic_percent
def calculate_ideal_atomic_percent(pif): """ Calculates ideal atomic percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object """ if not isinstance(pif, ChemicalSystem):...
python
def calculate_ideal_atomic_percent(pif): """ Calculates ideal atomic percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object """ if not isinstance(pif, ChemicalSystem):...
[ "def", "calculate_ideal_atomic_percent", "(", "pif", ")", ":", "if", "not", "isinstance", "(", "pif", ",", "ChemicalSystem", ")", ":", "return", "pif", "if", "not", "pif", ".", "chemical_formula", ":", "return", "pif", "else", ":", "expanded_formula_no_special_c...
Calculates ideal atomic percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object
[ "Calculates", "ideal", "atomic", "percents", "from", "a", "chemical", "formula", "string", "from", "a", "pif", ".", "Returns", "an", "appended", "pif", "with", "composition", "elements", "modified", "or", "added", "." ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L16-L51
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
calculate_ideal_weight_percent
def calculate_ideal_weight_percent(pif): """ Calculates ideal atomic weight percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object """ if not isinstance(pif, ChemicalS...
python
def calculate_ideal_weight_percent(pif): """ Calculates ideal atomic weight percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object """ if not isinstance(pif, ChemicalS...
[ "def", "calculate_ideal_weight_percent", "(", "pif", ")", ":", "if", "not", "isinstance", "(", "pif", ",", "ChemicalSystem", ")", ":", "return", "pif", "if", "not", "pif", ".", "chemical_formula", ":", "return", "pif", "else", ":", "expanded_formula_no_special_c...
Calculates ideal atomic weight percents from a chemical formula string from a pif. Returns an appended pif with composition elements modified or added. :param pif: a ChemicalSystem pif :return: modified pif object
[ "Calculates", "ideal", "atomic", "weight", "percents", "from", "a", "chemical", "formula", "string", "from", "a", "pif", ".", "Returns", "an", "appended", "pif", "with", "composition", "elements", "modified", "or", "added", "." ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L54-L90
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_expand_formula_
def _expand_formula_(formula_string): """ Accounts for the many ways a user may write a formula string, and returns an expanded chemical formula string. Assumptions: -The Chemical Formula string it is supplied is well-written, and has no hanging parethneses -The number of repeats occurs after the el...
python
def _expand_formula_(formula_string): """ Accounts for the many ways a user may write a formula string, and returns an expanded chemical formula string. Assumptions: -The Chemical Formula string it is supplied is well-written, and has no hanging parethneses -The number of repeats occurs after the el...
[ "def", "_expand_formula_", "(", "formula_string", ")", ":", "formula_string", "=", "re", ".", "sub", "(", "r'[^A-Za-z0-9\\(\\)\\[\\]\\·\\.]+',", " ", "',", " ", "ormula_string)", "", "hydrate_pos", "=", "formula_string", ".", "find", "(", "'·')", "", "if", "hydr...
Accounts for the many ways a user may write a formula string, and returns an expanded chemical formula string. Assumptions: -The Chemical Formula string it is supplied is well-written, and has no hanging parethneses -The number of repeats occurs after the elemental symbol or ) ] character EXCEPT in the case...
[ "Accounts", "for", "the", "many", "ways", "a", "user", "may", "write", "a", "formula", "string", "and", "returns", "an", "expanded", "chemical", "formula", "string", ".", "Assumptions", ":", "-", "The", "Chemical", "Formula", "string", "it", "is", "supplied"...
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L93-L142
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_expand_hydrate_
def _expand_hydrate_(hydrate_pos, formula_string): """ Handles the expansion of hydrate portions of a chemical formula, and expands out the coefficent to all elements :param hydrate_pos: the index in the formula_string of the · symbol :param formula_string: the unexpanded formula string :return: a ...
python
def _expand_hydrate_(hydrate_pos, formula_string): """ Handles the expansion of hydrate portions of a chemical formula, and expands out the coefficent to all elements :param hydrate_pos: the index in the formula_string of the · symbol :param formula_string: the unexpanded formula string :return: a ...
[ "def", "_expand_hydrate_", "(", "hydrate_pos", ",", "formula_string", ")", ":", "hydrate", "=", "formula_string", "[", "hydrate_pos", "+", "1", ":", "]", "hydrate_string", "=", "\"\"", "multiplier", "=", "float", "(", "re", ".", "search", "(", "r'^[\\d\\.]+'",...
Handles the expansion of hydrate portions of a chemical formula, and expands out the coefficent to all elements :param hydrate_pos: the index in the formula_string of the · symbol :param formula_string: the unexpanded formula string :return: a formula string without the · character with the hydrate portion...
[ "Handles", "the", "expansion", "of", "hydrate", "portions", "of", "a", "chemical", "formula", "and", "expands", "out", "the", "coefficent", "to", "all", "elements" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L145-L171
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_create_compositional_array_
def _create_compositional_array_(expanded_chemical_formaula_string): """ Splits an expanded chemical formula string into an array of dictionaries containing information about each element :param expanded_chemical_formaula_string: a clean (not necessarily emperical, but without any special characters) chemi...
python
def _create_compositional_array_(expanded_chemical_formaula_string): """ Splits an expanded chemical formula string into an array of dictionaries containing information about each element :param expanded_chemical_formaula_string: a clean (not necessarily emperical, but without any special characters) chemi...
[ "def", "_create_compositional_array_", "(", "expanded_chemical_formaula_string", ")", ":", "element_array", "=", "re", ".", "findall", "(", "'[A-Z][^A-Z]*'", ",", "expanded_chemical_formaula_string", ")", "split_element_array", "=", "[", "]", "for", "s", "in", "element_...
Splits an expanded chemical formula string into an array of dictionaries containing information about each element :param expanded_chemical_formaula_string: a clean (not necessarily emperical, but without any special characters) chemical formula string, as returned by _expand_formula_() :return: an array of di...
[ "Splits", "an", "expanded", "chemical", "formula", "string", "into", "an", "array", "of", "dictionaries", "containing", "information", "about", "each", "element" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L174-L194
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_consolidate_elemental_array_
def _consolidate_elemental_array_(elemental_array): """ Accounts for non-empirical chemical formulas by taking in the compositional array generated by _create_compositional_array_() and returning a consolidated array of dictionaries with no repeating elements :param elemental_array: an elemental array gene...
python
def _consolidate_elemental_array_(elemental_array): """ Accounts for non-empirical chemical formulas by taking in the compositional array generated by _create_compositional_array_() and returning a consolidated array of dictionaries with no repeating elements :param elemental_array: an elemental array gene...
[ "def", "_consolidate_elemental_array_", "(", "elemental_array", ")", ":", "condensed_array", "=", "[", "]", "for", "e", "in", "elemental_array", ":", "exists", "=", "False", "for", "k", "in", "condensed_array", ":", "if", "k", "[", "\"symbol\"", "]", "==", "...
Accounts for non-empirical chemical formulas by taking in the compositional array generated by _create_compositional_array_() and returning a consolidated array of dictionaries with no repeating elements :param elemental_array: an elemental array generated from _create_compositional_array_() :return: an array ...
[ "Accounts", "for", "non", "-", "empirical", "chemical", "formulas", "by", "taking", "in", "the", "compositional", "array", "generated", "by", "_create_compositional_array_", "()", "and", "returning", "a", "consolidated", "array", "of", "dictionaries", "with", "no", ...
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L197-L214
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_add_ideal_atomic_weights_
def _add_ideal_atomic_weights_(elemental_array): """ Uses elements.json to find the molar mass of the element in question, and then multiplies that by the occurances of the element. Adds the "weight" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionarie...
python
def _add_ideal_atomic_weights_(elemental_array): """ Uses elements.json to find the molar mass of the element in question, and then multiplies that by the occurances of the element. Adds the "weight" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionarie...
[ "def", "_add_ideal_atomic_weights_", "(", "elemental_array", ")", ":", "for", "a", "in", "elemental_array", ":", "this_atomic_weight", "=", "elements_data", "[", "a", "[", "\"symbol\"", "]", "]", "[", "\"atomic_weight\"", "]", "a", "[", "\"weight\"", "]", "=", ...
Uses elements.json to find the molar mass of the element in question, and then multiplies that by the occurances of the element. Adds the "weight" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionaries containing information about the elements in the system ...
[ "Uses", "elements", ".", "json", "to", "find", "the", "molar", "mass", "of", "the", "element", "in", "question", "and", "then", "multiplies", "that", "by", "the", "occurances", "of", "the", "element", ".", "Adds", "the", "weight", "property", "to", "each",...
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L227-L238
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_add_ideal_weight_percent_
def _add_ideal_weight_percent_(elemental_array): """ Adds the "weight_percent" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the appended elemental_array """ t_mass = _cal...
python
def _add_ideal_weight_percent_(elemental_array): """ Adds the "weight_percent" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the appended elemental_array """ t_mass = _cal...
[ "def", "_add_ideal_weight_percent_", "(", "elemental_array", ")", ":", "t_mass", "=", "_calculate_total_mass_", "(", "elemental_array", ")", "for", "a", "in", "elemental_array", ":", "a", "[", "\"weight_percent\"", "]", "=", "a", "[", "\"weight\"", "]", "/", "t_...
Adds the "weight_percent" property to each of the dictionaries in elemental_array :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the appended elemental_array
[ "Adds", "the", "weight_percent", "property", "to", "each", "of", "the", "dictionaries", "in", "elemental_array" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L251-L261
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_add_atomic_percents_
def _add_atomic_percents_(elemental_array): """ Adds ideal atomic percents to a emperical compositional element array generated using _create_emprical_compositional_array_() :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the elemental_a...
python
def _add_atomic_percents_(elemental_array): """ Adds ideal atomic percents to a emperical compositional element array generated using _create_emprical_compositional_array_() :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the elemental_a...
[ "def", "_add_atomic_percents_", "(", "elemental_array", ")", ":", "n_atoms", "=", "_calculate_n_atoms_", "(", "elemental_array", ")", "for", "e", "in", "elemental_array", ":", "e", "[", "\"atomic_percent\"", "]", "=", "e", "[", "\"occurances\"", "]", "/", "n_ato...
Adds ideal atomic percents to a emperical compositional element array generated using _create_emprical_compositional_array_() :param elemental_array: an array of dictionaries containing information about the elements in the system :return: the elemental_array with the atomic percent of each element added
[ "Adds", "ideal", "atomic", "percents", "to", "a", "emperical", "compositional", "element", "array", "generated", "using", "_create_emprical_compositional_array_", "()" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L277-L287
CitrineInformatics/pypif-sdk
pypif_sdk/func/calculate_funcs.py
_get_element_in_pif_composition_
def _get_element_in_pif_composition_(pif, elemental_symbol): """ If the element in question if in the composition array in the pif, it returns that Composition object and the position in the composition array otherwise it returns False :param pif: ChemicalSystem Pif in question :param elemental_symbol:...
python
def _get_element_in_pif_composition_(pif, elemental_symbol): """ If the element in question if in the composition array in the pif, it returns that Composition object and the position in the composition array otherwise it returns False :param pif: ChemicalSystem Pif in question :param elemental_symbol:...
[ "def", "_get_element_in_pif_composition_", "(", "pif", ",", "elemental_symbol", ")", ":", "if", "pif", ".", "composition", "is", "None", ":", "pif", ".", "composition", "=", "[", "]", "for", "i", ",", "c", "in", "enumerate", "(", "pif", ".", "composition",...
If the element in question if in the composition array in the pif, it returns that Composition object and the position in the composition array otherwise it returns False :param pif: ChemicalSystem Pif in question :param elemental_symbol: string of the atomic symbol of the element in question :return: eith...
[ "If", "the", "element", "in", "question", "if", "in", "the", "composition", "array", "in", "the", "pif", "it", "returns", "that", "Composition", "object", "and", "the", "position", "in", "the", "composition", "array", "otherwise", "it", "returns", "False" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/calculate_funcs.py#L290-L305
CitrineInformatics/pypif-sdk
pypif_sdk/interop/datacite.py
parse_name_string
def parse_name_string(full_name): """ Parse a full name into a Name object :param full_name: e.g. "John Smith" or "Smith, John" :return: Name object """ name = Name() if "," in full_name: toks = full_name.split(",") name.family = toks[0] name.given = ",".join(toks[1:...
python
def parse_name_string(full_name): """ Parse a full name into a Name object :param full_name: e.g. "John Smith" or "Smith, John" :return: Name object """ name = Name() if "," in full_name: toks = full_name.split(",") name.family = toks[0] name.given = ",".join(toks[1:...
[ "def", "parse_name_string", "(", "full_name", ")", ":", "name", "=", "Name", "(", ")", "if", "\",\"", "in", "full_name", ":", "toks", "=", "full_name", ".", "split", "(", "\",\"", ")", "name", ".", "family", "=", "toks", "[", "0", "]", "name", ".", ...
Parse a full name into a Name object :param full_name: e.g. "John Smith" or "Smith, John" :return: Name object
[ "Parse", "a", "full", "name", "into", "a", "Name", "object" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/datacite.py#L5-L21
CitrineInformatics/pypif-sdk
pypif_sdk/interop/datacite.py
creator_to_person
def creator_to_person(creator): """ Parse the creator block in datacite into a Person :param creator: block in datacite format :return: Person """ name = Name() if "creatorName" in creator: name = parse_name_string(creator["creatorName"]) if "familyName" in creator: name....
python
def creator_to_person(creator): """ Parse the creator block in datacite into a Person :param creator: block in datacite format :return: Person """ name = Name() if "creatorName" in creator: name = parse_name_string(creator["creatorName"]) if "familyName" in creator: name....
[ "def", "creator_to_person", "(", "creator", ")", ":", "name", "=", "Name", "(", ")", "if", "\"creatorName\"", "in", "creator", ":", "name", "=", "parse_name_string", "(", "creator", "[", "\"creatorName\"", "]", ")", "if", "\"familyName\"", "in", "creator", "...
Parse the creator block in datacite into a Person :param creator: block in datacite format :return: Person
[ "Parse", "the", "creator", "block", "in", "datacite", "into", "a", "Person", ":", "param", "creator", ":", "block", "in", "datacite", "format", ":", "return", ":", "Person" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/datacite.py#L24-L39
CitrineInformatics/pypif-sdk
pypif_sdk/interop/datacite.py
datacite_to_pif_reference
def datacite_to_pif_reference(dc): """ Parse a top-level datacite dictionary into a Reference :param dc: dictionary containing datacite metadata :return: Reference corresponding to that datacite entry """ ref = Reference() if dc.get('identifier', {}).get('identifierType') == "DOI": r...
python
def datacite_to_pif_reference(dc): """ Parse a top-level datacite dictionary into a Reference :param dc: dictionary containing datacite metadata :return: Reference corresponding to that datacite entry """ ref = Reference() if dc.get('identifier', {}).get('identifierType') == "DOI": r...
[ "def", "datacite_to_pif_reference", "(", "dc", ")", ":", "ref", "=", "Reference", "(", ")", "if", "dc", ".", "get", "(", "'identifier'", ",", "{", "}", ")", ".", "get", "(", "'identifierType'", ")", "==", "\"DOI\"", ":", "ref", ".", "doi", "=", "dc",...
Parse a top-level datacite dictionary into a Reference :param dc: dictionary containing datacite metadata :return: Reference corresponding to that datacite entry
[ "Parse", "a", "top", "-", "level", "datacite", "dictionary", "into", "a", "Reference", ":", "param", "dc", ":", "dictionary", "containing", "datacite", "metadata", ":", "return", ":", "Reference", "corresponding", "to", "that", "datacite", "entry" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/datacite.py#L42-L57
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
query_to_mdf_records
def query_to_mdf_records(query=None, dataset_id=None, mdf_acl=None): """Evaluate a query and return a list of MDF records If a datasetID is specified by there is no query, a simple whole dataset query is formed for the user """ if not query and not dataset_id: raise ValueError("Either query...
python
def query_to_mdf_records(query=None, dataset_id=None, mdf_acl=None): """Evaluate a query and return a list of MDF records If a datasetID is specified by there is no query, a simple whole dataset query is formed for the user """ if not query and not dataset_id: raise ValueError("Either query...
[ "def", "query_to_mdf_records", "(", "query", "=", "None", ",", "dataset_id", "=", "None", ",", "mdf_acl", "=", "None", ")", ":", "if", "not", "query", "and", "not", "dataset_id", ":", "raise", "ValueError", "(", "\"Either query or dataset_id must be specified\"", ...
Evaluate a query and return a list of MDF records If a datasetID is specified by there is no query, a simple whole dataset query is formed for the user
[ "Evaluate", "a", "query", "and", "return", "a", "list", "of", "MDF", "records" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L11-L56
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
pif_to_mdf_record
def pif_to_mdf_record(pif_obj, dataset_hit, mdf_acl): """Convert a PIF into partial MDF record""" res = {} res["mdf"] = _to_meta_data(pif_obj, dataset_hit, mdf_acl) res[res["mdf"]["source_name"]] = _to_user_defined(pif_obj) return dumps(res)
python
def pif_to_mdf_record(pif_obj, dataset_hit, mdf_acl): """Convert a PIF into partial MDF record""" res = {} res["mdf"] = _to_meta_data(pif_obj, dataset_hit, mdf_acl) res[res["mdf"]["source_name"]] = _to_user_defined(pif_obj) return dumps(res)
[ "def", "pif_to_mdf_record", "(", "pif_obj", ",", "dataset_hit", ",", "mdf_acl", ")", ":", "res", "=", "{", "}", "res", "[", "\"mdf\"", "]", "=", "_to_meta_data", "(", "pif_obj", ",", "dataset_hit", ",", "mdf_acl", ")", "res", "[", "res", "[", "\"mdf\"", ...
Convert a PIF into partial MDF record
[ "Convert", "a", "PIF", "into", "partial", "MDF", "record" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L59-L64
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
_to_meta_data
def _to_meta_data(pif_obj, dataset_hit, mdf_acl): """Convert the meta-data from the PIF into MDF""" pif = pif_obj.as_dictionary() dataset = dataset_hit.as_dictionary() mdf = {} try: if pif.get("names"): mdf["title"] = pif["names"][0] else: mdf["title"] = "Citr...
python
def _to_meta_data(pif_obj, dataset_hit, mdf_acl): """Convert the meta-data from the PIF into MDF""" pif = pif_obj.as_dictionary() dataset = dataset_hit.as_dictionary() mdf = {} try: if pif.get("names"): mdf["title"] = pif["names"][0] else: mdf["title"] = "Citr...
[ "def", "_to_meta_data", "(", "pif_obj", ",", "dataset_hit", ",", "mdf_acl", ")", ":", "pif", "=", "pif_obj", ".", "as_dictionary", "(", ")", "dataset", "=", "dataset_hit", ".", "as_dictionary", "(", ")", "mdf", "=", "{", "}", "try", ":", "if", "pif", "...
Convert the meta-data from the PIF into MDF
[ "Convert", "the", "meta", "-", "data", "from", "the", "PIF", "into", "MDF" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L67-L149
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
_to_user_defined
def _to_user_defined(pif_obj): """Read the systems in the PIF to populate the user-defined portion""" res = {} # make a read view to flatten the hierarchy rv = ReadView(pif_obj) # Iterate over the keys in the read view for k in rv.keys(): name, value = _extract_key_value(rv[k].raw) ...
python
def _to_user_defined(pif_obj): """Read the systems in the PIF to populate the user-defined portion""" res = {} # make a read view to flatten the hierarchy rv = ReadView(pif_obj) # Iterate over the keys in the read view for k in rv.keys(): name, value = _extract_key_value(rv[k].raw) ...
[ "def", "_to_user_defined", "(", "pif_obj", ")", ":", "res", "=", "{", "}", "# make a read view to flatten the hierarchy", "rv", "=", "ReadView", "(", "pif_obj", ")", "# Iterate over the keys in the read view", "for", "k", "in", "rv", ".", "keys", "(", ")", ":", ...
Read the systems in the PIF to populate the user-defined portion
[ "Read", "the", "systems", "in", "the", "PIF", "to", "populate", "the", "user", "-", "defined", "portion" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L152-L205
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
_construct_new_key
def _construct_new_key(name, units=None): """Construct an MDF safe key from the name and units""" to_replace = ["/", "\\", "*", "^", "#", " ", "\n", "\t", ",", ".", ")", "(", "'", "`", "-"] to_remove = ["$", "{", "}"] cat = name if units: cat = "_".join([name, units]) for c in to_replac...
python
def _construct_new_key(name, units=None): """Construct an MDF safe key from the name and units""" to_replace = ["/", "\\", "*", "^", "#", " ", "\n", "\t", ",", ".", ")", "(", "'", "`", "-"] to_remove = ["$", "{", "}"] cat = name if units: cat = "_".join([name, units]) for c in to_replac...
[ "def", "_construct_new_key", "(", "name", ",", "units", "=", "None", ")", ":", "to_replace", "=", "[", "\"/\"", ",", "\"\\\\\"", ",", "\"*\"", ",", "\"^\"", ",", "\"#\"", ",", "\" \"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "\",\"", ",", "\".\"", ",", ...
Construct an MDF safe key from the name and units
[ "Construct", "an", "MDF", "safe", "key", "from", "the", "name", "and", "units" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L208-L223
CitrineInformatics/pypif-sdk
pypif_sdk/interop/mdf.py
_extract_key_value
def _extract_key_value(obj): """Extract the value from the object and make a descriptive key""" key = None; value = None # Parse a Value object, which includes Properties if isinstance(obj, Value): key = _construct_new_key(obj.name, obj.units) value = [] if obj.scalars: ...
python
def _extract_key_value(obj): """Extract the value from the object and make a descriptive key""" key = None; value = None # Parse a Value object, which includes Properties if isinstance(obj, Value): key = _construct_new_key(obj.name, obj.units) value = [] if obj.scalars: ...
[ "def", "_extract_key_value", "(", "obj", ")", ":", "key", "=", "None", "value", "=", "None", "# Parse a Value object, which includes Properties", "if", "isinstance", "(", "obj", ",", "Value", ")", ":", "key", "=", "_construct_new_key", "(", "obj", ".", "name", ...
Extract the value from the object and make a descriptive key
[ "Extract", "the", "value", "from", "the", "object", "and", "make", "a", "descriptive", "key" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/mdf.py#L226-L251
innogames/polysh
polysh/stdin.py
process_input_buffer
def process_input_buffer(): """Send the content of the input buffer to all remote processes, this must be called in the main thread""" from polysh.control_commands_helpers import handle_control_command data = the_stdin_thread.input_buffer.get() remote_dispatcher.log(b'> ' + data) if data.starts...
python
def process_input_buffer(): """Send the content of the input buffer to all remote processes, this must be called in the main thread""" from polysh.control_commands_helpers import handle_control_command data = the_stdin_thread.input_buffer.get() remote_dispatcher.log(b'> ' + data) if data.starts...
[ "def", "process_input_buffer", "(", ")", ":", "from", "polysh", ".", "control_commands_helpers", "import", "handle_control_command", "data", "=", "the_stdin_thread", ".", "input_buffer", ".", "get", "(", ")", "remote_dispatcher", ".", "log", "(", "b'> '", "+", "da...
Send the content of the input buffer to all remote processes, this must be called in the main thread
[ "Send", "the", "content", "of", "the", "input", "buffer", "to", "all", "remote", "processes", "this", "must", "be", "called", "in", "the", "main", "thread" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L60-L104
innogames/polysh
polysh/stdin.py
write_main_socket
def write_main_socket(c): """Synchronous write to the main socket, wait for ACK""" the_stdin_thread.socket_write.send(c) while True: try: the_stdin_thread.socket_write.recv(1) except socket.error as e: if e.errno != errno.EINTR: raise else: ...
python
def write_main_socket(c): """Synchronous write to the main socket, wait for ACK""" the_stdin_thread.socket_write.send(c) while True: try: the_stdin_thread.socket_write.recv(1) except socket.error as e: if e.errno != errno.EINTR: raise else: ...
[ "def", "write_main_socket", "(", "c", ")", ":", "the_stdin_thread", ".", "socket_write", ".", "send", "(", "c", ")", "while", "True", ":", "try", ":", "the_stdin_thread", ".", "socket_write", ".", "recv", "(", "1", ")", "except", "socket", ".", "error", ...
Synchronous write to the main socket, wait for ACK
[ "Synchronous", "write", "to", "the", "main", "socket", "wait", "for", "ACK" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L149-L159
innogames/polysh
polysh/stdin.py
get_stdin_pid
def get_stdin_pid(cached_result=None): """Try to get the PID of the stdin thread, otherwise get the whole process ID""" if cached_result is None: try: tasks = os.listdir('/proc/self/task') except OSError as e: if e.errno != errno.ENOENT: raise ...
python
def get_stdin_pid(cached_result=None): """Try to get the PID of the stdin thread, otherwise get the whole process ID""" if cached_result is None: try: tasks = os.listdir('/proc/self/task') except OSError as e: if e.errno != errno.ENOENT: raise ...
[ "def", "get_stdin_pid", "(", "cached_result", "=", "None", ")", ":", "if", "cached_result", "is", "None", ":", "try", ":", "tasks", "=", "os", ".", "listdir", "(", "'/proc/self/task'", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", ...
Try to get the PID of the stdin thread, otherwise get the whole process ID
[ "Try", "to", "get", "the", "PID", "of", "the", "stdin", "thread", "otherwise", "get", "the", "whole", "process", "ID" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L172-L186
innogames/polysh
polysh/stdin.py
interrupt_stdin_thread
def interrupt_stdin_thread(): """The stdin thread may be in raw_input(), get out of it""" dupped_stdin = os.dup(0) # Backup the stdin fd assert not the_stdin_thread.interrupt_asked # Sanity check the_stdin_thread.interrupt_asked = True # Not user triggered os.lseek(tempfile_fd, 0, 0) # Rewind in...
python
def interrupt_stdin_thread(): """The stdin thread may be in raw_input(), get out of it""" dupped_stdin = os.dup(0) # Backup the stdin fd assert not the_stdin_thread.interrupt_asked # Sanity check the_stdin_thread.interrupt_asked = True # Not user triggered os.lseek(tempfile_fd, 0, 0) # Rewind in...
[ "def", "interrupt_stdin_thread", "(", ")", ":", "dupped_stdin", "=", "os", ".", "dup", "(", "0", ")", "# Backup the stdin fd", "assert", "not", "the_stdin_thread", ".", "interrupt_asked", "# Sanity check", "the_stdin_thread", ".", "interrupt_asked", "=", "True", "# ...
The stdin thread may be in raw_input(), get out of it
[ "The", "stdin", "thread", "may", "be", "in", "raw_input", "()", "get", "out", "of", "it" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L189-L201
innogames/polysh
polysh/stdin.py
InputBuffer.add
def add(self, data): """Add data to the buffer""" assert isinstance(data, bytes) with self.lock: self.buf += data
python
def add(self, data): """Add data to the buffer""" assert isinstance(data, bytes) with self.lock: self.buf += data
[ "def", "add", "(", "self", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "with", "self", ".", "lock", ":", "self", ".", "buf", "+=", "data" ]
Add data to the buffer
[ "Add", "data", "to", "the", "buffer" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L45-L49
innogames/polysh
polysh/stdin.py
InputBuffer.get
def get(self): """Get the content of the buffer""" data = b'' with self.lock: data, self.buf = self.buf, b'' return data
python
def get(self): """Get the content of the buffer""" data = b'' with self.lock: data, self.buf = self.buf, b'' return data
[ "def", "get", "(", "self", ")", ":", "data", "=", "b''", "with", "self", ".", "lock", ":", "data", ",", "self", ".", "buf", "=", "self", ".", "buf", ",", "b''", "return", "data" ]
Get the content of the buffer
[ "Get", "the", "content", "of", "the", "buffer" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L51-L57
innogames/polysh
polysh/stdin.py
SocketNotificationReader.handle_read
def handle_read(self): """Handle all the available character commands in the socket""" while True: try: c = self.recv(1) except socket.error as e: if e.errno == errno.EWOULDBLOCK: return else: ...
python
def handle_read(self): """Handle all the available character commands in the socket""" while True: try: c = self.recv(1) except socket.error as e: if e.errno == errno.EWOULDBLOCK: return else: ...
[ "def", "handle_read", "(", "self", ")", ":", "while", "True", ":", "try", ":", "c", "=", "self", ".", "recv", "(", "1", ")", "except", "socket", ".", "error", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "EWOULDBLOCK", ":", "retur...
Handle all the available character commands in the socket
[ "Handle", "all", "the", "available", "character", "commands", "in", "the", "socket" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/stdin.py#L128-L142
nschloe/accupy
accupy/sums.py
knuth_sum
def knuth_sum(a, b): """Error-free transformation of the sum of two floating point numbers according to D.E. Knuth. The Art of Computer Programming: Seminumerical Algorithms, volume 2. Addison Wesley, Reading, Massachusetts, second edition, 1981. The underlying problem is that the exact sum a+...
python
def knuth_sum(a, b): """Error-free transformation of the sum of two floating point numbers according to D.E. Knuth. The Art of Computer Programming: Seminumerical Algorithms, volume 2. Addison Wesley, Reading, Massachusetts, second edition, 1981. The underlying problem is that the exact sum a+...
[ "def", "knuth_sum", "(", "a", ",", "b", ")", ":", "x", "=", "a", "+", "b", "z", "=", "x", "-", "a", "y", "=", "(", "a", "-", "(", "x", "-", "z", ")", ")", "+", "(", "b", "-", "z", ")", "return", "x", ",", "y" ]
Error-free transformation of the sum of two floating point numbers according to D.E. Knuth. The Art of Computer Programming: Seminumerical Algorithms, volume 2. Addison Wesley, Reading, Massachusetts, second edition, 1981. The underlying problem is that the exact sum a+b of two floating point ...
[ "Error", "-", "free", "transformation", "of", "the", "sum", "of", "two", "floating", "point", "numbers", "according", "to" ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L10-L30
nschloe/accupy
accupy/sums.py
decker_sum
def decker_sum(a, b): """Computationally equivalent to knuth_sum, but formally a bit cheaper. Only works for floats though (and not arrays), and the branch make it in fact less favorable in terms of actual speed. """ x = a + b y = b - (x - a) if abs(a) > abs(b) else a - (x - b) return x, y
python
def decker_sum(a, b): """Computationally equivalent to knuth_sum, but formally a bit cheaper. Only works for floats though (and not arrays), and the branch make it in fact less favorable in terms of actual speed. """ x = a + b y = b - (x - a) if abs(a) > abs(b) else a - (x - b) return x, y
[ "def", "decker_sum", "(", "a", ",", "b", ")", ":", "x", "=", "a", "+", "b", "y", "=", "b", "-", "(", "x", "-", "a", ")", "if", "abs", "(", "a", ")", ">", "abs", "(", "b", ")", "else", "a", "-", "(", "x", "-", "b", ")", "return", "x", ...
Computationally equivalent to knuth_sum, but formally a bit cheaper. Only works for floats though (and not arrays), and the branch make it in fact less favorable in terms of actual speed.
[ "Computationally", "equivalent", "to", "knuth_sum", "but", "formally", "a", "bit", "cheaper", ".", "Only", "works", "for", "floats", "though", "(", "and", "not", "arrays", ")", "and", "the", "branch", "make", "it", "in", "fact", "less", "favorable", "in", ...
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L33-L40
nschloe/accupy
accupy/sums.py
distill
def distill(p, K): """Algorithm 4.3. Error-free vector transformation for summation. The vector p is transformed without changing the sum, and p_n is replaced by float(sum(p)). Kahan [21] calls this a 'distillation algorithm.' """ q = p.reshape(p.shape[0], -1) for _ in range(K): _accupy...
python
def distill(p, K): """Algorithm 4.3. Error-free vector transformation for summation. The vector p is transformed without changing the sum, and p_n is replaced by float(sum(p)). Kahan [21] calls this a 'distillation algorithm.' """ q = p.reshape(p.shape[0], -1) for _ in range(K): _accupy...
[ "def", "distill", "(", "p", ",", "K", ")", ":", "q", "=", "p", ".", "reshape", "(", "p", ".", "shape", "[", "0", "]", ",", "-", "1", ")", "for", "_", "in", "range", "(", "K", ")", ":", "_accupy", ".", "distill", "(", "q", ")", "return", "...
Algorithm 4.3. Error-free vector transformation for summation. The vector p is transformed without changing the sum, and p_n is replaced by float(sum(p)). Kahan [21] calls this a 'distillation algorithm.'
[ "Algorithm", "4", ".", "3", ".", "Error", "-", "free", "vector", "transformation", "for", "summation", "." ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L43-L52
nschloe/accupy
accupy/sums.py
ksum
def ksum(p, K=2): """From T. Ogita, S.M. Rump, and S. Oishi. Accurate Sum and Dot Product, SIAM J. Sci. Comput., 26(6), 1955–1988 (34 pages). <https://doi.org/10.1137/030601818>. Algorithm 4.8. Summation as in K-fold precision by (K−1)-fold error-free vector transformation. """ # D...
python
def ksum(p, K=2): """From T. Ogita, S.M. Rump, and S. Oishi. Accurate Sum and Dot Product, SIAM J. Sci. Comput., 26(6), 1955–1988 (34 pages). <https://doi.org/10.1137/030601818>. Algorithm 4.8. Summation as in K-fold precision by (K−1)-fold error-free vector transformation. """ # D...
[ "def", "ksum", "(", "p", ",", "K", "=", "2", ")", ":", "# Don't override the input data.", "q", "=", "p", ".", "copy", "(", ")", "distill", "(", "q", ",", "K", "-", "1", ")", "return", "numpy", ".", "sum", "(", "q", "[", ":", "-", "1", "]", "...
From T. Ogita, S.M. Rump, and S. Oishi. Accurate Sum and Dot Product, SIAM J. Sci. Comput., 26(6), 1955–1988 (34 pages). <https://doi.org/10.1137/030601818>. Algorithm 4.8. Summation as in K-fold precision by (K−1)-fold error-free vector transformation.
[ "From" ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L55-L69
nschloe/accupy
accupy/sums.py
kahan_sum
def kahan_sum(p): """Kahan summation <https://en.wikipedia.org/wiki/Kahan_summation_algorithm>. """ q = p.reshape(p.shape[0], -1) s = _accupy.kahan(q) return s.reshape(p.shape[1:])
python
def kahan_sum(p): """Kahan summation <https://en.wikipedia.org/wiki/Kahan_summation_algorithm>. """ q = p.reshape(p.shape[0], -1) s = _accupy.kahan(q) return s.reshape(p.shape[1:])
[ "def", "kahan_sum", "(", "p", ")", ":", "q", "=", "p", ".", "reshape", "(", "p", ".", "shape", "[", "0", "]", ",", "-", "1", ")", "s", "=", "_accupy", ".", "kahan", "(", "q", ")", "return", "s", ".", "reshape", "(", "p", ".", "shape", "[", ...
Kahan summation <https://en.wikipedia.org/wiki/Kahan_summation_algorithm>.
[ "Kahan", "summation", "<https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Kahan_summation_algorithm", ">", "." ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/sums.py#L79-L85
innogames/polysh
polysh/control_commands_helpers.py
toggle_shells
def toggle_shells(command, enable): """Enable or disable the specified shells. If the command would have no effect, it changes all other shells to the inverse enable value.""" selection = list(selected_shells(command)) if command and command != '*' and selection: for i in selection: ...
python
def toggle_shells(command, enable): """Enable or disable the specified shells. If the command would have no effect, it changes all other shells to the inverse enable value.""" selection = list(selected_shells(command)) if command and command != '*' and selection: for i in selection: ...
[ "def", "toggle_shells", "(", "command", ",", "enable", ")", ":", "selection", "=", "list", "(", "selected_shells", "(", "command", ")", ")", "if", "command", "and", "command", "!=", "'*'", "and", "selection", ":", "for", "i", "in", "selection", ":", "if"...
Enable or disable the specified shells. If the command would have no effect, it changes all other shells to the inverse enable value.
[ "Enable", "or", "disable", "the", "specified", "shells", ".", "If", "the", "command", "would", "have", "no", "effect", "it", "changes", "all", "other", "shells", "to", "the", "inverse", "enable", "value", "." ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/control_commands_helpers.py#L29-L42
innogames/polysh
polysh/control_commands_helpers.py
selected_shells
def selected_shells(command): """Iterator over the shells with names matching the patterns. An empty patterns matches all the shells""" if not command or command == '*': for i in dispatchers.all_instances(): yield i return selected = set() instance_found = False for p...
python
def selected_shells(command): """Iterator over the shells with names matching the patterns. An empty patterns matches all the shells""" if not command or command == '*': for i in dispatchers.all_instances(): yield i return selected = set() instance_found = False for p...
[ "def", "selected_shells", "(", "command", ")", ":", "if", "not", "command", "or", "command", "==", "'*'", ":", "for", "i", "in", "dispatchers", ".", "all_instances", "(", ")", ":", "yield", "i", "return", "selected", "=", "set", "(", ")", "instance_found...
Iterator over the shells with names matching the patterns. An empty patterns matches all the shells
[ "Iterator", "over", "the", "shells", "with", "names", "matching", "the", "patterns", ".", "An", "empty", "patterns", "matches", "all", "the", "shells" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/control_commands_helpers.py#L45-L65
innogames/polysh
polysh/control_commands_helpers.py
complete_shells
def complete_shells(line, text, predicate=lambda i: True): """Return the shell names to include in the completion""" res = [i.display_name + ' ' for i in dispatchers.all_instances() if i.display_name.startswith(text) and predicate(i) and ' ' + i.display_name + ' ' not in line] ...
python
def complete_shells(line, text, predicate=lambda i: True): """Return the shell names to include in the completion""" res = [i.display_name + ' ' for i in dispatchers.all_instances() if i.display_name.startswith(text) and predicate(i) and ' ' + i.display_name + ' ' not in line] ...
[ "def", "complete_shells", "(", "line", ",", "text", ",", "predicate", "=", "lambda", "i", ":", "True", ")", ":", "res", "=", "[", "i", ".", "display_name", "+", "' '", "for", "i", "in", "dispatchers", ".", "all_instances", "(", ")", "if", "i", ".", ...
Return the shell names to include in the completion
[ "Return", "the", "shell", "names", "to", "include", "in", "the", "completion" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/control_commands_helpers.py#L68-L74
nschloe/accupy
accupy/dot.py
kdot
def kdot(x, y, K=2): """Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3. """ xx = x.reshape(-1, x.shape[-1]) yy = y.reshape(y.shape[0], -1) xx = numpy.ascontiguousarray(xx) yy = numpy.ascontiguousarray(yy) r = _accupy.kdot_helper(xx, yy).reshape((-1,) + x.shap...
python
def kdot(x, y, K=2): """Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3. """ xx = x.reshape(-1, x.shape[-1]) yy = y.reshape(y.shape[0], -1) xx = numpy.ascontiguousarray(xx) yy = numpy.ascontiguousarray(yy) r = _accupy.kdot_helper(xx, yy).reshape((-1,) + x.shap...
[ "def", "kdot", "(", "x", ",", "y", ",", "K", "=", "2", ")", ":", "xx", "=", "x", ".", "reshape", "(", "-", "1", ",", "x", ".", "shape", "[", "-", "1", "]", ")", "yy", "=", "y", ".", "reshape", "(", "y", ".", "shape", "[", "0", "]", ",...
Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3.
[ "Algorithm", "5", ".", "10", ".", "Dot", "product", "algorithm", "in", "K", "-", "fold", "working", "precision", "K", ">", "=", "3", "." ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/dot.py#L23-L34
nschloe/accupy
accupy/dot.py
fdot
def fdot(x, y): """Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3. """ xx = x.reshape(-1, x.shape[-1]) yy = y.reshape(y.shape[0], -1) xx = numpy.ascontiguousarray(xx) yy = numpy.ascontiguousarray(yy) r = _accupy.kdot_helper(xx, yy).reshape((-1,) + x.shape[:-1...
python
def fdot(x, y): """Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3. """ xx = x.reshape(-1, x.shape[-1]) yy = y.reshape(y.shape[0], -1) xx = numpy.ascontiguousarray(xx) yy = numpy.ascontiguousarray(yy) r = _accupy.kdot_helper(xx, yy).reshape((-1,) + x.shape[:-1...
[ "def", "fdot", "(", "x", ",", "y", ")", ":", "xx", "=", "x", ".", "reshape", "(", "-", "1", ",", "x", ".", "shape", "[", "-", "1", "]", ")", "yy", "=", "y", ".", "reshape", "(", "y", ".", "shape", "[", "0", "]", ",", "-", "1", ")", "x...
Algorithm 5.10. Dot product algorithm in K-fold working precision, K >= 3.
[ "Algorithm", "5", ".", "10", ".", "Dot", "product", "algorithm", "in", "K", "-", "fold", "working", "precision", "K", ">", "=", "3", "." ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/dot.py#L37-L48
innogames/polysh
polysh/main.py
kill_all
def kill_all(): """When polysh quits, we kill all the remote shells we started""" for i in dispatchers.all_instances(): try: os.kill(-i.pid, signal.SIGKILL) except OSError: # The process was already dead, no problem pass
python
def kill_all(): """When polysh quits, we kill all the remote shells we started""" for i in dispatchers.all_instances(): try: os.kill(-i.pid, signal.SIGKILL) except OSError: # The process was already dead, no problem pass
[ "def", "kill_all", "(", ")", ":", "for", "i", "in", "dispatchers", ".", "all_instances", "(", ")", ":", "try", ":", "os", ".", "kill", "(", "-", "i", ".", "pid", ",", "signal", ".", "SIGKILL", ")", "except", "OSError", ":", "# The process was already d...
When polysh quits, we kill all the remote shells we started
[ "When", "polysh", "quits", "we", "kill", "all", "the", "remote", "shells", "we", "started" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/main.py#L39-L46
innogames/polysh
polysh/main.py
run
def run(): """Launch polysh""" locale.setlocale(locale.LC_ALL, '') atexit.register(kill_all) signal.signal(signal.SIGPIPE, signal.SIG_DFL) args = parse_cmdline() args.command = find_non_interactive_command(args.command) args.exit_code = 0 args.interactive = ( not args.command ...
python
def run(): """Launch polysh""" locale.setlocale(locale.LC_ALL, '') atexit.register(kill_all) signal.signal(signal.SIGPIPE, signal.SIG_DFL) args = parse_cmdline() args.command = find_non_interactive_command(args.command) args.exit_code = 0 args.interactive = ( not args.command ...
[ "def", "run", "(", ")", ":", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "''", ")", "atexit", ".", "register", "(", "kill_all", ")", "signal", ".", "signal", "(", "signal", ".", "SIGPIPE", ",", "signal", ".", "SIG_DFL", ")", "args"...
Launch polysh
[ "Launch", "polysh" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/main.py#L220-L258
innogames/polysh
polysh/main.py
main
def main(): """Wrapper around run() to setup sentry""" sentry_dsn = os.environ.get('POLYSH_SENTRY_DSN') if sentry_dsn: from raven import Client client = Client( dsn=sentry_dsn, release='.'.join(map(str, VERSION)), ignore_exceptions=[ Keyb...
python
def main(): """Wrapper around run() to setup sentry""" sentry_dsn = os.environ.get('POLYSH_SENTRY_DSN') if sentry_dsn: from raven import Client client = Client( dsn=sentry_dsn, release='.'.join(map(str, VERSION)), ignore_exceptions=[ Keyb...
[ "def", "main", "(", ")", ":", "sentry_dsn", "=", "os", ".", "environ", ".", "get", "(", "'POLYSH_SENTRY_DSN'", ")", "if", "sentry_dsn", ":", "from", "raven", "import", "Client", "client", "=", "Client", "(", "dsn", "=", "sentry_dsn", ",", "release", "=",...
Wrapper around run() to setup sentry
[ "Wrapper", "around", "run", "()", "to", "setup", "sentry" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/main.py#L261-L282
innogames/polysh
polysh/buffered_dispatcher.py
BufferedDispatcher._handle_read_chunk
def _handle_read_chunk(self): """Some data can be read""" new_data = b'' buffer_length = len(self.read_buffer) try: while buffer_length < self.MAX_BUFFER_SIZE: try: piece = self.recv(4096) except OSError as e: ...
python
def _handle_read_chunk(self): """Some data can be read""" new_data = b'' buffer_length = len(self.read_buffer) try: while buffer_length < self.MAX_BUFFER_SIZE: try: piece = self.recv(4096) except OSError as e: ...
[ "def", "_handle_read_chunk", "(", "self", ")", ":", "new_data", "=", "b''", "buffer_length", "=", "len", "(", "self", ".", "read_buffer", ")", "try", ":", "while", "buffer_length", "<", "self", ".", "MAX_BUFFER_SIZE", ":", "try", ":", "piece", "=", "self",...
Some data can be read
[ "Some", "data", "can", "be", "read" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/buffered_dispatcher.py#L41-L71
innogames/polysh
polysh/buffered_dispatcher.py
BufferedDispatcher.dispatch_write
def dispatch_write(self, buf): """Augment the buffer with stuff to write when possible""" self.write_buffer += buf if len(self.write_buffer) > self.MAX_BUFFER_SIZE: console_output('Buffer too big ({:d}) for {}\n'.format( len(self.write_buffer), str(self)).encode()) ...
python
def dispatch_write(self, buf): """Augment the buffer with stuff to write when possible""" self.write_buffer += buf if len(self.write_buffer) > self.MAX_BUFFER_SIZE: console_output('Buffer too big ({:d}) for {}\n'.format( len(self.write_buffer), str(self)).encode()) ...
[ "def", "dispatch_write", "(", "self", ",", "buf", ")", ":", "self", ".", "write_buffer", "+=", "buf", "if", "len", "(", "self", ".", "write_buffer", ")", ">", "self", ".", "MAX_BUFFER_SIZE", ":", "console_output", "(", "'Buffer too big ({:d}) for {}\\n'", ".",...
Augment the buffer with stuff to write when possible
[ "Augment", "the", "buffer", "with", "stuff", "to", "write", "when", "possible" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/buffered_dispatcher.py#L81-L88
innogames/polysh
polysh/console.py
safe_write
def safe_write(buf): """We can get a SIGWINCH when printing, which will cause write to raise an EINTR. That's not a reason to stop printing.""" assert isinstance(buf, bytes) while True: try: os.write(1, buf) break except IOError as e: if e.errno != err...
python
def safe_write(buf): """We can get a SIGWINCH when printing, which will cause write to raise an EINTR. That's not a reason to stop printing.""" assert isinstance(buf, bytes) while True: try: os.write(1, buf) break except IOError as e: if e.errno != err...
[ "def", "safe_write", "(", "buf", ")", ":", "assert", "isinstance", "(", "buf", ",", "bytes", ")", "while", "True", ":", "try", ":", "os", ".", "write", "(", "1", ",", "buf", ")", "break", "except", "IOError", "as", "e", ":", "if", "e", ".", "errn...
We can get a SIGWINCH when printing, which will cause write to raise an EINTR. That's not a reason to stop printing.
[ "We", "can", "get", "a", "SIGWINCH", "when", "printing", "which", "will", "cause", "write", "to", "raise", "an", "EINTR", ".", "That", "s", "not", "a", "reason", "to", "stop", "printing", "." ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/console.py#L27-L37
innogames/polysh
polysh/console.py
console_output
def console_output(msg, logging_msg=None): """Use instead of print, to clear the status information before printing""" assert isinstance(msg, bytes) assert isinstance(logging_msg, bytes) or logging_msg is None from polysh import remote_dispatcher remote_dispatcher.log(logging_msg or msg) if re...
python
def console_output(msg, logging_msg=None): """Use instead of print, to clear the status information before printing""" assert isinstance(msg, bytes) assert isinstance(logging_msg, bytes) or logging_msg is None from polysh import remote_dispatcher remote_dispatcher.log(logging_msg or msg) if re...
[ "def", "console_output", "(", "msg", ",", "logging_msg", "=", "None", ")", ":", "assert", "isinstance", "(", "msg", ",", "bytes", ")", "assert", "isinstance", "(", "logging_msg", ",", "bytes", ")", "or", "logging_msg", "is", "None", "from", "polysh", "impo...
Use instead of print, to clear the status information before printing
[ "Use", "instead", "of", "print", "to", "clear", "the", "status", "information", "before", "printing" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/console.py#L40-L56
innogames/polysh
polysh/host_syntax.py
expand_syntax
def expand_syntax(string): """Iterator over all the strings in the expansion of the argument""" match = syntax_pattern.search(string) if match: prefix = string[:match.start()] suffix = string[match.end():] intervals = match.group(1).split(',') for interval in intervals: ...
python
def expand_syntax(string): """Iterator over all the strings in the expansion of the argument""" match = syntax_pattern.search(string) if match: prefix = string[:match.start()] suffix = string[match.end():] intervals = match.group(1).split(',') for interval in intervals: ...
[ "def", "expand_syntax", "(", "string", ")", ":", "match", "=", "syntax_pattern", ".", "search", "(", "string", ")", "if", "match", ":", "prefix", "=", "string", "[", ":", "match", ".", "start", "(", ")", "]", "suffix", "=", "string", "[", "match", "....
Iterator over all the strings in the expansion of the argument
[ "Iterator", "over", "all", "the", "strings", "in", "the", "expansion", "of", "the", "argument" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/host_syntax.py#L57-L73
innogames/polysh
polysh/dispatchers.py
all_instances
def all_instances(): """Iterator over all the remote_dispatcher instances""" return sorted([i for i in asyncore.socket_map.values() if isinstance(i, remote_dispatcher.RemoteDispatcher)], key=lambda i: i.display_name or '')
python
def all_instances(): """Iterator over all the remote_dispatcher instances""" return sorted([i for i in asyncore.socket_map.values() if isinstance(i, remote_dispatcher.RemoteDispatcher)], key=lambda i: i.display_name or '')
[ "def", "all_instances", "(", ")", ":", "return", "sorted", "(", "[", "i", "for", "i", "in", "asyncore", ".", "socket_map", ".", "values", "(", ")", "if", "isinstance", "(", "i", ",", "remote_dispatcher", ".", "RemoteDispatcher", ")", "]", ",", "key", "...
Iterator over all the remote_dispatcher instances
[ "Iterator", "over", "all", "the", "remote_dispatcher", "instances" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/dispatchers.py#L40-L44
innogames/polysh
polysh/dispatchers.py
count_awaited_processes
def count_awaited_processes(): """Return a tuple with the number of awaited processes and the total number""" awaited = 0 total = 0 for i in all_instances(): if i.enabled: total += 1 if i.state is not remote_dispatcher.STATE_IDLE: awaited += 1 retu...
python
def count_awaited_processes(): """Return a tuple with the number of awaited processes and the total number""" awaited = 0 total = 0 for i in all_instances(): if i.enabled: total += 1 if i.state is not remote_dispatcher.STATE_IDLE: awaited += 1 retu...
[ "def", "count_awaited_processes", "(", ")", ":", "awaited", "=", "0", "total", "=", "0", "for", "i", "in", "all_instances", "(", ")", ":", "if", "i", ".", "enabled", ":", "total", "+=", "1", "if", "i", ".", "state", "is", "not", "remote_dispatcher", ...
Return a tuple with the number of awaited processes and the total number
[ "Return", "a", "tuple", "with", "the", "number", "of", "awaited", "processes", "and", "the", "total", "number" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/dispatchers.py#L47-L57
innogames/polysh
polysh/dispatchers.py
all_terminated
def all_terminated(): """For each remote shell determine if its terminated""" instances_found = False for i in all_instances(): instances_found = True if i.state not in (remote_dispatcher.STATE_TERMINATED, remote_dispatcher.STATE_DEAD): return False ...
python
def all_terminated(): """For each remote shell determine if its terminated""" instances_found = False for i in all_instances(): instances_found = True if i.state not in (remote_dispatcher.STATE_TERMINATED, remote_dispatcher.STATE_DEAD): return False ...
[ "def", "all_terminated", "(", ")", ":", "instances_found", "=", "False", "for", "i", "in", "all_instances", "(", ")", ":", "instances_found", "=", "True", "if", "i", ".", "state", "not", "in", "(", "remote_dispatcher", ".", "STATE_TERMINATED", ",", "remote_d...
For each remote shell determine if its terminated
[ "For", "each", "remote", "shell", "determine", "if", "its", "terminated" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/dispatchers.py#L60-L68
innogames/polysh
polysh/dispatchers.py
update_terminal_size
def update_terminal_size(): """Propagate the terminal size to the remote shells accounting for the place taken by the longest name""" w, h = terminal_size() w = max(w - display_names.max_display_name_length - 2, min(w, 10)) # python bug http://python.org/sf/1112949 on amd64 # from ajaxterm.py ...
python
def update_terminal_size(): """Propagate the terminal size to the remote shells accounting for the place taken by the longest name""" w, h = terminal_size() w = max(w - display_names.max_display_name_length - 2, min(w, 10)) # python bug http://python.org/sf/1112949 on amd64 # from ajaxterm.py ...
[ "def", "update_terminal_size", "(", ")", ":", "w", ",", "h", "=", "terminal_size", "(", ")", "w", "=", "max", "(", "w", "-", "display_names", ".", "max_display_name_length", "-", "2", ",", "min", "(", "w", ",", "10", ")", ")", "# python bug http://python...
Propagate the terminal size to the remote shells accounting for the place taken by the longest name
[ "Propagate", "the", "terminal", "size", "to", "the", "remote", "shells", "accounting", "for", "the", "place", "taken", "by", "the", "longest", "name" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/dispatchers.py#L71-L84
innogames/polysh
polysh/dispatchers.py
format_info
def format_info(info_list): """Turn a 2-dimension list of bytes into a 1-dimension list of bytes with correct spacing""" max_lengths = [] if info_list: nr_columns = len(info_list[0]) else: nr_columns = 0 for i in range(nr_columns): max_lengths.append(max([len(info[i]) fo...
python
def format_info(info_list): """Turn a 2-dimension list of bytes into a 1-dimension list of bytes with correct spacing""" max_lengths = [] if info_list: nr_columns = len(info_list[0]) else: nr_columns = 0 for i in range(nr_columns): max_lengths.append(max([len(info[i]) fo...
[ "def", "format_info", "(", "info_list", ")", ":", "max_lengths", "=", "[", "]", "if", "info_list", ":", "nr_columns", "=", "len", "(", "info_list", "[", "0", "]", ")", "else", ":", "nr_columns", "=", "0", "for", "i", "in", "range", "(", "nr_columns", ...
Turn a 2-dimension list of bytes into a 1-dimension list of bytes with correct spacing
[ "Turn", "a", "2", "-", "dimension", "list", "of", "bytes", "into", "a", "1", "-", "dimension", "list", "of", "bytes", "with", "correct", "spacing" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/dispatchers.py#L87-L110
nschloe/accupy
accupy/ill_cond.py
generate_ill_conditioned_dot_product
def generate_ill_conditioned_dot_product(n, c, dps=100): """n ... length of vector c ... target condition number """ # Algorithm 6.1 from # # ACCURATE SUM AND DOT PRODUCT, # TAKESHI OGITA, SIEGFRIED M. RUMP, AND SHIN'ICHI OISHI. assert n >= 6 n2 = round(n / 2) x = numpy.zeros(n) ...
python
def generate_ill_conditioned_dot_product(n, c, dps=100): """n ... length of vector c ... target condition number """ # Algorithm 6.1 from # # ACCURATE SUM AND DOT PRODUCT, # TAKESHI OGITA, SIEGFRIED M. RUMP, AND SHIN'ICHI OISHI. assert n >= 6 n2 = round(n / 2) x = numpy.zeros(n) ...
[ "def", "generate_ill_conditioned_dot_product", "(", "n", ",", "c", ",", "dps", "=", "100", ")", ":", "# Algorithm 6.1 from", "#", "# ACCURATE SUM AND DOT PRODUCT,", "# TAKESHI OGITA, SIEGFRIED M. RUMP, AND SHIN'ICHI OISHI.", "assert", "n", ">=", "6", "n2", "=", "round", ...
n ... length of vector c ... target condition number
[ "n", "...", "length", "of", "vector", "c", "...", "target", "condition", "number" ]
train
https://github.com/nschloe/accupy/blob/63a031cab7f4d3b9ba1073f9328c10c1862d1c4d/accupy/ill_cond.py#L34-L85
innogames/polysh
polysh/remote_dispatcher.py
main_loop_iteration
def main_loop_iteration(timeout=None): """Return the number of RemoteDispatcher.handle_read() calls made by this iteration""" prev_nr_read = nr_handle_read asyncore.loop(count=1, timeout=timeout, use_poll=True) return nr_handle_read - prev_nr_read
python
def main_loop_iteration(timeout=None): """Return the number of RemoteDispatcher.handle_read() calls made by this iteration""" prev_nr_read = nr_handle_read asyncore.loop(count=1, timeout=timeout, use_poll=True) return nr_handle_read - prev_nr_read
[ "def", "main_loop_iteration", "(", "timeout", "=", "None", ")", ":", "prev_nr_read", "=", "nr_handle_read", "asyncore", ".", "loop", "(", "count", "=", "1", ",", "timeout", "=", "timeout", ",", "use_poll", "=", "True", ")", "return", "nr_handle_read", "-", ...
Return the number of RemoteDispatcher.handle_read() calls made by this iteration
[ "Return", "the", "number", "of", "RemoteDispatcher", ".", "handle_read", "()", "calls", "made", "by", "this", "iteration" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L51-L56
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.launch_ssh
def launch_ssh(self, name, port): """Launch the ssh command in the child process""" if options.user: name = '%s@%s' % (options.user, name) evaluated = options.ssh % {'host': name, 'port': port} if evaluated == options.ssh: evaluated = '%s %s' % (evaluated, name) ...
python
def launch_ssh(self, name, port): """Launch the ssh command in the child process""" if options.user: name = '%s@%s' % (options.user, name) evaluated = options.ssh % {'host': name, 'port': port} if evaluated == options.ssh: evaluated = '%s %s' % (evaluated, name) ...
[ "def", "launch_ssh", "(", "self", ",", "name", ",", "port", ")", ":", "if", "options", ".", "user", ":", "name", "=", "'%s@%s'", "%", "(", "options", ".", "user", ",", "name", ")", "evaluated", "=", "options", ".", "ssh", "%", "{", "'host'", ":", ...
Launch the ssh command in the child process
[ "Launch", "the", "ssh", "command", "in", "the", "child", "process" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L113-L120
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.change_state
def change_state(self, state): """Change the state of the remote process, logging the change""" if state is not self.state: if self.debug: self.print_debug(b'state => ' + STATE_NAMES[state].encode()) if self.state is STATE_NOT_STARTED: self.read_in...
python
def change_state(self, state): """Change the state of the remote process, logging the change""" if state is not self.state: if self.debug: self.print_debug(b'state => ' + STATE_NAMES[state].encode()) if self.state is STATE_NOT_STARTED: self.read_in...
[ "def", "change_state", "(", "self", ",", "state", ")", ":", "if", "state", "is", "not", "self", ".", "state", ":", "if", "self", ".", "debug", ":", "self", ".", "print_debug", "(", "b'state => '", "+", "STATE_NAMES", "[", "state", "]", ".", "encode", ...
Change the state of the remote process, logging the change
[ "Change", "the", "state", "of", "the", "remote", "process", "logging", "the", "change" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L130-L137
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.disconnect
def disconnect(self): """We are no more interested in this remote process""" try: os.kill(-self.pid, signal.SIGKILL) except OSError: # The process was already dead, no problem pass self.read_buffer = b'' self.write_buffer = b'' self.set...
python
def disconnect(self): """We are no more interested in this remote process""" try: os.kill(-self.pid, signal.SIGKILL) except OSError: # The process was already dead, no problem pass self.read_buffer = b'' self.write_buffer = b'' self.set...
[ "def", "disconnect", "(", "self", ")", ":", "try", ":", "os", ".", "kill", "(", "-", "self", ".", "pid", ",", "signal", ".", "SIGKILL", ")", "except", "OSError", ":", "# The process was already dead, no problem", "pass", "self", ".", "read_buffer", "=", "b...
We are no more interested in this remote process
[ "We", "are", "no", "more", "interested", "in", "this", "remote", "process" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L139-L154
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.configure_tty
def configure_tty(self): """We don't want \n to be replaced with \r\n, and we disable the echo""" attr = termios.tcgetattr(self.fd) attr[1] &= ~termios.ONLCR # oflag attr[3] &= ~termios.ECHO # lflag termios.tcsetattr(self.fd, termios.TCSANOW, attr) # unsetopt zle preven...
python
def configure_tty(self): """We don't want \n to be replaced with \r\n, and we disable the echo""" attr = termios.tcgetattr(self.fd) attr[1] &= ~termios.ONLCR # oflag attr[3] &= ~termios.ECHO # lflag termios.tcsetattr(self.fd, termios.TCSANOW, attr) # unsetopt zle preven...
[ "def", "configure_tty", "(", "self", ")", ":", "attr", "=", "termios", ".", "tcgetattr", "(", "self", ".", "fd", ")", "attr", "[", "1", "]", "&=", "~", "termios", ".", "ONLCR", "# oflag", "attr", "[", "3", "]", "&=", "~", "termios", ".", "ECHO", ...
We don't want \n to be replaced with \r\n, and we disable the echo
[ "We", "don", "t", "want", "\\", "n", "to", "be", "replaced", "with", "\\", "r", "\\", "n", "and", "we", "disable", "the", "echo" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L156-L163
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.set_prompt
def set_prompt(self): """The prompt is important because we detect the readyness of a process by waiting for its prompt.""" # No right prompt command_line = b'PS2=;RPS1=;RPROMPT=;' command_line += b'PROMPT_COMMAND=;' command_line += b'TERM=ansi;' command_line += b...
python
def set_prompt(self): """The prompt is important because we detect the readyness of a process by waiting for its prompt.""" # No right prompt command_line = b'PS2=;RPS1=;RPROMPT=;' command_line += b'PROMPT_COMMAND=;' command_line += b'TERM=ansi;' command_line += b...
[ "def", "set_prompt", "(", "self", ")", ":", "# No right prompt", "command_line", "=", "b'PS2=;RPS1=;RPROMPT=;'", "command_line", "+=", "b'PROMPT_COMMAND=;'", "command_line", "+=", "b'TERM=ansi;'", "command_line", "+=", "b'unset HISTFILE;'", "prompt1", ",", "prompt2", "=",...
The prompt is important because we detect the readyness of a process by waiting for its prompt.
[ "The", "prompt", "is", "important", "because", "we", "detect", "the", "readyness", "of", "a", "process", "by", "waiting", "for", "its", "prompt", "." ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L175-L185
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.handle_read_fast_case
def handle_read_fast_case(self, data): """If we are in a fast case we'll avoid the long processing of each line""" if self.state is not STATE_RUNNING or callbacks.any_in(data): # Slow case :-( return False last_nl = data.rfind(b'\n') if last_nl == -1: ...
python
def handle_read_fast_case(self, data): """If we are in a fast case we'll avoid the long processing of each line""" if self.state is not STATE_RUNNING or callbacks.any_in(data): # Slow case :-( return False last_nl = data.rfind(b'\n') if last_nl == -1: ...
[ "def", "handle_read_fast_case", "(", "self", ",", "data", ")", ":", "if", "self", ".", "state", "is", "not", "STATE_RUNNING", "or", "callbacks", ".", "any_in", "(", "data", ")", ":", "# Slow case :-(", "return", "False", "last_nl", "=", "data", ".", "rfind...
If we are in a fast case we'll avoid the long processing of each line
[ "If", "we", "are", "in", "a", "fast", "case", "we", "ll", "avoid", "the", "long", "processing", "of", "each", "line" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L243-L256
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.handle_read
def handle_read(self): """We got some output from a remote shell, this is one of the state machine""" if self.state == STATE_DEAD: return global nr_handle_read nr_handle_read += 1 new_data = self._handle_read_chunk() if self.debug: self.pri...
python
def handle_read(self): """We got some output from a remote shell, this is one of the state machine""" if self.state == STATE_DEAD: return global nr_handle_read nr_handle_read += 1 new_data = self._handle_read_chunk() if self.debug: self.pri...
[ "def", "handle_read", "(", "self", ")", ":", "if", "self", ".", "state", "==", "STATE_DEAD", ":", "return", "global", "nr_handle_read", "nr_handle_read", "+=", "1", "new_data", "=", "self", ".", "_handle_read_chunk", "(", ")", "if", "self", ".", "debug", "...
We got some output from a remote shell, this is one of the state machine
[ "We", "got", "some", "output", "from", "a", "remote", "shell", "this", "is", "one", "of", "the", "state", "machine" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L258-L310
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.print_unfinished_line
def print_unfinished_line(self): """The unfinished line stayed long enough in the buffer to be printed""" if self.state is STATE_RUNNING: if not callbacks.process(self.read_buffer): self.print_lines(self.read_buffer) self.read_buffer = b''
python
def print_unfinished_line(self): """The unfinished line stayed long enough in the buffer to be printed""" if self.state is STATE_RUNNING: if not callbacks.process(self.read_buffer): self.print_lines(self.read_buffer) self.read_buffer = b''
[ "def", "print_unfinished_line", "(", "self", ")", ":", "if", "self", ".", "state", "is", "STATE_RUNNING", ":", "if", "not", "callbacks", ".", "process", "(", "self", ".", "read_buffer", ")", ":", "self", ".", "print_lines", "(", "self", ".", "read_buffer",...
The unfinished line stayed long enough in the buffer to be printed
[ "The", "unfinished", "line", "stayed", "long", "enough", "in", "the", "buffer", "to", "be", "printed" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L312-L317
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.handle_write
def handle_write(self): """Let's write as much as we can""" num_sent = self.send(self.write_buffer) if self.debug: if self.state is not STATE_NOT_STARTED or options.password is None: self.print_debug(b'<== ' + self.write_buffer[:num_sent]) self.write_buffer = ...
python
def handle_write(self): """Let's write as much as we can""" num_sent = self.send(self.write_buffer) if self.debug: if self.state is not STATE_NOT_STARTED or options.password is None: self.print_debug(b'<== ' + self.write_buffer[:num_sent]) self.write_buffer = ...
[ "def", "handle_write", "(", "self", ")", ":", "num_sent", "=", "self", ".", "send", "(", "self", ".", "write_buffer", ")", "if", "self", ".", "debug", ":", "if", "self", ".", "state", "is", "not", "STATE_NOT_STARTED", "or", "options", ".", "password", ...
Let's write as much as we can
[ "Let", "s", "write", "as", "much", "as", "we", "can" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L324-L330
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.print_debug
def print_debug(self, msg): """Log some debugging information to the console""" assert isinstance(msg, bytes) state = STATE_NAMES[self.state].encode() console_output(b'[dbg] ' + self.display_name.encode() + b'[' + state + b']: ' + msg + b'\n')
python
def print_debug(self, msg): """Log some debugging information to the console""" assert isinstance(msg, bytes) state = STATE_NAMES[self.state].encode() console_output(b'[dbg] ' + self.display_name.encode() + b'[' + state + b']: ' + msg + b'\n')
[ "def", "print_debug", "(", "self", ",", "msg", ")", ":", "assert", "isinstance", "(", "msg", ",", "bytes", ")", "state", "=", "STATE_NAMES", "[", "self", ".", "state", "]", ".", "encode", "(", ")", "console_output", "(", "b'[dbg] '", "+", "self", ".", ...
Log some debugging information to the console
[ "Log", "some", "debugging", "information", "to", "the", "console" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L332-L337
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.get_info
def get_info(self): """Return a list with all information available about this process""" return [self.display_name.encode(), self.enabled and b'enabled' or b'disabled', STATE_NAMES[self.state].encode() + b':', self.last_printed_line.strip()]
python
def get_info(self): """Return a list with all information available about this process""" return [self.display_name.encode(), self.enabled and b'enabled' or b'disabled', STATE_NAMES[self.state].encode() + b':', self.last_printed_line.strip()]
[ "def", "get_info", "(", "self", ")", ":", "return", "[", "self", ".", "display_name", ".", "encode", "(", ")", ",", "self", ".", "enabled", "and", "b'enabled'", "or", "b'disabled'", ",", "STATE_NAMES", "[", "self", ".", "state", "]", ".", "encode", "("...
Return a list with all information available about this process
[ "Return", "a", "list", "with", "all", "information", "available", "about", "this", "process" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L339-L344
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.dispatch_write
def dispatch_write(self, buf): """There is new stuff to write when possible""" if self.state != STATE_DEAD and self.enabled: super().dispatch_write(buf) return True return False
python
def dispatch_write(self, buf): """There is new stuff to write when possible""" if self.state != STATE_DEAD and self.enabled: super().dispatch_write(buf) return True return False
[ "def", "dispatch_write", "(", "self", ",", "buf", ")", ":", "if", "self", ".", "state", "!=", "STATE_DEAD", "and", "self", ".", "enabled", ":", "super", "(", ")", ".", "dispatch_write", "(", "buf", ")", "return", "True", "return", "False" ]
There is new stuff to write when possible
[ "There", "is", "new", "stuff", "to", "write", "when", "possible" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L346-L351
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.change_name
def change_name(self, new_name): """Change the name of the shell, possibly updating the maximum name length""" if not new_name: name = self.hostname else: name = new_name.decode() self.display_name = display_names.change( self.display_name, nam...
python
def change_name(self, new_name): """Change the name of the shell, possibly updating the maximum name length""" if not new_name: name = self.hostname else: name = new_name.decode() self.display_name = display_names.change( self.display_name, nam...
[ "def", "change_name", "(", "self", ",", "new_name", ")", ":", "if", "not", "new_name", ":", "name", "=", "self", ".", "hostname", "else", ":", "name", "=", "new_name", ".", "decode", "(", ")", "self", ".", "display_name", "=", "display_names", ".", "ch...
Change the name of the shell, possibly updating the maximum name length
[ "Change", "the", "name", "of", "the", "shell", "possibly", "updating", "the", "maximum", "name", "length" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L357-L365
innogames/polysh
polysh/remote_dispatcher.py
RemoteDispatcher.rename
def rename(self, name): """Send to the remote shell, its new name to be shell expanded""" if name: # defug callback add? rename1, rename2 = callbacks.add( b'rename', self.change_name, False) self.dispatch_command(b'/bin/echo "' + rename1 + b'""' + rena...
python
def rename(self, name): """Send to the remote shell, its new name to be shell expanded""" if name: # defug callback add? rename1, rename2 = callbacks.add( b'rename', self.change_name, False) self.dispatch_command(b'/bin/echo "' + rename1 + b'""' + rena...
[ "def", "rename", "(", "self", ",", "name", ")", ":", "if", "name", ":", "# defug callback add?", "rename1", ",", "rename2", "=", "callbacks", ".", "add", "(", "b'rename'", ",", "self", ".", "change_name", ",", "False", ")", "self", ".", "dispatch_command",...
Send to the remote shell, its new name to be shell expanded
[ "Send", "to", "the", "remote", "shell", "its", "new", "name", "to", "be", "shell", "expanded" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/remote_dispatcher.py#L367-L376
innogames/polysh
polysh/terminal_size.py
terminal_size
def terminal_size(): # decide on *some* terminal size """Return (lines, columns).""" cr = _ioctl_GWINSZ(0) or _ioctl_GWINSZ( 1) or _ioctl_GWINSZ(2) # try open fds if not cr: # ...then ctty try: fd = os.open(os.ctermid(), os.O_RDO...
python
def terminal_size(): # decide on *some* terminal size """Return (lines, columns).""" cr = _ioctl_GWINSZ(0) or _ioctl_GWINSZ( 1) or _ioctl_GWINSZ(2) # try open fds if not cr: # ...then ctty try: fd = os.open(os.ctermid(), os.O_RDO...
[ "def", "terminal_size", "(", ")", ":", "# decide on *some* terminal size", "cr", "=", "_ioctl_GWINSZ", "(", "0", ")", "or", "_ioctl_GWINSZ", "(", "1", ")", "or", "_ioctl_GWINSZ", "(", "2", ")", "# try open fds", "if", "not", "cr", ":", "# ...then ctty", "try",...
Return (lines, columns).
[ "Return", "(", "lines", "columns", ")", "." ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/terminal_size.py#L48-L64
innogames/polysh
polysh/completion.py
complete
def complete(text, state): """On tab press, return the next possible completion""" global completion_results if state == 0: line = readline.get_line_buffer() if line.startswith(':'): # Control command completion completion_results = complete_control_command(line, text...
python
def complete(text, state): """On tab press, return the next possible completion""" global completion_results if state == 0: line = readline.get_line_buffer() if line.startswith(':'): # Control command completion completion_results = complete_control_command(line, text...
[ "def", "complete", "(", "text", ",", "state", ")", ":", "global", "completion_results", "if", "state", "==", "0", ":", "line", "=", "readline", ".", "get_line_buffer", "(", ")", "if", "line", ".", "startswith", "(", "':'", ")", ":", "# Control command comp...
On tab press, return the next possible completion
[ "On", "tab", "press", "return", "the", "next", "possible", "completion" ]
train
https://github.com/innogames/polysh/blob/fbea36f3bc9f47a62d72040c48dad1776124dae3/polysh/completion.py#L75-L107
aetros/aetros-cli
aetros/backend.py
Popen
def Popen(*args, **kwargs): """ Executes a command using subprocess.Popen and redirects output to AETROS and stdout. Parses stdout as well for stdout API calls. Use read_line argument to read stdout of command's stdout line by line. Use returned process stdin to communicate with the command. :...
python
def Popen(*args, **kwargs): """ Executes a command using subprocess.Popen and redirects output to AETROS and stdout. Parses stdout as well for stdout API calls. Use read_line argument to read stdout of command's stdout line by line. Use returned process stdin to communicate with the command. :...
[ "def", "Popen", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "read_line", "=", "None", "if", "'read_line'", "in", "kwargs", ":", "read_line", "=", "kwargs", "[", "'read_line'", "]", "del", "kwargs", "[", "'read_line'", "]", "p", "=", "subproces...
Executes a command using subprocess.Popen and redirects output to AETROS and stdout. Parses stdout as well for stdout API calls. Use read_line argument to read stdout of command's stdout line by line. Use returned process stdin to communicate with the command. :return: subprocess.Popen
[ "Executes", "a", "command", "using", "subprocess", ".", "Popen", "and", "redirects", "output", "to", "AETROS", "and", "stdout", ".", "Parses", "stdout", "as", "well", "for", "stdout", "API", "calls", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L65-L101
aetros/aetros-cli
aetros/backend.py
context
def context(): """ Returns a new JobBackend instance which connects to AETROS Trainer based on "model" in aetros.yml or (internal: env:AETROS_MODEL_NAME environment variable). internal: If env:AETROS_JOB_ID is not defined, it creates a new job. Job is ended either by calling JobBackend.done(), Job...
python
def context(): """ Returns a new JobBackend instance which connects to AETROS Trainer based on "model" in aetros.yml or (internal: env:AETROS_MODEL_NAME environment variable). internal: If env:AETROS_JOB_ID is not defined, it creates a new job. Job is ended either by calling JobBackend.done(), Job...
[ "def", "context", "(", ")", ":", "job", "=", "JobBackend", "(", ")", "offline", "=", "False", "if", "'1'", "==", "os", ".", "getenv", "(", "'AETROS_OFFLINE'", ",", "''", ")", ":", "offline", "=", "True", "if", "os", ".", "getenv", "(", "'AETROS_JOB_I...
Returns a new JobBackend instance which connects to AETROS Trainer based on "model" in aetros.yml or (internal: env:AETROS_MODEL_NAME environment variable). internal: If env:AETROS_JOB_ID is not defined, it creates a new job. Job is ended either by calling JobBackend.done(), JobBackend.fail() or JobBacken...
[ "Returns", "a", "new", "JobBackend", "instance", "which", "connects", "to", "AETROS", "Trainer", "based", "on", "model", "in", "aetros", ".", "yml", "or", "(", "internal", ":", "env", ":", "AETROS_MODEL_NAME", "environment", "variable", ")", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L127-L157
aetros/aetros-cli
aetros/backend.py
JobBackend.on_sigint
def on_sigint(self, sig, frame): """ We got SIGINT signal. """ if self.stop_requested or self.stop_requested_force: # signal has already been sent or we force a shutdown. # handles the keystroke 2x CTRL+C to force an exit. self.stop_requested_force = ...
python
def on_sigint(self, sig, frame): """ We got SIGINT signal. """ if self.stop_requested or self.stop_requested_force: # signal has already been sent or we force a shutdown. # handles the keystroke 2x CTRL+C to force an exit. self.stop_requested_force = ...
[ "def", "on_sigint", "(", "self", ",", "sig", ",", "frame", ")", ":", "if", "self", ".", "stop_requested", "or", "self", ".", "stop_requested_force", ":", "# signal has already been sent or we force a shutdown.", "# handles the keystroke 2x CTRL+C to force an exit.", "self",...
We got SIGINT signal.
[ "We", "got", "SIGINT", "signal", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L474-L503
aetros/aetros-cli
aetros/backend.py
JobBackend.external_aborted
def external_aborted(self, params): """ Immediately abort the job by server. This runs in the Client:read() thread. """ self.ended = True self.running = False # When the server sends an abort signal, we really have to close immediately, # since for examp...
python
def external_aborted(self, params): """ Immediately abort the job by server. This runs in the Client:read() thread. """ self.ended = True self.running = False # When the server sends an abort signal, we really have to close immediately, # since for examp...
[ "def", "external_aborted", "(", "self", ",", "params", ")", ":", "self", ".", "ended", "=", "True", "self", ".", "running", "=", "False", "# When the server sends an abort signal, we really have to close immediately,", "# since for example the job has been already deleted.", ...
Immediately abort the job by server. This runs in the Client:read() thread.
[ "Immediately", "abort", "the", "job", "by", "server", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L505-L517
aetros/aetros-cli
aetros/backend.py
JobBackend.external_stop
def external_stop(self, force): """ Stop signal by server. """ # only the master processes handles the regular stop signal from the server, sending a SIGINT to # all its child (means to us, non-master process) if not self.is_master_process(): if force: ...
python
def external_stop(self, force): """ Stop signal by server. """ # only the master processes handles the regular stop signal from the server, sending a SIGINT to # all its child (means to us, non-master process) if not self.is_master_process(): if force: ...
[ "def", "external_stop", "(", "self", ",", "force", ")", ":", "# only the master processes handles the regular stop signal from the server, sending a SIGINT to", "# all its child (means to us, non-master process)", "if", "not", "self", ".", "is_master_process", "(", ")", ":", "if"...
Stop signal by server.
[ "Stop", "signal", "by", "server", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L519-L537
aetros/aetros-cli
aetros/backend.py
JobBackend.step
def step(self, step, total, label='STEP', speed_label='STEPS/S', size=1): """ Increase the step indicator, which is a sub progress circle of the actual main progress circle (epoch, progress() method). """ self.lock.acquire() try: time_diff = time.time() - sel...
python
def step(self, step, total, label='STEP', speed_label='STEPS/S', size=1): """ Increase the step indicator, which is a sub progress circle of the actual main progress circle (epoch, progress() method). """ self.lock.acquire() try: time_diff = time.time() - sel...
[ "def", "step", "(", "self", ",", "step", ",", "total", ",", "label", "=", "'STEP'", ",", "speed_label", "=", "'STEPS/S'", ",", "size", "=", "1", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "time_diff", "=", "time", ".", "...
Increase the step indicator, which is a sub progress circle of the actual main progress circle (epoch, progress() method).
[ "Increase", "the", "step", "indicator", "which", "is", "a", "sub", "progress", "circle", "of", "the", "actual", "main", "progress", "circle", "(", "epoch", "progress", "()", "method", ")", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L553-L614
aetros/aetros-cli
aetros/backend.py
JobBackend.create_loss_channel
def create_loss_channel(self, name='loss', xaxis=None, yaxis=None, layout=None): """ :param name: string :return: JobLossGraph """ return JobLossChannel(self, name, xaxis, yaxis, layout)
python
def create_loss_channel(self, name='loss', xaxis=None, yaxis=None, layout=None): """ :param name: string :return: JobLossGraph """ return JobLossChannel(self, name, xaxis, yaxis, layout)
[ "def", "create_loss_channel", "(", "self", ",", "name", "=", "'loss'", ",", "xaxis", "=", "None", ",", "yaxis", "=", "None", ",", "layout", "=", "None", ")", ":", "return", "JobLossChannel", "(", "self", ",", "name", ",", "xaxis", ",", "yaxis", ",", ...
:param name: string :return: JobLossGraph
[ ":", "param", "name", ":", "string", ":", "return", ":", "JobLossGraph" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L759-L765
aetros/aetros-cli
aetros/backend.py
JobBackend.create_channel
def create_channel(self, name, traces=None, main=False, kpi=False, kpiTrace=0, max_optimization=True, type=JobChannel.NUMBER, xaxis=None, yaxis=None, layout=None): """ :param name: str :param traces: None|list : per default cre...
python
def create_channel(self, name, traces=None, main=False, kpi=False, kpiTrace=0, max_optimization=True, type=JobChannel.NUMBER, xaxis=None, yaxis=None, layout=None): """ :param name: str :param traces: None|list : per default cre...
[ "def", "create_channel", "(", "self", ",", "name", ",", "traces", "=", "None", ",", "main", "=", "False", ",", "kpi", "=", "False", ",", "kpiTrace", "=", "0", ",", "max_optimization", "=", "True", ",", "type", "=", "JobChannel", ".", "NUMBER", ",", "...
:param name: str :param traces: None|list : per default create a trace based on "name". :param main: bool : whether this channel is visible in the job list as column for better comparison. :param kpi: bool : whether this channel is the KPI (key performance indicator). ...
[ ":", "param", "name", ":", "str", ":", "param", "traces", ":", "None|list", ":", "per", "default", "create", "a", "trace", "based", "on", "name", ".", ":", "param", "main", ":", "bool", ":", "whether", "this", "channel", "is", "visible", "in", "the", ...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L767-L788
aetros/aetros-cli
aetros/backend.py
JobBackend.on_shutdown
def on_shutdown(self): """ Shutdown routine. Sets the last progress (done, aborted, failed) and tries to send last logs and git commits. Also makes sure the ssh connection is closed (thus, the job marked as offline). Is triggered by atexit.register(). """ self.in_shutdo...
python
def on_shutdown(self): """ Shutdown routine. Sets the last progress (done, aborted, failed) and tries to send last logs and git commits. Also makes sure the ssh connection is closed (thus, the job marked as offline). Is triggered by atexit.register(). """ self.in_shutdo...
[ "def", "on_shutdown", "(", "self", ")", ":", "self", ".", "in_shutdown", "=", "True", "self", ".", "logger", ".", "debug", "(", "'on_shutdown, stopped=%s, ended=%s, early_stop=%s, stop_requested=%s'", "%", "(", "str", "(", "self", ".", "stopped", ")", ",", "str"...
Shutdown routine. Sets the last progress (done, aborted, failed) and tries to send last logs and git commits. Also makes sure the ssh connection is closed (thus, the job marked as offline). Is triggered by atexit.register().
[ "Shutdown", "routine", ".", "Sets", "the", "last", "progress", "(", "done", "aborted", "failed", ")", "and", "tries", "to", "send", "last", "logs", "and", "git", "commits", ".", "Also", "makes", "sure", "the", "ssh", "connection", "is", "closed", "(", "t...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L951-L1003
aetros/aetros-cli
aetros/backend.py
JobBackend.fail
def fail(self, message=None, force_exit=False): """ Marks the job as failed, saves the given error message and force exists the process when force_exit=True. """ global last_exit_code if not last_exit_code: last_exit_code = 1 with self.git.batch_commit('FAIL...
python
def fail(self, message=None, force_exit=False): """ Marks the job as failed, saves the given error message and force exists the process when force_exit=True. """ global last_exit_code if not last_exit_code: last_exit_code = 1 with self.git.batch_commit('FAIL...
[ "def", "fail", "(", "self", ",", "message", "=", "None", ",", "force_exit", "=", "False", ")", ":", "global", "last_exit_code", "if", "not", "last_exit_code", ":", "last_exit_code", "=", "1", "with", "self", ".", "git", ".", "batch_commit", "(", "'FAILED'"...
Marks the job as failed, saves the given error message and force exists the process when force_exit=True.
[ "Marks", "the", "job", "as", "failed", "saves", "the", "given", "error", "message", "and", "force", "exists", "the", "process", "when", "force_exit", "=", "True", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1150-L1166
aetros/aetros-cli
aetros/backend.py
JobBackend.write_log
def write_log(self, message): """ Proxy method for GeneralLogger. """ if self.stream_log and not self.ended: # points to the Git stream write self.stream_log.write(message) return True
python
def write_log(self, message): """ Proxy method for GeneralLogger. """ if self.stream_log and not self.ended: # points to the Git stream write self.stream_log.write(message) return True
[ "def", "write_log", "(", "self", ",", "message", ")", ":", "if", "self", ".", "stream_log", "and", "not", "self", ".", "ended", ":", "# points to the Git stream write", "self", ".", "stream_log", ".", "write", "(", "message", ")", "return", "True" ]
Proxy method for GeneralLogger.
[ "Proxy", "method", "for", "GeneralLogger", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1168-L1175
aetros/aetros-cli
aetros/backend.py
JobBackend.set_status
def set_status(self, status, add_section=True): """ Set an arbitrary status, visible in the big wheel of the job view. """ status = str(status) if add_section: self.section(status) self.job_add_status('status', status)
python
def set_status(self, status, add_section=True): """ Set an arbitrary status, visible in the big wheel of the job view. """ status = str(status) if add_section: self.section(status) self.job_add_status('status', status)
[ "def", "set_status", "(", "self", ",", "status", ",", "add_section", "=", "True", ")", ":", "status", "=", "str", "(", "status", ")", "if", "add_section", ":", "self", ".", "section", "(", "status", ")", "self", ".", "job_add_status", "(", "'status'", ...
Set an arbitrary status, visible in the big wheel of the job view.
[ "Set", "an", "arbitrary", "status", "visible", "in", "the", "big", "wheel", "of", "the", "job", "view", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1177-L1186
aetros/aetros-cli
aetros/backend.py
JobBackend.create
def create(self, create_info=None, hyperparameter=None, server='local', insights=False): """ Creates a new job in git and pushes it. :param create_info: from the api.create_job_info(id). Contains the config and job info (type, server) :param hyperparameter: simple nested dict with key->...
python
def create(self, create_info=None, hyperparameter=None, server='local', insights=False): """ Creates a new job in git and pushes it. :param create_info: from the api.create_job_info(id). Contains the config and job info (type, server) :param hyperparameter: simple nested dict with key->...
[ "def", "create", "(", "self", ",", "create_info", "=", "None", ",", "hyperparameter", "=", "None", ",", "server", "=", "'local'", ",", "insights", "=", "False", ")", ":", "if", "not", "create_info", ":", "create_info", "=", "{", "'server'", ":", "server"...
Creates a new job in git and pushes it. :param create_info: from the api.create_job_info(id). Contains the config and job info (type, server) :param hyperparameter: simple nested dict with key->value, which overwrites stuff from aetros.yml :param server: if None, the the job will be assigned to...
[ "Creates", "a", "new", "job", "in", "git", "and", "pushes", "it", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1196-L1247
aetros/aetros-cli
aetros/backend.py
JobBackend.get_parameter
def get_parameter(self, path, default=None, return_group=False): """ Reads hyperparameter from job configuration. If nothing found use given default. :param path: str :param default: * :param return_group: If true and path is a choice_group, we return the dict instead of the gr...
python
def get_parameter(self, path, default=None, return_group=False): """ Reads hyperparameter from job configuration. If nothing found use given default. :param path: str :param default: * :param return_group: If true and path is a choice_group, we return the dict instead of the gr...
[ "def", "get_parameter", "(", "self", ",", "path", ",", "default", "=", "None", ",", "return_group", "=", "False", ")", ":", "value", "=", "read_parameter_by_path", "(", "self", ".", "job", "[", "'config'", "]", "[", "'parameters'", "]", ",", "path", ",",...
Reads hyperparameter from job configuration. If nothing found use given default. :param path: str :param default: * :param return_group: If true and path is a choice_group, we return the dict instead of the group name. :return: *
[ "Reads", "hyperparameter", "from", "job", "configuration", ".", "If", "nothing", "found", "use", "given", "default", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1280-L1294
aetros/aetros-cli
aetros/backend.py
JobBackend.load
def load(self, job_id): """ Loads job into index and work-tree, restart its ref and sets as current. :param job_id: int """ self.git.read_job(job_id, checkout=self.is_master_process()) self.load_job_from_ref()
python
def load(self, job_id): """ Loads job into index and work-tree, restart its ref and sets as current. :param job_id: int """ self.git.read_job(job_id, checkout=self.is_master_process()) self.load_job_from_ref()
[ "def", "load", "(", "self", ",", "job_id", ")", ":", "self", ".", "git", ".", "read_job", "(", "job_id", ",", "checkout", "=", "self", ".", "is_master_process", "(", ")", ")", "self", ".", "load_job_from_ref", "(", ")" ]
Loads job into index and work-tree, restart its ref and sets as current. :param job_id: int
[ "Loads", "job", "into", "index", "and", "work", "-", "tree", "restart", "its", "ref", "and", "sets", "as", "current", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1302-L1309
aetros/aetros-cli
aetros/backend.py
JobBackend.load_job_from_ref
def load_job_from_ref(self): """ Loads the job.json into self.job """ if not self.job_id: raise Exception('Job not loaded yet. Use load(id) first.') if not os.path.exists(self.git.work_tree + '/aetros/job.json'): raise Exception('Could not load aetros/job...
python
def load_job_from_ref(self): """ Loads the job.json into self.job """ if not self.job_id: raise Exception('Job not loaded yet. Use load(id) first.') if not os.path.exists(self.git.work_tree + '/aetros/job.json'): raise Exception('Could not load aetros/job...
[ "def", "load_job_from_ref", "(", "self", ")", ":", "if", "not", "self", ".", "job_id", ":", "raise", "Exception", "(", "'Job not loaded yet. Use load(id) first.'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "git", ".", "work_tree",...
Loads the job.json into self.job
[ "Loads", "the", "job", ".", "json", "into", "self", ".", "job" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1311-L1327
aetros/aetros-cli
aetros/backend.py
JobBackend.get_job_model
def get_job_model(self): """ Returns a new JobModel instance with current loaded job data attached. :return: JobModel """ if not self.job: raise Exception('Job not loaded yet. Use load(id) first.') return JobModel(self.job_id, self.job, self.home_config['stor...
python
def get_job_model(self): """ Returns a new JobModel instance with current loaded job data attached. :return: JobModel """ if not self.job: raise Exception('Job not loaded yet. Use load(id) first.') return JobModel(self.job_id, self.job, self.home_config['stor...
[ "def", "get_job_model", "(", "self", ")", ":", "if", "not", "self", ".", "job", ":", "raise", "Exception", "(", "'Job not loaded yet. Use load(id) first.'", ")", "return", "JobModel", "(", "self", ".", "job_id", ",", "self", ".", "job", ",", "self", ".", "...
Returns a new JobModel instance with current loaded job data attached. :return: JobModel
[ "Returns", "a", "new", "JobModel", "instance", "with", "current", "loaded", "job", "data", "attached", ".", ":", "return", ":", "JobModel" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1345-L1353
aetros/aetros-cli
aetros/backend.py
JobBackend.file_list
def file_list(self): """ Lists all files in the working directory. """ blacklist = ['.git', 'aetros'] working_tree = self.git.work_tree def recursive(path='.'): if os.path.basename(path) in blacklist: return 0, 0 if os.path.isdir(...
python
def file_list(self): """ Lists all files in the working directory. """ blacklist = ['.git', 'aetros'] working_tree = self.git.work_tree def recursive(path='.'): if os.path.basename(path) in blacklist: return 0, 0 if os.path.isdir(...
[ "def", "file_list", "(", "self", ")", ":", "blacklist", "=", "[", "'.git'", ",", "'aetros'", "]", "working_tree", "=", "self", ".", "git", ".", "work_tree", "def", "recursive", "(", "path", "=", "'.'", ")", ":", "if", "os", ".", "path", ".", "basenam...
Lists all files in the working directory.
[ "Lists", "all", "files", "in", "the", "working", "directory", "." ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1559-L1589
aetros/aetros-cli
aetros/backend.py
JobBackend.add_files
def add_files(self, working_tree, report=False): """ Commits all files from limited in aetros.yml. `files` is a whitelist, `exclude_files` is a blacklist. If both are empty, we commit all files smaller than 10MB. :return: """ blacklist = ['.git'] def add_resursiv...
python
def add_files(self, working_tree, report=False): """ Commits all files from limited in aetros.yml. `files` is a whitelist, `exclude_files` is a blacklist. If both are empty, we commit all files smaller than 10MB. :return: """ blacklist = ['.git'] def add_resursiv...
[ "def", "add_files", "(", "self", ",", "working_tree", ",", "report", "=", "False", ")", ":", "blacklist", "=", "[", "'.git'", "]", "def", "add_resursiv", "(", "path", "=", "'.'", ",", "report", "=", "report", ")", ":", "if", "os", ".", "path", ".", ...
Commits all files from limited in aetros.yml. `files` is a whitelist, `exclude_files` is a blacklist. If both are empty, we commit all files smaller than 10MB. :return:
[ "Commits", "all", "files", "from", "limited", "in", "aetros", ".", "yml", ".", "files", "is", "a", "whitelist", "exclude_files", "is", "a", "blacklist", ".", "If", "both", "are", "empty", "we", "commit", "all", "files", "smaller", "than", "10MB", ".", ":...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1591-L1637
aetros/aetros-cli
aetros/backend.py
JobBackend.add_embedding_word2vec
def add_embedding_word2vec(self, x, path, dimensions=None, header_with_dimensions=True): """ Parse the word2vec file and extracts vectors as bytes and labels as TSV file. The format is simple: It's a UTF-8 encoded file, each word + vectors separated by new line. Vector is space separated...
python
def add_embedding_word2vec(self, x, path, dimensions=None, header_with_dimensions=True): """ Parse the word2vec file and extracts vectors as bytes and labels as TSV file. The format is simple: It's a UTF-8 encoded file, each word + vectors separated by new line. Vector is space separated...
[ "def", "add_embedding_word2vec", "(", "self", ",", "x", ",", "path", ",", "dimensions", "=", "None", ",", "header_with_dimensions", "=", "True", ")", ":", "if", "path", ".", "endswith", "(", "'.txt'", ")", ":", "if", "not", "os", ".", "path", ".", "exi...
Parse the word2vec file and extracts vectors as bytes and labels as TSV file. The format is simple: It's a UTF-8 encoded file, each word + vectors separated by new line. Vector is space separated. At the very first line might be dimensions, given as space separated value. Line 1: 2 4\n...
[ "Parse", "the", "word2vec", "file", "and", "extracts", "vectors", "as", "bytes", "and", "labels", "as", "TSV", "file", ".", "The", "format", "is", "simple", ":", "It", "s", "a", "UTF", "-", "8", "encoded", "file", "each", "word", "+", "vectors", "separ...
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1639-L1703
aetros/aetros-cli
aetros/backend.py
JobBackend.add_embedding_path
def add_embedding_path(self, x, dimensions, vectors_path, metadata=None, image_shape=None, image=None): """ Adds a new embedding with optional metadata. Example how to generate vectors based on 2D numpy array: # 4 vectors, each size of 3 vectors = [ [2.3, 4....
python
def add_embedding_path(self, x, dimensions, vectors_path, metadata=None, image_shape=None, image=None): """ Adds a new embedding with optional metadata. Example how to generate vectors based on 2D numpy array: # 4 vectors, each size of 3 vectors = [ [2.3, 4....
[ "def", "add_embedding_path", "(", "self", ",", "x", ",", "dimensions", ",", "vectors_path", ",", "metadata", "=", "None", ",", "image_shape", "=", "None", ",", "image", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "vectors...
Adds a new embedding with optional metadata. Example how to generate vectors based on 2D numpy array: # 4 vectors, each size of 3 vectors = [ [2.3, 4.0, 33], [2.4, 4.2, 44], [2.5, 3.9, 34], [5.5, 200.2, 66] ] metadata = [...
[ "Adds", "a", "new", "embedding", "with", "optional", "metadata", ".", "Example", "how", "to", "generate", "vectors", "based", "on", "2D", "numpy", "array", ":" ]
train
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/backend.py#L1705-L1779
codebynumbers/ftpretty
ftpretty.py
split_file_info
def split_file_info(fileinfo): """ Parse sane directory output usually ls -l Adapted from https://gist.github.com/tobiasoberrauch/2942716 """ current_year = datetime.datetime.now().strftime('%Y') files = [] for line in fileinfo: parts = re.split( r'^([\-dbclps])' + ...
python
def split_file_info(fileinfo): """ Parse sane directory output usually ls -l Adapted from https://gist.github.com/tobiasoberrauch/2942716 """ current_year = datetime.datetime.now().strftime('%Y') files = [] for line in fileinfo: parts = re.split( r'^([\-dbclps])' + ...
[ "def", "split_file_info", "(", "fileinfo", ")", ":", "current_year", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y'", ")", "files", "=", "[", "]", "for", "line", "in", "fileinfo", ":", "parts", "=", "re", ".", "sp...
Parse sane directory output usually ls -l Adapted from https://gist.github.com/tobiasoberrauch/2942716
[ "Parse", "sane", "directory", "output", "usually", "ls", "-", "l", "Adapted", "from", "https", ":", "//", "gist", ".", "github", ".", "com", "/", "tobiasoberrauch", "/", "2942716" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L225-L263
codebynumbers/ftpretty
ftpretty.py
ftpretty.get
def get(self, remote, local=None): """ Gets the file from FTP server local can be: a file: opened for writing, left open a string: path to output file None: contents are returned """ if isinstance(local, file_type): # open file, leave...
python
def get(self, remote, local=None): """ Gets the file from FTP server local can be: a file: opened for writing, left open a string: path to output file None: contents are returned """ if isinstance(local, file_type): # open file, leave...
[ "def", "get", "(", "self", ",", "remote", ",", "local", "=", "None", ")", ":", "if", "isinstance", "(", "local", ",", "file_type", ")", ":", "# open file, leave open", "local_file", "=", "local", "elif", "local", "is", "None", ":", "# return string", "loca...
Gets the file from FTP server local can be: a file: opened for writing, left open a string: path to output file None: contents are returned
[ "Gets", "the", "file", "from", "FTP", "server" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L58-L84
codebynumbers/ftpretty
ftpretty.py
ftpretty.put
def put(self, local, remote, contents=None, quiet=False): """ Puts a local file (or contents) on to the FTP server local can be: a string: path to inpit file a file: opened for reading None: contents are pushed """ remote_dir = os.path...
python
def put(self, local, remote, contents=None, quiet=False): """ Puts a local file (or contents) on to the FTP server local can be: a string: path to inpit file a file: opened for reading None: contents are pushed """ remote_dir = os.path...
[ "def", "put", "(", "self", ",", "local", ",", "remote", ",", "contents", "=", "None", ",", "quiet", "=", "False", ")", ":", "remote_dir", "=", "os", ".", "path", ".", "dirname", "(", "remote", ")", "remote_file", "=", "os", ".", "path", ".", "basen...
Puts a local file (or contents) on to the FTP server local can be: a string: path to inpit file a file: opened for reading None: contents are pushed
[ "Puts", "a", "local", "file", "(", "or", "contents", ")", "on", "to", "the", "FTP", "server" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L86-L118
codebynumbers/ftpretty
ftpretty.py
ftpretty.upload_tree
def upload_tree(self, src, dst, ignore=None): """Recursively upload a directory tree. Although similar to shutil.copytree we don't follow symlinks. """ names = os.listdir(src) if ignore is not None: ignored_names = ignore(src, names) else: ignored...
python
def upload_tree(self, src, dst, ignore=None): """Recursively upload a directory tree. Although similar to shutil.copytree we don't follow symlinks. """ names = os.listdir(src) if ignore is not None: ignored_names = ignore(src, names) else: ignored...
[ "def", "upload_tree", "(", "self", ",", "src", ",", "dst", ",", "ignore", "=", "None", ")", ":", "names", "=", "os", ".", "listdir", "(", "src", ")", "if", "ignore", "is", "not", "None", ":", "ignored_names", "=", "ignore", "(", "src", ",", "names"...
Recursively upload a directory tree. Although similar to shutil.copytree we don't follow symlinks.
[ "Recursively", "upload", "a", "directory", "tree", "." ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L120-L153
codebynumbers/ftpretty
ftpretty.py
ftpretty.list
def list(self, remote='.', extra=False, remove_relative_paths=False): """ Return directory list """ if extra: self.tmp_output = [] self.conn.dir(remote, self._collector) directory_list = split_file_info(self.tmp_output) else: directory_list = self....
python
def list(self, remote='.', extra=False, remove_relative_paths=False): """ Return directory list """ if extra: self.tmp_output = [] self.conn.dir(remote, self._collector) directory_list = split_file_info(self.tmp_output) else: directory_list = self....
[ "def", "list", "(", "self", ",", "remote", "=", "'.'", ",", "extra", "=", "False", ",", "remove_relative_paths", "=", "False", ")", ":", "if", "extra", ":", "self", ".", "tmp_output", "=", "[", "]", "self", ".", "conn", ".", "dir", "(", "remote", "...
Return directory list
[ "Return", "directory", "list" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L155-L167
codebynumbers/ftpretty
ftpretty.py
ftpretty.descend
def descend(self, remote, force=False): """ Descend, possibly creating directories as needed """ remote_dirs = remote.split('/') for directory in remote_dirs: try: self.conn.cwd(directory) except Exception: if force: sel...
python
def descend(self, remote, force=False): """ Descend, possibly creating directories as needed """ remote_dirs = remote.split('/') for directory in remote_dirs: try: self.conn.cwd(directory) except Exception: if force: sel...
[ "def", "descend", "(", "self", ",", "remote", ",", "force", "=", "False", ")", ":", "remote_dirs", "=", "remote", ".", "split", "(", "'/'", ")", "for", "directory", "in", "remote_dirs", ":", "try", ":", "self", ".", "conn", ".", "cwd", "(", "director...
Descend, possibly creating directories as needed
[ "Descend", "possibly", "creating", "directories", "as", "needed" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L175-L185
codebynumbers/ftpretty
ftpretty.py
ftpretty.delete
def delete(self, remote): """ Delete a file from server """ try: self.conn.delete(remote) except Exception: return False else: return True
python
def delete(self, remote): """ Delete a file from server """ try: self.conn.delete(remote) except Exception: return False else: return True
[ "def", "delete", "(", "self", ",", "remote", ")", ":", "try", ":", "self", ".", "conn", ".", "delete", "(", "remote", ")", "except", "Exception", ":", "return", "False", "else", ":", "return", "True" ]
Delete a file from server
[ "Delete", "a", "file", "from", "server" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L187-L194
codebynumbers/ftpretty
ftpretty.py
ftpretty.cd
def cd(self, remote): """ Change working directory on server """ try: self.conn.cwd(remote) except Exception: return False else: return self.pwd()
python
def cd(self, remote): """ Change working directory on server """ try: self.conn.cwd(remote) except Exception: return False else: return self.pwd()
[ "def", "cd", "(", "self", ",", "remote", ")", ":", "try", ":", "self", ".", "conn", ".", "cwd", "(", "remote", ")", "except", "Exception", ":", "return", "False", "else", ":", "return", "self", ".", "pwd", "(", ")" ]
Change working directory on server
[ "Change", "working", "directory", "on", "server" ]
train
https://github.com/codebynumbers/ftpretty/blob/5ee6e2cc679199ff52d1cd2ed1b0613f12aa6f67/ftpretty.py#L196-L203