repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
marcotcr/lime | lime/lime_base.py | LimeBase.explain_instance_with_data | def explain_instance_with_data(self,
neighborhood_data,
neighborhood_labels,
distances,
label,
num_features,
f... | python | def explain_instance_with_data(self,
neighborhood_data,
neighborhood_labels,
distances,
label,
num_features,
f... | [
"def",
"explain_instance_with_data",
"(",
"self",
",",
"neighborhood_data",
",",
"neighborhood_labels",
",",
"distances",
",",
"label",
",",
"num_features",
",",
"feature_selection",
"=",
"'auto'",
",",
"model_regressor",
"=",
"None",
")",
":",
"weights",
"=",
"se... | Takes perturbed data, labels and distances, returns explanation.
Args:
neighborhood_data: perturbed data, 2d array. first element is
assumed to be the original data point.
neighborhood_labels: corresponding perturbed labels. should have as
... | [
"Takes",
"perturbed",
"data",
"labels",
"and",
"distances",
"returns",
"explanation",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_base.py#L108-L179 | train |
marcotcr/lime | lime/explanation.py | id_generator | def id_generator(size=15, random_state=None):
"""Helper function to generate random div ids. This is useful for embedding
HTML into ipython notebooks."""
chars = list(string.ascii_uppercase + string.digits)
return ''.join(random_state.choice(chars, size, replace=True)) | python | def id_generator(size=15, random_state=None):
"""Helper function to generate random div ids. This is useful for embedding
HTML into ipython notebooks."""
chars = list(string.ascii_uppercase + string.digits)
return ''.join(random_state.choice(chars, size, replace=True)) | [
"def",
"id_generator",
"(",
"size",
"=",
"15",
",",
"random_state",
"=",
"None",
")",
":",
"chars",
"=",
"list",
"(",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
")",
"return",
"''",
".",
"join",
"(",
"random_state",
".",
"choice",
... | Helper function to generate random div ids. This is useful for embedding
HTML into ipython notebooks. | [
"Helper",
"function",
"to",
"generate",
"random",
"div",
"ids",
".",
"This",
"is",
"useful",
"for",
"embedding",
"HTML",
"into",
"ipython",
"notebooks",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L17-L21 | train |
marcotcr/lime | lime/explanation.py | Explanation.available_labels | def available_labels(self):
"""
Returns the list of classification labels for which we have any explanations.
"""
try:
assert self.mode == "classification"
except AssertionError:
raise NotImplementedError('Not supported for regression explanations.')
... | python | def available_labels(self):
"""
Returns the list of classification labels for which we have any explanations.
"""
try:
assert self.mode == "classification"
except AssertionError:
raise NotImplementedError('Not supported for regression explanations.')
... | [
"def",
"available_labels",
"(",
"self",
")",
":",
"try",
":",
"assert",
"self",
".",
"mode",
"==",
"\"classification\"",
"except",
"AssertionError",
":",
"raise",
"NotImplementedError",
"(",
"'Not supported for regression explanations.'",
")",
"else",
":",
"ans",
"=... | Returns the list of classification labels for which we have any explanations. | [
"Returns",
"the",
"list",
"of",
"classification",
"labels",
"for",
"which",
"we",
"have",
"any",
"explanations",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L117-L127 | train |
marcotcr/lime | lime/explanation.py | Explanation.as_list | def as_list(self, label=1, **kwargs):
"""Returns the explanation as a list.
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exception.
Will be ignored for regression explanations.
kwargs: ... | python | def as_list(self, label=1, **kwargs):
"""Returns the explanation as a list.
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exception.
Will be ignored for regression explanations.
kwargs: ... | [
"def",
"as_list",
"(",
"self",
",",
"label",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"label_to_use",
"=",
"label",
"if",
"self",
".",
"mode",
"==",
"\"classification\"",
"else",
"self",
".",
"dummy_label",
"ans",
"=",
"self",
".",
"domain_mapper",
... | Returns the explanation as a list.
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exception.
Will be ignored for regression explanations.
kwargs: keyword arguments, passed to domain_mapper
... | [
"Returns",
"the",
"explanation",
"as",
"a",
"list",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L129-L145 | train |
marcotcr/lime | lime/explanation.py | Explanation.as_pyplot_figure | def as_pyplot_figure(self, label=1, **kwargs):
"""Returns the explanation as a pyplot figure.
Will throw an error if you don't have matplotlib installed
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exce... | python | def as_pyplot_figure(self, label=1, **kwargs):
"""Returns the explanation as a pyplot figure.
Will throw an error if you don't have matplotlib installed
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exce... | [
"def",
"as_pyplot_figure",
"(",
"self",
",",
"label",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"exp",
"=",
"self",
".",
"as_list",
"(",
"label",
"=",
"label",
",",
"*",
"*",
"kwargs",
")",
"fi... | Returns the explanation as a pyplot figure.
Will throw an error if you don't have matplotlib installed
Args:
label: desired label. If you ask for a label for which an
explanation wasn't computed, will throw an exception.
Will be ignored for regression e... | [
"Returns",
"the",
"explanation",
"as",
"a",
"pyplot",
"figure",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L155-L184 | train |
marcotcr/lime | lime/explanation.py | Explanation.show_in_notebook | def show_in_notebook(self,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Shows html explanation in ipython notebook.
See as_html() for parameters.
This will throw an e... | python | def show_in_notebook(self,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Shows html explanation in ipython notebook.
See as_html() for parameters.
This will throw an e... | [
"def",
"show_in_notebook",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"predict_proba",
"=",
"True",
",",
"show_predicted_value",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"IPython",
".",
"core",
".",
"display",
"import",
"display",
",",
... | Shows html explanation in ipython notebook.
See as_html() for parameters.
This will throw an error if you don't have IPython installed | [
"Shows",
"html",
"explanation",
"in",
"ipython",
"notebook",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L186-L200 | train |
marcotcr/lime | lime/explanation.py | Explanation.save_to_file | def save_to_file(self,
file_path,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Saves html explanation to file. .
Params:
file_path: file to save explanations... | python | def save_to_file(self,
file_path,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Saves html explanation to file. .
Params:
file_path: file to save explanations... | [
"def",
"save_to_file",
"(",
"self",
",",
"file_path",
",",
"labels",
"=",
"None",
",",
"predict_proba",
"=",
"True",
",",
"show_predicted_value",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"file_",
"=",
"open",
"(",
"file_path",
",",
"'w'",
",",
"... | Saves html explanation to file. .
Params:
file_path: file to save explanations to
See as_html() for additional parameters. | [
"Saves",
"html",
"explanation",
"to",
"file",
".",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L202-L221 | train |
marcotcr/lime | lime/explanation.py | Explanation.as_html | def as_html(self,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Returns the explanation as an html page.
Args:
labels: desired labels to show explanations for (as barcharts).
If you a... | python | def as_html(self,
labels=None,
predict_proba=True,
show_predicted_value=True,
**kwargs):
"""Returns the explanation as an html page.
Args:
labels: desired labels to show explanations for (as barcharts).
If you a... | [
"def",
"as_html",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"predict_proba",
"=",
"True",
",",
"show_predicted_value",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"jsonize",
"(",
"x",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"x",... | Returns the explanation as an html page.
Args:
labels: desired labels to show explanations for (as barcharts).
If you ask for a label for which an explanation wasn't
computed, will throw an exception. If None, will show
explanations for all available ... | [
"Returns",
"the",
"explanation",
"as",
"an",
"html",
"page",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/explanation.py#L223-L328 | train |
marcotcr/lime | lime/wrappers/scikit_image.py | BaseWrapper._check_params | def _check_params(self, parameters):
"""Checks for mistakes in 'parameters'
Args :
parameters: dict, parameters to be checked
Raises :
ValueError: if any parameter is not a valid argument for the target function
or the target function is not defined
... | python | def _check_params(self, parameters):
"""Checks for mistakes in 'parameters'
Args :
parameters: dict, parameters to be checked
Raises :
ValueError: if any parameter is not a valid argument for the target function
or the target function is not defined
... | [
"def",
"_check_params",
"(",
"self",
",",
"parameters",
")",
":",
"a_valid_fn",
"=",
"[",
"]",
"if",
"self",
".",
"target_fn",
"is",
"None",
":",
"if",
"callable",
"(",
"self",
")",
":",
"a_valid_fn",
".",
"append",
"(",
"self",
".",
"__call__",
")",
... | Checks for mistakes in 'parameters'
Args :
parameters: dict, parameters to be checked
Raises :
ValueError: if any parameter is not a valid argument for the target function
or the target function is not defined
TypeError: if argument parameters is not... | [
"Checks",
"for",
"mistakes",
"in",
"parameters"
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/wrappers/scikit_image.py#L26-L58 | train |
marcotcr/lime | lime/wrappers/scikit_image.py | BaseWrapper.filter_params | def filter_params(self, fn, override=None):
"""Filters `target_params` and return those in `fn`'s arguments.
Args:
fn : arbitrary function
override: dict, values to override target_params
Returns:
result : dict, dictionary containing variables
in b... | python | def filter_params(self, fn, override=None):
"""Filters `target_params` and return those in `fn`'s arguments.
Args:
fn : arbitrary function
override: dict, values to override target_params
Returns:
result : dict, dictionary containing variables
in b... | [
"def",
"filter_params",
"(",
"self",
",",
"fn",
",",
"override",
"=",
"None",
")",
":",
"override",
"=",
"override",
"or",
"{",
"}",
"result",
"=",
"{",
"}",
"for",
"name",
",",
"value",
"in",
"self",
".",
"target_params",
".",
"items",
"(",
")",
"... | Filters `target_params` and return those in `fn`'s arguments.
Args:
fn : arbitrary function
override: dict, values to override target_params
Returns:
result : dict, dictionary containing variables
in both target_params and fn's arguments. | [
"Filters",
"target_params",
"and",
"return",
"those",
"in",
"fn",
"s",
"arguments",
".",
"Args",
":",
"fn",
":",
"arbitrary",
"function",
"override",
":",
"dict",
"values",
"to",
"override",
"target_params",
"Returns",
":",
"result",
":",
"dict",
"dictionary",... | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/wrappers/scikit_image.py#L72-L87 | train |
marcotcr/lime | lime/lime_text.py | TextDomainMapper.map_exp_ids | def map_exp_ids(self, exp, positions=False):
"""Maps ids to words or word-position strings.
Args:
exp: list of tuples [(id, weight), (id,weight)]
positions: if True, also return word positions
Returns:
list of tuples (word, weight), or (word_positions, weigh... | python | def map_exp_ids(self, exp, positions=False):
"""Maps ids to words or word-position strings.
Args:
exp: list of tuples [(id, weight), (id,weight)]
positions: if True, also return word positions
Returns:
list of tuples (word, weight), or (word_positions, weigh... | [
"def",
"map_exp_ids",
"(",
"self",
",",
"exp",
",",
"positions",
"=",
"False",
")",
":",
"if",
"positions",
":",
"exp",
"=",
"[",
"(",
"'%s_%s'",
"%",
"(",
"self",
".",
"indexed_string",
".",
"word",
"(",
"x",
"[",
"0",
"]",
")",
",",
"'-'",
".",... | Maps ids to words or word-position strings.
Args:
exp: list of tuples [(id, weight), (id,weight)]
positions: if True, also return word positions
Returns:
list of tuples (word, weight), or (word_positions, weight) if
examples: ('bad', 1) or ('bad_3-6-12',... | [
"Maps",
"ids",
"to",
"words",
"or",
"word",
"-",
"position",
"strings",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L31-L51 | train |
marcotcr/lime | lime/lime_text.py | TextDomainMapper.visualize_instance_html | def visualize_instance_html(self, exp, label, div_name, exp_object_name,
text=True, opacity=True):
"""Adds text with highlighted words to visualization.
Args:
exp: list of tuples [(id, weight), (id,weight)]
label: label id (integer)
... | python | def visualize_instance_html(self, exp, label, div_name, exp_object_name,
text=True, opacity=True):
"""Adds text with highlighted words to visualization.
Args:
exp: list of tuples [(id, weight), (id,weight)]
label: label id (integer)
... | [
"def",
"visualize_instance_html",
"(",
"self",
",",
"exp",
",",
"label",
",",
"div_name",
",",
"exp_object_name",
",",
"text",
"=",
"True",
",",
"opacity",
"=",
"True",
")",
":",
"if",
"not",
"text",
":",
"return",
"u''",
"text",
"=",
"(",
"self",
".",... | Adds text with highlighted words to visualization.
Args:
exp: list of tuples [(id, weight), (id,weight)]
label: label id (integer)
div_name: name of div object to be used for rendering(in js)
exp_object_name: name of js explanation object
text: i... | [
"Adds",
"text",
"with",
"highlighted",
"words",
"to",
"visualization",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L53-L80 | train |
marcotcr/lime | lime/lime_text.py | IndexedString.string_position | def string_position(self, id_):
"""Returns a np array with indices to id_ (int) occurrences"""
if self.bow:
return self.string_start[self.positions[id_]]
else:
return self.string_start[[self.positions[id_]]] | python | def string_position(self, id_):
"""Returns a np array with indices to id_ (int) occurrences"""
if self.bow:
return self.string_start[self.positions[id_]]
else:
return self.string_start[[self.positions[id_]]] | [
"def",
"string_position",
"(",
"self",
",",
"id_",
")",
":",
"if",
"self",
".",
"bow",
":",
"return",
"self",
".",
"string_start",
"[",
"self",
".",
"positions",
"[",
"id_",
"]",
"]",
"else",
":",
"return",
"self",
".",
"string_start",
"[",
"[",
"sel... | Returns a np array with indices to id_ (int) occurrences | [
"Returns",
"a",
"np",
"array",
"with",
"indices",
"to",
"id_",
"(",
"int",
")",
"occurrences"
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L155-L160 | train |
marcotcr/lime | lime/lime_text.py | IndexedString.inverse_removing | def inverse_removing(self, words_to_remove):
"""Returns a string after removing the appropriate words.
If self.bow is false, replaces word with UNKWORDZ instead of removing
it.
Args:
words_to_remove: list of ids (ints) to remove
Returns:
original raw st... | python | def inverse_removing(self, words_to_remove):
"""Returns a string after removing the appropriate words.
If self.bow is false, replaces word with UNKWORDZ instead of removing
it.
Args:
words_to_remove: list of ids (ints) to remove
Returns:
original raw st... | [
"def",
"inverse_removing",
"(",
"self",
",",
"words_to_remove",
")",
":",
"mask",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"as_np",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"'bool'",
")",
"mask",
"[",
"self",
".",
"__get_idxs",
"(",
"words_to... | Returns a string after removing the appropriate words.
If self.bow is false, replaces word with UNKWORDZ instead of removing
it.
Args:
words_to_remove: list of ids (ints) to remove
Returns:
original raw string with appropriate words removed. | [
"Returns",
"a",
"string",
"after",
"removing",
"the",
"appropriate",
"words",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L162-L179 | train |
marcotcr/lime | lime/lime_text.py | IndexedString._segment_with_tokens | def _segment_with_tokens(text, tokens):
"""Segment a string around the tokens created by a passed-in tokenizer"""
list_form = []
text_ptr = 0
for token in tokens:
inter_token_string = []
while not text[text_ptr:].startswith(token):
inter_token_stri... | python | def _segment_with_tokens(text, tokens):
"""Segment a string around the tokens created by a passed-in tokenizer"""
list_form = []
text_ptr = 0
for token in tokens:
inter_token_string = []
while not text[text_ptr:].startswith(token):
inter_token_stri... | [
"def",
"_segment_with_tokens",
"(",
"text",
",",
"tokens",
")",
":",
"list_form",
"=",
"[",
"]",
"text_ptr",
"=",
"0",
"for",
"token",
"in",
"tokens",
":",
"inter_token_string",
"=",
"[",
"]",
"while",
"not",
"text",
"[",
"text_ptr",
":",
"]",
".",
"st... | Segment a string around the tokens created by a passed-in tokenizer | [
"Segment",
"a",
"string",
"around",
"the",
"tokens",
"created",
"by",
"a",
"passed",
"-",
"in",
"tokenizer"
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L182-L199 | train |
marcotcr/lime | lime/lime_text.py | IndexedString.__get_idxs | def __get_idxs(self, words):
"""Returns indexes to appropriate words."""
if self.bow:
return list(itertools.chain.from_iterable(
[self.positions[z] for z in words]))
else:
return self.positions[words] | python | def __get_idxs(self, words):
"""Returns indexes to appropriate words."""
if self.bow:
return list(itertools.chain.from_iterable(
[self.positions[z] for z in words]))
else:
return self.positions[words] | [
"def",
"__get_idxs",
"(",
"self",
",",
"words",
")",
":",
"if",
"self",
".",
"bow",
":",
"return",
"list",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"[",
"self",
".",
"positions",
"[",
"z",
"]",
"for",
"z",
"in",
"words",
"]",
")",... | Returns indexes to appropriate words. | [
"Returns",
"indexes",
"to",
"appropriate",
"words",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L201-L207 | train |
marcotcr/lime | lime/lime_text.py | LimeTextExplainer.explain_instance | def explain_instance(self,
text_instance,
classifier_fn,
labels=(1,),
top_labels=None,
num_features=10,
num_samples=5000,
distance_metric='cosine... | python | def explain_instance(self,
text_instance,
classifier_fn,
labels=(1,),
top_labels=None,
num_features=10,
num_samples=5000,
distance_metric='cosine... | [
"def",
"explain_instance",
"(",
"self",
",",
"text_instance",
",",
"classifier_fn",
",",
"labels",
"=",
"(",
"1",
",",
")",
",",
"top_labels",
"=",
"None",
",",
"num_features",
"=",
"10",
",",
"num_samples",
"=",
"5000",
",",
"distance_metric",
"=",
"'cosi... | Generates explanations for a prediction.
First, we generate neighborhood data by randomly hiding features from
the instance (see __data_labels_distance_mapping). We then learn
locally weighted linear models on this neighborhood data to explain
each of the classes in an interpretable way... | [
"Generates",
"explanations",
"for",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L356-L418 | train |
marcotcr/lime | lime/lime_text.py | LimeTextExplainer.__data_labels_distances | def __data_labels_distances(self,
indexed_string,
classifier_fn,
num_samples,
distance_metric='cosine'):
"""Generates a neighborhood around a prediction.
Generates neighborhoo... | python | def __data_labels_distances(self,
indexed_string,
classifier_fn,
num_samples,
distance_metric='cosine'):
"""Generates a neighborhood around a prediction.
Generates neighborhoo... | [
"def",
"__data_labels_distances",
"(",
"self",
",",
"indexed_string",
",",
"classifier_fn",
",",
"num_samples",
",",
"distance_metric",
"=",
"'cosine'",
")",
":",
"def",
"distance_fn",
"(",
"x",
")",
":",
"return",
"sklearn",
".",
"metrics",
".",
"pairwise",
"... | Generates a neighborhood around a prediction.
Generates neighborhood data by randomly removing words from
the instance, and predicting with the classifier. Uses cosine distance
to compute distances between original and perturbed instances.
Args:
indexed_string: document (Ind... | [
"Generates",
"a",
"neighborhood",
"around",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_text.py#L420-L469 | train |
marcotcr/lime | lime/lime_tabular.py | TableDomainMapper.map_exp_ids | def map_exp_ids(self, exp):
"""Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight)
"""
names = self.exp_feature_names
if self.discretized_feature_names is not None:
... | python | def map_exp_ids(self, exp):
"""Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight)
"""
names = self.exp_feature_names
if self.discretized_feature_names is not None:
... | [
"def",
"map_exp_ids",
"(",
"self",
",",
"exp",
")",
":",
"names",
"=",
"self",
".",
"exp_feature_names",
"if",
"self",
".",
"discretized_feature_names",
"is",
"not",
"None",
":",
"names",
"=",
"self",
".",
"discretized_feature_names",
"return",
"[",
"(",
"na... | Maps ids to feature names.
Args:
exp: list of tuples [(id, weight), (id,weight)]
Returns:
list of tuples (feature_name, weight) | [
"Maps",
"ids",
"to",
"feature",
"names",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L45-L57 | train |
marcotcr/lime | lime/lime_tabular.py | TableDomainMapper.visualize_instance_html | def visualize_instance_html(self,
exp,
label,
div_name,
exp_object_name,
show_table=True,
show_all=False):
"""Shows the ... | python | def visualize_instance_html(self,
exp,
label,
div_name,
exp_object_name,
show_table=True,
show_all=False):
"""Shows the ... | [
"def",
"visualize_instance_html",
"(",
"self",
",",
"exp",
",",
"label",
",",
"div_name",
",",
"exp_object_name",
",",
"show_table",
"=",
"True",
",",
"show_all",
"=",
"False",
")",
":",
"if",
"not",
"show_table",
":",
"return",
"''",
"weights",
"=",
"[",
... | Shows the current example in a table format.
Args:
exp: list of tuples [(id, weight), (id,weight)]
label: label id (integer)
div_name: name of div object to be used for rendering(in js)
exp_object_name: name of js explanation object
show_table: i... | [
"Shows",
"the",
"current",
"example",
"in",
"a",
"table",
"format",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L59-L89 | train |
marcotcr/lime | lime/lime_tabular.py | LimeTabularExplainer.validate_training_data_stats | def validate_training_data_stats(training_data_stats):
"""
Method to validate the structure of training data stats
"""
stat_keys = list(training_data_stats.keys())
valid_stat_keys = ["means", "mins", "maxs", "stds", "feature_values", "feature_frequencies"]
missing_key... | python | def validate_training_data_stats(training_data_stats):
"""
Method to validate the structure of training data stats
"""
stat_keys = list(training_data_stats.keys())
valid_stat_keys = ["means", "mins", "maxs", "stds", "feature_values", "feature_frequencies"]
missing_key... | [
"def",
"validate_training_data_stats",
"(",
"training_data_stats",
")",
":",
"stat_keys",
"=",
"list",
"(",
"training_data_stats",
".",
"keys",
"(",
")",
")",
"valid_stat_keys",
"=",
"[",
"\"means\"",
",",
"\"mins\"",
",",
"\"maxs\"",
",",
"\"stds\"",
",",
"\"fe... | Method to validate the structure of training data stats | [
"Method",
"to",
"validate",
"the",
"structure",
"of",
"training",
"data",
"stats"
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L260-L268 | train |
marcotcr/lime | lime/lime_tabular.py | LimeTabularExplainer.explain_instance | def explain_instance(self,
data_row,
predict_fn,
labels=(1,),
top_labels=None,
num_features=10,
num_samples=5000,
distance_metric='euclidean',
... | python | def explain_instance(self,
data_row,
predict_fn,
labels=(1,),
top_labels=None,
num_features=10,
num_samples=5000,
distance_metric='euclidean',
... | [
"def",
"explain_instance",
"(",
"self",
",",
"data_row",
",",
"predict_fn",
",",
"labels",
"=",
"(",
"1",
",",
")",
",",
"top_labels",
"=",
"None",
",",
"num_features",
"=",
"10",
",",
"num_samples",
"=",
"5000",
",",
"distance_metric",
"=",
"'euclidean'",... | Generates explanations for a prediction.
First, we generate neighborhood data by randomly perturbing features
from the instance (see __data_inverse). We then learn locally weighted
linear models on this neighborhood data to explain each of the classes
in an interpretable way (see lime_b... | [
"Generates",
"explanations",
"for",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L270-L425 | train |
marcotcr/lime | lime/lime_tabular.py | LimeTabularExplainer.__data_inverse | def __data_inverse(self,
data_row,
num_samples):
"""Generates a neighborhood around a prediction.
For numerical features, perturb them by sampling from a Normal(0,1) and
doing the inverse operation of mean-centering and scaling, according to
... | python | def __data_inverse(self,
data_row,
num_samples):
"""Generates a neighborhood around a prediction.
For numerical features, perturb them by sampling from a Normal(0,1) and
doing the inverse operation of mean-centering and scaling, according to
... | [
"def",
"__data_inverse",
"(",
"self",
",",
"data_row",
",",
"num_samples",
")",
":",
"data",
"=",
"np",
".",
"zeros",
"(",
"(",
"num_samples",
",",
"data_row",
".",
"shape",
"[",
"0",
"]",
")",
")",
"categorical_features",
"=",
"range",
"(",
"data_row",
... | Generates a neighborhood around a prediction.
For numerical features, perturb them by sampling from a Normal(0,1) and
doing the inverse operation of mean-centering and scaling, according to
the means and stds in the training data. For categorical features,
perturb by sampling according ... | [
"Generates",
"a",
"neighborhood",
"around",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L427-L481 | train |
marcotcr/lime | lime/lime_tabular.py | RecurrentTabularExplainer._make_predict_proba | def _make_predict_proba(self, func):
"""
The predict_proba method will expect 3d arrays, but we are reshaping
them to 2D so that LIME works correctly. This wraps the function
you give in explain_instance to first reshape the data to have
the shape the the keras-style network expe... | python | def _make_predict_proba(self, func):
"""
The predict_proba method will expect 3d arrays, but we are reshaping
them to 2D so that LIME works correctly. This wraps the function
you give in explain_instance to first reshape the data to have
the shape the the keras-style network expe... | [
"def",
"_make_predict_proba",
"(",
"self",
",",
"func",
")",
":",
"def",
"predict_proba",
"(",
"X",
")",
":",
"n_samples",
"=",
"X",
".",
"shape",
"[",
"0",
"]",
"new_shape",
"=",
"(",
"n_samples",
",",
"self",
".",
"n_features",
",",
"self",
".",
"n... | The predict_proba method will expect 3d arrays, but we are reshaping
them to 2D so that LIME works correctly. This wraps the function
you give in explain_instance to first reshape the data to have
the shape the the keras-style network expects. | [
"The",
"predict_proba",
"method",
"will",
"expect",
"3d",
"arrays",
"but",
"we",
"are",
"reshaping",
"them",
"to",
"2D",
"so",
"that",
"LIME",
"works",
"correctly",
".",
"This",
"wraps",
"the",
"function",
"you",
"give",
"in",
"explain_instance",
"to",
"firs... | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L571-L585 | train |
marcotcr/lime | lime/lime_tabular.py | RecurrentTabularExplainer.explain_instance | def explain_instance(self, data_row, classifier_fn, labels=(1,),
top_labels=None, num_features=10, num_samples=5000,
distance_metric='euclidean', model_regressor=None):
"""Generates explanations for a prediction.
First, we generate neighborhood data by ... | python | def explain_instance(self, data_row, classifier_fn, labels=(1,),
top_labels=None, num_features=10, num_samples=5000,
distance_metric='euclidean', model_regressor=None):
"""Generates explanations for a prediction.
First, we generate neighborhood data by ... | [
"def",
"explain_instance",
"(",
"self",
",",
"data_row",
",",
"classifier_fn",
",",
"labels",
"=",
"(",
"1",
",",
")",
",",
"top_labels",
"=",
"None",
",",
"num_features",
"=",
"10",
",",
"num_samples",
"=",
"5000",
",",
"distance_metric",
"=",
"'euclidean... | Generates explanations for a prediction.
First, we generate neighborhood data by randomly perturbing features
from the instance (see __data_inverse). We then learn locally weighted
linear models on this neighborhood data to explain each of the classes
in an interpretable way (see lime_b... | [
"Generates",
"explanations",
"for",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_tabular.py#L587-L631 | train |
marcotcr/lime | lime/lime_image.py | ImageExplanation.get_image_and_mask | def get_image_and_mask(self, label, positive_only=True, hide_rest=False,
num_features=5, min_weight=0.):
"""Init function.
Args:
label: label to explain
positive_only: if True, only take superpixels that contribute to
the prediction of ... | python | def get_image_and_mask(self, label, positive_only=True, hide_rest=False,
num_features=5, min_weight=0.):
"""Init function.
Args:
label: label to explain
positive_only: if True, only take superpixels that contribute to
the prediction of ... | [
"def",
"get_image_and_mask",
"(",
"self",
",",
"label",
",",
"positive_only",
"=",
"True",
",",
"hide_rest",
"=",
"False",
",",
"num_features",
"=",
"5",
",",
"min_weight",
"=",
"0.",
")",
":",
"if",
"label",
"not",
"in",
"self",
".",
"local_exp",
":",
... | Init function.
Args:
label: label to explain
positive_only: if True, only take superpixels that contribute to
the prediction of the label. Otherwise, use the top
num_features superpixels, which can be positive or negative
towards the label... | [
"Init",
"function",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L31-L80 | train |
marcotcr/lime | lime/lime_image.py | LimeImageExplainer.explain_instance | def explain_instance(self, image, classifier_fn, labels=(1,),
hide_color=None,
top_labels=5, num_features=100000, num_samples=1000,
batch_size=10,
segmentation_fn=None,
distance_metric='cosine',
... | python | def explain_instance(self, image, classifier_fn, labels=(1,),
hide_color=None,
top_labels=5, num_features=100000, num_samples=1000,
batch_size=10,
segmentation_fn=None,
distance_metric='cosine',
... | [
"def",
"explain_instance",
"(",
"self",
",",
"image",
",",
"classifier_fn",
",",
"labels",
"=",
"(",
"1",
",",
")",
",",
"hide_color",
"=",
"None",
",",
"top_labels",
"=",
"5",
",",
"num_features",
"=",
"100000",
",",
"num_samples",
"=",
"1000",
",",
"... | Generates explanations for a prediction.
First, we generate neighborhood data by randomly perturbing features
from the instance (see __data_inverse). We then learn locally weighted
linear models on this neighborhood data to explain each of the classes
in an interpretable way (see lime_b... | [
"Generates",
"explanations",
"for",
"a",
"prediction",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L123-L214 | train |
marcotcr/lime | lime/lime_image.py | LimeImageExplainer.data_labels | def data_labels(self,
image,
fudged_image,
segments,
classifier_fn,
num_samples,
batch_size=10):
"""Generates images and predictions in the neighborhood of this image.
Args:
... | python | def data_labels(self,
image,
fudged_image,
segments,
classifier_fn,
num_samples,
batch_size=10):
"""Generates images and predictions in the neighborhood of this image.
Args:
... | [
"def",
"data_labels",
"(",
"self",
",",
"image",
",",
"fudged_image",
",",
"segments",
",",
"classifier_fn",
",",
"num_samples",
",",
"batch_size",
"=",
"10",
")",
":",
"n_features",
"=",
"np",
".",
"unique",
"(",
"segments",
")",
".",
"shape",
"[",
"0",... | Generates images and predictions in the neighborhood of this image.
Args:
image: 3d numpy array, the image
fudged_image: 3d numpy array, image to replace original image when
superpixel is turned off
segments: segmentation of the image
classifier_f... | [
"Generates",
"images",
"and",
"predictions",
"in",
"the",
"neighborhood",
"of",
"this",
"image",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/lime_image.py#L216-L261 | train |
marcotcr/lime | lime/utils/generic_utils.py | has_arg | def has_arg(fn, arg_name):
"""Checks if a callable accepts a given keyword argument.
Args:
fn: callable to inspect
arg_name: string, keyword argument name to check
Returns:
bool, whether `fn` accepts a `arg_name` keyword argument.
"""
if sys.version_info < (3,):
if ... | python | def has_arg(fn, arg_name):
"""Checks if a callable accepts a given keyword argument.
Args:
fn: callable to inspect
arg_name: string, keyword argument name to check
Returns:
bool, whether `fn` accepts a `arg_name` keyword argument.
"""
if sys.version_info < (3,):
if ... | [
"def",
"has_arg",
"(",
"fn",
",",
"arg_name",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
")",
":",
"if",
"isinstance",
"(",
"fn",
",",
"types",
".",
"FunctionType",
")",
"or",
"isinstance",
"(",
"fn",
",",
"types",
".",
"Method... | Checks if a callable accepts a given keyword argument.
Args:
fn: callable to inspect
arg_name: string, keyword argument name to check
Returns:
bool, whether `fn` accepts a `arg_name` keyword argument. | [
"Checks",
"if",
"a",
"callable",
"accepts",
"a",
"given",
"keyword",
"argument",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/utils/generic_utils.py#L6-L39 | train |
marcotcr/lime | lime/discretize.py | BaseDiscretizer.discretize | def discretize(self, data):
"""Discretizes the data.
Args:
data: numpy 2d or 1d array
Returns:
numpy array of same dimension, discretized.
"""
ret = data.copy()
for feature in self.lambdas:
if len(data.shape) == 1:
ret[f... | python | def discretize(self, data):
"""Discretizes the data.
Args:
data: numpy 2d or 1d array
Returns:
numpy array of same dimension, discretized.
"""
ret = data.copy()
for feature in self.lambdas:
if len(data.shape) == 1:
ret[f... | [
"def",
"discretize",
"(",
"self",
",",
"data",
")",
":",
"ret",
"=",
"data",
".",
"copy",
"(",
")",
"for",
"feature",
"in",
"self",
".",
"lambdas",
":",
"if",
"len",
"(",
"data",
".",
"shape",
")",
"==",
"1",
":",
"ret",
"[",
"feature",
"]",
"=... | Discretizes the data.
Args:
data: numpy 2d or 1d array
Returns:
numpy array of same dimension, discretized. | [
"Discretizes",
"the",
"data",
".",
"Args",
":",
"data",
":",
"numpy",
"2d",
"or",
"1d",
"array",
"Returns",
":",
"numpy",
"array",
"of",
"same",
"dimension",
"discretized",
"."
] | 08133d47df00ed918e22005e0c98f6eefd5a1d71 | https://github.com/marcotcr/lime/blob/08133d47df00ed918e22005e0c98f6eefd5a1d71/lime/discretize.py#L99-L113 | train |
iterative/dvc | dvc/cache.py | Cache._get_remote | def _get_remote(self, config, name):
"""
The config file is stored in a way that allows you to have a
cache for each remote.
This is needed when specifying external outputs
(as they require you to have an external cache location).
Imagine a config file like the followin... | python | def _get_remote(self, config, name):
"""
The config file is stored in a way that allows you to have a
cache for each remote.
This is needed when specifying external outputs
(as they require you to have an external cache location).
Imagine a config file like the followin... | [
"def",
"_get_remote",
"(",
"self",
",",
"config",
",",
"name",
")",
":",
"from",
"dvc",
".",
"remote",
"import",
"Remote",
"remote",
"=",
"config",
".",
"get",
"(",
"name",
")",
"if",
"not",
"remote",
":",
"return",
"None",
"settings",
"=",
"self",
"... | The config file is stored in a way that allows you to have a
cache for each remote.
This is needed when specifying external outputs
(as they require you to have an external cache location).
Imagine a config file like the following:
['remote "dvc-storage"']
... | [
"The",
"config",
"file",
"is",
"stored",
"in",
"a",
"way",
"that",
"allows",
"you",
"to",
"have",
"a",
"cache",
"for",
"each",
"remote",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cache.py#L52-L91 | train |
iterative/dvc | dvc/dagascii.py | draw | def draw(vertexes, edges):
"""Build a DAG and draw it in ASCII.
Args:
vertexes (list): list of graph vertexes.
edges (list): list of graph edges.
"""
# pylint: disable=too-many-locals
# NOTE: coordinates might me negative, so we need to shift
# everything to the positive plane b... | python | def draw(vertexes, edges):
"""Build a DAG and draw it in ASCII.
Args:
vertexes (list): list of graph vertexes.
edges (list): list of graph edges.
"""
# pylint: disable=too-many-locals
# NOTE: coordinates might me negative, so we need to shift
# everything to the positive plane b... | [
"def",
"draw",
"(",
"vertexes",
",",
"edges",
")",
":",
"# pylint: disable=too-many-locals",
"# NOTE: coordinates might me negative, so we need to shift",
"# everything to the positive plane before we actually draw it.",
"Xs",
"=",
"[",
"]",
"# pylint: disable=invalid-name",
"Ys",
... | Build a DAG and draw it in ASCII.
Args:
vertexes (list): list of graph vertexes.
edges (list): list of graph edges. | [
"Build",
"a",
"DAG",
"and",
"draw",
"it",
"in",
"ASCII",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L297-L370 | train |
iterative/dvc | dvc/dagascii.py | AsciiCanvas.draw | def draw(self):
"""Draws ASCII canvas on the screen."""
if sys.stdout.isatty(): # pragma: no cover
from asciimatics.screen import Screen
Screen.wrapper(self._do_draw)
else:
for line in self.canvas:
print("".join(line)) | python | def draw(self):
"""Draws ASCII canvas on the screen."""
if sys.stdout.isatty(): # pragma: no cover
from asciimatics.screen import Screen
Screen.wrapper(self._do_draw)
else:
for line in self.canvas:
print("".join(line)) | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"# pragma: no cover",
"from",
"asciimatics",
".",
"screen",
"import",
"Screen",
"Screen",
".",
"wrapper",
"(",
"self",
".",
"_do_draw",
")",
"else",
":",
"f... | Draws ASCII canvas on the screen. | [
"Draws",
"ASCII",
"canvas",
"on",
"the",
"screen",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L59-L67 | train |
iterative/dvc | dvc/dagascii.py | AsciiCanvas.point | def point(self, x, y, char):
"""Create a point on ASCII canvas.
Args:
x (int): x coordinate. Should be >= 0 and < number of columns in
the canvas.
y (int): y coordinate. Should be >= 0 an < number of lines in the
canvas.
char (str): ch... | python | def point(self, x, y, char):
"""Create a point on ASCII canvas.
Args:
x (int): x coordinate. Should be >= 0 and < number of columns in
the canvas.
y (int): y coordinate. Should be >= 0 an < number of lines in the
canvas.
char (str): ch... | [
"def",
"point",
"(",
"self",
",",
"x",
",",
"y",
",",
"char",
")",
":",
"assert",
"len",
"(",
"char",
")",
"==",
"1",
"assert",
"x",
">=",
"0",
"assert",
"x",
"<",
"self",
".",
"cols",
"assert",
"y",
">=",
"0",
"assert",
"y",
"<",
"self",
"."... | Create a point on ASCII canvas.
Args:
x (int): x coordinate. Should be >= 0 and < number of columns in
the canvas.
y (int): y coordinate. Should be >= 0 an < number of lines in the
canvas.
char (str): character to place in the specified point ... | [
"Create",
"a",
"point",
"on",
"ASCII",
"canvas",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L155-L172 | train |
iterative/dvc | dvc/dagascii.py | AsciiCanvas.line | def line(self, x0, y0, x1, y1, char):
"""Create a line on ASCII canvas.
Args:
x0 (int): x coordinate where the line should start.
y0 (int): y coordinate where the line should start.
x1 (int): x coordinate where the line should end.
y1 (int): y coordinate ... | python | def line(self, x0, y0, x1, y1, char):
"""Create a line on ASCII canvas.
Args:
x0 (int): x coordinate where the line should start.
y0 (int): y coordinate where the line should start.
x1 (int): x coordinate where the line should end.
y1 (int): y coordinate ... | [
"def",
"line",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"char",
")",
":",
"# pylint: disable=too-many-arguments, too-many-branches",
"if",
"x0",
">",
"x1",
":",
"x1",
",",
"x0",
"=",
"x0",
",",
"x1",
"y1",
",",
"y0",
"=",
"y0",
... | Create a line on ASCII canvas.
Args:
x0 (int): x coordinate where the line should start.
y0 (int): y coordinate where the line should start.
x1 (int): x coordinate where the line should end.
y1 (int): y coordinate where the line should end.
char (str)... | [
"Create",
"a",
"line",
"on",
"ASCII",
"canvas",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L174-L214 | train |
iterative/dvc | dvc/dagascii.py | AsciiCanvas.text | def text(self, x, y, text):
"""Print a text on ASCII canvas.
Args:
x (int): x coordinate where the text should start.
y (int): y coordinate where the text should start.
text (str): string that should be printed.
"""
for i, char in enumerate(text):
... | python | def text(self, x, y, text):
"""Print a text on ASCII canvas.
Args:
x (int): x coordinate where the text should start.
y (int): y coordinate where the text should start.
text (str): string that should be printed.
"""
for i, char in enumerate(text):
... | [
"def",
"text",
"(",
"self",
",",
"x",
",",
"y",
",",
"text",
")",
":",
"for",
"i",
",",
"char",
"in",
"enumerate",
"(",
"text",
")",
":",
"self",
".",
"point",
"(",
"x",
"+",
"i",
",",
"y",
",",
"char",
")"
] | Print a text on ASCII canvas.
Args:
x (int): x coordinate where the text should start.
y (int): y coordinate where the text should start.
text (str): string that should be printed. | [
"Print",
"a",
"text",
"on",
"ASCII",
"canvas",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L216-L225 | train |
iterative/dvc | dvc/dagascii.py | AsciiCanvas.box | def box(self, x0, y0, width, height):
"""Create a box on ASCII canvas.
Args:
x0 (int): x coordinate of the box corner.
y0 (int): y coordinate of the box corner.
width (int): box width.
height (int): box height.
"""
assert width > 1
... | python | def box(self, x0, y0, width, height):
"""Create a box on ASCII canvas.
Args:
x0 (int): x coordinate of the box corner.
y0 (int): y coordinate of the box corner.
width (int): box width.
height (int): box height.
"""
assert width > 1
... | [
"def",
"box",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"width",
",",
"height",
")",
":",
"assert",
"width",
">",
"1",
"assert",
"height",
">",
"1",
"width",
"-=",
"1",
"height",
"-=",
"1",
"for",
"x",
"in",
"range",
"(",
"x0",
",",
"x0",
"+",
... | Create a box on ASCII canvas.
Args:
x0 (int): x coordinate of the box corner.
y0 (int): y coordinate of the box corner.
width (int): box width.
height (int): box height. | [
"Create",
"a",
"box",
"on",
"ASCII",
"canvas",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/dagascii.py#L227-L253 | train |
iterative/dvc | dvc/progress.py | Progress.refresh | def refresh(self, line=None):
"""Refreshes progress bar."""
# Just go away if it is locked. Will update next time
if not self._lock.acquire(False):
return
if line is None:
line = self._line
if sys.stdout.isatty() and line is not None:
self._w... | python | def refresh(self, line=None):
"""Refreshes progress bar."""
# Just go away if it is locked. Will update next time
if not self._lock.acquire(False):
return
if line is None:
line = self._line
if sys.stdout.isatty() and line is not None:
self._w... | [
"def",
"refresh",
"(",
"self",
",",
"line",
"=",
"None",
")",
":",
"# Just go away if it is locked. Will update next time",
"if",
"not",
"self",
".",
"_lock",
".",
"acquire",
"(",
"False",
")",
":",
"return",
"if",
"line",
"is",
"None",
":",
"line",
"=",
"... | Refreshes progress bar. | [
"Refreshes",
"progress",
"bar",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L49-L62 | train |
iterative/dvc | dvc/progress.py | Progress.update_target | def update_target(self, name, current, total):
"""Updates progress bar for a specified target."""
self.refresh(self._bar(name, current, total)) | python | def update_target(self, name, current, total):
"""Updates progress bar for a specified target."""
self.refresh(self._bar(name, current, total)) | [
"def",
"update_target",
"(",
"self",
",",
"name",
",",
"current",
",",
"total",
")",
":",
"self",
".",
"refresh",
"(",
"self",
".",
"_bar",
"(",
"name",
",",
"current",
",",
"total",
")",
")"
] | Updates progress bar for a specified target. | [
"Updates",
"progress",
"bar",
"for",
"a",
"specified",
"target",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L64-L66 | train |
iterative/dvc | dvc/progress.py | Progress.finish_target | def finish_target(self, name):
"""Finishes progress bar for a specified target."""
# We have to write a msg about finished target
with self._lock:
pbar = self._bar(name, 100, 100)
if sys.stdout.isatty():
self.clearln()
self._print(pbar)
... | python | def finish_target(self, name):
"""Finishes progress bar for a specified target."""
# We have to write a msg about finished target
with self._lock:
pbar = self._bar(name, 100, 100)
if sys.stdout.isatty():
self.clearln()
self._print(pbar)
... | [
"def",
"finish_target",
"(",
"self",
",",
"name",
")",
":",
"# We have to write a msg about finished target",
"with",
"self",
".",
"_lock",
":",
"pbar",
"=",
"self",
".",
"_bar",
"(",
"name",
",",
"100",
",",
"100",
")",
"if",
"sys",
".",
"stdout",
".",
... | Finishes progress bar for a specified target. | [
"Finishes",
"progress",
"bar",
"for",
"a",
"specified",
"target",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L68-L80 | train |
iterative/dvc | dvc/progress.py | Progress._bar | def _bar(self, target_name, current, total):
"""
Make a progress bar out of info, which looks like:
(1/2): [########################################] 100% master.zip
"""
bar_len = 30
if total is None:
state = 0
percent = "?% "
else:
... | python | def _bar(self, target_name, current, total):
"""
Make a progress bar out of info, which looks like:
(1/2): [########################################] 100% master.zip
"""
bar_len = 30
if total is None:
state = 0
percent = "?% "
else:
... | [
"def",
"_bar",
"(",
"self",
",",
"target_name",
",",
"current",
",",
"total",
")",
":",
"bar_len",
"=",
"30",
"if",
"total",
"is",
"None",
":",
"state",
"=",
"0",
"percent",
"=",
"\"?% \"",
"else",
":",
"total",
"=",
"int",
"(",
"total",
")",
"stat... | Make a progress bar out of info, which looks like:
(1/2): [########################################] 100% master.zip | [
"Make",
"a",
"progress",
"bar",
"out",
"of",
"info",
"which",
"looks",
"like",
":",
"(",
"1",
"/",
"2",
")",
":",
"[",
"########################################",
"]",
"100%",
"master",
".",
"zip"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/progress.py#L82-L106 | train |
iterative/dvc | dvc/repo/diff.py | _extract_dir | def _extract_dir(self, dir_not_exists, output):
"""Extract the content of dvc tree file
Args:
self(object) - Repo class instance
dir_not_exists(bool) - flag for directory existence
output(object) - OutputLOCAL class instance
Returns:
dict - dictionary with keys - paths to fil... | python | def _extract_dir(self, dir_not_exists, output):
"""Extract the content of dvc tree file
Args:
self(object) - Repo class instance
dir_not_exists(bool) - flag for directory existence
output(object) - OutputLOCAL class instance
Returns:
dict - dictionary with keys - paths to fil... | [
"def",
"_extract_dir",
"(",
"self",
",",
"dir_not_exists",
",",
"output",
")",
":",
"if",
"not",
"dir_not_exists",
":",
"lst",
"=",
"output",
".",
"dir_cache",
"return",
"{",
"i",
"[",
"\"relpath\"",
"]",
":",
"i",
"[",
"\"md5\"",
"]",
"for",
"i",
"in"... | Extract the content of dvc tree file
Args:
self(object) - Repo class instance
dir_not_exists(bool) - flag for directory existence
output(object) - OutputLOCAL class instance
Returns:
dict - dictionary with keys - paths to file in .dvc/cache
values -... | [
"Extract",
"the",
"content",
"of",
"dvc",
"tree",
"file",
"Args",
":",
"self",
"(",
"object",
")",
"-",
"Repo",
"class",
"instance",
"dir_not_exists",
"(",
"bool",
")",
"-",
"flag",
"for",
"directory",
"existence",
"output",
"(",
"object",
")",
"-",
"Out... | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/diff.py#L45-L58 | train |
iterative/dvc | dvc/repo/diff.py | diff | def diff(self, a_ref, target=None, b_ref=None):
"""Gerenates diff message string output
Args:
target(str) - file/directory to check diff of
a_ref(str) - first tag
(optional) b_ref(str) - second git tag
Returns:
string: string of output message with diff info
"""
res... | python | def diff(self, a_ref, target=None, b_ref=None):
"""Gerenates diff message string output
Args:
target(str) - file/directory to check diff of
a_ref(str) - first tag
(optional) b_ref(str) - second git tag
Returns:
string: string of output message with diff info
"""
res... | [
"def",
"diff",
"(",
"self",
",",
"a_ref",
",",
"target",
"=",
"None",
",",
"b_ref",
"=",
"None",
")",
":",
"result",
"=",
"{",
"}",
"diff_dct",
"=",
"self",
".",
"scm",
".",
"get_diff_trees",
"(",
"a_ref",
",",
"b_ref",
"=",
"b_ref",
")",
"result",... | Gerenates diff message string output
Args:
target(str) - file/directory to check diff of
a_ref(str) - first tag
(optional) b_ref(str) - second git tag
Returns:
string: string of output message with diff info | [
"Gerenates",
"diff",
"message",
"string",
"output"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/diff.py#L223-L252 | train |
iterative/dvc | dvc/repo/reproduce.py | _reproduce_stages | def _reproduce_stages(
G,
stages,
node,
force,
dry,
interactive,
ignore_build_cache,
no_commit,
downstream,
):
r"""Derive the evaluation of the given node for the given graph.
When you _reproduce a stage_, you want to _evaluate the descendants_
to know if it make sense t... | python | def _reproduce_stages(
G,
stages,
node,
force,
dry,
interactive,
ignore_build_cache,
no_commit,
downstream,
):
r"""Derive the evaluation of the given node for the given graph.
When you _reproduce a stage_, you want to _evaluate the descendants_
to know if it make sense t... | [
"def",
"_reproduce_stages",
"(",
"G",
",",
"stages",
",",
"node",
",",
"force",
",",
"dry",
",",
"interactive",
",",
"ignore_build_cache",
",",
"no_commit",
",",
"downstream",
",",
")",
":",
"import",
"networkx",
"as",
"nx",
"if",
"downstream",
":",
"# NOT... | r"""Derive the evaluation of the given node for the given graph.
When you _reproduce a stage_, you want to _evaluate the descendants_
to know if it make sense to _recompute_ it. A post-ordered search
will give us an order list of the nodes we want.
For example, let's say that we have the following pip... | [
"r",
"Derive",
"the",
"evaluation",
"of",
"the",
"given",
"node",
"for",
"the",
"given",
"graph",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/reproduce.py#L132-L210 | train |
iterative/dvc | dvc/istextfile.py | istextfile | def istextfile(fname, blocksize=512):
""" Uses heuristics to guess whether the given file is text or binary,
by reading a single block of bytes from the file.
If more than 30% of the chars in the block are non-text, or there
are NUL ('\x00') bytes in the block, assume this is a binary file.
... | python | def istextfile(fname, blocksize=512):
""" Uses heuristics to guess whether the given file is text or binary,
by reading a single block of bytes from the file.
If more than 30% of the chars in the block are non-text, or there
are NUL ('\x00') bytes in the block, assume this is a binary file.
... | [
"def",
"istextfile",
"(",
"fname",
",",
"blocksize",
"=",
"512",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"rb\"",
")",
"as",
"fobj",
":",
"block",
"=",
"fobj",
".",
"read",
"(",
"blocksize",
")",
"if",
"not",
"block",
":",
"# An empty file is con... | Uses heuristics to guess whether the given file is text or binary,
by reading a single block of bytes from the file.
If more than 30% of the chars in the block are non-text, or there
are NUL ('\x00') bytes in the block, assume this is a binary file. | [
"Uses",
"heuristics",
"to",
"guess",
"whether",
"the",
"given",
"file",
"is",
"text",
"or",
"binary",
"by",
"reading",
"a",
"single",
"block",
"of",
"bytes",
"from",
"the",
"file",
".",
"If",
"more",
"than",
"30%",
"of",
"the",
"chars",
"in",
"the",
"b... | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/istextfile.py#L24-L44 | train |
iterative/dvc | dvc/utils/compat.py | csv_reader | def csv_reader(unicode_csv_data, dialect=None, **kwargs):
"""csv.reader doesn't support Unicode input, so need to use some tricks
to work around this.
Source: https://docs.python.org/2/library/csv.html#csv-examples
"""
import csv
dialect = dialect or csv.excel
if is_py3:
# Python3... | python | def csv_reader(unicode_csv_data, dialect=None, **kwargs):
"""csv.reader doesn't support Unicode input, so need to use some tricks
to work around this.
Source: https://docs.python.org/2/library/csv.html#csv-examples
"""
import csv
dialect = dialect or csv.excel
if is_py3:
# Python3... | [
"def",
"csv_reader",
"(",
"unicode_csv_data",
",",
"dialect",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"csv",
"dialect",
"=",
"dialect",
"or",
"csv",
".",
"excel",
"if",
"is_py3",
":",
"# Python3 supports encoding by default, so just return the ob... | csv.reader doesn't support Unicode input, so need to use some tricks
to work around this.
Source: https://docs.python.org/2/library/csv.html#csv-examples | [
"csv",
".",
"reader",
"doesn",
"t",
"support",
"Unicode",
"input",
"so",
"need",
"to",
"use",
"some",
"tricks",
"to",
"work",
"around",
"this",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/compat.py#L30-L52 | train |
iterative/dvc | dvc/utils/compat.py | cast_bytes | def cast_bytes(s, encoding=None):
"""Source: https://github.com/ipython/ipython_genutils"""
if not isinstance(s, bytes):
return encode(s, encoding)
return s | python | def cast_bytes(s, encoding=None):
"""Source: https://github.com/ipython/ipython_genutils"""
if not isinstance(s, bytes):
return encode(s, encoding)
return s | [
"def",
"cast_bytes",
"(",
"s",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"bytes",
")",
":",
"return",
"encode",
"(",
"s",
",",
"encoding",
")",
"return",
"s"
] | Source: https://github.com/ipython/ipython_genutils | [
"Source",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"ipython",
"/",
"ipython_genutils"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/compat.py#L61-L65 | train |
iterative/dvc | dvc/utils/compat.py | _makedirs | def _makedirs(name, mode=0o777, exist_ok=False):
"""Source: https://github.com/python/cpython/blob/
3ce3dea60646d8a5a1c952469a2eb65f937875b3/Lib/os.py#L196-L226
"""
head, tail = os.path.split(name)
if not tail:
head, tail = os.path.split(head)
if head and tail and not os.path.exists(... | python | def _makedirs(name, mode=0o777, exist_ok=False):
"""Source: https://github.com/python/cpython/blob/
3ce3dea60646d8a5a1c952469a2eb65f937875b3/Lib/os.py#L196-L226
"""
head, tail = os.path.split(name)
if not tail:
head, tail = os.path.split(head)
if head and tail and not os.path.exists(... | [
"def",
"_makedirs",
"(",
"name",
",",
"mode",
"=",
"0o777",
",",
"exist_ok",
"=",
"False",
")",
":",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"name",
")",
"if",
"not",
"tail",
":",
"head",
",",
"tail",
"=",
"os",
".",
"pa... | Source: https://github.com/python/cpython/blob/
3ce3dea60646d8a5a1c952469a2eb65f937875b3/Lib/os.py#L196-L226 | [
"Source",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"python",
"/",
"cpython",
"/",
"blob",
"/",
"3ce3dea60646d8a5a1c952469a2eb65f937875b3",
"/",
"Lib",
"/",
"os",
".",
"py#L196",
"-",
"L226"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/compat.py#L68-L90 | train |
iterative/dvc | dvc/repo/pkg/install.py | install | def install(self, address, target_dir, select=[], fname=None):
"""
Install package.
The command can be run only from DVC project root.
E.g.
Having: DVC package in https://github.com/dmpetrov/tag_classifier
$ dvc pkg install https://github.com/dmpetrov/tag_classifier
Res... | python | def install(self, address, target_dir, select=[], fname=None):
"""
Install package.
The command can be run only from DVC project root.
E.g.
Having: DVC package in https://github.com/dmpetrov/tag_classifier
$ dvc pkg install https://github.com/dmpetrov/tag_classifier
Res... | [
"def",
"install",
"(",
"self",
",",
"address",
",",
"target_dir",
",",
"select",
"=",
"[",
"]",
",",
"fname",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"target_dir",
")",
":",
"raise",
"DvcException",
"(",
"\"target di... | Install package.
The command can be run only from DVC project root.
E.g.
Having: DVC package in https://github.com/dmpetrov/tag_classifier
$ dvc pkg install https://github.com/dmpetrov/tag_classifier
Result: tag_classifier package in dvc_mod/ directory | [
"Install",
"package",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/pkg/install.py#L144-L173 | train |
iterative/dvc | dvc/stage.py | Stage.is_import | def is_import(self):
"""Whether the stage file was created with `dvc import`."""
return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1 | python | def is_import(self):
"""Whether the stage file was created with `dvc import`."""
return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1 | [
"def",
"is_import",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"cmd",
"and",
"len",
"(",
"self",
".",
"deps",
")",
"==",
"1",
"and",
"len",
"(",
"self",
".",
"outs",
")",
"==",
"1"
] | Whether the stage file was created with `dvc import`. | [
"Whether",
"the",
"stage",
"file",
"was",
"created",
"with",
"dvc",
"import",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/stage.py#L211-L213 | train |
iterative/dvc | dvc/stage.py | Stage.remove_outs | def remove_outs(self, ignore_remove=False, force=False):
"""Used mainly for `dvc remove --outs` and :func:`Stage.reproduce`."""
for out in self.outs:
if out.persist and not force:
out.unprotect()
else:
logger.debug(
"Removing ou... | python | def remove_outs(self, ignore_remove=False, force=False):
"""Used mainly for `dvc remove --outs` and :func:`Stage.reproduce`."""
for out in self.outs:
if out.persist and not force:
out.unprotect()
else:
logger.debug(
"Removing ou... | [
"def",
"remove_outs",
"(",
"self",
",",
"ignore_remove",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"for",
"out",
"in",
"self",
".",
"outs",
":",
"if",
"out",
".",
"persist",
"and",
"not",
"force",
":",
"out",
".",
"unprotect",
"(",
")",
"... | Used mainly for `dvc remove --outs` and :func:`Stage.reproduce`. | [
"Used",
"mainly",
"for",
"dvc",
"remove",
"--",
"outs",
"and",
":",
"func",
":",
"Stage",
".",
"reproduce",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/stage.py#L272-L283 | train |
iterative/dvc | dvc/stage.py | Stage.is_cached | def is_cached(self):
"""
Checks if this stage has been already ran and stored
"""
from dvc.remote.local import RemoteLOCAL
from dvc.remote.s3 import RemoteS3
old = Stage.load(self.repo, self.path)
if old._changed_outs():
return False
# NOTE: ... | python | def is_cached(self):
"""
Checks if this stage has been already ran and stored
"""
from dvc.remote.local import RemoteLOCAL
from dvc.remote.s3 import RemoteS3
old = Stage.load(self.repo, self.path)
if old._changed_outs():
return False
# NOTE: ... | [
"def",
"is_cached",
"(",
"self",
")",
":",
"from",
"dvc",
".",
"remote",
".",
"local",
"import",
"RemoteLOCAL",
"from",
"dvc",
".",
"remote",
".",
"s3",
"import",
"RemoteS3",
"old",
"=",
"Stage",
".",
"load",
"(",
"self",
".",
"repo",
",",
"self",
".... | Checks if this stage has been already ran and stored | [
"Checks",
"if",
"this",
"stage",
"has",
"been",
"already",
"ran",
"and",
"stored"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/stage.py#L369-L411 | train |
iterative/dvc | dvc/daemon.py | daemon | def daemon(args):
"""Launch a `dvc daemon` command in a detached process.
Args:
args (list): list of arguments to append to `dvc daemon` command.
"""
if os.environ.get(DVC_DAEMON):
logger.debug("skipping launching a new daemon.")
return
cmd = [sys.executable]
if not is_... | python | def daemon(args):
"""Launch a `dvc daemon` command in a detached process.
Args:
args (list): list of arguments to append to `dvc daemon` command.
"""
if os.environ.get(DVC_DAEMON):
logger.debug("skipping launching a new daemon.")
return
cmd = [sys.executable]
if not is_... | [
"def",
"daemon",
"(",
"args",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"DVC_DAEMON",
")",
":",
"logger",
".",
"debug",
"(",
"\"skipping launching a new daemon.\"",
")",
"return",
"cmd",
"=",
"[",
"sys",
".",
"executable",
"]",
"if",
"not",
... | Launch a `dvc daemon` command in a detached process.
Args:
args (list): list of arguments to append to `dvc daemon` command. | [
"Launch",
"a",
"dvc",
"daemon",
"command",
"in",
"a",
"detached",
"process",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/daemon.py#L85-L107 | train |
iterative/dvc | dvc/command/run.py | CmdRun._parsed_cmd | def _parsed_cmd(self):
"""
We need to take into account two cases:
- ['python code.py foo bar']: Used mainly with dvc as a library
- ['echo', 'foo bar']: List of arguments received from the CLI
The second case would need quoting, as it was passed through:
dvc ru... | python | def _parsed_cmd(self):
"""
We need to take into account two cases:
- ['python code.py foo bar']: Used mainly with dvc as a library
- ['echo', 'foo bar']: List of arguments received from the CLI
The second case would need quoting, as it was passed through:
dvc ru... | [
"def",
"_parsed_cmd",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"args",
".",
"command",
")",
"<",
"2",
":",
"return",
"\" \"",
".",
"join",
"(",
"self",
".",
"args",
".",
"command",
")",
"return",
"\" \"",
".",
"join",
"(",
"self",
".... | We need to take into account two cases:
- ['python code.py foo bar']: Used mainly with dvc as a library
- ['echo', 'foo bar']: List of arguments received from the CLI
The second case would need quoting, as it was passed through:
dvc run echo "foo bar" | [
"We",
"need",
"to",
"take",
"into",
"account",
"two",
"cases",
":"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/run.py#L61-L74 | train |
iterative/dvc | dvc/command/init.py | add_parser | def add_parser(subparsers, parent_parser):
"""Setup parser for `dvc init`."""
INIT_HELP = "Initialize DVC in the current directory."
INIT_DESCRIPTION = (
"Initialize DVC in the current directory. Expects directory\n"
"to be a Git repository unless --no-scm option is specified."
)
in... | python | def add_parser(subparsers, parent_parser):
"""Setup parser for `dvc init`."""
INIT_HELP = "Initialize DVC in the current directory."
INIT_DESCRIPTION = (
"Initialize DVC in the current directory. Expects directory\n"
"to be a Git repository unless --no-scm option is specified."
)
in... | [
"def",
"add_parser",
"(",
"subparsers",
",",
"parent_parser",
")",
":",
"INIT_HELP",
"=",
"\"Initialize DVC in the current directory.\"",
"INIT_DESCRIPTION",
"=",
"(",
"\"Initialize DVC in the current directory. Expects directory\\n\"",
"\"to be a Git repository unless --no-scm option ... | Setup parser for `dvc init`. | [
"Setup",
"parser",
"for",
"dvc",
"init",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/init.py#L31-L63 | train |
iterative/dvc | dvc/repo/metrics/show.py | _format_csv | def _format_csv(content, delimiter):
"""Format delimited text to have same column width.
Args:
content (str): The content of a metric.
delimiter (str): Value separator
Returns:
str: Formatted content.
Example:
>>> content = (
"value_mse,deviation_mse,data_... | python | def _format_csv(content, delimiter):
"""Format delimited text to have same column width.
Args:
content (str): The content of a metric.
delimiter (str): Value separator
Returns:
str: Formatted content.
Example:
>>> content = (
"value_mse,deviation_mse,data_... | [
"def",
"_format_csv",
"(",
"content",
",",
"delimiter",
")",
":",
"reader",
"=",
"csv_reader",
"(",
"StringIO",
"(",
"content",
")",
",",
"delimiter",
"=",
"builtin_str",
"(",
"delimiter",
")",
")",
"rows",
"=",
"[",
"row",
"for",
"row",
"in",
"reader",
... | Format delimited text to have same column width.
Args:
content (str): The content of a metric.
delimiter (str): Value separator
Returns:
str: Formatted content.
Example:
>>> content = (
"value_mse,deviation_mse,data_set\n"
"0.421601,0.173461,train\... | [
"Format",
"delimited",
"text",
"to",
"have",
"same",
"column",
"width",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L77-L114 | train |
iterative/dvc | dvc/repo/metrics/show.py | _format_output | def _format_output(content, typ):
"""Tabularize the content according to its type.
Args:
content (str): The content of a metric.
typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv).
Returns:
str: Content in a raw or tabular format.
"""
if "csv" in str(typ):
... | python | def _format_output(content, typ):
"""Tabularize the content according to its type.
Args:
content (str): The content of a metric.
typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv).
Returns:
str: Content in a raw or tabular format.
"""
if "csv" in str(typ):
... | [
"def",
"_format_output",
"(",
"content",
",",
"typ",
")",
":",
"if",
"\"csv\"",
"in",
"str",
"(",
"typ",
")",
":",
"return",
"_format_csv",
"(",
"content",
",",
"delimiter",
"=",
"\",\"",
")",
"if",
"\"tsv\"",
"in",
"str",
"(",
"typ",
")",
":",
"retu... | Tabularize the content according to its type.
Args:
content (str): The content of a metric.
typ (str): The type of metric -- (raw|json|tsv|htsv|csv|hcsv).
Returns:
str: Content in a raw or tabular format. | [
"Tabularize",
"the",
"content",
"according",
"to",
"its",
"type",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L117-L134 | train |
iterative/dvc | dvc/repo/metrics/show.py | _collect_metrics | def _collect_metrics(repo, path, recursive, typ, xpath, branch):
"""Gather all the metric outputs.
Args:
path (str): Path to a metric file or a directory.
recursive (bool): If path is a directory, do a recursive search for
metrics on the given path.
typ (str): The type of me... | python | def _collect_metrics(repo, path, recursive, typ, xpath, branch):
"""Gather all the metric outputs.
Args:
path (str): Path to a metric file or a directory.
recursive (bool): If path is a directory, do a recursive search for
metrics on the given path.
typ (str): The type of me... | [
"def",
"_collect_metrics",
"(",
"repo",
",",
"path",
",",
"recursive",
",",
"typ",
",",
"xpath",
",",
"branch",
")",
":",
"outs",
"=",
"[",
"out",
"for",
"stage",
"in",
"repo",
".",
"stages",
"(",
")",
"for",
"out",
"in",
"stage",
".",
"outs",
"]",... | Gather all the metric outputs.
Args:
path (str): Path to a metric file or a directory.
recursive (bool): If path is a directory, do a recursive search for
metrics on the given path.
typ (str): The type of metric to search for, could be one of the
following (raw|json|... | [
"Gather",
"all",
"the",
"metric",
"outputs",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L155-L200 | train |
iterative/dvc | dvc/repo/metrics/show.py | _read_metrics | def _read_metrics(repo, metrics, branch):
"""Read the content of each metric file and format it.
Args:
metrics (list): List of metric touples
branch (str): Branch to look up for metrics.
Returns:
A dict mapping keys with metrics path name and content.
For example:
... | python | def _read_metrics(repo, metrics, branch):
"""Read the content of each metric file and format it.
Args:
metrics (list): List of metric touples
branch (str): Branch to look up for metrics.
Returns:
A dict mapping keys with metrics path name and content.
For example:
... | [
"def",
"_read_metrics",
"(",
"repo",
",",
"metrics",
",",
"branch",
")",
":",
"res",
"=",
"{",
"}",
"for",
"out",
",",
"typ",
",",
"xpath",
"in",
"metrics",
":",
"assert",
"out",
".",
"scheme",
"==",
"\"local\"",
"if",
"not",
"typ",
":",
"typ",
"="... | Read the content of each metric file and format it.
Args:
metrics (list): List of metric touples
branch (str): Branch to look up for metrics.
Returns:
A dict mapping keys with metrics path name and content.
For example:
{'metric.csv': ("value_mse deviation_mse data_... | [
"Read",
"the",
"content",
"of",
"each",
"metric",
"file",
"and",
"format",
"it",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/metrics/show.py#L203-L256 | train |
iterative/dvc | dvc/repo/__init__.py | Repo.graph | def graph(self, stages=None, from_directory=None):
"""Generate a graph by using the given stages on the given directory
The nodes of the graph are the stage's path relative to the root.
Edges are created when the output of one stage is used as a
dependency in other stage.
The ... | python | def graph(self, stages=None, from_directory=None):
"""Generate a graph by using the given stages on the given directory
The nodes of the graph are the stage's path relative to the root.
Edges are created when the output of one stage is used as a
dependency in other stage.
The ... | [
"def",
"graph",
"(",
"self",
",",
"stages",
"=",
"None",
",",
"from_directory",
"=",
"None",
")",
":",
"import",
"networkx",
"as",
"nx",
"from",
"dvc",
".",
"exceptions",
"import",
"(",
"OutputDuplicationError",
",",
"StagePathAsOutputError",
",",
"Overlapping... | Generate a graph by using the given stages on the given directory
The nodes of the graph are the stage's path relative to the root.
Edges are created when the output of one stage is used as a
dependency in other stage.
The direction of the edges goes from the stage to its dependency:
... | [
"Generate",
"a",
"graph",
"by",
"using",
"the",
"given",
"stages",
"on",
"the",
"given",
"directory"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/__init__.py#L300-L404 | train |
iterative/dvc | dvc/repo/__init__.py | Repo.stages | def stages(self, from_directory=None, check_dag=True):
"""
Walks down the root directory looking for Dvcfiles,
skipping the directories that are related with
any SCM (e.g. `.git`), DVC itself (`.dvc`), or directories
tracked by DVC (e.g. `dvc add data` would skip `data/`)
... | python | def stages(self, from_directory=None, check_dag=True):
"""
Walks down the root directory looking for Dvcfiles,
skipping the directories that are related with
any SCM (e.g. `.git`), DVC itself (`.dvc`), or directories
tracked by DVC (e.g. `dvc add data` would skip `data/`)
... | [
"def",
"stages",
"(",
"self",
",",
"from_directory",
"=",
"None",
",",
"check_dag",
"=",
"True",
")",
":",
"from",
"dvc",
".",
"stage",
"import",
"Stage",
"if",
"not",
"from_directory",
":",
"from_directory",
"=",
"self",
".",
"root_dir",
"elif",
"not",
... | Walks down the root directory looking for Dvcfiles,
skipping the directories that are related with
any SCM (e.g. `.git`), DVC itself (`.dvc`), or directories
tracked by DVC (e.g. `dvc add data` would skip `data/`)
NOTE: For large repos, this could be an expensive
operation... | [
"Walks",
"down",
"the",
"root",
"directory",
"looking",
"for",
"Dvcfiles",
"skipping",
"the",
"directories",
"that",
"are",
"related",
"with",
"any",
"SCM",
"(",
"e",
".",
"g",
".",
".",
"git",
")",
"DVC",
"itself",
"(",
".",
"dvc",
")",
"or",
"directo... | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/__init__.py#L415-L462 | train |
iterative/dvc | dvc/logger.py | ColorFormatter._progress_aware | def _progress_aware(self):
"""Add a new line if progress bar hasn't finished"""
from dvc.progress import progress
if not progress.is_finished:
progress._print()
progress.clearln() | python | def _progress_aware(self):
"""Add a new line if progress bar hasn't finished"""
from dvc.progress import progress
if not progress.is_finished:
progress._print()
progress.clearln() | [
"def",
"_progress_aware",
"(",
"self",
")",
":",
"from",
"dvc",
".",
"progress",
"import",
"progress",
"if",
"not",
"progress",
".",
"is_finished",
":",
"progress",
".",
"_print",
"(",
")",
"progress",
".",
"clearln",
"(",
")"
] | Add a new line if progress bar hasn't finished | [
"Add",
"a",
"new",
"line",
"if",
"progress",
"bar",
"hasn",
"t",
"finished"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/logger.py#L134-L140 | train |
iterative/dvc | dvc/scm/tree.py | WorkingTree.open | def open(self, path, binary=False):
"""Open file and return a stream."""
if binary:
return open(path, "rb")
return open(path, encoding="utf-8") | python | def open(self, path, binary=False):
"""Open file and return a stream."""
if binary:
return open(path, "rb")
return open(path, encoding="utf-8") | [
"def",
"open",
"(",
"self",
",",
"path",
",",
"binary",
"=",
"False",
")",
":",
"if",
"binary",
":",
"return",
"open",
"(",
"path",
",",
"\"rb\"",
")",
"return",
"open",
"(",
"path",
",",
"encoding",
"=",
"\"utf-8\"",
")"
] | Open file and return a stream. | [
"Open",
"file",
"and",
"return",
"a",
"stream",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/tree.py#L45-L49 | train |
iterative/dvc | dvc/scm/tree.py | WorkingTree.walk | def walk(self, top, topdown=True, ignore_file_handler=None):
"""Directory tree generator.
See `os.walk` for the docs. Differences:
- no support for symlinks
- it could raise exceptions, there is no onerror argument
"""
def onerror(e):
raise e
for ro... | python | def walk(self, top, topdown=True, ignore_file_handler=None):
"""Directory tree generator.
See `os.walk` for the docs. Differences:
- no support for symlinks
- it could raise exceptions, there is no onerror argument
"""
def onerror(e):
raise e
for ro... | [
"def",
"walk",
"(",
"self",
",",
"top",
",",
"topdown",
"=",
"True",
",",
"ignore_file_handler",
"=",
"None",
")",
":",
"def",
"onerror",
"(",
"e",
")",
":",
"raise",
"e",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"dvc_walk",
"(",
"os",
".",
... | Directory tree generator.
See `os.walk` for the docs. Differences:
- no support for symlinks
- it could raise exceptions, there is no onerror argument | [
"Directory",
"tree",
"generator",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/tree.py#L63-L80 | train |
iterative/dvc | dvc/remote/s3.py | RemoteS3._list_paths | def _list_paths(self, bucket, prefix):
""" Read config for list object api, paginate through list objects."""
s3 = self.s3
kwargs = {"Bucket": bucket, "Prefix": prefix}
if self.list_objects:
list_objects_api = "list_objects"
else:
list_objects_api = "list_... | python | def _list_paths(self, bucket, prefix):
""" Read config for list object api, paginate through list objects."""
s3 = self.s3
kwargs = {"Bucket": bucket, "Prefix": prefix}
if self.list_objects:
list_objects_api = "list_objects"
else:
list_objects_api = "list_... | [
"def",
"_list_paths",
"(",
"self",
",",
"bucket",
",",
"prefix",
")",
":",
"s3",
"=",
"self",
".",
"s3",
"kwargs",
"=",
"{",
"\"Bucket\"",
":",
"bucket",
",",
"\"Prefix\"",
":",
"prefix",
"}",
"if",
"self",
".",
"list_objects",
":",
"list_objects_api",
... | Read config for list object api, paginate through list objects. | [
"Read",
"config",
"for",
"list",
"object",
"api",
"paginate",
"through",
"list",
"objects",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/s3.py#L212-L226 | train |
iterative/dvc | dvc/command/remote.py | CmdRemoteAdd.resolve_path | def resolve_path(path, config_file):
"""Resolve path relative to config file location.
Args:
path: Path to be resolved.
config_file: Path to config file, which `path` is specified
relative to.
Returns:
Path relative to the `config_file` locat... | python | def resolve_path(path, config_file):
"""Resolve path relative to config file location.
Args:
path: Path to be resolved.
config_file: Path to config file, which `path` is specified
relative to.
Returns:
Path relative to the `config_file` locat... | [
"def",
"resolve_path",
"(",
"path",
",",
"config_file",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
":",
"return",
"path",
"return",
"os",
".",
"path",
".",
"relpath",
"(",
"path",
",",
"os",
".",
"path",
".",
"dirname",
"(",... | Resolve path relative to config file location.
Args:
path: Path to be resolved.
config_file: Path to config file, which `path` is specified
relative to.
Returns:
Path relative to the `config_file` location. If `path` is an
absolute path t... | [
"Resolve",
"path",
"relative",
"to",
"config",
"file",
"location",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/remote.py#L18-L33 | train |
iterative/dvc | dvc/scm/git/__init__.py | Git.get_diff_trees | def get_diff_trees(self, a_ref, b_ref=None):
"""Method for getting two repo trees between two git tag commits
returns the dvc hash names of changed file/directory
Args:
a_ref(str) - git reference
b_ref(str) - optional second git reference, default None
Returns:
... | python | def get_diff_trees(self, a_ref, b_ref=None):
"""Method for getting two repo trees between two git tag commits
returns the dvc hash names of changed file/directory
Args:
a_ref(str) - git reference
b_ref(str) - optional second git reference, default None
Returns:
... | [
"def",
"get_diff_trees",
"(",
"self",
",",
"a_ref",
",",
"b_ref",
"=",
"None",
")",
":",
"diff_dct",
"=",
"{",
"DIFF_EQUAL",
":",
"False",
"}",
"trees",
",",
"commit_refs",
"=",
"self",
".",
"_get_diff_trees",
"(",
"a_ref",
",",
"b_ref",
")",
"diff_dct",... | Method for getting two repo trees between two git tag commits
returns the dvc hash names of changed file/directory
Args:
a_ref(str) - git reference
b_ref(str) - optional second git reference, default None
Returns:
dict - dictionary with keys: (a_tree, b_tree... | [
"Method",
"for",
"getting",
"two",
"repo",
"trees",
"between",
"two",
"git",
"tag",
"commits",
"returns",
"the",
"dvc",
"hash",
"names",
"of",
"changed",
"file",
"/",
"directory"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/git/__init__.py#L272-L292 | train |
iterative/dvc | dvc/remote/base.py | RemoteBase.changed | def changed(self, path_info, checksum_info):
"""Checks if data has changed.
A file is considered changed if:
- It doesn't exist on the working directory (was unlinked)
- Checksum is not computed (saving a new file)
- The checkusm stored in the State is different from... | python | def changed(self, path_info, checksum_info):
"""Checks if data has changed.
A file is considered changed if:
- It doesn't exist on the working directory (was unlinked)
- Checksum is not computed (saving a new file)
- The checkusm stored in the State is different from... | [
"def",
"changed",
"(",
"self",
",",
"path_info",
",",
"checksum_info",
")",
":",
"logger",
".",
"debug",
"(",
"\"checking if '{}'('{}') has changed.\"",
".",
"format",
"(",
"path_info",
",",
"checksum_info",
")",
")",
"if",
"not",
"self",
".",
"exists",
"(",
... | Checks if data has changed.
A file is considered changed if:
- It doesn't exist on the working directory (was unlinked)
- Checksum is not computed (saving a new file)
- The checkusm stored in the State is different from the given one
- There's no file in the cach... | [
"Checks",
"if",
"data",
"has",
"changed",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/base.py#L270-L318 | train |
iterative/dvc | dvc/prompt.py | confirm | def confirm(statement):
"""Ask the user for confirmation about the specified statement.
Args:
statement (unicode): statement to ask the user confirmation about.
Returns:
bool: whether or not specified statement was confirmed.
"""
prompt = "{statement} [y/n]".format(statement=statem... | python | def confirm(statement):
"""Ask the user for confirmation about the specified statement.
Args:
statement (unicode): statement to ask the user confirmation about.
Returns:
bool: whether or not specified statement was confirmed.
"""
prompt = "{statement} [y/n]".format(statement=statem... | [
"def",
"confirm",
"(",
"statement",
")",
":",
"prompt",
"=",
"\"{statement} [y/n]\"",
".",
"format",
"(",
"statement",
"=",
"statement",
")",
"answer",
"=",
"_ask",
"(",
"prompt",
",",
"limited_to",
"=",
"[",
"\"yes\"",
",",
"\"no\"",
",",
"\"y\"",
",",
... | Ask the user for confirmation about the specified statement.
Args:
statement (unicode): statement to ask the user confirmation about.
Returns:
bool: whether or not specified statement was confirmed. | [
"Ask",
"the",
"user",
"for",
"confirmation",
"about",
"the",
"specified",
"statement",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/prompt.py#L38-L49 | train |
iterative/dvc | dvc/main.py | main | def main(argv=None):
"""Run dvc CLI command.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Returns:
int: command's return code.
"""
args = None
cmd = None
try:
args = parse_args(argv)
if args.quiet:
logger.setLev... | python | def main(argv=None):
"""Run dvc CLI command.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Returns:
int: command's return code.
"""
args = None
cmd = None
try:
args = parse_args(argv)
if args.quiet:
logger.setLev... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"args",
"=",
"None",
"cmd",
"=",
"None",
"try",
":",
"args",
"=",
"parse_args",
"(",
"argv",
")",
"if",
"args",
".",
"quiet",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"CRITICAL",
")",
... | Run dvc CLI command.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Returns:
int: command's return code. | [
"Run",
"dvc",
"CLI",
"command",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/main.py#L15-L52 | train |
iterative/dvc | dvc/config.py | supported_cache_type | def supported_cache_type(types):
"""Checks if link type config option has a valid value.
Args:
types (list/string): type(s) of links that dvc should try out.
"""
if isinstance(types, str):
types = [typ.strip() for typ in types.split(",")]
for typ in types:
if typ not in ["re... | python | def supported_cache_type(types):
"""Checks if link type config option has a valid value.
Args:
types (list/string): type(s) of links that dvc should try out.
"""
if isinstance(types, str):
types = [typ.strip() for typ in types.split(",")]
for typ in types:
if typ not in ["re... | [
"def",
"supported_cache_type",
"(",
"types",
")",
":",
"if",
"isinstance",
"(",
"types",
",",
"str",
")",
":",
"types",
"=",
"[",
"typ",
".",
"strip",
"(",
")",
"for",
"typ",
"in",
"types",
".",
"split",
"(",
"\",\"",
")",
"]",
"for",
"typ",
"in",
... | Checks if link type config option has a valid value.
Args:
types (list/string): type(s) of links that dvc should try out. | [
"Checks",
"if",
"link",
"type",
"config",
"option",
"has",
"a",
"valid",
"value",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L32-L43 | train |
iterative/dvc | dvc/config.py | Config.get_global_config_dir | def get_global_config_dir():
"""Returns global config location. E.g. ~/.config/dvc/config.
Returns:
str: path to the global config directory.
"""
from appdirs import user_config_dir
return user_config_dir(
appname=Config.APPNAME, appauthor=Config.APPAUTH... | python | def get_global_config_dir():
"""Returns global config location. E.g. ~/.config/dvc/config.
Returns:
str: path to the global config directory.
"""
from appdirs import user_config_dir
return user_config_dir(
appname=Config.APPNAME, appauthor=Config.APPAUTH... | [
"def",
"get_global_config_dir",
"(",
")",
":",
"from",
"appdirs",
"import",
"user_config_dir",
"return",
"user_config_dir",
"(",
"appname",
"=",
"Config",
".",
"APPNAME",
",",
"appauthor",
"=",
"Config",
".",
"APPAUTHOR",
")"
] | Returns global config location. E.g. ~/.config/dvc/config.
Returns:
str: path to the global config directory. | [
"Returns",
"global",
"config",
"location",
".",
"E",
".",
"g",
".",
"~",
"/",
".",
"config",
"/",
"dvc",
"/",
"config",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L319-L329 | train |
iterative/dvc | dvc/config.py | Config.get_system_config_dir | def get_system_config_dir():
"""Returns system config location. E.g. /etc/dvc.conf.
Returns:
str: path to the system config directory.
"""
from appdirs import site_config_dir
return site_config_dir(
appname=Config.APPNAME, appauthor=Config.APPAUTHOR
... | python | def get_system_config_dir():
"""Returns system config location. E.g. /etc/dvc.conf.
Returns:
str: path to the system config directory.
"""
from appdirs import site_config_dir
return site_config_dir(
appname=Config.APPNAME, appauthor=Config.APPAUTHOR
... | [
"def",
"get_system_config_dir",
"(",
")",
":",
"from",
"appdirs",
"import",
"site_config_dir",
"return",
"site_config_dir",
"(",
"appname",
"=",
"Config",
".",
"APPNAME",
",",
"appauthor",
"=",
"Config",
".",
"APPAUTHOR",
")"
] | Returns system config location. E.g. /etc/dvc.conf.
Returns:
str: path to the system config directory. | [
"Returns",
"system",
"config",
"location",
".",
"E",
".",
"g",
".",
"/",
"etc",
"/",
"dvc",
".",
"conf",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L332-L342 | train |
iterative/dvc | dvc/config.py | Config.init | def init(dvc_dir):
"""Initializes dvc config.
Args:
dvc_dir (str): path to .dvc directory.
Returns:
dvc.config.Config: config object.
"""
config_file = os.path.join(dvc_dir, Config.CONFIG)
open(config_file, "w+").close()
return Config(dvc... | python | def init(dvc_dir):
"""Initializes dvc config.
Args:
dvc_dir (str): path to .dvc directory.
Returns:
dvc.config.Config: config object.
"""
config_file = os.path.join(dvc_dir, Config.CONFIG)
open(config_file, "w+").close()
return Config(dvc... | [
"def",
"init",
"(",
"dvc_dir",
")",
":",
"config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dvc_dir",
",",
"Config",
".",
"CONFIG",
")",
"open",
"(",
"config_file",
",",
"\"w+\"",
")",
".",
"close",
"(",
")",
"return",
"Config",
"(",
"dvc_dir"... | Initializes dvc config.
Args:
dvc_dir (str): path to .dvc directory.
Returns:
dvc.config.Config: config object. | [
"Initializes",
"dvc",
"config",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L345-L356 | train |
iterative/dvc | dvc/config.py | Config.load | def load(self, validate=True):
"""Loads config from all the config files.
Args:
validate (bool): optional flag to tell dvc if it should validate
the config or just load it as is. 'True' by default.
Raises:
dvc.config.ConfigError: thrown if config has in... | python | def load(self, validate=True):
"""Loads config from all the config files.
Args:
validate (bool): optional flag to tell dvc if it should validate
the config or just load it as is. 'True' by default.
Raises:
dvc.config.ConfigError: thrown if config has in... | [
"def",
"load",
"(",
"self",
",",
"validate",
"=",
"True",
")",
":",
"self",
".",
"_load",
"(",
")",
"try",
":",
"self",
".",
"config",
"=",
"self",
".",
"_load_config",
"(",
"self",
".",
"system_config_file",
")",
"user",
"=",
"self",
".",
"_load_con... | Loads config from all the config files.
Args:
validate (bool): optional flag to tell dvc if it should validate
the config or just load it as is. 'True' by default.
Raises:
dvc.config.ConfigError: thrown if config has invalid format. | [
"Loads",
"config",
"from",
"all",
"the",
"config",
"files",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L408-L441 | train |
iterative/dvc | dvc/config.py | Config.save | def save(self, config=None):
"""Saves config to config files.
Args:
config (configobj.ConfigObj): optional config object to save.
Raises:
dvc.config.ConfigError: thrown if failed to write config file.
"""
if config is not None:
clist = [confi... | python | def save(self, config=None):
"""Saves config to config files.
Args:
config (configobj.ConfigObj): optional config object to save.
Raises:
dvc.config.ConfigError: thrown if failed to write config file.
"""
if config is not None:
clist = [confi... | [
"def",
"save",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"if",
"config",
"is",
"not",
"None",
":",
"clist",
"=",
"[",
"config",
"]",
"else",
":",
"clist",
"=",
"[",
"self",
".",
"_system_config",
",",
"self",
".",
"_global_config",
",",
"s... | Saves config to config files.
Args:
config (configobj.ConfigObj): optional config object to save.
Raises:
dvc.config.ConfigError: thrown if failed to write config file. | [
"Saves",
"config",
"to",
"config",
"files",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L455-L489 | train |
iterative/dvc | dvc/config.py | Config.get_remote_settings | def get_remote_settings(self, name):
import posixpath
"""
Args:
name (str): The name of the remote that we want to retrieve
Returns:
dict: The content beneath the given remote name.
Example:
>>> config = {'remote "server"': {'url': 'ssh://lo... | python | def get_remote_settings(self, name):
import posixpath
"""
Args:
name (str): The name of the remote that we want to retrieve
Returns:
dict: The content beneath the given remote name.
Example:
>>> config = {'remote "server"': {'url': 'ssh://lo... | [
"def",
"get_remote_settings",
"(",
"self",
",",
"name",
")",
":",
"import",
"posixpath",
"settings",
"=",
"self",
".",
"config",
"[",
"self",
".",
"SECTION_REMOTE_FMT",
".",
"format",
"(",
"name",
")",
"]",
"parsed",
"=",
"urlparse",
"(",
"settings",
"[",
... | Args:
name (str): The name of the remote that we want to retrieve
Returns:
dict: The content beneath the given remote name.
Example:
>>> config = {'remote "server"': {'url': 'ssh://localhost/'}}
>>> get_remote_settings("server")
{'url': 'ssh:... | [
"Args",
":",
"name",
"(",
"str",
")",
":",
"The",
"name",
"of",
"the",
"remote",
"that",
"we",
"want",
"to",
"retrieve"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L491-L539 | train |
iterative/dvc | dvc/config.py | Config.unset | def unset(config, section, opt=None):
"""Unsets specified option and/or section in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): optional option name.
"""
if section not in config.keys():
... | python | def unset(config, section, opt=None):
"""Unsets specified option and/or section in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): optional option name.
"""
if section not in config.keys():
... | [
"def",
"unset",
"(",
"config",
",",
"section",
",",
"opt",
"=",
"None",
")",
":",
"if",
"section",
"not",
"in",
"config",
".",
"keys",
"(",
")",
":",
"raise",
"ConfigError",
"(",
"\"section '{}' doesn't exist\"",
".",
"format",
"(",
"section",
")",
")",
... | Unsets specified option and/or section in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): optional option name. | [
"Unsets",
"specified",
"option",
"and",
"/",
"or",
"section",
"in",
"the",
"config",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L542-L564 | train |
iterative/dvc | dvc/config.py | Config.set | def set(config, section, opt, value):
"""Sets specified option in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
value: value to set option to.
"""
if section not in ... | python | def set(config, section, opt, value):
"""Sets specified option in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
value: value to set option to.
"""
if section not in ... | [
"def",
"set",
"(",
"config",
",",
"section",
",",
"opt",
",",
"value",
")",
":",
"if",
"section",
"not",
"in",
"config",
".",
"keys",
"(",
")",
":",
"config",
"[",
"section",
"]",
"=",
"{",
"}",
"config",
"[",
"section",
"]",
"[",
"opt",
"]",
"... | Sets specified option in the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
value: value to set option to. | [
"Sets",
"specified",
"option",
"in",
"the",
"config",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L567-L579 | train |
iterative/dvc | dvc/config.py | Config.show | def show(config, section, opt):
"""Prints option value from the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
"""
if section not in config.keys():
raise ConfigError("sec... | python | def show(config, section, opt):
"""Prints option value from the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name.
"""
if section not in config.keys():
raise ConfigError("sec... | [
"def",
"show",
"(",
"config",
",",
"section",
",",
"opt",
")",
":",
"if",
"section",
"not",
"in",
"config",
".",
"keys",
"(",
")",
":",
"raise",
"ConfigError",
"(",
"\"section '{}' doesn't exist\"",
".",
"format",
"(",
"section",
")",
")",
"if",
"opt",
... | Prints option value from the config.
Args:
config (configobj.ConfigObj): config to work on.
section (str): section name.
opt (str): option name. | [
"Prints",
"option",
"value",
"from",
"the",
"config",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/config.py#L582-L598 | train |
iterative/dvc | dvc/repo/move.py | move | def move(self, from_path, to_path):
"""
Renames an output file and modifies the stage associated
to reflect the change on the pipeline.
If the output has the same name as its stage, it would
also rename the corresponding stage file.
E.g.
Having: (hello, hello.dvc)
$ dvc mo... | python | def move(self, from_path, to_path):
"""
Renames an output file and modifies the stage associated
to reflect the change on the pipeline.
If the output has the same name as its stage, it would
also rename the corresponding stage file.
E.g.
Having: (hello, hello.dvc)
$ dvc mo... | [
"def",
"move",
"(",
"self",
",",
"from_path",
",",
"to_path",
")",
":",
"import",
"dvc",
".",
"output",
"as",
"Output",
"from",
"dvc",
".",
"stage",
"import",
"Stage",
"from_out",
"=",
"Output",
".",
"loads_from",
"(",
"Stage",
"(",
"self",
")",
",",
... | Renames an output file and modifies the stage associated
to reflect the change on the pipeline.
If the output has the same name as its stage, it would
also rename the corresponding stage file.
E.g.
Having: (hello, hello.dvc)
$ dvc move hello greetings
Result: (greeting,... | [
"Renames",
"an",
"output",
"file",
"and",
"modifies",
"the",
"stage",
"associated",
"to",
"reflect",
"the",
"change",
"on",
"the",
"pipeline",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/move.py#L14-L68 | train |
iterative/dvc | dvc/repo/init.py | init | def init(root_dir=os.curdir, no_scm=False, force=False):
"""
Creates an empty repo on the given directory -- basically a
`.dvc` directory with subdirectories for configuration and cache.
It should be tracked by a SCM or use the `--no-scm` flag.
If the given directory is not empty, you must use the... | python | def init(root_dir=os.curdir, no_scm=False, force=False):
"""
Creates an empty repo on the given directory -- basically a
`.dvc` directory with subdirectories for configuration and cache.
It should be tracked by a SCM or use the `--no-scm` flag.
If the given directory is not empty, you must use the... | [
"def",
"init",
"(",
"root_dir",
"=",
"os",
".",
"curdir",
",",
"no_scm",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"root_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"root_dir",
")",
"dvc_dir",
"=",
"os",
".",
"path",
".",
"join",
... | Creates an empty repo on the given directory -- basically a
`.dvc` directory with subdirectories for configuration and cache.
It should be tracked by a SCM or use the `--no-scm` flag.
If the given directory is not empty, you must use the `--force`
flag to override it.
Args:
root_dir: Path... | [
"Creates",
"an",
"empty",
"repo",
"on",
"the",
"given",
"directory",
"--",
"basically",
"a",
".",
"dvc",
"directory",
"with",
"subdirectories",
"for",
"configuration",
"and",
"cache",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/repo/init.py#L43-L96 | train |
iterative/dvc | dvc/version.py | _generate_version | def _generate_version(base_version):
"""Generate a version with information about the git repository"""
pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
if not _is_git_repo(pkg_dir) or not _have_git():
return base_version
if _is_release(pkg_dir, base_version) and not _is_d... | python | def _generate_version(base_version):
"""Generate a version with information about the git repository"""
pkg_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
if not _is_git_repo(pkg_dir) or not _have_git():
return base_version
if _is_release(pkg_dir, base_version) and not _is_d... | [
"def",
"_generate_version",
"(",
"base_version",
")",
":",
"pkg_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
")",
"if",
"not",
"_is_git_repo",
... | Generate a version with information about the git repository | [
"Generate",
"a",
"version",
"with",
"information",
"about",
"the",
"git",
"repository"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/version.py#L13-L27 | train |
iterative/dvc | dvc/version.py | _is_dirty | def _is_dirty(dir_path):
"""Check whether a git repository has uncommitted changes."""
try:
subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path)
return False
except subprocess.CalledProcessError:
return True | python | def _is_dirty(dir_path):
"""Check whether a git repository has uncommitted changes."""
try:
subprocess.check_call(["git", "diff", "--quiet"], cwd=dir_path)
return False
except subprocess.CalledProcessError:
return True | [
"def",
"_is_dirty",
"(",
"dir_path",
")",
":",
"try",
":",
"subprocess",
".",
"check_call",
"(",
"[",
"\"git\"",
",",
"\"diff\"",
",",
"\"--quiet\"",
"]",
",",
"cwd",
"=",
"dir_path",
")",
"return",
"False",
"except",
"subprocess",
".",
"CalledProcessError",... | Check whether a git repository has uncommitted changes. | [
"Check",
"whether",
"a",
"git",
"repository",
"has",
"uncommitted",
"changes",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/version.py#L66-L72 | train |
iterative/dvc | dvc/utils/__init__.py | file_md5 | def file_md5(fname):
""" get the (md5 hexdigest, md5 digest) of a file """
from dvc.progress import progress
from dvc.istextfile import istextfile
if os.path.exists(fname):
hash_md5 = hashlib.md5()
binary = not istextfile(fname)
size = os.path.getsize(fname)
bar = False
... | python | def file_md5(fname):
""" get the (md5 hexdigest, md5 digest) of a file """
from dvc.progress import progress
from dvc.istextfile import istextfile
if os.path.exists(fname):
hash_md5 = hashlib.md5()
binary = not istextfile(fname)
size = os.path.getsize(fname)
bar = False
... | [
"def",
"file_md5",
"(",
"fname",
")",
":",
"from",
"dvc",
".",
"progress",
"import",
"progress",
"from",
"dvc",
".",
"istextfile",
"import",
"istextfile",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"hash_md5",
"=",
"hashlib",
".",
... | get the (md5 hexdigest, md5 digest) of a file | [
"get",
"the",
"(",
"md5",
"hexdigest",
"md5",
"digest",
")",
"of",
"a",
"file"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L35-L74 | train |
iterative/dvc | dvc/utils/__init__.py | dict_filter | def dict_filter(d, exclude=[]):
"""
Exclude specified keys from a nested dict
"""
if isinstance(d, list):
ret = []
for e in d:
ret.append(dict_filter(e, exclude))
return ret
elif isinstance(d, dict):
ret = {}
for k, v in d.items():
if ... | python | def dict_filter(d, exclude=[]):
"""
Exclude specified keys from a nested dict
"""
if isinstance(d, list):
ret = []
for e in d:
ret.append(dict_filter(e, exclude))
return ret
elif isinstance(d, dict):
ret = {}
for k, v in d.items():
if ... | [
"def",
"dict_filter",
"(",
"d",
",",
"exclude",
"=",
"[",
"]",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"list",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"e",
"in",
"d",
":",
"ret",
".",
"append",
"(",
"dict_filter",
"(",
"e",
",",
"exclude",
... | Exclude specified keys from a nested dict | [
"Exclude",
"specified",
"keys",
"from",
"a",
"nested",
"dict"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L83-L105 | train |
iterative/dvc | dvc/utils/__init__.py | copyfile | def copyfile(src, dest, no_progress_bar=False, name=None):
"""Copy file with progress bar"""
from dvc.progress import progress
copied = 0
name = name if name else os.path.basename(dest)
total = os.stat(src).st_size
if os.path.isdir(dest):
dest = os.path.join(dest, os.path.basename(src)... | python | def copyfile(src, dest, no_progress_bar=False, name=None):
"""Copy file with progress bar"""
from dvc.progress import progress
copied = 0
name = name if name else os.path.basename(dest)
total = os.stat(src).st_size
if os.path.isdir(dest):
dest = os.path.join(dest, os.path.basename(src)... | [
"def",
"copyfile",
"(",
"src",
",",
"dest",
",",
"no_progress_bar",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"from",
"dvc",
".",
"progress",
"import",
"progress",
"copied",
"=",
"0",
"name",
"=",
"name",
"if",
"name",
"else",
"os",
".",
"pat... | Copy file with progress bar | [
"Copy",
"file",
"with",
"progress",
"bar"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L114-L136 | train |
iterative/dvc | dvc/utils/__init__.py | dvc_walk | def dvc_walk(
top,
topdown=True,
onerror=None,
followlinks=False,
ignore_file_handler=None,
):
"""
Proxy for `os.walk` directory tree generator.
Utilizes DvcIgnoreFilter functionality.
"""
ignore_filter = None
if topdown:
from dvc.ignore import DvcIgnoreFilter
... | python | def dvc_walk(
top,
topdown=True,
onerror=None,
followlinks=False,
ignore_file_handler=None,
):
"""
Proxy for `os.walk` directory tree generator.
Utilizes DvcIgnoreFilter functionality.
"""
ignore_filter = None
if topdown:
from dvc.ignore import DvcIgnoreFilter
... | [
"def",
"dvc_walk",
"(",
"top",
",",
"topdown",
"=",
"True",
",",
"onerror",
"=",
"None",
",",
"followlinks",
"=",
"False",
",",
"ignore_file_handler",
"=",
"None",
",",
")",
":",
"ignore_filter",
"=",
"None",
"if",
"topdown",
":",
"from",
"dvc",
".",
"... | Proxy for `os.walk` directory tree generator.
Utilizes DvcIgnoreFilter functionality. | [
"Proxy",
"for",
"os",
".",
"walk",
"directory",
"tree",
"generator",
".",
"Utilizes",
"DvcIgnoreFilter",
"functionality",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L251-L277 | train |
iterative/dvc | dvc/utils/__init__.py | colorize | def colorize(message, color=None):
"""Returns a message in a specified color."""
if not color:
return message
colors = {
"green": colorama.Fore.GREEN,
"yellow": colorama.Fore.YELLOW,
"blue": colorama.Fore.BLUE,
"red": colorama.Fore.RED,
}
return "{color}{mes... | python | def colorize(message, color=None):
"""Returns a message in a specified color."""
if not color:
return message
colors = {
"green": colorama.Fore.GREEN,
"yellow": colorama.Fore.YELLOW,
"blue": colorama.Fore.BLUE,
"red": colorama.Fore.RED,
}
return "{color}{mes... | [
"def",
"colorize",
"(",
"message",
",",
"color",
"=",
"None",
")",
":",
"if",
"not",
"color",
":",
"return",
"message",
"colors",
"=",
"{",
"\"green\"",
":",
"colorama",
".",
"Fore",
".",
"GREEN",
",",
"\"yellow\"",
":",
"colorama",
".",
"Fore",
".",
... | Returns a message in a specified color. | [
"Returns",
"a",
"message",
"in",
"a",
"specified",
"color",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L288-L302 | train |
iterative/dvc | dvc/utils/__init__.py | boxify | def boxify(message, border_color=None):
"""Put a message inside a box.
Args:
message (unicode): message to decorate.
border_color (unicode): name of the color to outline the box with.
"""
lines = message.split("\n")
max_width = max(_visual_width(line) for line in lines)
padding... | python | def boxify(message, border_color=None):
"""Put a message inside a box.
Args:
message (unicode): message to decorate.
border_color (unicode): name of the color to outline the box with.
"""
lines = message.split("\n")
max_width = max(_visual_width(line) for line in lines)
padding... | [
"def",
"boxify",
"(",
"message",
",",
"border_color",
"=",
"None",
")",
":",
"lines",
"=",
"message",
".",
"split",
"(",
"\"\\n\"",
")",
"max_width",
"=",
"max",
"(",
"_visual_width",
"(",
"line",
")",
"for",
"line",
"in",
"lines",
")",
"padding_horizont... | Put a message inside a box.
Args:
message (unicode): message to decorate.
border_color (unicode): name of the color to outline the box with. | [
"Put",
"a",
"message",
"inside",
"a",
"box",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L305-L349 | train |
iterative/dvc | dvc/utils/__init__.py | _visual_width | def _visual_width(line):
"""Get the the number of columns required to display a string"""
return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line)) | python | def _visual_width(line):
"""Get the the number of columns required to display a string"""
return len(re.sub(colorama.ansitowin32.AnsiToWin32.ANSI_CSI_RE, "", line)) | [
"def",
"_visual_width",
"(",
"line",
")",
":",
"return",
"len",
"(",
"re",
".",
"sub",
"(",
"colorama",
".",
"ansitowin32",
".",
"AnsiToWin32",
".",
"ANSI_CSI_RE",
",",
"\"\"",
",",
"line",
")",
")"
] | Get the the number of columns required to display a string | [
"Get",
"the",
"the",
"number",
"of",
"columns",
"required",
"to",
"display",
"a",
"string"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L352-L355 | train |
iterative/dvc | dvc/utils/__init__.py | _visual_center | def _visual_center(line, width):
"""Center align string according to it's visual width"""
spaces = max(width - _visual_width(line), 0)
left_padding = int(spaces / 2)
right_padding = spaces - left_padding
return (left_padding * " ") + line + (right_padding * " ") | python | def _visual_center(line, width):
"""Center align string according to it's visual width"""
spaces = max(width - _visual_width(line), 0)
left_padding = int(spaces / 2)
right_padding = spaces - left_padding
return (left_padding * " ") + line + (right_padding * " ") | [
"def",
"_visual_center",
"(",
"line",
",",
"width",
")",
":",
"spaces",
"=",
"max",
"(",
"width",
"-",
"_visual_width",
"(",
"line",
")",
",",
"0",
")",
"left_padding",
"=",
"int",
"(",
"spaces",
"/",
"2",
")",
"right_padding",
"=",
"spaces",
"-",
"l... | Center align string according to it's visual width | [
"Center",
"align",
"string",
"according",
"to",
"it",
"s",
"visual",
"width"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/__init__.py#L358-L365 | train |
iterative/dvc | dvc/command/base.py | fix_subparsers | def fix_subparsers(subparsers):
"""Workaround for bug in Python 3. See more info at:
https://bugs.python.org/issue16308
https://github.com/iterative/dvc/issues/769
Args:
subparsers: subparsers to fix.
"""
from dvc.utils.compat import is_py3
if is_py3: # pragma: no ... | python | def fix_subparsers(subparsers):
"""Workaround for bug in Python 3. See more info at:
https://bugs.python.org/issue16308
https://github.com/iterative/dvc/issues/769
Args:
subparsers: subparsers to fix.
"""
from dvc.utils.compat import is_py3
if is_py3: # pragma: no ... | [
"def",
"fix_subparsers",
"(",
"subparsers",
")",
":",
"from",
"dvc",
".",
"utils",
".",
"compat",
"import",
"is_py3",
"if",
"is_py3",
":",
"# pragma: no cover",
"subparsers",
".",
"required",
"=",
"True",
"subparsers",
".",
"dest",
"=",
"\"cmd\""
] | Workaround for bug in Python 3. See more info at:
https://bugs.python.org/issue16308
https://github.com/iterative/dvc/issues/769
Args:
subparsers: subparsers to fix. | [
"Workaround",
"for",
"bug",
"in",
"Python",
"3",
".",
"See",
"more",
"info",
"at",
":",
"https",
":",
"//",
"bugs",
".",
"python",
".",
"org",
"/",
"issue16308",
"https",
":",
"//",
"github",
".",
"com",
"/",
"iterative",
"/",
"dvc",
"/",
"issues",
... | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/base.py#L10-L22 | train |
iterative/dvc | dvc/command/base.py | CmdBase.default_targets | def default_targets(self):
"""Default targets for `dvc repro` and `dvc pipeline`."""
from dvc.stage import Stage
msg = "assuming default target '{}'.".format(Stage.STAGE_FILE)
logger.warning(msg)
return [Stage.STAGE_FILE] | python | def default_targets(self):
"""Default targets for `dvc repro` and `dvc pipeline`."""
from dvc.stage import Stage
msg = "assuming default target '{}'.".format(Stage.STAGE_FILE)
logger.warning(msg)
return [Stage.STAGE_FILE] | [
"def",
"default_targets",
"(",
"self",
")",
":",
"from",
"dvc",
".",
"stage",
"import",
"Stage",
"msg",
"=",
"\"assuming default target '{}'.\"",
".",
"format",
"(",
"Stage",
".",
"STAGE_FILE",
")",
"logger",
".",
"warning",
"(",
"msg",
")",
"return",
"[",
... | Default targets for `dvc repro` and `dvc pipeline`. | [
"Default",
"targets",
"for",
"dvc",
"repro",
"and",
"dvc",
"pipeline",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/command/base.py#L47-L53 | train |
iterative/dvc | dvc/scm/__init__.py | SCM | def SCM(root_dir, repo=None): # pylint: disable=invalid-name
"""Returns SCM instance that corresponds to a repo at the specified
path.
Args:
root_dir (str): path to a root directory of the repo.
repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to.
Returns:
dvc.scm... | python | def SCM(root_dir, repo=None): # pylint: disable=invalid-name
"""Returns SCM instance that corresponds to a repo at the specified
path.
Args:
root_dir (str): path to a root directory of the repo.
repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to.
Returns:
dvc.scm... | [
"def",
"SCM",
"(",
"root_dir",
",",
"repo",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name",
"if",
"Git",
".",
"is_repo",
"(",
"root_dir",
")",
"or",
"Git",
".",
"is_submodule",
"(",
"root_dir",
")",
":",
"return",
"Git",
"(",
"root_dir",
",",
"r... | Returns SCM instance that corresponds to a repo at the specified
path.
Args:
root_dir (str): path to a root directory of the repo.
repo (dvc.repo.Repo): dvc repo instance that root_dir belongs to.
Returns:
dvc.scm.base.Base: SCM instance. | [
"Returns",
"SCM",
"instance",
"that",
"corresponds",
"to",
"a",
"repo",
"at",
"the",
"specified",
"path",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/scm/__init__.py#L15-L29 | train |
iterative/dvc | dvc/cli.py | get_parent_parser | def get_parent_parser():
"""Create instances of a parser containing common arguments shared among
all the commands.
When overwritting `-q` or `-v`, you need to instantiate a new object
in order to prevent some weird behavior.
"""
parent_parser = argparse.ArgumentParser(add_help=False)
log_... | python | def get_parent_parser():
"""Create instances of a parser containing common arguments shared among
all the commands.
When overwritting `-q` or `-v`, you need to instantiate a new object
in order to prevent some weird behavior.
"""
parent_parser = argparse.ArgumentParser(add_help=False)
log_... | [
"def",
"get_parent_parser",
"(",
")",
":",
"parent_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"add_help",
"=",
"False",
")",
"log_level_group",
"=",
"parent_parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"log_level_group",
".",
"add_argument",
"(... | Create instances of a parser containing common arguments shared among
all the commands.
When overwritting `-q` or `-v`, you need to instantiate a new object
in order to prevent some weird behavior. | [
"Create",
"instances",
"of",
"a",
"parser",
"containing",
"common",
"arguments",
"shared",
"among",
"all",
"the",
"commands",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cli.py#L98-L119 | train |
iterative/dvc | dvc/cli.py | parse_args | def parse_args(argv=None):
"""Parses CLI arguments.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Raises:
dvc.exceptions.DvcParserError: raised for argument parsing errors.
"""
parent_parser = get_parent_parser()
# Main parser
desc = "Data V... | python | def parse_args(argv=None):
"""Parses CLI arguments.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Raises:
dvc.exceptions.DvcParserError: raised for argument parsing errors.
"""
parent_parser = get_parent_parser()
# Main parser
desc = "Data V... | [
"def",
"parse_args",
"(",
"argv",
"=",
"None",
")",
":",
"parent_parser",
"=",
"get_parent_parser",
"(",
")",
"# Main parser",
"desc",
"=",
"\"Data Version Control\"",
"parser",
"=",
"DvcParser",
"(",
"prog",
"=",
"\"dvc\"",
",",
"description",
"=",
"desc",
",... | Parses CLI arguments.
Args:
argv: optional list of arguments to parse. sys.argv is used by default.
Raises:
dvc.exceptions.DvcParserError: raised for argument parsing errors. | [
"Parses",
"CLI",
"arguments",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/cli.py#L122-L167 | train |
iterative/dvc | dvc/utils/collections.py | apply_diff | def apply_diff(src, dest):
"""Recursively apply changes from src to dest.
Preserves dest type and hidden info in dest structure,
like ruamel.yaml leaves when parses files. This includes comments,
ordering and line foldings.
Used in Stage load/dump cycle to preserve comments and custom formatting.
... | python | def apply_diff(src, dest):
"""Recursively apply changes from src to dest.
Preserves dest type and hidden info in dest structure,
like ruamel.yaml leaves when parses files. This includes comments,
ordering and line foldings.
Used in Stage load/dump cycle to preserve comments and custom formatting.
... | [
"def",
"apply_diff",
"(",
"src",
",",
"dest",
")",
":",
"Seq",
"=",
"(",
"list",
",",
"tuple",
")",
"Container",
"=",
"(",
"Mapping",
",",
"list",
",",
"tuple",
")",
"def",
"is_same_type",
"(",
"a",
",",
"b",
")",
":",
"return",
"any",
"(",
"isin... | Recursively apply changes from src to dest.
Preserves dest type and hidden info in dest structure,
like ruamel.yaml leaves when parses files. This includes comments,
ordering and line foldings.
Used in Stage load/dump cycle to preserve comments and custom formatting. | [
"Recursively",
"apply",
"changes",
"from",
"src",
"to",
"dest",
"."
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/utils/collections.py#L10-L54 | train |
iterative/dvc | dvc/remote/ssh/connection.py | percent_cb | def percent_cb(name, complete, total):
""" Callback for updating target progress """
logger.debug(
"{}: {} transferred out of {}".format(
name, sizeof_fmt(complete), sizeof_fmt(total)
)
)
progress.update_target(name, complete, total) | python | def percent_cb(name, complete, total):
""" Callback for updating target progress """
logger.debug(
"{}: {} transferred out of {}".format(
name, sizeof_fmt(complete), sizeof_fmt(total)
)
)
progress.update_target(name, complete, total) | [
"def",
"percent_cb",
"(",
"name",
",",
"complete",
",",
"total",
")",
":",
"logger",
".",
"debug",
"(",
"\"{}: {} transferred out of {}\"",
".",
"format",
"(",
"name",
",",
"sizeof_fmt",
"(",
"complete",
")",
",",
"sizeof_fmt",
"(",
"total",
")",
")",
")",... | Callback for updating target progress | [
"Callback",
"for",
"updating",
"target",
"progress"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/ssh/connection.py#L31-L38 | train |
iterative/dvc | dvc/remote/ssh/connection.py | SSHConnection.md5 | def md5(self, path):
"""
Use different md5 commands depending on the OS:
- Darwin's `md5` returns BSD-style checksums by default
- Linux's `md5sum` needs the `--tag` flag for a similar output
Example:
MD5 (foo.txt) = f3d220a856b52aabbf294351e8a24300
"""... | python | def md5(self, path):
"""
Use different md5 commands depending on the OS:
- Darwin's `md5` returns BSD-style checksums by default
- Linux's `md5sum` needs the `--tag` flag for a similar output
Example:
MD5 (foo.txt) = f3d220a856b52aabbf294351e8a24300
"""... | [
"def",
"md5",
"(",
"self",
",",
"path",
")",
":",
"uname",
"=",
"self",
".",
"execute",
"(",
"\"uname\"",
")",
".",
"strip",
"(",
")",
"command",
"=",
"{",
"\"Darwin\"",
":",
"\"md5 {}\"",
".",
"format",
"(",
"path",
")",
",",
"\"Linux\"",
":",
"\"... | Use different md5 commands depending on the OS:
- Darwin's `md5` returns BSD-style checksums by default
- Linux's `md5sum` needs the `--tag` flag for a similar output
Example:
MD5 (foo.txt) = f3d220a856b52aabbf294351e8a24300 | [
"Use",
"different",
"md5",
"commands",
"depending",
"on",
"the",
"OS",
":"
] | 8bb21261e34c9632453e09090de7ebe50e38d341 | https://github.com/iterative/dvc/blob/8bb21261e34c9632453e09090de7ebe50e38d341/dvc/remote/ssh/connection.py#L294-L318 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.