hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1a9aa6f116020180ebd30617e5a5310750c6ffd8 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/config.py | [
"MIT"
] | Python | initialize_lr_config | null | def initialize_lr_config(self, warm_steps, n_epochs):
"""This function sets the configuration to initialize learning rate
Args:
warm_steps (int): Number of steps The learning rate is increased
n_epochs (int): Number of epochs
"""
self.lr_config = dict(
... | This function sets the configuration to initialize learning rate
Args:
warm_steps (int): Number of steps The learning rate is increased
n_epochs (int): Number of epochs
| This function sets the configuration to initialize learning rate | [
"This",
"function",
"sets",
"the",
"configuration",
"to",
"initialize",
"learning",
"rate"
] | def initialize_lr_config(self, warm_steps, n_epochs):
self.lr_config = dict(
warm_steps=warm_steps,
n_epochs=n_epochs,
) | [
"def",
"initialize_lr_config",
"(",
"self",
",",
"warm_steps",
",",
"n_epochs",
")",
":",
"self",
".",
"lr_config",
"=",
"dict",
"(",
"warm_steps",
"=",
"warm_steps",
",",
"n_epochs",
"=",
"n_epochs",
",",
")"
] | This function sets the configuration to initialize learning rate | [
"This",
"function",
"sets",
"the",
"configuration",
"to",
"initialize",
"learning",
"rate"
] | [
"\"\"\"This function sets the configuration to initialize learning rate\n\n Args:\n warm_steps (int): Number of steps The learning rate is increased\n n_epochs (int): Number of epochs\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "warm_steps",
"type": null
},
{
"param": "n_epochs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "warm_steps",
"type": null,
"docstring": "Number of steps The learni... |
1a9aa6f116020180ebd30617e5a5310750c6ffd8 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/config.py | [
"MIT"
] | Python | prepare_models | <not_specific> | def prepare_models(encoder_config, transformer_config, replica_batch_size, verbose=0):
"""This function is used to initiate the Encoder and the Transformer with appropriate
configs set by the user. After initiating the models this function returns the Encoder,Transformer
and the optimizer.
Args:
... | This function is used to initiate the Encoder and the Transformer with appropriate
configs set by the user. After initiating the models this function returns the Encoder,Transformer
and the optimizer.
Args:
encoder_config ([type]): Encoder configuration set by user in the config class.
tran... | This function is used to initiate the Encoder and the Transformer with appropriate
configs set by the user. After initiating the models this function returns the Encoder,Transformer
and the optimizer. | [
"This",
"function",
"is",
"used",
"to",
"initiate",
"the",
"Encoder",
"and",
"the",
"Transformer",
"with",
"appropriate",
"configs",
"set",
"by",
"the",
"user",
".",
"After",
"initiating",
"the",
"models",
"this",
"function",
"returns",
"the",
"Encoder",
"Tran... | def prepare_models(encoder_config, transformer_config, replica_batch_size, verbose=0):
optimizer = tf.keras.optimizers.Adam(learning_rate=0.00051)
encoder = Efficient_Net_encoder.Encoder(**encoder_config)
initialization_batch = encoder(
tf.ones(
((replica_batch_size,) + encoder_config["i... | [
"def",
"prepare_models",
"(",
"encoder_config",
",",
"transformer_config",
",",
"replica_batch_size",
",",
"verbose",
"=",
"0",
")",
":",
"optimizer",
"=",
"tf",
".",
"keras",
".",
"optimizers",
".",
"Adam",
"(",
"learning_rate",
"=",
"0.00051",
")",
"encoder"... | This function is used to initiate the Encoder and the Transformer with appropriate
configs set by the user. | [
"This",
"function",
"is",
"used",
"to",
"initiate",
"the",
"Encoder",
"and",
"the",
"Transformer",
"with",
"appropriate",
"configs",
"set",
"by",
"the",
"user",
"."
] | [
"\"\"\"This function is used to initiate the Encoder and the Transformer with appropriate\n configs set by the user. After initiating the models this function returns the Encoder,Transformer\n and the optimizer.\n\n Args:\n encoder_config ([type]): Encoder configuration set by user in the config cla... | [
{
"param": "encoder_config",
"type": null
},
{
"param": "transformer_config",
"type": null
},
{
"param": "replica_batch_size",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [
{
"docstring": "Optimizer, Encoder model and the Transformer",
"docstring_tokens": [
"Optimizer",
"Encoder",
"model",
"and",
"the",
"Transformer"
],
"type": "[type]"
}
],
"raises": [],
"params": [
{
"identif... |
1a9aa6f116020180ebd30617e5a5310750c6ffd8 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/config.py | [
"MIT"
] | Python | download_trained_weights | null | def download_trained_weights(model_url: str, model_path: str, verbose=1):
"""This function downloads the trained models and tokenizers to a default location.
After downloading the zipped file the function unzips the file automatically.
If the model exists on the default location this function will not work.... | This function downloads the trained models and tokenizers to a default location.
After downloading the zipped file the function unzips the file automatically.
If the model exists on the default location this function will not work.
Args:
model_url (str): trained model url for downloading.
mo... | This function downloads the trained models and tokenizers to a default location.
After downloading the zipped file the function unzips the file automatically.
If the model exists on the default location this function will not work. | [
"This",
"function",
"downloads",
"the",
"trained",
"models",
"and",
"tokenizers",
"to",
"a",
"default",
"location",
".",
"After",
"downloading",
"the",
"zipped",
"file",
"the",
"function",
"unzips",
"the",
"file",
"automatically",
".",
"If",
"the",
"model",
"e... | def download_trained_weights(model_url: str, model_path: str, verbose=1):
if verbose > 0:
print("Downloading trained model to " + str(model_path))
model_path = pystow.ensure("DECIMER-V2", url=model_url)
print(model_path)
if verbose > 0:
print("... done downloading trained model!"... | [
"def",
"download_trained_weights",
"(",
"model_url",
":",
"str",
",",
"model_path",
":",
"str",
",",
"verbose",
"=",
"1",
")",
":",
"if",
"verbose",
">",
"0",
":",
"print",
"(",
"\"Downloading trained model to \"",
"+",
"str",
"(",
"model_path",
")",
")",
... | This function downloads the trained models and tokenizers to a default location. | [
"This",
"function",
"downloads",
"the",
"trained",
"models",
"and",
"tokenizers",
"to",
"a",
"default",
"location",
"."
] | [
"\"\"\"This function downloads the trained models and tokenizers to a default location.\n After downloading the zipped file the function unzips the file automatically.\n If the model exists on the default location this function will not work.\n Args:\n model_url (str): trained model url for download... | [
{
"param": "model_url",
"type": "str"
},
{
"param": "model_path",
"type": "str"
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "model_url",
"type": "str",
"docstring": "trained model url for downloading.",
"docstring_tokens": [
"traine... |
07321e62900cba09798c29a6d30e4273fcaab38a | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/decimer.py | [
"MIT"
] | Python | main | null | def main():
"""
This function take the path of the image as user input
and returns the predicted SMILES as output in CLI.
Agrs:
str: image_path
Returns:
str: predicted SMILES
"""
if len(sys.argv) != 2:
print("Usage: {} $image_path".format(sys.argv[0]))
else:
... |
This function take the path of the image as user input
and returns the predicted SMILES as output in CLI.
Agrs:
str: image_path
Returns:
str: predicted SMILES
| This function take the path of the image as user input
and returns the predicted SMILES as output in CLI.
| [
"This",
"function",
"take",
"the",
"path",
"of",
"the",
"image",
"as",
"user",
"input",
"and",
"returns",
"the",
"predicted",
"SMILES",
"as",
"output",
"in",
"CLI",
"."
] | def main():
if len(sys.argv) != 2:
print("Usage: {} $image_path".format(sys.argv[0]))
else:
SMILES = predict_SMILES(sys.argv[1])
print(SMILES) | [
"def",
"main",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"!=",
"2",
":",
"print",
"(",
"\"Usage: {} $image_path\"",
".",
"format",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
"else",
":",
"SMILES",
"=",
"predict_SMILES",
"(",
... | This function take the path of the image as user input
and returns the predicted SMILES as output in CLI. | [
"This",
"function",
"take",
"the",
"path",
"of",
"the",
"image",
"as",
"user",
"input",
"and",
"returns",
"the",
"predicted",
"SMILES",
"as",
"output",
"in",
"CLI",
"."
] | [
"\"\"\"\n This function take the path of the image as user input\n and returns the predicted SMILES as output in CLI.\n\n Agrs:\n str: image_path\n\n Returns:\n str: predicted SMILES\n\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "str"
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
07321e62900cba09798c29a6d30e4273fcaab38a | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/decimer.py | [
"MIT"
] | Python | detokenize_output | str | def detokenize_output(predicted_array: int) -> str:
"""
This function takes the predited tokens from the DECIMER model
and returns the decoded SMILES string.
Args:
predicted_array (int): Predicted tokens from DECIMER
Returns:
(str): SMILES representation of the molecule
"""
... |
This function takes the predited tokens from the DECIMER model
and returns the decoded SMILES string.
Args:
predicted_array (int): Predicted tokens from DECIMER
Returns:
(str): SMILES representation of the molecule
| This function takes the predited tokens from the DECIMER model
and returns the decoded SMILES string. | [
"This",
"function",
"takes",
"the",
"predited",
"tokens",
"from",
"the",
"DECIMER",
"model",
"and",
"returns",
"the",
"decoded",
"SMILES",
"string",
"."
] | def detokenize_output(predicted_array: int) -> str:
outputs = [tokenizer.index_word[i] for i in predicted_array[0].numpy()]
prediction = (
"".join([str(elem) for elem in outputs])
.replace("<start>", "")
.replace("<end>", "")
)
return prediction | [
"def",
"detokenize_output",
"(",
"predicted_array",
":",
"int",
")",
"->",
"str",
":",
"outputs",
"=",
"[",
"tokenizer",
".",
"index_word",
"[",
"i",
"]",
"for",
"i",
"in",
"predicted_array",
"[",
"0",
"]",
".",
"numpy",
"(",
")",
"]",
"prediction",
"=... | This function takes the predited tokens from the DECIMER model
and returns the decoded SMILES string. | [
"This",
"function",
"takes",
"the",
"predited",
"tokens",
"from",
"the",
"DECIMER",
"model",
"and",
"returns",
"the",
"decoded",
"SMILES",
"string",
"."
] | [
"\"\"\"\n This function takes the predited tokens from the DECIMER model\n and returns the decoded SMILES string.\n\n Args:\n predicted_array (int): Predicted tokens from DECIMER\n\n Returns:\n (str): SMILES representation of the molecule\n \"\"\""
] | [
{
"param": "predicted_array",
"type": "int"
}
] | {
"returns": [
{
"docstring": "SMILES representation of the molecule",
"docstring_tokens": [
"SMILES",
"representation",
"of",
"the",
"molecule"
],
"type": "(str)"
}
],
"raises": [],
"params": [
{
"identifier": "predicted_array",
... |
07321e62900cba09798c29a6d30e4273fcaab38a | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/decimer.py | [
"MIT"
] | Python | predict_SMILES | str | def predict_SMILES(image_path: str) -> str:
"""
This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SMILES representation of the molecule in ... |
This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SMILES representation of the molecule in the input image
| This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SMILES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | def predict_SMILES(image_path: str) -> str:
chemical_structure = config.decode_image(image_path)
predicted_tokens = DECIMER_V2(chemical_structure)
predicted_SMILES = detokenize_output(predicted_tokens)
return predicted_SMILES | [
"def",
"predict_SMILES",
"(",
"image_path",
":",
"str",
")",
"->",
"str",
":",
"chemical_structure",
"=",
"config",
".",
"decode_image",
"(",
"image_path",
")",
"predicted_tokens",
"=",
"DECIMER_V2",
"(",
"chemical_structure",
")",
"predicted_SMILES",
"=",
"detoke... | This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SMILES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | [
"\"\"\"\n This function takes an image path (str) and returns the SMILES\n representation of the depicted molecule (str).\n\n Args:\n image_path (str): Path of chemical structure depiction image\n\n Returns:\n (str): SMILES representation of the molecule in the input image\n \"\"\""
] | [
{
"param": "image_path",
"type": "str"
}
] | {
"returns": [
{
"docstring": "SMILES representation of the molecule in the input image",
"docstring_tokens": [
"SMILES",
"representation",
"of",
"the",
"molecule",
"in",
"the",
"input",
"image"
],
"type": "(str)"
... |
a1f149b967c2af55e0d8d72eace6a8c181a2e223 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/DECIMER_EfficinetNetV2_Transfomer_Trainer.py | [
"MIT"
] | Python | decode_image | <not_specific> | def decode_image(image_data):
"""Preprocess the input image for Efficient-Net and
returned the preprocessed image
Args:
image_data (int array): Decoded image in 2D array
Returns:
image (array): Preprocessed image in 2D array
"""
try:
img = tf.image.decode_png(image_data... | Preprocess the input image for Efficient-Net and
returned the preprocessed image
Args:
image_data (int array): Decoded image in 2D array
Returns:
image (array): Preprocessed image in 2D array
| Preprocess the input image for Efficient-Net and
returned the preprocessed image | [
"Preprocess",
"the",
"input",
"image",
"for",
"Efficient",
"-",
"Net",
"and",
"returned",
"the",
"preprocessed",
"image"
] | def decode_image(image_data):
try:
img = tf.image.decode_png(image_data, channels=3)
except InvalidArgumentError as e:
print(e)
pass
img = tf.image.resize(img, (299, 299))
img = efn.preprocess_input(img)
return img | [
"def",
"decode_image",
"(",
"image_data",
")",
":",
"try",
":",
"img",
"=",
"tf",
".",
"image",
".",
"decode_png",
"(",
"image_data",
",",
"channels",
"=",
"3",
")",
"except",
"InvalidArgumentError",
"as",
"e",
":",
"print",
"(",
"e",
")",
"pass",
"img... | Preprocess the input image for Efficient-Net and
returned the preprocessed image | [
"Preprocess",
"the",
"input",
"image",
"for",
"Efficient",
"-",
"Net",
"and",
"returned",
"the",
"preprocessed",
"image"
] | [
"\"\"\"Preprocess the input image for Efficient-Net and\n returned the preprocessed image\n\n Args:\n image_data (int array): Decoded image in 2D array\n\n Returns:\n image (array): Preprocessed image in 2D array\n \"\"\"",
"# img = tf.expand_dims(img, 0)",
"# print(img)"
] | [
{
"param": "image_data",
"type": null
}
] | {
"returns": [
{
"docstring": "image (array): Preprocessed image in 2D array",
"docstring_tokens": [
"image",
"(",
"array",
")",
":",
"Preprocessed",
"image",
"in",
"2D",
"array"
],
"type": null
}
],
"r... |
a1f149b967c2af55e0d8d72eace6a8c181a2e223 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/DECIMER_EfficinetNetV2_Transfomer_Trainer.py | [
"MIT"
] | Python | read_tfrecord | <not_specific> | def read_tfrecord(example):
"""Read a tf record file and decodes the image and text data
back into original form.
Args:
example (tf.record): single entry from tf record file
Returns:
img (float array): 2D float array
caption: tokenized SMILES string
"""
feature = {
... | Read a tf record file and decodes the image and text data
back into original form.
Args:
example (tf.record): single entry from tf record file
Returns:
img (float array): 2D float array
caption: tokenized SMILES string
| Read a tf record file and decodes the image and text data
back into original form. | [
"Read",
"a",
"tf",
"record",
"file",
"and",
"decodes",
"the",
"image",
"and",
"text",
"data",
"back",
"into",
"original",
"form",
"."
] | def read_tfrecord(example):
feature = {
"image_raw": tf.io.FixedLenFeature([], tf.string),
"caption": tf.io.FixedLenFeature([], tf.string),
}
example = tf.io.parse_single_example(example, feature)
img = decode_image(example["image_raw"])
caption = tf.io.decode_raw(example["caption"],... | [
"def",
"read_tfrecord",
"(",
"example",
")",
":",
"feature",
"=",
"{",
"\"image_raw\"",
":",
"tf",
".",
"io",
".",
"FixedLenFeature",
"(",
"[",
"]",
",",
"tf",
".",
"string",
")",
",",
"\"caption\"",
":",
"tf",
".",
"io",
".",
"FixedLenFeature",
"(",
... | Read a tf record file and decodes the image and text data
back into original form. | [
"Read",
"a",
"tf",
"record",
"file",
"and",
"decodes",
"the",
"image",
"and",
"text",
"data",
"back",
"into",
"original",
"form",
"."
] | [
"\"\"\"Read a tf record file and decodes the image and text data\n back into original form.\n\n Args:\n example (tf.record): single entry from tf record file\n\n Returns:\n img (float array): 2D float array\n caption: tokenized SMILES string\n \"\"\"",
"# decode the TFRecord"
] | [
{
"param": "example",
"type": null
}
] | {
"returns": [
{
"docstring": "img (float array): 2D float array\ncaption: tokenized SMILES string",
"docstring_tokens": [
"img",
"(",
"float",
"array",
")",
":",
"2D",
"float",
"array",
"caption",
":",
"to... |
a1f149b967c2af55e0d8d72eace6a8c181a2e223 | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/DECIMER_EfficinetNetV2_Transfomer_Trainer.py | [
"MIT"
] | Python | prepare_for_training | <not_specific> | def prepare_for_training(lr_config, encoder_config, transformer_config, verbose=0):
"""Preparte the model for training. initiate the learning rate, loss object, metrics
and optimizer
Args:
lr_config (int): values for learning rate configuration
encoder_config (_type_): encoder configuration... | Preparte the model for training. initiate the learning rate, loss object, metrics
and optimizer
Args:
lr_config (int): values for learning rate configuration
encoder_config (_type_): encoder configuration values
transformer_config (_type_): transformer configuration values
verbo... | Preparte the model for training. initiate the learning rate, loss object, metrics
and optimizer | [
"Preparte",
"the",
"model",
"for",
"training",
".",
"initiate",
"the",
"learning",
"rate",
"loss",
"object",
"metrics",
"and",
"optimizer"
] | def prepare_for_training(lr_config, encoder_config, transformer_config, verbose=0):
with strategy.scope():
loss_object = tf.keras.losses.SparseCategoricalCrossentropy(
from_logits=True, reduction=tf.keras.losses.Reduction.NONE
)
def loss_fn(real, pred):
mask = tf.math... | [
"def",
"prepare_for_training",
"(",
"lr_config",
",",
"encoder_config",
",",
"transformer_config",
",",
"verbose",
"=",
"0",
")",
":",
"with",
"strategy",
".",
"scope",
"(",
")",
":",
"loss_object",
"=",
"tf",
".",
"keras",
".",
"losses",
".",
"SparseCategor... | Preparte the model for training. | [
"Preparte",
"the",
"model",
"for",
"training",
"."
] | [
"\"\"\"Preparte the model for training. initiate the learning rate, loss object, metrics\n and optimizer\n\n Args:\n lr_config (int): values for learning rate configuration\n encoder_config (_type_): encoder configuration values\n transformer_config (_type_): transformer configuration val... | [
{
"param": "lr_config",
"type": null
},
{
"param": "encoder_config",
"type": null
},
{
"param": "transformer_config",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [
{
"docstring": "loss_function, optimizer, model and the metrics",
"docstring_tokens": [
"loss_function",
"optimizer",
"model",
"and",
"the",
"metrics"
],
"type": null
}
],
"raises": [],
"params": [
{
"identi... |
6fed6e222c90c198530df949727632923645d36a | Steinbeck-Lab/DECIMER-Image_Transformer | Benchmark/run_decimer_save_results.py | [
"MIT"
] | Python | main | null | def main():
"""
This script runs Decimer on every image in a given directory (first argument) and saves the
results in a text file with a given ID (second argument).
"""
im_path = sys.argv[1]
save_ID = sys.argv[2]
# Don't start from beginning if a benchmark run aborted for some reason
w... |
This script runs Decimer on every image in a given directory (first argument) and saves the
results in a text file with a given ID (second argument).
| This script runs Decimer on every image in a given directory (first argument) and saves the
results in a text file with a given ID (second argument). | [
"This",
"script",
"runs",
"Decimer",
"on",
"every",
"image",
"in",
"a",
"given",
"directory",
"(",
"first",
"argument",
")",
"and",
"saves",
"the",
"results",
"in",
"a",
"text",
"file",
"with",
"a",
"given",
"ID",
"(",
"second",
"argument",
")",
"."
] | def main():
im_path = sys.argv[1]
save_ID = sys.argv[2]
with open("{}.txt".format(save_ID), "a+") as output:
lines = output.readlines()
already_processed = list([line.split("\t")[0] for line in lines])
for im in os.listdir(im_path):
if im not in already_processed:
wit... | [
"def",
"main",
"(",
")",
":",
"im_path",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"save_ID",
"=",
"sys",
".",
"argv",
"[",
"2",
"]",
"with",
"open",
"(",
"\"{}.txt\"",
".",
"format",
"(",
"save_ID",
")",
",",
"\"a+\"",
")",
"as",
"output",
":",
... | This script runs Decimer on every image in a given directory (first argument) and saves the
results in a text file with a given ID (second argument). | [
"This",
"script",
"runs",
"Decimer",
"on",
"every",
"image",
"in",
"a",
"given",
"directory",
"(",
"first",
"argument",
")",
"and",
"saves",
"the",
"results",
"in",
"a",
"text",
"file",
"with",
"a",
"given",
"ID",
"(",
"second",
"argument",
")",
"."
] | [
"\"\"\"\n This script runs Decimer on every image in a given directory (first argument) and saves the\n results in a text file with a given ID (second argument).\n \"\"\"",
"# Don't start from beginning if a benchmark run aborted for some reason"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7e24b86d8b36f2271ae93a4331f8b34429f402d9 | Steinbeck-Lab/DECIMER-Image_Transformer | Benchmark/evaluate_benchmarks.py | [
"MIT"
] | Python | compare_molecules_inchi_match | None | def compare_molecules_inchi_match(
input_file_path: str, reference_directory: str
) -> None:
"""
This function checks if the molecules in the DECIMER results to a set of reference
mol-files using Standard InChI.
Args:
input_file (str): Path of file that contains image names and SMILES a... |
This function checks if the molecules in the DECIMER results to a set of reference
mol-files using Standard InChI.
Args:
input_file (str): Path of file that contains image names and SMILES as created by run_decimer_save_results.py
reference_directory (str): Path of directory with m... | This function checks if the molecules in the DECIMER results to a set of reference
mol-files using Standard InChI. | [
"This",
"function",
"checks",
"if",
"the",
"molecules",
"in",
"the",
"DECIMER",
"results",
"to",
"a",
"set",
"of",
"reference",
"mol",
"-",
"files",
"using",
"Standard",
"InChI",
"."
] | def compare_molecules_inchi_match(
input_file_path: str, reference_directory: str
) -> None:
tanimoto_list = []
perfect_match_count = 0
with open(input_file_path, "r") as input_file:
lines = input_file.readlines()
for line in lines:
ID, smiles = line.split("\t")
s... | [
"def",
"compare_molecules_inchi_match",
"(",
"input_file_path",
":",
"str",
",",
"reference_directory",
":",
"str",
")",
"->",
"None",
":",
"\"\"\"\"\"\"",
"tanimoto_list",
"=",
"[",
"]",
"perfect_match_count",
"=",
"0",
"with",
"open",
"(",
"input_file_path",
","... | This function checks if the molecules in the DECIMER results to a set of reference
mol-files using Standard InChI. | [
"This",
"function",
"checks",
"if",
"the",
"molecules",
"in",
"the",
"DECIMER",
"results",
"to",
"a",
"set",
"of",
"reference",
"mol",
"-",
"files",
"using",
"Standard",
"InChI",
"."
] | [
"\"\"\"\n This function checks if the molecules in the DECIMER results to a set of reference\n mol-files using Standard InChI.\n\n Args:\n input_file (str): Path of file that contains image names and SMILES as created by run_decimer_save_results.py\n reference_directory (str): Path of... | [
{
"param": "input_file_path",
"type": "str"
},
{
"param": "reference_directory",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_file_path",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reference_directory",
"type": "str",
"docstring": "Path... |
6265c6c673a75fadbf0413b13d2fee186bbc4f7f | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/Predictor_EfficientNet2.py | [
"MIT"
] | Python | evaluate | <not_specific> | def evaluate(image_path: str):
"""
This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SELFIES representation of the molecule in the input i... |
This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SELFIES representation of the molecule in the input image
| This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SELFIES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | def evaluate(image_path: str):
sample = config.decode_image(image_path)
_image_batch = tf.expand_dims(sample, 0)
_image_embedding = encoder(_image_batch, training=False)
output = tf.expand_dims([tokenizer.word_index["<start>"]], 0)
result = []
end_token = tokenizer.word_index["<end>"]
for i ... | [
"def",
"evaluate",
"(",
"image_path",
":",
"str",
")",
":",
"sample",
"=",
"config",
".",
"decode_image",
"(",
"image_path",
")",
"_image_batch",
"=",
"tf",
".",
"expand_dims",
"(",
"sample",
",",
"0",
")",
"_image_embedding",
"=",
"encoder",
"(",
"_image_... | This function takes an image path (str) and returns the SELFIES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SELFIES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | [
"\"\"\"\n This function takes an image path (str) and returns the SELFIES\n representation of the depicted molecule (str).\n\n Args:\n image_path (str): Path of chemical structure depiction image\n\n Returns:\n (str): SELFIES representation of the molecule in the input image\n \"\"\""
] | [
{
"param": "image_path",
"type": "str"
}
] | {
"returns": [
{
"docstring": "SELFIES representation of the molecule in the input image",
"docstring_tokens": [
"SELFIES",
"representation",
"of",
"the",
"molecule",
"in",
"the",
"input",
"image"
],
"type": "(str)"
... |
6265c6c673a75fadbf0413b13d2fee186bbc4f7f | Steinbeck-Lab/DECIMER-Image_Transformer | DECIMER/Predictor_EfficientNet2.py | [
"MIT"
] | Python | predict_SMILES | <not_specific> | def predict_SMILES(image_path: str):
"""
This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SMILES representation of the molecule in the inp... |
This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str).
Args:
image_path (str): Path of chemical structure depiction image
Returns:
(str): SMILES representation of the molecule in the input image
| This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SMILES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | def predict_SMILES(image_path: str):
predicted_SELFIES = evaluate(image_path)
predicted_SMILES = decoder(
"".join(predicted_SELFIES).replace("<start>", "").replace("<end>", "")
)
return predicted_SMILES | [
"def",
"predict_SMILES",
"(",
"image_path",
":",
"str",
")",
":",
"predicted_SELFIES",
"=",
"evaluate",
"(",
"image_path",
")",
"predicted_SMILES",
"=",
"decoder",
"(",
"\"\"",
".",
"join",
"(",
"predicted_SELFIES",
")",
".",
"replace",
"(",
"\"<start>\"",
","... | This function takes an image path (str) and returns the SMILES
representation of the depicted molecule (str). | [
"This",
"function",
"takes",
"an",
"image",
"path",
"(",
"str",
")",
"and",
"returns",
"the",
"SMILES",
"representation",
"of",
"the",
"depicted",
"molecule",
"(",
"str",
")",
"."
] | [
"\"\"\"\n This function takes an image path (str) and returns the SMILES\n representation of the depicted molecule (str).\n\n Args:\n image_path (str): Path of chemical structure depiction image\n\n Returns:\n (str): SMILES representation of the molecule in the input image\n \"\"\""
] | [
{
"param": "image_path",
"type": "str"
}
] | {
"returns": [
{
"docstring": "SMILES representation of the molecule in the input image",
"docstring_tokens": [
"SMILES",
"representation",
"of",
"the",
"molecule",
"in",
"the",
"input",
"image"
],
"type": "(str)"
... |
a93cbdaaf899703eb431a6a6998985d1464c6558 | HyperGH/Starr | starr/db.py | [
"BSD-3-Clause"
] | Python | with_connection | t.Callable[..., t.Any] | def with_connection(func: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
"""A decorator used to acquire a connection from the pool."""
@functools.wraps(func)
async def wrapper(self: Database, *args: t.Any) -> t.Any:
async with self.pool.acquire() as conn:
return ... | A decorator used to acquire a connection from the pool. | A decorator used to acquire a connection from the pool. | [
"A",
"decorator",
"used",
"to",
"acquire",
"a",
"connection",
"from",
"the",
"pool",
"."
] | def with_connection(func: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
@functools.wraps(func)
async def wrapper(self: Database, *args: t.Any) -> t.Any:
async with self.pool.acquire() as conn:
return await func(self, *args, conn=conn)
return wrapper | [
"def",
"with_connection",
"(",
"func",
":",
"t",
".",
"Callable",
"[",
"...",
",",
"t",
".",
"Any",
"]",
")",
"->",
"t",
".",
"Callable",
"[",
"...",
",",
"t",
".",
"Any",
"]",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"async",
"de... | A decorator used to acquire a connection from the pool. | [
"A",
"decorator",
"used",
"to",
"acquire",
"a",
"connection",
"from",
"the",
"pool",
"."
] | [
"\"\"\"A decorator used to acquire a connection from the pool.\"\"\""
] | [
{
"param": "func",
"type": "t.Callable[..., t.Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": "t.Callable[..., t.Any]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a93cbdaaf899703eb431a6a6998985d1464c6558 | HyperGH/Starr | starr/db.py | [
"BSD-3-Clause"
] | Python | fetch_row | t.Optional[t.List[t.Any]] | async def fetch_row(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.Optional[t.List[t.Any]]:
"""Read 1 row of applicable data."""
query = await conn.prepare(q)
if data := await query.fetchrow(*values):
return [r for r in data]
return None | Read 1 row of applicable data. | Read 1 row of applicable data. | [
"Read",
"1",
"row",
"of",
"applicable",
"data",
"."
] | async def fetch_row(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.Optional[t.List[t.Any]]:
query = await conn.prepare(q)
if data := await query.fetchrow(*values):
return [r for r in data]
return None | [
"async",
"def",
"fetch_row",
"(",
"self",
",",
"q",
":",
"str",
",",
"*",
"values",
":",
"t",
".",
"Any",
",",
"conn",
":",
"asyncpg",
".",
"Connection",
")",
"->",
"t",
".",
"Optional",
"[",
"t",
".",
"List",
"[",
"t",
".",
"Any",
"]",
"]",
... | Read 1 row of applicable data. | [
"Read",
"1",
"row",
"of",
"applicable",
"data",
"."
] | [
"\"\"\"Read 1 row of applicable data.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "q",
"type": "str"
},
{
"param": "values",
"type": "t.Any"
},
{
"param": "conn",
"type": "asyncpg.Connection"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q",
"type": "str",
"docstring": null,
"docstring_tokens": [],... |
a93cbdaaf899703eb431a6a6998985d1464c6558 | HyperGH/Starr | starr/db.py | [
"BSD-3-Clause"
] | Python | fetch_rows | t.Optional[t.List[t.Iterable[t.Any]]] | async def fetch_rows(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.Optional[t.List[t.Iterable[t.Any]]]:
"""Read all rows of applicable data."""
query = await conn.prepare(q)
if data := await query.fetch(*values):
return [*map(lambda r: tuple(r.values()), ... | Read all rows of applicable data. | Read all rows of applicable data. | [
"Read",
"all",
"rows",
"of",
"applicable",
"data",
"."
] | async def fetch_rows(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.Optional[t.List[t.Iterable[t.Any]]]:
query = await conn.prepare(q)
if data := await query.fetch(*values):
return [*map(lambda r: tuple(r.values()), data)]
return None | [
"async",
"def",
"fetch_rows",
"(",
"self",
",",
"q",
":",
"str",
",",
"*",
"values",
":",
"t",
".",
"Any",
",",
"conn",
":",
"asyncpg",
".",
"Connection",
")",
"->",
"t",
".",
"Optional",
"[",
"t",
".",
"List",
"[",
"t",
".",
"Iterable",
"[",
"... | Read all rows of applicable data. | [
"Read",
"all",
"rows",
"of",
"applicable",
"data",
"."
] | [
"\"\"\"Read all rows of applicable data.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "q",
"type": "str"
},
{
"param": "values",
"type": "t.Any"
},
{
"param": "conn",
"type": "asyncpg.Connection"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q",
"type": "str",
"docstring": null,
"docstring_tokens": [],... |
a93cbdaaf899703eb431a6a6998985d1464c6558 | HyperGH/Starr | starr/db.py | [
"BSD-3-Clause"
] | Python | fetch_column | t.List[t.Any] | async def fetch_column(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.List[t.Any]:
"""Read a single column of applicable data."""
query = await conn.prepare(q)
return [r[0] for r in await query.fetch(*values)] | Read a single column of applicable data. | Read a single column of applicable data. | [
"Read",
"a",
"single",
"column",
"of",
"applicable",
"data",
"."
] | async def fetch_column(
self, q: str, *values: t.Any, conn: asyncpg.Connection
) -> t.List[t.Any]:
query = await conn.prepare(q)
return [r[0] for r in await query.fetch(*values)] | [
"async",
"def",
"fetch_column",
"(",
"self",
",",
"q",
":",
"str",
",",
"*",
"values",
":",
"t",
".",
"Any",
",",
"conn",
":",
"asyncpg",
".",
"Connection",
")",
"->",
"t",
".",
"List",
"[",
"t",
".",
"Any",
"]",
":",
"query",
"=",
"await",
"co... | Read a single column of applicable data. | [
"Read",
"a",
"single",
"column",
"of",
"applicable",
"data",
"."
] | [
"\"\"\"Read a single column of applicable data.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "q",
"type": "str"
},
{
"param": "values",
"type": "t.Any"
},
{
"param": "conn",
"type": "asyncpg.Connection"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "q",
"type": "str",
"docstring": null,
"docstring_tokens": [],... |
6d94c448f26e5fb8b8f9fc513a7b5b6e64921669 | InbarRose/kitir | kitir/_libs/byte_utils.py | [
"MIT"
] | Python | check_file_size | <not_specific> | def check_file_size(file_path, min_file_size=0):
"""
Check file size is greater than min_file_size. Default is larger than 0 bytes.
:param file_path:
:param min_file_size:
:return:
"""
try:
size = os.path.getsize(file_path)
except Exception as exc:
log.error('Exception re... |
Check file size is greater than min_file_size. Default is larger than 0 bytes.
:param file_path:
:param min_file_size:
:return:
| Check file size is greater than min_file_size. Default is larger than 0 bytes. | [
"Check",
"file",
"size",
"is",
"greater",
"than",
"min_file_size",
".",
"Default",
"is",
"larger",
"than",
"0",
"bytes",
"."
] | def check_file_size(file_path, min_file_size=0):
try:
size = os.path.getsize(file_path)
except Exception as exc:
log.error('Exception retrieving file size: file_path={} exc={}'.format(file_path, exc))
else:
log.trace('check file size: file={} min_file_size={} actual_size={}'.format(f... | [
"def",
"check_file_size",
"(",
"file_path",
",",
"min_file_size",
"=",
"0",
")",
":",
"try",
":",
"size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"file_path",
")",
"except",
"Exception",
"as",
"exc",
":",
"log",
".",
"error",
"(",
"'Exception retrie... | Check file size is greater than min_file_size. | [
"Check",
"file",
"size",
"is",
"greater",
"than",
"min_file_size",
"."
] | [
"\"\"\"\n Check file size is greater than min_file_size. Default is larger than 0 bytes.\n :param file_path:\n :param min_file_size:\n :return:\n \"\"\""
] | [
{
"param": "file_path",
"type": null
},
{
"param": "min_file_size",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_path",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
6d94c448f26e5fb8b8f9fc513a7b5b6e64921669 | InbarRose/kitir | kitir/_libs/byte_utils.py | [
"MIT"
] | Python | bytes2human | <not_specific> | def bytes2human(n, frmt='%(value).1f%(symbol)s', symbols='customary'):
"""
Convert n bytes into a human readable string based on format.
symbols can be either "customary", "customary_ext", "iec" or "iec_ext",
see: http://goo.gl/kTQMs
"""
# Bytes-to-human / human-to-bytes converter.
# Based o... |
Convert n bytes into a human readable string based on format.
symbols can be either "customary", "customary_ext", "iec" or "iec_ext",
see: http://goo.gl/kTQMs
| Convert n bytes into a human readable string based on format. | [
"Convert",
"n",
"bytes",
"into",
"a",
"human",
"readable",
"string",
"based",
"on",
"format",
"."
] | def bytes2human(n, frmt='%(value).1f%(symbol)s', symbols='customary'):
Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
License: MIT
copied from: http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764
n = int(n)
if n < 0:
raise ValueEr... | [
"def",
"bytes2human",
"(",
"n",
",",
"frmt",
"=",
"'%(value).1f%(symbol)s'",
",",
"symbols",
"=",
"'customary'",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"if",
"n",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"n < 0\"",
")",
"symbols",
"=",
"SYMBOLS"... | Convert n bytes into a human readable string based on format. | [
"Convert",
"n",
"bytes",
"into",
"a",
"human",
"readable",
"string",
"based",
"on",
"format",
"."
] | [
"\"\"\"\n Convert n bytes into a human readable string based on format.\n symbols can be either \"customary\", \"customary_ext\", \"iec\" or \"iec_ext\",\n see: http://goo.gl/kTQMs\n \"\"\"",
"# Bytes-to-human / human-to-bytes converter.",
"# Based on: http://goo.gl/kTQMs",
"# Working with Python ... | [
{
"param": "n",
"type": null
},
{
"param": "frmt",
"type": null
},
{
"param": "symbols",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frmt",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
6d94c448f26e5fb8b8f9fc513a7b5b6e64921669 | InbarRose/kitir | kitir/_libs/byte_utils.py | [
"MIT"
] | Python | human2bytes | <not_specific> | def human2bytes(s):
"""
Attempts to guess the string format based on default symbols
set and return the corresponding bytes as an integer.
When unable to recognize the format ValueError is raised.
"""
# Bytes-to-human / human-to-bytes converter.
# Based on: http://goo.gl/kTQMs
# Working ... |
Attempts to guess the string format based on default symbols
set and return the corresponding bytes as an integer.
When unable to recognize the format ValueError is raised.
| Attempts to guess the string format based on default symbols
set and return the corresponding bytes as an integer.
When unable to recognize the format ValueError is raised. | [
"Attempts",
"to",
"guess",
"the",
"string",
"format",
"based",
"on",
"default",
"symbols",
"set",
"and",
"return",
"the",
"corresponding",
"bytes",
"as",
"an",
"integer",
".",
"When",
"unable",
"to",
"recognize",
"the",
"format",
"ValueError",
"is",
"raised",
... | def human2bytes(s):
Author: Giampaolo Rodola' <g.rodola [AT] gmail [DOT] com>
License: MIT
copied from: http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/?in=user-4178764
init = s
num = ""
while s and s[0:1].isdigit() or s[0:1] == '.':
num += s[0]
... | [
"def",
"human2bytes",
"(",
"s",
")",
":",
"init",
"=",
"s",
"num",
"=",
"\"\"",
"while",
"s",
"and",
"s",
"[",
"0",
":",
"1",
"]",
".",
"isdigit",
"(",
")",
"or",
"s",
"[",
"0",
":",
"1",
"]",
"==",
"'.'",
":",
"num",
"+=",
"s",
"[",
"0",... | Attempts to guess the string format based on default symbols
set and return the corresponding bytes as an integer. | [
"Attempts",
"to",
"guess",
"the",
"string",
"format",
"based",
"on",
"default",
"symbols",
"set",
"and",
"return",
"the",
"corresponding",
"bytes",
"as",
"an",
"integer",
"."
] | [
"\"\"\"\n Attempts to guess the string format based on default symbols\n set and return the corresponding bytes as an integer.\n When unable to recognize the format ValueError is raised.\n \"\"\"",
"# Bytes-to-human / human-to-bytes converter.",
"# Based on: http://goo.gl/kTQMs",
"# Working with P... | [
{
"param": "s",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _log_transaction | <not_specific> | def _log_transaction(cls, response, **kwargs):
"""
logs the request transaction, both request and response with optional kwargs
:param response:
:param kwargs:
:return:
"""
only_not_ok = kwargs.pop('only_not_ok', False)
transact_name = kwargs.pop('transact... |
logs the request transaction, both request and response with optional kwargs
:param response:
:param kwargs:
:return:
| logs the request transaction, both request and response with optional kwargs | [
"logs",
"the",
"request",
"transaction",
"both",
"request",
"and",
"response",
"with",
"optional",
"kwargs"
] | def _log_transaction(cls, response, **kwargs):
only_not_ok = kwargs.pop('only_not_ok', False)
transact_name = kwargs.pop('transact_name', None)
transact_parts = [transact_name, response.request.method]
transact_id = kwargs.pop('transact_id', None) or cls._make_transaction_id(*transact_pa... | [
"def",
"_log_transaction",
"(",
"cls",
",",
"response",
",",
"**",
"kwargs",
")",
":",
"only_not_ok",
"=",
"kwargs",
".",
"pop",
"(",
"'only_not_ok'",
",",
"False",
")",
"transact_name",
"=",
"kwargs",
".",
"pop",
"(",
"'transact_name'",
",",
"None",
")",
... | logs the request transaction, both request and response with optional kwargs | [
"logs",
"the",
"request",
"transaction",
"both",
"request",
"and",
"response",
"with",
"optional",
"kwargs"
] | [
"\"\"\"\n logs the request transaction, both request and response with optional kwargs\n :param response:\n :param kwargs:\n :return:\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _log_request_full | null | def _log_request_full(cls, response, request_file_path):
"""log the full request side of a transaction"""
assert isinstance(response, requests.Response)
req = response.request
assert isinstance(req, requests.PreparedRequest)
data = {
'url': req.url,
'heade... | log the full request side of a transaction | log the full request side of a transaction | [
"log",
"the",
"full",
"request",
"side",
"of",
"a",
"transaction"
] | def _log_request_full(cls, response, request_file_path):
assert isinstance(response, requests.Response)
req = response.request
assert isinstance(req, requests.PreparedRequest)
data = {
'url': req.url,
'headers': dict(req.headers),
'method': req.method,... | [
"def",
"_log_request_full",
"(",
"cls",
",",
"response",
",",
"request_file_path",
")",
":",
"assert",
"isinstance",
"(",
"response",
",",
"requests",
".",
"Response",
")",
"req",
"=",
"response",
".",
"request",
"assert",
"isinstance",
"(",
"req",
",",
"req... | log the full request side of a transaction | [
"log",
"the",
"full",
"request",
"side",
"of",
"a",
"transaction"
] | [
"\"\"\"log the full request side of a transaction\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "request_file_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens"... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _log_response_full | null | def _log_response_full(cls, response, response_file_path):
"""log the full response side of a transaction"""
assert isinstance(response, requests.Response)
_ignore_fields = ['history', 'links', 'raw', 'reason', 'next', 'connection', 'request', 'text']
data = {
'ok': response.... | log the full response side of a transaction | log the full response side of a transaction | [
"log",
"the",
"full",
"response",
"side",
"of",
"a",
"transaction"
] | def _log_response_full(cls, response, response_file_path):
assert isinstance(response, requests.Response)
_ignore_fields = ['history', 'links', 'raw', 'reason', 'next', 'connection', 'request', 'text']
data = {
'ok': response.ok,
'url': response.url,
'headers'... | [
"def",
"_log_response_full",
"(",
"cls",
",",
"response",
",",
"response_file_path",
")",
":",
"assert",
"isinstance",
"(",
"response",
",",
"requests",
".",
"Response",
")",
"_ignore_fields",
"=",
"[",
"'history'",
",",
"'links'",
",",
"'raw'",
",",
"'reason'... | log the full response side of a transaction | [
"log",
"the",
"full",
"response",
"side",
"of",
"a",
"transaction"
] | [
"\"\"\"log the full response side of a transaction\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "response_file_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens"... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _log_request | null | def _log_request(cls, response, request_file_path):
"""log the request side of a transaction"""
if response.request.body:
content = response.request.body
else:
content = response.request.url
data_file = utils.write_file(request_file_path, content)
log.trac... | log the request side of a transaction | log the request side of a transaction | [
"log",
"the",
"request",
"side",
"of",
"a",
"transaction"
] | def _log_request(cls, response, request_file_path):
if response.request.body:
content = response.request.body
else:
content = response.request.url
data_file = utils.write_file(request_file_path, content)
log.trace('log-request: method={} url={} path={} data={}'.fo... | [
"def",
"_log_request",
"(",
"cls",
",",
"response",
",",
"request_file_path",
")",
":",
"if",
"response",
".",
"request",
".",
"body",
":",
"content",
"=",
"response",
".",
"request",
".",
"body",
"else",
":",
"content",
"=",
"response",
".",
"request",
... | log the request side of a transaction | [
"log",
"the",
"request",
"side",
"of",
"a",
"transaction"
] | [
"\"\"\"log the request side of a transaction\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "request_file_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens"... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _log_response | null | def _log_response(cls, response, response_file_path):
"""log the response side of a transaction"""
content = cls._get_content_from_response(response)
if content is not None:
data_file = utils.write_file(response_file_path, content)
log.trace('log-response: status={} data=... | log the response side of a transaction | log the response side of a transaction | [
"log",
"the",
"response",
"side",
"of",
"a",
"transaction"
] | def _log_response(cls, response, response_file_path):
content = cls._get_content_from_response(response)
if content is not None:
data_file = utils.write_file(response_file_path, content)
log.trace('log-response: status={} data={}'.format(response.status_code, data_file))
... | [
"def",
"_log_response",
"(",
"cls",
",",
"response",
",",
"response_file_path",
")",
":",
"content",
"=",
"cls",
".",
"_get_content_from_response",
"(",
"response",
")",
"if",
"content",
"is",
"not",
"None",
":",
"data_file",
"=",
"utils",
".",
"write_file",
... | log the response side of a transaction | [
"log",
"the",
"response",
"side",
"of",
"a",
"transaction"
] | [
"\"\"\"log the response side of a transaction\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "response_file_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens"... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _get_body_from_req | <not_specific> | def _get_body_from_req(cls, req):
"""attempts to extract body from req as json, if fails, gets raw body (as string)"""
assert isinstance(req, requests.PreparedRequest)
if not req.body:
return req.body
try:
body = json.loads(req.body)
except TypeError:
... | attempts to extract body from req as json, if fails, gets raw body (as string) | attempts to extract body from req as json, if fails, gets raw body (as string) | [
"attempts",
"to",
"extract",
"body",
"from",
"req",
"as",
"json",
"if",
"fails",
"gets",
"raw",
"body",
"(",
"as",
"string",
")"
] | def _get_body_from_req(cls, req):
assert isinstance(req, requests.PreparedRequest)
if not req.body:
return req.body
try:
body = json.loads(req.body)
except TypeError:
body = req.body.decode('utf-8', errors='replace')
return body | [
"def",
"_get_body_from_req",
"(",
"cls",
",",
"req",
")",
":",
"assert",
"isinstance",
"(",
"req",
",",
"requests",
".",
"PreparedRequest",
")",
"if",
"not",
"req",
".",
"body",
":",
"return",
"req",
".",
"body",
"try",
":",
"body",
"=",
"json",
".",
... | attempts to extract body from req as json, if fails, gets raw body (as string) | [
"attempts",
"to",
"extract",
"body",
"from",
"req",
"as",
"json",
"if",
"fails",
"gets",
"raw",
"body",
"(",
"as",
"string",
")"
] | [
"\"\"\"attempts to extract body from req as json, if fails, gets raw body (as string)\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "req",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _get_content_from_response | <not_specific> | def _get_content_from_response(cls, response, prefer_json=False):
"""attempts to extract content from response as json, if fails, gets raw content"""
try:
content = response.json()
# except json.JSONDecodeError as jde:
except ValueError as vexc:
if not any([ignore... | attempts to extract content from response as json, if fails, gets raw content | attempts to extract content from response as json, if fails, gets raw content | [
"attempts",
"to",
"extract",
"content",
"from",
"response",
"as",
"json",
"if",
"fails",
"gets",
"raw",
"content"
] | def _get_content_from_response(cls, response, prefer_json=False):
try:
content = response.json()
except ValueError as vexc:
if not any([ignored_msg in str(vexc) for ignored_msg in cls._ignored_json_convert_error_messages]):
raise
elif response.content:... | [
"def",
"_get_content_from_response",
"(",
"cls",
",",
"response",
",",
"prefer_json",
"=",
"False",
")",
":",
"try",
":",
"content",
"=",
"response",
".",
"json",
"(",
")",
"except",
"ValueError",
"as",
"vexc",
":",
"if",
"not",
"any",
"(",
"[",
"ignored... | attempts to extract content from response as json, if fails, gets raw content | [
"attempts",
"to",
"extract",
"content",
"from",
"response",
"as",
"json",
"if",
"fails",
"gets",
"raw",
"content"
] | [
"\"\"\"attempts to extract content from response as json, if fails, gets raw content\"\"\"",
"# except json.JSONDecodeError as jde:"
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": null
},
{
"param": "prefer_json",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens"... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _request_get | <not_specific> | def _request_get(cls, url, **kwargs):
"""sends a GET command using requests package"""
ignore_request_timeout = kwargs.pop('ignore_request_timeout', False)
ignore_connection_aborted = kwargs.pop('ignore_connection_aborted', False)
log_action = kwargs.pop('log_action', True)
sessi... | sends a GET command using requests package | sends a GET command using requests package | [
"sends",
"a",
"GET",
"command",
"using",
"requests",
"package"
] | def _request_get(cls, url, **kwargs):
ignore_request_timeout = kwargs.pop('ignore_request_timeout', False)
ignore_connection_aborted = kwargs.pop('ignore_connection_aborted', False)
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefaul... | [
"def",
"_request_get",
"(",
"cls",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"ignore_request_timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'ignore_request_timeout'",
",",
"False",
")",
"ignore_connection_aborted",
"=",
"kwargs",
".",
"pop",
"(",
"'ignore_connectio... | sends a GET command using requests package | [
"sends",
"a",
"GET",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a GET command using requests package\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | request_get | <not_specific> | def request_get(self, url, **kwargs):
"""sends a GET command using requests package"""
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_get(url, **kwargs) | sends a GET command using requests package | sends a GET command using requests package | [
"sends",
"a",
"GET",
"command",
"using",
"requests",
"package"
] | def request_get(self, url, **kwargs):
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_get(url, **kwargs) | [
"def",
"request_get",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"__add_default_log_params_to_kwargs",
"(",
"kwargs",
")",
"kwargs",
".",
"setdefault",
"(",
"'session'",
",",
"self",
".",
"session",
")",
"return",
"self",
".",
"_r... | sends a GET command using requests package | [
"sends",
"a",
"GET",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a GET command using requests package\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _request_post | <not_specific> | def _request_post(cls, url, **kwargs):
"""sends a POST command using requests package"""
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
... | sends a POST command using requests package | sends a POST command using requests package | [
"sends",
"a",
"POST",
"command",
"using",
"requests",
"package"
] | def _request_post(cls, url, **kwargs):
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
if log_action:
log.debug('request.post: ur... | [
"def",
"_request_post",
"(",
"cls",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"log_action",
"=",
"kwargs",
".",
"pop",
"(",
"'log_action'",
",",
"True",
")",
"session",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"None",
")",
"kwargs",
".",
"s... | sends a POST command using requests package | [
"sends",
"a",
"POST",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a POST command using requests package\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | request_post | <not_specific> | def request_post(self, url, **kwargs):
"""sends a POST command using requests package"""
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_post(url, **kwargs) | sends a POST command using requests package | sends a POST command using requests package | [
"sends",
"a",
"POST",
"command",
"using",
"requests",
"package"
] | def request_post(self, url, **kwargs):
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_post(url, **kwargs) | [
"def",
"request_post",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"__add_default_log_params_to_kwargs",
"(",
"kwargs",
")",
"kwargs",
".",
"setdefault",
"(",
"'session'",
",",
"self",
".",
"session",
")",
"return",
"self",
".",
"_... | sends a POST command using requests package | [
"sends",
"a",
"POST",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a POST command using requests package\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _request_put | <not_specific> | def _request_put(cls, url, **kwargs):
"""sends a PUT command using requests package"""
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
... | sends a PUT command using requests package | sends a PUT command using requests package | [
"sends",
"a",
"PUT",
"command",
"using",
"requests",
"package"
] | def _request_put(cls, url, **kwargs):
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
if log_action:
log.debug('request.put: url=... | [
"def",
"_request_put",
"(",
"cls",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"log_action",
"=",
"kwargs",
".",
"pop",
"(",
"'log_action'",
",",
"True",
")",
"session",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"None",
")",
"kwargs",
".",
"se... | sends a PUT command using requests package | [
"sends",
"a",
"PUT",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a PUT command using requests package\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | request_put | <not_specific> | def request_put(self, url, **kwargs):
"""sends a PUT command using requests package"""
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_put(url, **kwargs) | sends a PUT command using requests package | sends a PUT command using requests package | [
"sends",
"a",
"PUT",
"command",
"using",
"requests",
"package"
] | def request_put(self, url, **kwargs):
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_put(url, **kwargs) | [
"def",
"request_put",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"__add_default_log_params_to_kwargs",
"(",
"kwargs",
")",
"kwargs",
".",
"setdefault",
"(",
"'session'",
",",
"self",
".",
"session",
")",
"return",
"self",
".",
"_r... | sends a PUT command using requests package | [
"sends",
"a",
"PUT",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a PUT command using requests package\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _request_patch | <not_specific> | def _request_patch(cls, url, **kwargs):
"""sends a PATCH command using requests package"""
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
... | sends a PATCH command using requests package | sends a PATCH command using requests package | [
"sends",
"a",
"PATCH",
"command",
"using",
"requests",
"package"
] | def _request_patch(cls, url, **kwargs):
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
if log_action:
log.debug('request.patch: ... | [
"def",
"_request_patch",
"(",
"cls",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"log_action",
"=",
"kwargs",
".",
"pop",
"(",
"'log_action'",
",",
"True",
")",
"session",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"None",
")",
"kwargs",
".",
"... | sends a PATCH command using requests package | [
"sends",
"a",
"PATCH",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a PATCH command using requests package\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | request_patch | <not_specific> | def request_patch(self, url, **kwargs):
"""sends a PATCH command using requests package"""
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_patch(url, **kwargs) | sends a PATCH command using requests package | sends a PATCH command using requests package | [
"sends",
"a",
"PATCH",
"command",
"using",
"requests",
"package"
] | def request_patch(self, url, **kwargs):
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_patch(url, **kwargs) | [
"def",
"request_patch",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"__add_default_log_params_to_kwargs",
"(",
"kwargs",
")",
"kwargs",
".",
"setdefault",
"(",
"'session'",
",",
"self",
".",
"session",
")",
"return",
"self",
".",
"... | sends a PATCH command using requests package | [
"sends",
"a",
"PATCH",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a PATCH command using requests package\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | _request_delete | <not_specific> | def _request_delete(cls, url, **kwargs):
"""sends a DELETE command using requests package"""
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
... | sends a DELETE command using requests package | sends a DELETE command using requests package | [
"sends",
"a",
"DELETE",
"command",
"using",
"requests",
"package"
] | def _request_delete(cls, url, **kwargs):
log_action = kwargs.pop('log_action', True)
session = kwargs.pop('session', None)
kwargs.setdefault('timeout', cls.request_timeout)
log_kwargs, kwargs = cls._extract_log_kwargs(**kwargs)
if log_action:
log.debug('request.delete... | [
"def",
"_request_delete",
"(",
"cls",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"log_action",
"=",
"kwargs",
".",
"pop",
"(",
"'log_action'",
",",
"True",
")",
"session",
"=",
"kwargs",
".",
"pop",
"(",
"'session'",
",",
"None",
")",
"kwargs",
".",
... | sends a DELETE command using requests package | [
"sends",
"a",
"DELETE",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a DELETE command using requests package\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
a4f7b19d36f0dff5b59f552fbb1a50e67c89c4cf | InbarRose/kitir | kitir/kits/restful_api.py | [
"MIT"
] | Python | request_delete | <not_specific> | def request_delete(self, url, **kwargs):
"""sends a DELETE command using requests package"""
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_delete(url, **kwargs) | sends a DELETE command using requests package | sends a DELETE command using requests package | [
"sends",
"a",
"DELETE",
"command",
"using",
"requests",
"package"
] | def request_delete(self, url, **kwargs):
self.__add_default_log_params_to_kwargs(kwargs)
kwargs.setdefault('session', self.session)
return self._request_delete(url, **kwargs) | [
"def",
"request_delete",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"__add_default_log_params_to_kwargs",
"(",
"kwargs",
")",
"kwargs",
".",
"setdefault",
"(",
"'session'",
",",
"self",
".",
"session",
")",
"return",
"self",
".",
... | sends a DELETE command using requests package | [
"sends",
"a",
"DELETE",
"command",
"using",
"requests",
"package"
] | [
"\"\"\"sends a DELETE command using requests package\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
665e23901c38f0189a15ce2fba1e6ff5459defad | InbarRose/kitir | kitir/utils.py | [
"MIT"
] | Python | try_get_rc | <not_specific> | def try_get_rc(ret, raise_on_fail=False, fail_rc=3, **kwargs):
"""
try to get a numeric RC
:param ret: the object to examine for an rc
:param raise_on_fail:
:param fail_rc:
:return:
"""
rc_attributes = kwargs.pop('rc_attributes', ['rc'])
parse_execresults = kwargs.pop('parse_execres... |
try to get a numeric RC
:param ret: the object to examine for an rc
:param raise_on_fail:
:param fail_rc:
:return:
| try to get a numeric RC | [
"try",
"to",
"get",
"a",
"numeric",
"RC"
] | def try_get_rc(ret, raise_on_fail=False, fail_rc=3, **kwargs):
rc_attributes = kwargs.pop('rc_attributes', ['rc'])
parse_execresults = kwargs.pop('parse_execresults', True)
if isinstance(ret, int):
return int(ret)
if parse_execresults and isinstance(ret, ExecResult):
return ret.rc
if... | [
"def",
"try_get_rc",
"(",
"ret",
",",
"raise_on_fail",
"=",
"False",
",",
"fail_rc",
"=",
"3",
",",
"**",
"kwargs",
")",
":",
"rc_attributes",
"=",
"kwargs",
".",
"pop",
"(",
"'rc_attributes'",
",",
"[",
"'rc'",
"]",
")",
"parse_execresults",
"=",
"kwarg... | try to get a numeric RC | [
"try",
"to",
"get",
"a",
"numeric",
"RC"
] | [
"\"\"\"\n try to get a numeric RC\n :param ret: the object to examine for an rc\n :param raise_on_fail:\n :param fail_rc:\n :return:\n \"\"\"",
"# first, if it is an int, return it",
"# if it is an ExecResult, return the RC",
"# if it has an rc attribute, return that (if its an in)",
"# if... | [
{
"param": "ret",
"type": null
},
{
"param": "raise_on_fail",
"type": null
},
{
"param": "fail_rc",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "ret",
"type": null,
"docstring": "the object to examine for an rc",
"docstring_tokens": [
"the",
"o... |
665e23901c38f0189a15ce2fba1e6ff5459defad | InbarRose/kitir | kitir/utils.py | [
"MIT"
] | Python | deepgetattr | <not_specific> | def deepgetattr(obj, attr, default=None, raise_if_missing=False):
"""Recurses through an attribute chain to get the ultimate value."""
if isinstance(attr, str):
attr = attr.split('.')
try:
return functools.reduce(getattr, attr, obj)
except AttributeError:
if raise_if_missing:
... | Recurses through an attribute chain to get the ultimate value. | Recurses through an attribute chain to get the ultimate value. | [
"Recurses",
"through",
"an",
"attribute",
"chain",
"to",
"get",
"the",
"ultimate",
"value",
"."
] | def deepgetattr(obj, attr, default=None, raise_if_missing=False):
if isinstance(attr, str):
attr = attr.split('.')
try:
return functools.reduce(getattr, attr, obj)
except AttributeError:
if raise_if_missing:
raise
return default | [
"def",
"deepgetattr",
"(",
"obj",
",",
"attr",
",",
"default",
"=",
"None",
",",
"raise_if_missing",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"str",
")",
":",
"attr",
"=",
"attr",
".",
"split",
"(",
"'.'",
")",
"try",
":",
"ret... | Recurses through an attribute chain to get the ultimate value. | [
"Recurses",
"through",
"an",
"attribute",
"chain",
"to",
"get",
"the",
"ultimate",
"value",
"."
] | [
"\"\"\"Recurses through an attribute chain to get the ultimate value.\"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "attr",
"type": null
},
{
"param": "default",
"type": null
},
{
"param": "raise_if_missing",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attr",
"type": null,
"docstring": null,
"docstring_tokens": []... |
665e23901c38f0189a15ce2fba1e6ff5459defad | InbarRose/kitir | kitir/utils.py | [
"MIT"
] | Python | deepgetkey | <not_specific> | def deepgetkey(col, key, default=None, raise_if_missing=False):
"""Recurses through a key chain to get the ultimate value."""
if isinstance(key, str):
key = key.split('.')
try:
return functools.reduce(dict.get, key, col)
except KeyError:
if raise_if_missing:
raise
... | Recurses through a key chain to get the ultimate value. | Recurses through a key chain to get the ultimate value. | [
"Recurses",
"through",
"a",
"key",
"chain",
"to",
"get",
"the",
"ultimate",
"value",
"."
] | def deepgetkey(col, key, default=None, raise_if_missing=False):
if isinstance(key, str):
key = key.split('.')
try:
return functools.reduce(dict.get, key, col)
except KeyError:
if raise_if_missing:
raise
return default | [
"def",
"deepgetkey",
"(",
"col",
",",
"key",
",",
"default",
"=",
"None",
",",
"raise_if_missing",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"key",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"try",
":",
"return",... | Recurses through a key chain to get the ultimate value. | [
"Recurses",
"through",
"a",
"key",
"chain",
"to",
"get",
"the",
"ultimate",
"value",
"."
] | [
"\"\"\"Recurses through a key chain to get the ultimate value.\"\"\""
] | [
{
"param": "col",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "default",
"type": null
},
{
"param": "raise_if_missing",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "col",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
665e23901c38f0189a15ce2fba1e6ff5459defad | InbarRose/kitir | kitir/utils.py | [
"MIT"
] | Python | is_same_class_or_subclass | <not_specific> | def is_same_class_or_subclass(target, main_class):
"""
checks if target is the same class or a subclass of main_class
:param target:
:param main_class:
:return:
"""
return isinstance(target, main_class) or issubclass(target.__class__, main_class) |
checks if target is the same class or a subclass of main_class
:param target:
:param main_class:
:return:
| checks if target is the same class or a subclass of main_class | [
"checks",
"if",
"target",
"is",
"the",
"same",
"class",
"or",
"a",
"subclass",
"of",
"main_class"
] | def is_same_class_or_subclass(target, main_class):
return isinstance(target, main_class) or issubclass(target.__class__, main_class) | [
"def",
"is_same_class_or_subclass",
"(",
"target",
",",
"main_class",
")",
":",
"return",
"isinstance",
"(",
"target",
",",
"main_class",
")",
"or",
"issubclass",
"(",
"target",
".",
"__class__",
",",
"main_class",
")"
] | checks if target is the same class or a subclass of main_class | [
"checks",
"if",
"target",
"is",
"the",
"same",
"class",
"or",
"a",
"subclass",
"of",
"main_class"
] | [
"\"\"\"\n checks if target is the same class or a subclass of main_class\n :param target:\n :param main_class:\n :return:\n \"\"\""
] | [
{
"param": "target",
"type": null
},
{
"param": "main_class",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
0a16368509b08037c47429e027e58570fb2b2faf | InbarRose/kitir | kitir/_libs/package_utils.py | [
"MIT"
] | Python | verify_pip | <not_specific> | def verify_pip(get_if_needed=True, raise_on_failure=True, **kwargs):
"""
verify that pip exists on machine
:param get_if_needed: get pip if missing
:param raise_on_failure: raise exception if no pip at the end
:return: returns the pip base if all is okay, or false otherwise (or raises exception)
... |
verify that pip exists on machine
:param get_if_needed: get pip if missing
:param raise_on_failure: raise exception if no pip at the end
:return: returns the pip base if all is okay, or false otherwise (or raises exception)
| verify that pip exists on machine | [
"verify",
"that",
"pip",
"exists",
"on",
"machine"
] | def verify_pip(get_if_needed=True, raise_on_failure=True, **kwargs):
log.trace('verifying pip exists: get_if_needed={}'.format(get_if_needed))
kwargs.setdefault('to_console', False)
kwargs.setdefault('trace_file', ir_artifact_dir + '/packages/pip/verify_pip.trace.out')
def _check_for_pip():
for ... | [
"def",
"verify_pip",
"(",
"get_if_needed",
"=",
"True",
",",
"raise_on_failure",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"log",
".",
"trace",
"(",
"'verifying pip exists: get_if_needed={}'",
".",
"format",
"(",
"get_if_needed",
")",
")",
"kwargs",
".",
"se... | verify that pip exists on machine | [
"verify",
"that",
"pip",
"exists",
"on",
"machine"
] | [
"\"\"\"\n verify that pip exists on machine\n :param get_if_needed: get pip if missing\n :param raise_on_failure: raise exception if no pip at the end\n :return: returns the pip base if all is okay, or false otherwise (or raises exception)\n \"\"\""
] | [
{
"param": "get_if_needed",
"type": null
},
{
"param": "raise_on_failure",
"type": null
}
] | {
"returns": [
{
"docstring": "returns the pip base if all is okay, or false otherwise (or raises exception)",
"docstring_tokens": [
"returns",
"the",
"pip",
"base",
"if",
"all",
"is",
"okay",
"or",
"false",
"other... |
0a16368509b08037c47429e027e58570fb2b2faf | InbarRose/kitir | kitir/_libs/package_utils.py | [
"MIT"
] | Python | pip_cmd | <not_specific> | def pip_cmd(*packages, **kwargs):
"""
executes pip on current machine. Using the supplied mode and packages
:param packages: a list of packages,
:param kwargs: kwargs for iexec and flags
:return:
"""
# delete pip cache dir
shutil.rmtree('/root/.cache/pip', ignore_errors=True)
# tes... |
executes pip on current machine. Using the supplied mode and packages
:param packages: a list of packages,
:param kwargs: kwargs for iexec and flags
:return:
| executes pip on current machine. Using the supplied mode and packages | [
"executes",
"pip",
"on",
"current",
"machine",
".",
"Using",
"the",
"supplied",
"mode",
"and",
"packages"
] | def pip_cmd(*packages, **kwargs):
shutil.rmtree('/root/.cache/pip', ignore_errors=True)
if running_on_windows:
pip_base = 'python -m pip'
else:
pip_base = verify_pip(**kwargs)
mode = kwargs.pop('mode', 'install')
assert mode in ['install', 'uninstall']
kwargs.setdefault('trace_... | [
"def",
"pip_cmd",
"(",
"*",
"packages",
",",
"**",
"kwargs",
")",
":",
"shutil",
".",
"rmtree",
"(",
"'/root/.cache/pip'",
",",
"ignore_errors",
"=",
"True",
")",
"if",
"running_on_windows",
":",
"pip_base",
"=",
"'python -m pip'",
"else",
":",
"pip_base",
"... | executes pip on current machine. | [
"executes",
"pip",
"on",
"current",
"machine",
"."
] | [
"\"\"\"\n executes pip on current machine. Using the supplied mode and packages\n :param packages: a list of packages,\n :param kwargs: kwargs for iexec and flags\n :return:\n \"\"\"",
"# delete pip cache dir",
"# test for pip",
"# validate",
"# todo: expand modes",
"# kwargs",
"# flags ... | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [
{
"identifier": "packages",
"type": null,
"docstring": "a list of packages.",
"docstring_tokens": [
... |
d3398089555244f019fe44321a09f12792ac8080 | InbarRose/kitir | kitir/_libs/csv_utils.py | [
"MIT"
] | Python | read_csv_from_string | <not_specific> | def read_csv_from_string(text, return_headers=False):
"""
reads a csv (comma separated values) string using DictReader and returns a rowdicts list
:param text: string to parse CSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
"""
log.trace('read... |
reads a csv (comma separated values) string using DictReader and returns a rowdicts list
:param text: string to parse CSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
| reads a csv (comma separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"csv",
"(",
"comma",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | def read_csv_from_string(text, return_headers=False):
log.trace('reading csv string: content[:20]={} len={}'.format(repr(text[:20]), len(text)))
reader = csv.DictReader(text.splitlines())
rows = [row for row in reader]
if return_headers:
return rows, reader.fieldnames
return rows | [
"def",
"read_csv_from_string",
"(",
"text",
",",
"return_headers",
"=",
"False",
")",
":",
"log",
".",
"trace",
"(",
"'reading csv string: content[:20]={} len={}'",
".",
"format",
"(",
"repr",
"(",
"text",
"[",
":",
"20",
"]",
")",
",",
"len",
"(",
"text",
... | reads a csv (comma separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"csv",
"(",
"comma",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | [
"\"\"\"\n reads a csv (comma separated values) string using DictReader and returns a rowdicts list\n :param text: string to parse CSV from\n :param return_headers: return value becomes (rows, headers)\n :return: rows read from csv\n \"\"\""
] | [
{
"param": "text",
"type": null
},
{
"param": "return_headers",
"type": null
}
] | {
"returns": [
{
"docstring": "rows read from csv",
"docstring_tokens": [
"rows",
"read",
"from",
"csv"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": "string to parse CSV fro... |
d3398089555244f019fe44321a09f12792ac8080 | InbarRose/kitir | kitir/_libs/csv_utils.py | [
"MIT"
] | Python | read_tsv_from_string | <not_specific> | def read_tsv_from_string(text, return_headers=False):
"""
reads a tsv (tab separated values) string using DictReader and returns a rowdicts list
:param text: string to parse TSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
"""
log.trace('readin... |
reads a tsv (tab separated values) string using DictReader and returns a rowdicts list
:param text: string to parse TSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
| reads a tsv (tab separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"tsv",
"(",
"tab",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | def read_tsv_from_string(text, return_headers=False):
log.trace('reading tsv string: content[:20]={} len={}'.format(repr(text[:20]), len(text)))
reader = csv.DictReader(text.splitlines(), dialect='excel-tab')
rows = [row for row in reader]
if return_headers:
return rows, reader.fieldnames
re... | [
"def",
"read_tsv_from_string",
"(",
"text",
",",
"return_headers",
"=",
"False",
")",
":",
"log",
".",
"trace",
"(",
"'reading tsv string: content[:20]={} len={}'",
".",
"format",
"(",
"repr",
"(",
"text",
"[",
":",
"20",
"]",
")",
",",
"len",
"(",
"text",
... | reads a tsv (tab separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"tsv",
"(",
"tab",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | [
"\"\"\"\n reads a tsv (tab separated values) string using DictReader and returns a rowdicts list\n :param text: string to parse TSV from\n :param return_headers: return value becomes (rows, headers)\n :return: rows read from csv\n \"\"\""
] | [
{
"param": "text",
"type": null
},
{
"param": "return_headers",
"type": null
}
] | {
"returns": [
{
"docstring": "rows read from csv",
"docstring_tokens": [
"rows",
"read",
"from",
"csv"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": "string to parse TSV fro... |
d3398089555244f019fe44321a09f12792ac8080 | InbarRose/kitir | kitir/_libs/csv_utils.py | [
"MIT"
] | Python | read_ssv_from_string | <not_specific> | def read_ssv_from_string(text, return_headers=False):
"""
reads a ssv (space separated values) string using DictReader and returns a rowdicts list
:param text: string to parse SSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
"""
log.trace('read... |
reads a ssv (space separated values) string using DictReader and returns a rowdicts list
:param text: string to parse SSV from
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
| reads a ssv (space separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"ssv",
"(",
"space",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | def read_ssv_from_string(text, return_headers=False):
log.trace('reading ssv string: content[:20]={} len={}'.format(repr(text[:20]), len(text)))
reader = csv.DictReader(text.splitlines(), dialect='excel-space')
rows = [row for row in reader]
if return_headers:
return rows, reader.fieldnames
... | [
"def",
"read_ssv_from_string",
"(",
"text",
",",
"return_headers",
"=",
"False",
")",
":",
"log",
".",
"trace",
"(",
"'reading ssv string: content[:20]={} len={}'",
".",
"format",
"(",
"repr",
"(",
"text",
"[",
":",
"20",
"]",
")",
",",
"len",
"(",
"text",
... | reads a ssv (space separated values) string using DictReader and returns a rowdicts list | [
"reads",
"a",
"ssv",
"(",
"space",
"separated",
"values",
")",
"string",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | [
"\"\"\"\n reads a ssv (space separated values) string using DictReader and returns a rowdicts list\n :param text: string to parse SSV from\n :param return_headers: return value becomes (rows, headers)\n :return: rows read from csv\n \"\"\""
] | [
{
"param": "text",
"type": null
},
{
"param": "return_headers",
"type": null
}
] | {
"returns": [
{
"docstring": "rows read from csv",
"docstring_tokens": [
"rows",
"read",
"from",
"csv"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": "string to parse SSV fro... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | write_to_tmp_file | <not_specific> | def write_to_tmp_file(content, **kwargs):
"""
writes the content to a temporary file
:param content: the content to write (string)
:return: returns the file_path
"""
kwargs.setdefault('mode', 'w+')
with tempfile.NamedTemporaryFile(delete=False, **kwargs) as f:
f.write(content)
re... |
writes the content to a temporary file
:param content: the content to write (string)
:return: returns the file_path
| writes the content to a temporary file | [
"writes",
"the",
"content",
"to",
"a",
"temporary",
"file"
] | def write_to_tmp_file(content, **kwargs):
kwargs.setdefault('mode', 'w+')
with tempfile.NamedTemporaryFile(delete=False, **kwargs) as f:
f.write(content)
return f.name | [
"def",
"write_to_tmp_file",
"(",
"content",
",",
"**",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'mode'",
",",
"'w+'",
")",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
",",
"**",
"kwargs",
")",
"as",
"f",
":",... | writes the content to a temporary file | [
"writes",
"the",
"content",
"to",
"a",
"temporary",
"file"
] | [
"\"\"\"\n writes the content to a temporary file\n :param content: the content to write (string)\n :return: returns the file_path\n \"\"\""
] | [
{
"param": "content",
"type": null
}
] | {
"returns": [
{
"docstring": "returns the file_path",
"docstring_tokens": [
"returns",
"the",
"file_path"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "content",
"type": null,
"docstring": "the content to write (str... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | write_file | <not_specific> | def write_file(file_name, contents=None, filemode='w', rotate=False, **kwargs):
"""
create, or append to a file, optionally with content, return file_name
:param file_name:
:param contents:
:param filemode:
:param rotate:
:return: the filename that was written
"""
check_makedir(os.pa... |
create, or append to a file, optionally with content, return file_name
:param file_name:
:param contents:
:param filemode:
:param rotate:
:return: the filename that was written
| create, or append to a file, optionally with content, return file_name | [
"create",
"or",
"append",
"to",
"a",
"file",
"optionally",
"with",
"content",
"return",
"file_name"
] | def write_file(file_name, contents=None, filemode='w', rotate=False, **kwargs):
check_makedir(os.path.dirname(file_name))
if rotate:
file_name = file_rotation(file_name, rotate_rx=kwargs.get('rotate_rx', '_rx_'))
with open(file_name, filemode) as f:
if contents:
if isinstance(con... | [
"def",
"write_file",
"(",
"file_name",
",",
"contents",
"=",
"None",
",",
"filemode",
"=",
"'w'",
",",
"rotate",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"check_makedir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"file_name",
")",
")",
"if",
"... | create, or append to a file, optionally with content, return file_name | [
"create",
"or",
"append",
"to",
"a",
"file",
"optionally",
"with",
"content",
"return",
"file_name"
] | [
"\"\"\"\n create, or append to a file, optionally with content, return file_name\n :param file_name:\n :param contents:\n :param filemode:\n :param rotate:\n :return: the filename that was written\n \"\"\""
] | [
{
"param": "file_name",
"type": null
},
{
"param": "contents",
"type": null
},
{
"param": "filemode",
"type": null
},
{
"param": "rotate",
"type": null
}
] | {
"returns": [
{
"docstring": "the filename that was written",
"docstring_tokens": [
"the",
"filename",
"that",
"was",
"written"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | write_csv | <not_specific> | def write_csv(file_name, contents, headers=None, **kwargs):
"""
writes a csv file using DictWriter and returns the filename
if contents is a rowdicts uses the keys of the first dict in contents as the headers
if contents is a dictionary, you must supply the headers, for 2 columns [key, value]
:param... |
writes a csv file using DictWriter and returns the filename
if contents is a rowdicts uses the keys of the first dict in contents as the headers
if contents is a dictionary, you must supply the headers, for 2 columns [key, value]
:param file_name: path of the file
:param contents: rowdicts list (or... | writes a csv file using DictWriter and returns the filename
if contents is a rowdicts uses the keys of the first dict in contents as the headers
if contents is a dictionary, you must supply the headers, for 2 columns [key, value] | [
"writes",
"a",
"csv",
"file",
"using",
"DictWriter",
"and",
"returns",
"the",
"filename",
"if",
"contents",
"is",
"a",
"rowdicts",
"uses",
"the",
"keys",
"of",
"the",
"first",
"dict",
"in",
"contents",
"as",
"the",
"headers",
"if",
"contents",
"is",
"a",
... | def write_csv(file_name, contents, headers=None, **kwargs):
filemode = kwargs.pop('filemode', 'w')
if isinstance(contents, dict):
assert headers and len(headers) == 2
contents = [{headers[0]: key, headers[1]: value} for key, value in contents.items()]
headers = headers or contents[0].keys()
... | [
"def",
"write_csv",
"(",
"file_name",
",",
"contents",
",",
"headers",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"filemode",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode'",
",",
"'w'",
")",
"if",
"isinstance",
"(",
"contents",
",",
"dict",
")",
":",
... | writes a csv file using DictWriter and returns the filename
if contents is a rowdicts uses the keys of the first dict in contents as the headers
if contents is a dictionary, you must supply the headers, for 2 columns [key, value] | [
"writes",
"a",
"csv",
"file",
"using",
"DictWriter",
"and",
"returns",
"the",
"filename",
"if",
"contents",
"is",
"a",
"rowdicts",
"uses",
"the",
"keys",
"of",
"the",
"first",
"dict",
"in",
"contents",
"as",
"the",
"headers",
"if",
"contents",
"is",
"a",
... | [
"\"\"\"\n writes a csv file using DictWriter and returns the filename\n if contents is a rowdicts uses the keys of the first dict in contents as the headers\n if contents is a dictionary, you must supply the headers, for 2 columns [key, value]\n :param file_name: path of the file\n :param contents: r... | [
{
"param": "file_name",
"type": null
},
{
"param": "contents",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [
{
"docstring": "the filename that was written",
"docstring_tokens": [
"the",
"filename",
"that",
"was",
"written"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | read_csv | <not_specific> | def read_csv(file_name, return_headers=False, **kwargs):
"""
reads a csv file using DictReader and returns a rowdicts list
:param file_name: path of the file
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
"""
filemode = kwargs.pop('filemode', 'r')
... |
reads a csv file using DictReader and returns a rowdicts list
:param file_name: path of the file
:param return_headers: return value becomes (rows, headers)
:return: rows read from csv
| reads a csv file using DictReader and returns a rowdicts list | [
"reads",
"a",
"csv",
"file",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | def read_csv(file_name, return_headers=False, **kwargs):
filemode = kwargs.pop('filemode', 'r')
log.trace('reading csv file: path={}'.format(file_name))
with open(file_name, filemode) as f:
if not check_file_size(file_name):
log.warning('csv file size is 0 bytes: csv={}'.format(file_name... | [
"def",
"read_csv",
"(",
"file_name",
",",
"return_headers",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"filemode",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode'",
",",
"'r'",
")",
"log",
".",
"trace",
"(",
"'reading csv file: path={}'",
".",
"format",
"(",... | reads a csv file using DictReader and returns a rowdicts list | [
"reads",
"a",
"csv",
"file",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"list"
] | [
"\"\"\"\n reads a csv file using DictReader and returns a rowdicts list\n :param file_name: path of the file\n :param return_headers: return value becomes (rows, headers)\n :return: rows read from csv\n \"\"\"",
"# verify file is not empty"
] | [
{
"param": "file_name",
"type": null
},
{
"param": "return_headers",
"type": null
}
] | {
"returns": [
{
"docstring": "rows read from csv",
"docstring_tokens": [
"rows",
"read",
"from",
"csv"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
"docstring": "path of the file",... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | iread_csv | null | def iread_csv(file_name, return_headers=False, **kwargs):
"""
iter-reads a csv file using DictReader and returns a rowdicts generator
:param file_name: path of the file
:param return_headers: first yield is the headers
:return: rows read from csv as generator
"""
filemode = kwargs.pop('filem... |
iter-reads a csv file using DictReader and returns a rowdicts generator
:param file_name: path of the file
:param return_headers: first yield is the headers
:return: rows read from csv as generator
| iter-reads a csv file using DictReader and returns a rowdicts generator | [
"iter",
"-",
"reads",
"a",
"csv",
"file",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"generator"
] | def iread_csv(file_name, return_headers=False, **kwargs):
filemode = kwargs.pop('filemode', 'r')
log.trace('reading csv file: path={}'.format(file_name))
if not check_file_size(file_name):
log.warning('csv file size is 0 bytes: csv={}'.format(file_name))
raise StopIteration()
f = open(fi... | [
"def",
"iread_csv",
"(",
"file_name",
",",
"return_headers",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"filemode",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode'",
",",
"'r'",
")",
"log",
".",
"trace",
"(",
"'reading csv file: path={}'",
".",
"format",
"("... | iter-reads a csv file using DictReader and returns a rowdicts generator | [
"iter",
"-",
"reads",
"a",
"csv",
"file",
"using",
"DictReader",
"and",
"returns",
"a",
"rowdicts",
"generator"
] | [
"\"\"\"\n iter-reads a csv file using DictReader and returns a rowdicts generator\n :param file_name: path of the file\n :param return_headers: first yield is the headers\n :return: rows read from csv as generator\n \"\"\"",
"# verify file is not empty"
] | [
{
"param": "file_name",
"type": null
},
{
"param": "return_headers",
"type": null
}
] | {
"returns": [
{
"docstring": "rows read from csv as generator",
"docstring_tokens": [
"rows",
"read",
"from",
"csv",
"as",
"generator"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_name",
"typ... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | file_diff | <not_specific> | def file_diff(file_a, file_b, output=None, **kwargs):
"""
performance a diff between two files
:param file_a: first file
:param file_b: second file
:param output: output file for diff
:param kwargs: any kwargs
:return:
"""
filemode = kwargs.pop('filemode', 'Ur')
if kwargs.pop('sh... |
performance a diff between two files
:param file_a: first file
:param file_b: second file
:param output: output file for diff
:param kwargs: any kwargs
:return:
| performance a diff between two files | [
"performance",
"a",
"diff",
"between",
"two",
"files"
] | def file_diff(file_a, file_b, output=None, **kwargs):
filemode = kwargs.pop('filemode', 'Ur')
if kwargs.pop('show_log', True):
log.trace('performing file diff between two files: a={} b={}'.format(file_a, file_b))
with open(file_a, mode=filemode) as af, open(file_b, mode=filemode) as bf:
al =... | [
"def",
"file_diff",
"(",
"file_a",
",",
"file_b",
",",
"output",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"filemode",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode'",
",",
"'Ur'",
")",
"if",
"kwargs",
".",
"pop",
"(",
"'show_log'",
",",
"True",
")",
... | performance a diff between two files | [
"performance",
"a",
"diff",
"between",
"two",
"files"
] | [
"\"\"\"\n performance a diff between two files\n :param file_a: first file\n :param file_b: second file\n :param output: output file for diff\n :param kwargs: any kwargs\n :return:\n \"\"\""
] | [
{
"param": "file_a",
"type": null
},
{
"param": "file_b",
"type": null
},
{
"param": "output",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "file_a",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | bulk_rename | <not_specific> | def bulk_rename(src_dir, before, after, dst_dir=None, raise_on_error=True):
"""
Perform bulk-rename operation on files in a directory. optionally move them to another directory.
:param src_dir:
:param before:
:param after:
:param dst_dir:
:param raise_on_error:
:return:
"""
asser... |
Perform bulk-rename operation on files in a directory. optionally move them to another directory.
:param src_dir:
:param before:
:param after:
:param dst_dir:
:param raise_on_error:
:return:
| Perform bulk-rename operation on files in a directory. optionally move them to another directory. | [
"Perform",
"bulk",
"-",
"rename",
"operation",
"on",
"files",
"in",
"a",
"directory",
".",
"optionally",
"move",
"them",
"to",
"another",
"directory",
"."
] | def bulk_rename(src_dir, before, after, dst_dir=None, raise_on_error=True):
assert before != after
dst_dir = dst_dir or src_dir
log.debug('bulk-renaming: src={} dst={} before={} after={}'.format(src_dir, dst_dir, before, after))
fns = [fn for fn in os.listdir(src_dir) if os.path.isfile(fn) and before in... | [
"def",
"bulk_rename",
"(",
"src_dir",
",",
"before",
",",
"after",
",",
"dst_dir",
"=",
"None",
",",
"raise_on_error",
"=",
"True",
")",
":",
"assert",
"before",
"!=",
"after",
"dst_dir",
"=",
"dst_dir",
"or",
"src_dir",
"log",
".",
"debug",
"(",
"'bulk-... | Perform bulk-rename operation on files in a directory. | [
"Perform",
"bulk",
"-",
"rename",
"operation",
"on",
"files",
"in",
"a",
"directory",
"."
] | [
"\"\"\"\n Perform bulk-rename operation on files in a directory. optionally move them to another directory.\n :param src_dir:\n :param before:\n :param after:\n :param dst_dir:\n :param raise_on_error:\n :return:\n \"\"\""
] | [
{
"param": "src_dir",
"type": null
},
{
"param": "before",
"type": null
},
{
"param": "after",
"type": null
},
{
"param": "dst_dir",
"type": null
},
{
"param": "raise_on_error",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "src_dir",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | format_file | <not_specific> | def format_file(filepath, raise_on_fail=True, **kwargs):
"""
format a files contents with given kwargs using pythons string.format()
:param filepath: filepath to format
:param raise_on_fail: raise exceptions
:param kwargs:
:return: returns True if success else False
"""
filemode_read = k... |
format a files contents with given kwargs using pythons string.format()
:param filepath: filepath to format
:param raise_on_fail: raise exceptions
:param kwargs:
:return: returns True if success else False
| format a files contents with given kwargs using pythons string.format() | [
"format",
"a",
"files",
"contents",
"with",
"given",
"kwargs",
"using",
"pythons",
"string",
".",
"format",
"()"
] | def format_file(filepath, raise_on_fail=True, **kwargs):
filemode_read = kwargs.pop('filemode_read', 'r')
filemode_write = kwargs.pop('filemode_write', 'w')
try:
with open(filepath, filemode_read) as fr:
content_before = fr.readlines()
except Exception as exc:
log.error('Exce... | [
"def",
"format_file",
"(",
"filepath",
",",
"raise_on_fail",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"filemode_read",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode_read'",
",",
"'r'",
")",
"filemode_write",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode_write'"... | format a files contents with given kwargs using pythons string.format() | [
"format",
"a",
"files",
"contents",
"with",
"given",
"kwargs",
"using",
"pythons",
"string",
".",
"format",
"()"
] | [
"\"\"\"\n format a files contents with given kwargs using pythons string.format()\n :param filepath: filepath to format\n :param raise_on_fail: raise exceptions\n :param kwargs:\n :return: returns True if success else False\n \"\"\"",
"# todo: harden {} rules"
] | [
{
"param": "filepath",
"type": null
},
{
"param": "raise_on_fail",
"type": null
}
] | {
"returns": [
{
"docstring": "returns True if success else False",
"docstring_tokens": [
"returns",
"True",
"if",
"success",
"else",
"False"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filepath",
... |
cb53f210f08995c121062a27282bb1063402787e | InbarRose/kitir | kitir/_libs/file_utils.py | [
"MIT"
] | Python | replace_content_in_file | <not_specific> | def replace_content_in_file(filepath, replacements, raise_on_fail=True, **kwargs):
"""
replaces content in a file,
:param filepath: the path to the file for replacements
:param replacements: replacements should be a dictionary of {target: replacement}
:param raise_on_fail:
:param kwargs:
:re... |
replaces content in a file,
:param filepath: the path to the file for replacements
:param replacements: replacements should be a dictionary of {target: replacement}
:param raise_on_fail:
:param kwargs:
:return:
| replaces content in a file. | [
"replaces",
"content",
"in",
"a",
"file",
"."
] | def replace_content_in_file(filepath, replacements, raise_on_fail=True, **kwargs):
filemode_read = kwargs.pop('filemode_read', 'r')
filemode_write = kwargs.pop('filemode_write', 'w')
log.debug('Modifying file in-place: filepath={}'.format(filepath))
backup_file = kwargs.pop('backup_file', None)
retu... | [
"def",
"replace_content_in_file",
"(",
"filepath",
",",
"replacements",
",",
"raise_on_fail",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"filemode_read",
"=",
"kwargs",
".",
"pop",
"(",
"'filemode_read'",
",",
"'r'",
")",
"filemode_write",
"=",
"kwargs",
".",... | replaces content in a file, | [
"replaces",
"content",
"in",
"a",
"file"
] | [
"\"\"\"\n replaces content in a file,\n :param filepath: the path to the file for replacements\n :param replacements: replacements should be a dictionary of {target: replacement}\n :param raise_on_fail:\n :param kwargs:\n :return:\n \"\"\"",
"# will contain the final content of the conf file"... | [
{
"param": "filepath",
"type": null
},
{
"param": "replacements",
"type": null
},
{
"param": "raise_on_fail",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "filepath",
"type": null,
"docstring": "the path to the file for replacements",
"docstring_tokens": [
"the",... |
bd3b341c6bc3c84125c3ab07b8794677f3e4808f | autotraderuk/fastapi-mlflow | fastapi_mlflow/applications.py | [
"Apache-2.0"
] | Python | build_app | FastAPI | def build_app(pyfunc_model: PyFuncModel) -> FastAPI:
"""Build and return a FastAPI app for the mlflow model."""
app = FastAPI()
predictor = build_predictor(pyfunc_model)
response_model = signature(predictor).return_annotation
app.add_api_route(
"/predictions",
predictor,
resp... | Build and return a FastAPI app for the mlflow model. | Build and return a FastAPI app for the mlflow model. | [
"Build",
"and",
"return",
"a",
"FastAPI",
"app",
"for",
"the",
"mlflow",
"model",
"."
] | def build_app(pyfunc_model: PyFuncModel) -> FastAPI:
app = FastAPI()
predictor = build_predictor(pyfunc_model)
response_model = signature(predictor).return_annotation
app.add_api_route(
"/predictions",
predictor,
response_model=response_model,
methods=["POST"],
)
... | [
"def",
"build_app",
"(",
"pyfunc_model",
":",
"PyFuncModel",
")",
"->",
"FastAPI",
":",
"app",
"=",
"FastAPI",
"(",
")",
"predictor",
"=",
"build_predictor",
"(",
"pyfunc_model",
")",
"response_model",
"=",
"signature",
"(",
"predictor",
")",
".",
"return_anno... | Build and return a FastAPI app for the mlflow model. | [
"Build",
"and",
"return",
"a",
"FastAPI",
"app",
"for",
"the",
"mlflow",
"model",
"."
] | [
"\"\"\"Build and return a FastAPI app for the mlflow model.\"\"\""
] | [
{
"param": "pyfunc_model",
"type": "PyFuncModel"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pyfunc_model",
"type": "PyFuncModel",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
431de92a08ae414e9324d7577cb4a2a746439c64 | autotraderuk/fastapi-mlflow | fastapi_mlflow/predictors.py | [
"Apache-2.0"
] | Python | build_predictor | Callable[[List[BaseModel]], Any] | def build_predictor(model: PyFuncModel) -> Callable[[List[BaseModel]], Any]:
"""Build and return a function that wraps the mlflow model.
Currently supports only the `pyfunc`_ flavour of mlflow.
:param model: PyFuncModel
:return: Function suitable for mounting as a FastAPI endpoint or route.
Examp... | Build and return a function that wraps the mlflow model.
Currently supports only the `pyfunc`_ flavour of mlflow.
:param model: PyFuncModel
:return: Function suitable for mounting as a FastAPI endpoint or route.
Example::
model = load_model("/Users/me/path/to/local/model")
predictor ... | Build and return a function that wraps the mlflow model.
Currently supports only the `pyfunc`_ flavour of mlflow. | [
"Build",
"and",
"return",
"a",
"function",
"that",
"wraps",
"the",
"mlflow",
"model",
".",
"Currently",
"supports",
"only",
"the",
"`",
"pyfunc",
"`",
"_",
"flavour",
"of",
"mlflow",
"."
] | def build_predictor(model: PyFuncModel) -> Callable[[List[BaseModel]], Any]:
request_type: Any = _mlflow_types.build_input_model(
model.metadata.get_input_schema()
)
return_type: Any = _mlflow_types.build_output_model(
model.metadata.get_output_schema()
)
def predictor(request: List[... | [
"def",
"build_predictor",
"(",
"model",
":",
"PyFuncModel",
")",
"->",
"Callable",
"[",
"[",
"List",
"[",
"BaseModel",
"]",
"]",
",",
"Any",
"]",
":",
"request_type",
":",
"Any",
"=",
"_mlflow_types",
".",
"build_input_model",
"(",
"model",
".",
"metadata"... | Build and return a function that wraps the mlflow model. | [
"Build",
"and",
"return",
"a",
"function",
"that",
"wraps",
"the",
"mlflow",
"model",
"."
] | [
"\"\"\"Build and return a function that wraps the mlflow model.\n\n Currently supports only the `pyfunc`_ flavour of mlflow.\n\n :param model: PyFuncModel\n :return: Function suitable for mounting as a FastAPI endpoint or route.\n\n Example::\n\n model = load_model(\"/Users/me/path/to/local/model... | [
{
"param": "model",
"type": "PyFuncModel"
}
] | {
"returns": [
{
"docstring": "Function suitable for mounting as a FastAPI endpoint or route.\nExample:.\n\n\n\n",
"docstring_tokens": [
"Function",
"suitable",
"for",
"mounting",
"as",
"a",
"FastAPI",
"endpoint",
"or",
"r... |
3b8976a93318f45e933c0d30b646460662e27f1b | TharinduDR/STS-Transformers | examples/arabic_sts/arabic_preprocess.py | [
"Apache-2.0"
] | Python | preprocess | <not_specific> | def preprocess(text, do_farasa_tokenization=True, farasa=None, use_farasapy=False):
"""
Preprocess takes an input text line an applies the same preprocessing used in araBERT
pretraining
Note: a farasapy segmenter is ~6x faster than the py4j.java_gateway, consider setting use_farasapy=True
Farsa Segmentation... |
Preprocess takes an input text line an applies the same preprocessing used in araBERT
pretraining
Note: a farasapy segmenter is ~6x faster than the py4j.java_gateway, consider setting use_farasapy=True
Farsa Segmentation will soon be fully migrated to farasapy, and support for the py4j.java_gateway.JavaObject ... | Preprocess takes an input text line an applies the same preprocessing used in araBERT
pretraining
a farasapy segmenter is ~6x faster than the py4j.java_gateway, consider setting use_farasapy=True
Farsa Segmentation will soon be fully migrated to farasapy, and support for the py4j.java_gateway.JavaObject will be remove... | [
"Preprocess",
"takes",
"an",
"input",
"text",
"line",
"an",
"applies",
"the",
"same",
"preprocessing",
"used",
"in",
"araBERT",
"pretraining",
"a",
"farasapy",
"segmenter",
"is",
"~6x",
"faster",
"than",
"the",
"py4j",
".",
"java_gateway",
"consider",
"setting",... | def preprocess(text, do_farasa_tokenization=True, farasa=None, use_farasapy=False):
text = str(text)
processing_text = araby.strip_tashkeel(text)
processing_text = re.sub(r"\d+\/[ء-ي]+\/\d+\]", "", processing_text)
processing_text = re.sub("ـ", "", processing_text)
processing_text = re.sub("[«»]", '... | [
"def",
"preprocess",
"(",
"text",
",",
"do_farasa_tokenization",
"=",
"True",
",",
"farasa",
"=",
"None",
",",
"use_farasapy",
"=",
"False",
")",
":",
"text",
"=",
"str",
"(",
"text",
")",
"processing_text",
"=",
"araby",
".",
"strip_tashkeel",
"(",
"text"... | Preprocess takes an input text line an applies the same preprocessing used in araBERT
pretraining | [
"Preprocess",
"takes",
"an",
"input",
"text",
"line",
"an",
"applies",
"the",
"same",
"preprocessing",
"used",
"in",
"araBERT",
"pretraining"
] | [
"\"\"\"\n\tPreprocess takes an input text line an applies the same preprocessing used in araBERT\n\t\t\t\tpretraining\n\n\tNote: a farasapy segmenter is ~6x faster than the py4j.java_gateway, consider setting use_farasapy=True\n\tFarsa Segmentation will soon be fully migrated to farasapy, and support for the py4j.j... | [
{
"param": "text",
"type": null
},
{
"param": "do_farasa_tokenization",
"type": null
},
{
"param": "farasa",
"type": null
},
{
"param": "use_farasapy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": "inout text string",
"docstring_tokens": [
"inout",
"text",
"string"
],
"default": null,
"is_optional": false
},
{
"identifier": "do_far... |
4a9e0e607f54d99d430b0fec78a1dd55835c0210 | noosenergy/terraform-client | src/noos_tf/cli.py | [
"MIT"
] | Python | update | null | def update(ctx, variable="", value="", workspace="", organisation=None, token=None):
"""Update variable in Terraform cloud."""
organisation = organisation or os.getenv("TERRAFORM_USER")
token = token or os.getenv("TERRAFORM_TOKEN")
assert organisation is not None, "Missing Terraform Cloud organisation."... | Update variable in Terraform cloud. | Update variable in Terraform cloud. | [
"Update",
"variable",
"in",
"Terraform",
"cloud",
"."
] | def update(ctx, variable="", value="", workspace="", organisation=None, token=None):
organisation = organisation or os.getenv("TERRAFORM_USER")
token = token or os.getenv("TERRAFORM_TOKEN")
assert organisation is not None, "Missing Terraform Cloud organisation."
assert token is not None, "Missing Terraf... | [
"def",
"update",
"(",
"ctx",
",",
"variable",
"=",
"\"\"",
",",
"value",
"=",
"\"\"",
",",
"workspace",
"=",
"\"\"",
",",
"organisation",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"organisation",
"=",
"organisation",
"or",
"os",
".",
"getenv",
... | Update variable in Terraform cloud. | [
"Update",
"variable",
"in",
"Terraform",
"cloud",
"."
] | [
"\"\"\"Update variable in Terraform cloud.\"\"\""
] | [
{
"param": "ctx",
"type": null
},
{
"param": "variable",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "workspace",
"type": null
},
{
"param": "organisation",
"type": null
},
{
"param": "token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable",
"type": null,
"docstring": null,
"docstring_tokens"... |
4a9e0e607f54d99d430b0fec78a1dd55835c0210 | noosenergy/terraform-client | src/noos_tf/cli.py | [
"MIT"
] | Python | run | null | def run(ctx, message="", workspace="", organisation=None, token=None):
"""Run a plan in Terraform cloud."""
organisation = organisation or os.getenv("TERRAFORM_USER")
token = token or os.getenv("TERRAFORM_TOKEN")
assert organisation is not None, "Missing Terraform Cloud organisation."
assert token i... | Run a plan in Terraform cloud. | Run a plan in Terraform cloud. | [
"Run",
"a",
"plan",
"in",
"Terraform",
"cloud",
"."
] | def run(ctx, message="", workspace="", organisation=None, token=None):
organisation = organisation or os.getenv("TERRAFORM_USER")
token = token or os.getenv("TERRAFORM_TOKEN")
assert organisation is not None, "Missing Terraform Cloud organisation."
assert token is not None, "Missing Terraform Cloud toke... | [
"def",
"run",
"(",
"ctx",
",",
"message",
"=",
"\"\"",
",",
"workspace",
"=",
"\"\"",
",",
"organisation",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"organisation",
"=",
"organisation",
"or",
"os",
".",
"getenv",
"(",
"\"TERRAFORM_USER\"",
")",
... | Run a plan in Terraform cloud. | [
"Run",
"a",
"plan",
"in",
"Terraform",
"cloud",
"."
] | [
"\"\"\"Run a plan in Terraform cloud.\"\"\""
] | [
{
"param": "ctx",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "workspace",
"type": null
},
{
"param": "organisation",
"type": null
},
{
"param": "token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens":... |
8327657998506dc264c587a0f7559b3d0b86f5cc | noosenergy/terraform-client | src/noos_tf/client.py | [
"MIT"
] | Python | update_variable | None | def update_variable(self, variable_id: str, value: str) -> None:
"""Update the value of a variable stored onto a given workspace for a organization."""
data = {
"data": {
"type": "vars",
"id": variable_id,
"attributes": {"value": value},
... | Update the value of a variable stored onto a given workspace for a organization. | Update the value of a variable stored onto a given workspace for a organization. | [
"Update",
"the",
"value",
"of",
"a",
"variable",
"stored",
"onto",
"a",
"given",
"workspace",
"for",
"a",
"organization",
"."
] | def update_variable(self, variable_id: str, value: str) -> None:
data = {
"data": {
"type": "vars",
"id": variable_id,
"attributes": {"value": value},
}
}
self.patch(
path=f"v2/vars/{variable_id}",
da... | [
"def",
"update_variable",
"(",
"self",
",",
"variable_id",
":",
"str",
",",
"value",
":",
"str",
")",
"->",
"None",
":",
"data",
"=",
"{",
"\"data\"",
":",
"{",
"\"type\"",
":",
"\"vars\"",
",",
"\"id\"",
":",
"variable_id",
",",
"\"attributes\"",
":",
... | Update the value of a variable stored onto a given workspace for a organization. | [
"Update",
"the",
"value",
"of",
"a",
"variable",
"stored",
"onto",
"a",
"given",
"workspace",
"for",
"a",
"organization",
"."
] | [
"\"\"\"Update the value of a variable stored onto a given workspace for a organization.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "variable_id",
"type": "str"
},
{
"param": "value",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variable_id",
"type": "str",
"docstring": null,
"docstring_to... |
8327657998506dc264c587a0f7559b3d0b86f5cc | noosenergy/terraform-client | src/noos_tf/client.py | [
"MIT"
] | Python | run_plan | str | def run_plan(self, workspace_id: str, message: str) -> str:
"""Run a plan onto a given workspace for a organization."""
data = {
"data": {
"type": "runs",
"attributes": {"is-destroy": False, "message": message},
"relationships": {
... | Run a plan onto a given workspace for a organization. | Run a plan onto a given workspace for a organization. | [
"Run",
"a",
"plan",
"onto",
"a",
"given",
"workspace",
"for",
"a",
"organization",
"."
] | def run_plan(self, workspace_id: str, message: str) -> str:
data = {
"data": {
"type": "runs",
"attributes": {"is-destroy": False, "message": message},
"relationships": {
"workspace": {"data": {"type": "workspaces", "id": workspace_... | [
"def",
"run_plan",
"(",
"self",
",",
"workspace_id",
":",
"str",
",",
"message",
":",
"str",
")",
"->",
"str",
":",
"data",
"=",
"{",
"\"data\"",
":",
"{",
"\"type\"",
":",
"\"runs\"",
",",
"\"attributes\"",
":",
"{",
"\"is-destroy\"",
":",
"False",
",... | Run a plan onto a given workspace for a organization. | [
"Run",
"a",
"plan",
"onto",
"a",
"given",
"workspace",
"for",
"a",
"organization",
"."
] | [
"\"\"\"Run a plan onto a given workspace for a organization.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "workspace_id",
"type": "str"
},
{
"param": "message",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "workspace_id",
"type": "str",
"docstring": null,
"docstring_t... |
79733b32e2762ac9233295cf4fe7f7ce00d21e49 | noosenergy/terraform-client | src/noos_tf/api.py | [
"MIT"
] | Python | update_workspace_variable | None | def update_workspace_variable(
organization: str,
workspace: str,
token: str,
variable: str,
value: str,
) -> None:
"""Update variable in Terraform cloud."""
# Authenticate client
tf_client = client.TerraformClient()
tf_client.set_auth_header(token)
# Retrieve variables IDs
... | Update variable in Terraform cloud. | Update variable in Terraform cloud. | [
"Update",
"variable",
"in",
"Terraform",
"cloud",
"."
] | def update_workspace_variable(
organization: str,
workspace: str,
token: str,
variable: str,
value: str,
) -> None:
tf_client = client.TerraformClient()
tf_client.set_auth_header(token)
tf_vars = tf_client.get_variable_ids(organization, workspace)
if variable not in tf_vars:
... | [
"def",
"update_workspace_variable",
"(",
"organization",
":",
"str",
",",
"workspace",
":",
"str",
",",
"token",
":",
"str",
",",
"variable",
":",
"str",
",",
"value",
":",
"str",
",",
")",
"->",
"None",
":",
"tf_client",
"=",
"client",
".",
"TerraformCl... | Update variable in Terraform cloud. | [
"Update",
"variable",
"in",
"Terraform",
"cloud",
"."
] | [
"\"\"\"Update variable in Terraform cloud.\"\"\"",
"# Authenticate client",
"# Retrieve variables IDs",
"# Update variable with the new value"
] | [
{
"param": "organization",
"type": "str"
},
{
"param": "workspace",
"type": "str"
},
{
"param": "token",
"type": "str"
},
{
"param": "variable",
"type": "str"
},
{
"param": "value",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "organization",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "workspace",
"type": "str",
"docstring": null,
"docst... |
79733b32e2762ac9233295cf4fe7f7ce00d21e49 | noosenergy/terraform-client | src/noos_tf/api.py | [
"MIT"
] | Python | run_workspace_plan | str | def run_workspace_plan(organization: str, workspace: str, token: str, message: str) -> str:
"""Run a plan in Terraform cloud."""
# Authenticate client
tf_client = client.TerraformClient()
tf_client.set_auth_header(token)
# Retrieve workspace ID
workspace_id = tf_client.get_workspace_id(organiza... | Run a plan in Terraform cloud. | Run a plan in Terraform cloud. | [
"Run",
"a",
"plan",
"in",
"Terraform",
"cloud",
"."
] | def run_workspace_plan(organization: str, workspace: str, token: str, message: str) -> str:
tf_client = client.TerraformClient()
tf_client.set_auth_header(token)
workspace_id = tf_client.get_workspace_id(organization, workspace)
run_id = tf_client.run_plan(workspace_id, message)
return RUN_URL_TEMPL... | [
"def",
"run_workspace_plan",
"(",
"organization",
":",
"str",
",",
"workspace",
":",
"str",
",",
"token",
":",
"str",
",",
"message",
":",
"str",
")",
"->",
"str",
":",
"tf_client",
"=",
"client",
".",
"TerraformClient",
"(",
")",
"tf_client",
".",
"set_... | Run a plan in Terraform cloud. | [
"Run",
"a",
"plan",
"in",
"Terraform",
"cloud",
"."
] | [
"\"\"\"Run a plan in Terraform cloud.\"\"\"",
"# Authenticate client",
"# Retrieve workspace ID",
"# Create and apply a new plan"
] | [
{
"param": "organization",
"type": "str"
},
{
"param": "workspace",
"type": "str"
},
{
"param": "token",
"type": "str"
},
{
"param": "message",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "organization",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "workspace",
"type": "str",
"docstring": null,
"docst... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | num_container_updates | <not_specific> | def num_container_updates(container_replicas, container_quorum,
object_replicas, object_quorum):
"""
We need to send container updates via enough object servers such
that, if the object PUT succeeds, then the container update is
durable (either it's synchronously updated or wri... |
We need to send container updates via enough object servers such
that, if the object PUT succeeds, then the container update is
durable (either it's synchronously updated or written to async
pendings).
Define:
Qc = the quorum size for the container ring
Qo = the quorum size for the obj... | We need to send container updates via enough object servers such
that, if the object PUT succeeds, then the container update is
durable (either it's synchronously updated or written to async
pendings).
Qc = the quorum size for the container ring
Qo = the quorum size for the object ring
Rc = the replica count for the c... | [
"We",
"need",
"to",
"send",
"container",
"updates",
"via",
"enough",
"object",
"servers",
"such",
"that",
"if",
"the",
"object",
"PUT",
"succeeds",
"then",
"the",
"container",
"update",
"is",
"durable",
"(",
"either",
"it",
"'",
"s",
"synchronously",
"update... | def num_container_updates(container_replicas, container_quorum,
object_replicas, object_quorum):
return max(
container_quorum + object_replicas - object_quorum,
container_replicas) | [
"def",
"num_container_updates",
"(",
"container_replicas",
",",
"container_quorum",
",",
"object_replicas",
",",
"object_quorum",
")",
":",
"return",
"max",
"(",
"container_quorum",
"+",
"object_replicas",
"-",
"object_quorum",
",",
"container_replicas",
")"
] | We need to send container updates via enough object servers such
that, if the object PUT succeeds, then the container update is
durable (either it's synchronously updated or written to async
pendings). | [
"We",
"need",
"to",
"send",
"container",
"updates",
"via",
"enough",
"object",
"servers",
"such",
"that",
"if",
"the",
"object",
"PUT",
"succeeds",
"then",
"the",
"container",
"update",
"is",
"durable",
"(",
"either",
"it",
"'",
"s",
"synchronously",
"update... | [
"\"\"\"\n We need to send container updates via enough object servers such\n that, if the object PUT succeeds, then the container update is\n durable (either it's synchronously updated or written to async\n pendings).\n\n Define:\n Qc = the quorum size for the container ring\n Qo = the quor... | [
{
"param": "container_replicas",
"type": null
},
{
"param": "container_quorum",
"type": null
},
{
"param": "object_replicas",
"type": null
},
{
"param": "object_quorum",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "container_replicas",
"type": null,
"docstring": "replica count for the container ring (Rc)",
"docstring_tokens": [
"replica",
"count",
"for",
"the",
"container",
"ring",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | iter_nodes_local_first | <not_specific> | def iter_nodes_local_first(self, ring, partition, policy=None,
local_handoffs_first=False):
"""
Yields nodes for a ring partition.
If the 'write_affinity' setting is non-empty, then this will yield N
local nodes (as defined by the write_affinity setting) f... |
Yields nodes for a ring partition.
If the 'write_affinity' setting is non-empty, then this will yield N
local nodes (as defined by the write_affinity setting) first, then the
rest of the nodes as normal. It is a re-ordering of the nodes such
that the local ones come first; no n... | Yields nodes for a ring partition.
If the 'write_affinity' setting is non-empty, then this will yield N
local nodes (as defined by the write_affinity setting) first, then the
rest of the nodes as normal. It is a re-ordering of the nodes such
that the local ones come first; no node is omitted. The effect is
that the req... | [
"Yields",
"nodes",
"for",
"a",
"ring",
"partition",
".",
"If",
"the",
"'",
"write_affinity",
"'",
"setting",
"is",
"non",
"-",
"empty",
"then",
"this",
"will",
"yield",
"N",
"local",
"nodes",
"(",
"as",
"defined",
"by",
"the",
"write_affinity",
"setting",
... | def iter_nodes_local_first(self, ring, partition, policy=None,
local_handoffs_first=False):
policy_options = self.app.get_policy_options(policy)
is_local = policy_options.write_affinity_is_local_fn
if is_local is None:
return self.app.iter_nodes(ring, p... | [
"def",
"iter_nodes_local_first",
"(",
"self",
",",
"ring",
",",
"partition",
",",
"policy",
"=",
"None",
",",
"local_handoffs_first",
"=",
"False",
")",
":",
"policy_options",
"=",
"self",
".",
"app",
".",
"get_policy_options",
"(",
"policy",
")",
"is_local",
... | Yields nodes for a ring partition. | [
"Yields",
"nodes",
"for",
"a",
"ring",
"partition",
"."
] | [
"\"\"\"\n Yields nodes for a ring partition.\n\n If the 'write_affinity' setting is non-empty, then this will yield N\n local nodes (as defined by the write_affinity setting) first, then the\n rest of the nodes as normal. It is a re-ordering of the nodes such\n that the local ones... | [
{
"param": "self",
"type": null
},
{
"param": "ring",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "policy",
"type": null
},
{
"param": "local_handoffs_first",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ring",
"type": null,
"docstring": "ring to get nodes from",
"... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | GETorHEAD | <not_specific> | def GETorHEAD(self, req):
"""Handle HTTP GET or HEAD requests."""
container_info = self.container_info(
self.account_name, self.container_name, req)
req.acl = container_info['read_acl']
# pass the policy index to storage nodes via req header
policy_index = req.headers... | Handle HTTP GET or HEAD requests. | Handle HTTP GET or HEAD requests. | [
"Handle",
"HTTP",
"GET",
"or",
"HEAD",
"requests",
"."
] | def GETorHEAD(self, req):
container_info = self.container_info(
self.account_name, self.container_name, req)
req.acl = container_info['read_acl']
policy_index = req.headers.get('X-Backend-Storage-Policy-Index',
container_info['storage_policy'])
... | [
"def",
"GETorHEAD",
"(",
"self",
",",
"req",
")",
":",
"container_info",
"=",
"self",
".",
"container_info",
"(",
"self",
".",
"account_name",
",",
"self",
".",
"container_name",
",",
"req",
")",
"req",
".",
"acl",
"=",
"container_info",
"[",
"'read_acl'",... | Handle HTTP GET or HEAD requests. | [
"Handle",
"HTTP",
"GET",
"or",
"HEAD",
"requests",
"."
] | [
"\"\"\"Handle HTTP GET or HEAD requests.\"\"\"",
"# pass the policy index to storage nodes via req header",
"# node_iter 除了包含保存object的几个节点外,还包含其他节点 get_more_nodes()"
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _have_adequate_put_responses | null | def _have_adequate_put_responses(self, statuses, num_nodes, min_responses):
"""
Test for sufficient PUT responses from backend nodes to proceed with
PUT handling.
:param statuses: a list of response statuses.
:param num_nodes: number of backend nodes to which PUT requests may be... |
Test for sufficient PUT responses from backend nodes to proceed with
PUT handling.
:param statuses: a list of response statuses.
:param num_nodes: number of backend nodes to which PUT requests may be
issued.
:param min_responses: (optional) minimum num... | Test for sufficient PUT responses from backend nodes to proceed with
PUT handling. | [
"Test",
"for",
"sufficient",
"PUT",
"responses",
"from",
"backend",
"nodes",
"to",
"proceed",
"with",
"PUT",
"handling",
"."
] | def _have_adequate_put_responses(self, statuses, num_nodes, min_responses):
raise NotImplementedError | [
"def",
"_have_adequate_put_responses",
"(",
"self",
",",
"statuses",
",",
"num_nodes",
",",
"min_responses",
")",
":",
"raise",
"NotImplementedError"
] | Test for sufficient PUT responses from backend nodes to proceed with
PUT handling. | [
"Test",
"for",
"sufficient",
"PUT",
"responses",
"from",
"backend",
"nodes",
"to",
"proceed",
"with",
"PUT",
"handling",
"."
] | [
"\"\"\"\n Test for sufficient PUT responses from backend nodes to proceed with\n PUT handling.\n\n :param statuses: a list of response statuses.\n :param num_nodes: number of backend nodes to which PUT requests may be\n issued.\n :param min_responses: (opt... | [
{
"param": "self",
"type": null
},
{
"param": "statuses",
"type": null
},
{
"param": "num_nodes",
"type": null
},
{
"param": "min_responses",
"type": null
}
] | {
"returns": [
{
"docstring": "True if sufficient backend responses have returned a\nsatisfactory status code.",
"docstring_tokens": [
"True",
"if",
"sufficient",
"backend",
"responses",
"have",
"returned",
"a",
"satisfactory",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _get_put_responses | <not_specific> | def _get_put_responses(self, req, putters, num_nodes, final_phase=True,
min_responses=None):
"""
Collect object responses to a PUT request and determine if a
satisfactory number of nodes have returned success. Returns
lists of accumulated status codes, reasons... |
Collect object responses to a PUT request and determine if a
satisfactory number of nodes have returned success. Returns
lists of accumulated status codes, reasons, bodies and etags.
:param req: the request
:param putters: list of putters for the request
:param num_nod... | Collect object responses to a PUT request and determine if a
satisfactory number of nodes have returned success. Returns
lists of accumulated status codes, reasons, bodies and etags. | [
"Collect",
"object",
"responses",
"to",
"a",
"PUT",
"request",
"and",
"determine",
"if",
"a",
"satisfactory",
"number",
"of",
"nodes",
"have",
"returned",
"success",
".",
"Returns",
"lists",
"of",
"accumulated",
"status",
"codes",
"reasons",
"bodies",
"and",
"... | def _get_put_responses(self, req, putters, num_nodes, final_phase=True,
min_responses=None):
statuses = []
reasons = []
bodies = []
etags = set()
pile = GreenAsyncPile(len(putters))
for putter in putters:
if putter.failed:
... | [
"def",
"_get_put_responses",
"(",
"self",
",",
"req",
",",
"putters",
",",
"num_nodes",
",",
"final_phase",
"=",
"True",
",",
"min_responses",
"=",
"None",
")",
":",
"statuses",
"=",
"[",
"]",
"reasons",
"=",
"[",
"]",
"bodies",
"=",
"[",
"]",
"etags",... | Collect object responses to a PUT request and determine if a
satisfactory number of nodes have returned success. | [
"Collect",
"object",
"responses",
"to",
"a",
"PUT",
"request",
"and",
"determine",
"if",
"a",
"satisfactory",
"number",
"of",
"nodes",
"have",
"returned",
"success",
"."
] | [
"\"\"\"\n Collect object responses to a PUT request and determine if a\n satisfactory number of nodes have returned success. Returns\n lists of accumulated status codes, reasons, bodies and etags.\n\n :param req: the request\n :param putters: list of putters for the request\n ... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "putters",
"type": null
},
{
"param": "num_nodes",
"type": null
},
{
"param": "final_phase",
"type": null
},
{
"param": "min_responses",
"type": null
}
] | {
"returns": [
{
"docstring": "a tuple of lists of status codes, reasons, bodies and etags.\nThe list of bodies and etags is only populated for the final\nphase of a PUT transaction.",
"docstring_tokens": [
"a",
"tuple",
"of",
"lists",
"of",
"status",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _check_failure_put_connections | null | def _check_failure_put_connections(self, putters, req, min_conns):
"""
Identify any failed connections and check minimum connection count.
:param putters: a list of Putter instances
:param req: request
:param min_conns: minimum number of putter connections required
"""
... |
Identify any failed connections and check minimum connection count.
:param putters: a list of Putter instances
:param req: request
:param min_conns: minimum number of putter connections required
| Identify any failed connections and check minimum connection count. | [
"Identify",
"any",
"failed",
"connections",
"and",
"check",
"minimum",
"connection",
"count",
"."
] | def _check_failure_put_connections(self, putters, req, min_conns):
if req.if_none_match is not None and '*' in req.if_none_match:
statuses = [
putter.resp.status for putter in putters if putter.resp]
if HTTP_PRECONDITION_FAILED in statuses:
self.app.logger... | [
"def",
"_check_failure_put_connections",
"(",
"self",
",",
"putters",
",",
"req",
",",
"min_conns",
")",
":",
"if",
"req",
".",
"if_none_match",
"is",
"not",
"None",
"and",
"'*'",
"in",
"req",
".",
"if_none_match",
":",
"statuses",
"=",
"[",
"putter",
".",... | Identify any failed connections and check minimum connection count. | [
"Identify",
"any",
"failed",
"connections",
"and",
"check",
"minimum",
"connection",
"count",
"."
] | [
"\"\"\"\n Identify any failed connections and check minimum connection count.\n\n :param putters: a list of Putter instances\n :param req: request\n :param min_conns: minimum number of putter connections required\n \"\"\"",
"# If we find any copy of the file, it shouldn't be upl... | [
{
"param": "self",
"type": null
},
{
"param": "putters",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "min_conns",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "putters",
"type": null,
"docstring": "a list of Putter instances",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _make_putter | null | def _make_putter(self, node, part, req, headers):
"""
Returns a putter object for handling streaming of object to object
servers.
Subclasses must implement this method.
:param node: a storage node
:param part: ring partition number
:param req: a swob Request
... |
Returns a putter object for handling streaming of object to object
servers.
Subclasses must implement this method.
:param node: a storage node
:param part: ring partition number
:param req: a swob Request
:param headers: request headers
:return: an inst... | Returns a putter object for handling streaming of object to object
servers.
Subclasses must implement this method. | [
"Returns",
"a",
"putter",
"object",
"for",
"handling",
"streaming",
"of",
"object",
"to",
"object",
"servers",
".",
"Subclasses",
"must",
"implement",
"this",
"method",
"."
] | def _make_putter(self, node, part, req, headers):
raise NotImplementedError | [
"def",
"_make_putter",
"(",
"self",
",",
"node",
",",
"part",
",",
"req",
",",
"headers",
")",
":",
"raise",
"NotImplementedError"
] | Returns a putter object for handling streaming of object to object
servers. | [
"Returns",
"a",
"putter",
"object",
"for",
"handling",
"streaming",
"of",
"object",
"to",
"object",
"servers",
"."
] | [
"\"\"\"\n Returns a putter object for handling streaming of object to object\n servers.\n\n Subclasses must implement this method.\n\n :param node: a storage node\n :param part: ring partition number\n :param req: a swob Request\n :param headers: request headers\n ... | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "part",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [
{
"docstring": "an instance of a Putter",
"docstring_tokens": [
"an",
"instance",
"of",
"a",
"Putter"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": nul... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _connect_put_node | <not_specific> | def _connect_put_node(self, nodes, part, req, headers,
logger_thread_locals):
"""
Make connection to storage nodes
Connects to the first working node that it finds in nodes iter and
sends over the request headers. Returns a Putter to handle the rest of
... |
Make connection to storage nodes
Connects to the first working node that it finds in nodes iter and
sends over the request headers. Returns a Putter to handle the rest of
the streaming, or None if no working nodes were found.
:param nodes: an iterator of the target storage nod... | Make connection to storage nodes
Connects to the first working node that it finds in nodes iter and
sends over the request headers. Returns a Putter to handle the rest of
the streaming, or None if no working nodes were found. | [
"Make",
"connection",
"to",
"storage",
"nodes",
"Connects",
"to",
"the",
"first",
"working",
"node",
"that",
"it",
"finds",
"in",
"nodes",
"iter",
"and",
"sends",
"over",
"the",
"request",
"headers",
".",
"Returns",
"a",
"Putter",
"to",
"handle",
"the",
"r... | def _connect_put_node(self, nodes, part, req, headers,
logger_thread_locals):
self.app.logger.thread_locals = logger_thread_locals
for node in nodes:
try:
putter = self._make_putter(node, part, req, headers)
self.app.set_node_timing(n... | [
"def",
"_connect_put_node",
"(",
"self",
",",
"nodes",
",",
"part",
",",
"req",
",",
"headers",
",",
"logger_thread_locals",
")",
":",
"self",
".",
"app",
".",
"logger",
".",
"thread_locals",
"=",
"logger_thread_locals",
"for",
"node",
"in",
"nodes",
":",
... | Make connection to storage nodes
Connects to the first working node that it finds in nodes iter and
sends over the request headers. | [
"Make",
"connection",
"to",
"storage",
"nodes",
"Connects",
"to",
"the",
"first",
"working",
"node",
"that",
"it",
"finds",
"in",
"nodes",
"iter",
"and",
"sends",
"over",
"the",
"request",
"headers",
"."
] | [
"\"\"\"\n Make connection to storage nodes\n\n Connects to the first working node that it finds in nodes iter and\n sends over the request headers. Returns a Putter to handle the rest of\n the streaming, or None if no working nodes were found.\n\n :param nodes: an iterator of the ... | [
{
"param": "self",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "part",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "logger_thread_locals",
"type": null
}
] | {
"returns": [
{
"docstring": "an instance of a Putter",
"docstring_tokens": [
"an",
"instance",
"of",
"a",
"Putter"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": nul... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _get_put_connections | <not_specific> | def _get_put_connections(self, req, nodes, partition, outgoing_headers,
policy):
"""
Establish connections to storage nodes for PUT request
"""
obj_ring = policy.object_ring
node_iter = GreenthreadSafeIterator(
self.iter_nodes_local_first(... |
Establish connections to storage nodes for PUT request
| Establish connections to storage nodes for PUT request | [
"Establish",
"connections",
"to",
"storage",
"nodes",
"for",
"PUT",
"request"
] | def _get_put_connections(self, req, nodes, partition, outgoing_headers,
policy):
obj_ring = policy.object_ring
node_iter = GreenthreadSafeIterator(
self.iter_nodes_local_first(obj_ring, partition, policy=policy))
pile = GreenPile(len(nodes))
for n... | [
"def",
"_get_put_connections",
"(",
"self",
",",
"req",
",",
"nodes",
",",
"partition",
",",
"outgoing_headers",
",",
"policy",
")",
":",
"obj_ring",
"=",
"policy",
".",
"object_ring",
"node_iter",
"=",
"GreenthreadSafeIterator",
"(",
"self",
".",
"iter_nodes_lo... | Establish connections to storage nodes for PUT request | [
"Establish",
"connections",
"to",
"storage",
"nodes",
"for",
"PUT",
"request"
] | [
"\"\"\"\n Establish connections to storage nodes for PUT request\n \"\"\"",
"# 该对象是一个可以向其中填充工作的迭代器,便于以后从其中读取结果",
"# RFC2616:8.2.3 disallows 100-continue without a body,",
"# so switch to chunked request",
"# 从给定的 list中选择出满足if条件的元素组成新的 list",
"# 从 pile 中选择不为空的 putter 组成 putters"
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "outgoing_headers",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _store_object | null | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
"""
This method is responsible for establishing connection
with storage nodes and sending the data to each one of those
nodes. The process of transferring data is specific to each
... |
This method is responsible for establishing connection
with storage nodes and sending the data to each one of those
nodes. The process of transferring data is specific to each
Storage Policy, thus it is required for each policy specific
ObjectController to provide their own impl... | This method is responsible for establishing connection
with storage nodes and sending the data to each one of those
nodes. The process of transferring data is specific to each
Storage Policy, thus it is required for each policy specific
ObjectController to provide their own implementation of this method. | [
"This",
"method",
"is",
"responsible",
"for",
"establishing",
"connection",
"with",
"storage",
"nodes",
"and",
"sending",
"the",
"data",
"to",
"each",
"one",
"of",
"those",
"nodes",
".",
"The",
"process",
"of",
"transferring",
"data",
"is",
"specific",
"to",
... | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
raise NotImplementedError() | [
"def",
"_store_object",
"(",
"self",
",",
"req",
",",
"data_source",
",",
"nodes",
",",
"partition",
",",
"outgoing_headers",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | This method is responsible for establishing connection
with storage nodes and sending the data to each one of those
nodes. | [
"This",
"method",
"is",
"responsible",
"for",
"establishing",
"connection",
"with",
"storage",
"nodes",
"and",
"sending",
"the",
"data",
"to",
"each",
"one",
"of",
"those",
"nodes",
"."
] | [
"\"\"\"\n This method is responsible for establishing connection\n with storage nodes and sending the data to each one of those\n nodes. The process of transferring data is specific to each\n Storage Policy, thus it is required for each policy specific\n ObjectController to provid... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "data_source",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "outgoing_headers",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _delete_object | <not_specific> | def _delete_object(self, req, obj_ring, partition, headers):
"""Delete object considering write-affinity.
When deleting object in write affinity deployment, also take configured
handoff nodes number into consideration, instead of just sending
requests to primary nodes. Otherwise (write-... | Delete object considering write-affinity.
When deleting object in write affinity deployment, also take configured
handoff nodes number into consideration, instead of just sending
requests to primary nodes. Otherwise (write-affinity is disabled),
go with the same way as before.
... | Delete object considering write-affinity.
When deleting object in write affinity deployment, also take configured
handoff nodes number into consideration, instead of just sending
requests to primary nodes. Otherwise (write-affinity is disabled),
go with the same way as before. | [
"Delete",
"object",
"considering",
"write",
"-",
"affinity",
".",
"When",
"deleting",
"object",
"in",
"write",
"affinity",
"deployment",
"also",
"take",
"configured",
"handoff",
"nodes",
"number",
"into",
"consideration",
"instead",
"of",
"just",
"sending",
"reque... | def _delete_object(self, req, obj_ring, partition, headers):
policy_index = req.headers.get('X-Backend-Storage-Policy-Index')
policy = POLICIES.get_by_index(policy_index)
node_count = None
node_iterator = None
policy_options = self.app.get_policy_options(policy)
is_local ... | [
"def",
"_delete_object",
"(",
"self",
",",
"req",
",",
"obj_ring",
",",
"partition",
",",
"headers",
")",
":",
"policy_index",
"=",
"req",
".",
"headers",
".",
"get",
"(",
"'X-Backend-Storage-Policy-Index'",
")",
"policy",
"=",
"POLICIES",
".",
"get_by_index",... | Delete object considering write-affinity. | [
"Delete",
"object",
"considering",
"write",
"-",
"affinity",
"."
] | [
"\"\"\"Delete object considering write-affinity.\n\n When deleting object in write affinity deployment, also take configured\n handoff nodes number into consideration, instead of just sending\n requests to primary nodes. Otherwise (write-affinity is disabled),\n go with the same way as b... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "obj_ring",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _post_object | <not_specific> | def _post_object(self, req, obj_ring, partition, headers):
"""
send object POST request to storage nodes.
:param req: the POST Request
:param obj_ring: the object ring
:param partition: ring partition number
:param headers: system headers to storage nodes
:return... |
send object POST request to storage nodes.
:param req: the POST Request
:param obj_ring: the object ring
:param partition: ring partition number
:param headers: system headers to storage nodes
:return: Response object
| send object POST request to storage nodes. | [
"send",
"object",
"POST",
"request",
"to",
"storage",
"nodes",
"."
] | def _post_object(self, req, obj_ring, partition, headers):
resp = self.make_requests(req, obj_ring, partition,
'POST', req.swift_entity_path, headers)
return resp | [
"def",
"_post_object",
"(",
"self",
",",
"req",
",",
"obj_ring",
",",
"partition",
",",
"headers",
")",
":",
"resp",
"=",
"self",
".",
"make_requests",
"(",
"req",
",",
"obj_ring",
",",
"partition",
",",
"'POST'",
",",
"req",
".",
"swift_entity_path",
",... | send object POST request to storage nodes. | [
"send",
"object",
"POST",
"request",
"to",
"storage",
"nodes",
"."
] | [
"\"\"\"\n send object POST request to storage nodes.\n\n :param req: the POST Request\n :param obj_ring: the object ring\n :param partition: ring partition number\n :param headers: system headers to storage nodes\n :return: Response object\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "obj_ring",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "headers",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _transfer_data | null | def _transfer_data(self, req, data_source, putters, nodes):
"""
Transfer data for a replicated object.
This method was added in the PUT method extraction change
"""
bytes_transferred = 0
def send_chunk(chunk):
for putter in list(putters):
if ... |
Transfer data for a replicated object.
This method was added in the PUT method extraction change
| Transfer data for a replicated object.
This method was added in the PUT method extraction change | [
"Transfer",
"data",
"for",
"a",
"replicated",
"object",
".",
"This",
"method",
"was",
"added",
"in",
"the",
"PUT",
"method",
"extraction",
"change"
] | def _transfer_data(self, req, data_source, putters, nodes):
bytes_transferred = 0
def send_chunk(chunk):
for putter in list(putters):
if not putter.failed:
putter.send_chunk(chunk)
else:
putter.close()
... | [
"def",
"_transfer_data",
"(",
"self",
",",
"req",
",",
"data_source",
",",
"putters",
",",
"nodes",
")",
":",
"bytes_transferred",
"=",
"0",
"def",
"send_chunk",
"(",
"chunk",
")",
":",
"for",
"putter",
"in",
"list",
"(",
"putters",
")",
":",
"if",
"no... | Transfer data for a replicated object. | [
"Transfer",
"data",
"for",
"a",
"replicated",
"object",
"."
] | [
"\"\"\"\n Transfer data for a replicated object.\n\n This method was added in the PUT method extraction change\n \"\"\"",
"# send any footers set by middleware"
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "data_source",
"type": null
},
{
"param": "putters",
"type": null
},
{
"param": "nodes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _store_object | <not_specific> | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
"""
Store a replicated object.
This method is responsible for establishing connection
with storage nodes and sending object to each one of those
nodes. After sending the data, th... |
Store a replicated object.
This method is responsible for establishing connection
with storage nodes and sending object to each one of those
nodes. After sending the data, the "best" response will be
returned based on statuses from all connections
| Store a replicated object.
This method is responsible for establishing connection
with storage nodes and sending object to each one of those
nodes. After sending the data, the "best" response will be
returned based on statuses from all connections | [
"Store",
"a",
"replicated",
"object",
".",
"This",
"method",
"is",
"responsible",
"for",
"establishing",
"connection",
"with",
"storage",
"nodes",
"and",
"sending",
"object",
"to",
"each",
"one",
"of",
"those",
"nodes",
".",
"After",
"sending",
"the",
"data",
... | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
policy_index = req.headers.get('X-Backend-Storage-Policy-Index')
policy = POLICIES.get_by_index(policy_index)
if not nodes:
return HTTPNotFound()
putters = self._get_put_conne... | [
"def",
"_store_object",
"(",
"self",
",",
"req",
",",
"data_source",
",",
"nodes",
",",
"partition",
",",
"outgoing_headers",
")",
":",
"policy_index",
"=",
"req",
".",
"headers",
".",
"get",
"(",
"'X-Backend-Storage-Policy-Index'",
")",
"policy",
"=",
"POLICI... | Store a replicated object. | [
"Store",
"a",
"replicated",
"object",
"."
] | [
"\"\"\"\n Store a replicated object.\n\n This method is responsible for establishing connection\n with storage nodes and sending object to each one of those\n nodes. After sending the data, the \"best\" response will be\n returned based on statuses from all connections\n \"... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "data_source",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "outgoing_headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | kickoff | null | def kickoff(self, req, resp):
"""
Start pulling data from the backends so that we can learn things like
the real Content-Type that might only be in the multipart/byteranges
response body. Update our response accordingly.
Also, this is the first point at which we can learn the MI... |
Start pulling data from the backends so that we can learn things like
the real Content-Type that might only be in the multipart/byteranges
response body. Update our response accordingly.
Also, this is the first point at which we can learn the MIME
boundary that our response has... | Start pulling data from the backends so that we can learn things like
the real Content-Type that might only be in the multipart/byteranges
response body. Update our response accordingly.
Also, this is the first point at which we can learn the MIME
boundary that our response has in the headers. We grab that so we
can a... | [
"Start",
"pulling",
"data",
"from",
"the",
"backends",
"so",
"that",
"we",
"can",
"learn",
"things",
"like",
"the",
"real",
"Content",
"-",
"Type",
"that",
"might",
"only",
"be",
"in",
"the",
"multipart",
"/",
"byteranges",
"response",
"body",
".",
"Update... | def kickoff(self, req, resp):
self.mime_boundary = resp.boundary
try:
self.stashed_iter = reiterate(self._real_iter(req, resp.headers))
except Exception:
self.close()
raise
if self.learned_content_type is not None:
resp.content_type = self.... | [
"def",
"kickoff",
"(",
"self",
",",
"req",
",",
"resp",
")",
":",
"self",
".",
"mime_boundary",
"=",
"resp",
".",
"boundary",
"try",
":",
"self",
".",
"stashed_iter",
"=",
"reiterate",
"(",
"self",
".",
"_real_iter",
"(",
"req",
",",
"resp",
".",
"he... | Start pulling data from the backends so that we can learn things like
the real Content-Type that might only be in the multipart/byteranges
response body. | [
"Start",
"pulling",
"data",
"from",
"the",
"backends",
"so",
"that",
"we",
"can",
"learn",
"things",
"like",
"the",
"real",
"Content",
"-",
"Type",
"that",
"might",
"only",
"be",
"in",
"the",
"multipart",
"/",
"byteranges",
"response",
"body",
"."
] | [
"\"\"\"\n Start pulling data from the backends so that we can learn things like\n the real Content-Type that might only be in the multipart/byteranges\n response body. Update our response accordingly.\n\n Also, this is the first point at which we can learn the MIME\n boundary that... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "resp",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "HTTPException"
}
],
"params": [
{
"identifier": "self",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | await_response | <not_specific> | def await_response(self, timeout, informational=False):
"""
Get 100-continue response indicating the end of 1st phase of a 2-phase
commit or the final response, i.e. the one with status >= 200.
Might or might not actually wait for anything. If we said Expect:
100-continue but go... |
Get 100-continue response indicating the end of 1st phase of a 2-phase
commit or the final response, i.e. the one with status >= 200.
Might or might not actually wait for anything. If we said Expect:
100-continue but got back a non-100 response, that'll be the thing
returned, a... | Get 100-continue response indicating the end of 1st phase of a 2-phase
commit or the final response, i.e. the one with status >= 200.
Might or might not actually wait for anything. If we said Expect:
100-continue but got back a non-100 response, that'll be the thing
returned, and we won't do any network IO to get it. ... | [
"Get",
"100",
"-",
"continue",
"response",
"indicating",
"the",
"end",
"of",
"1st",
"phase",
"of",
"a",
"2",
"-",
"phase",
"commit",
"or",
"the",
"final",
"response",
"i",
".",
"e",
".",
"the",
"one",
"with",
"status",
">",
"=",
"200",
".",
"Might",
... | def await_response(self, timeout, informational=False):
if not self.final_resp:
with Timeout(timeout):
if informational:
self.resp = self.conn.getexpect()
else:
self.resp = self.conn.getresponse()
return self.resp | [
"def",
"await_response",
"(",
"self",
",",
"timeout",
",",
"informational",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"final_resp",
":",
"with",
"Timeout",
"(",
"timeout",
")",
":",
"if",
"informational",
":",
"self",
".",
"resp",
"=",
"self",
... | Get 100-continue response indicating the end of 1st phase of a 2-phase
commit or the final response, i.e. | [
"Get",
"100",
"-",
"continue",
"response",
"indicating",
"the",
"end",
"of",
"1st",
"phase",
"of",
"a",
"2",
"-",
"phase",
"commit",
"or",
"the",
"final",
"response",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Get 100-continue response indicating the end of 1st phase of a 2-phase\n commit or the final response, i.e. the one with status >= 200.\n\n Might or might not actually wait for anything. If we said Expect:\n 100-continue but got back a non-100 response, that'll be the thing\n ... | [
{
"param": "self",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "informational",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [
{
"docstring": "if the response took too long",
"docstring_tokens": [
"if",
"the",
"response",
"took",
"too",
"l... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | end_of_object_data | null | def end_of_object_data(self, **kwargs):
"""
Call when there is no more data to send.
"""
if self.state == DATA_SENT:
raise ValueError("called end_of_object_data twice")
self.queue.put('')
self.state = DATA_SENT |
Call when there is no more data to send.
| Call when there is no more data to send. | [
"Call",
"when",
"there",
"is",
"no",
"more",
"data",
"to",
"send",
"."
] | def end_of_object_data(self, **kwargs):
if self.state == DATA_SENT:
raise ValueError("called end_of_object_data twice")
self.queue.put('')
self.state = DATA_SENT | [
"def",
"end_of_object_data",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"state",
"==",
"DATA_SENT",
":",
"raise",
"ValueError",
"(",
"\"called end_of_object_data twice\"",
")",
"self",
".",
"queue",
".",
"put",
"(",
"''",
")",
"self",
"... | Call when there is no more data to send. | [
"Call",
"when",
"there",
"is",
"no",
"more",
"data",
"to",
"send",
"."
] | [
"\"\"\"\n Call when there is no more data to send.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _send_file | null | def _send_file(self, write_timeout, exception_handler):
"""
Method for a file PUT coroutine. Takes chunks from a queue and sends
them down a socket.
If something goes wrong, the "failed" attribute will be set to true
and the exception handler will be called.
"""
... |
Method for a file PUT coroutine. Takes chunks from a queue and sends
them down a socket.
If something goes wrong, the "failed" attribute will be set to true
and the exception handler will be called.
| Method for a file PUT coroutine. Takes chunks from a queue and sends
them down a socket.
If something goes wrong, the "failed" attribute will be set to true
and the exception handler will be called. | [
"Method",
"for",
"a",
"file",
"PUT",
"coroutine",
".",
"Takes",
"chunks",
"from",
"a",
"queue",
"and",
"sends",
"them",
"down",
"a",
"socket",
".",
"If",
"something",
"goes",
"wrong",
"the",
"\"",
"failed",
"\"",
"attribute",
"will",
"be",
"set",
"to",
... | def _send_file(self, write_timeout, exception_handler):
while True:
chunk = self.queue.get()
if not self.failed:
if self.chunked:
to_send = "%x\r\n%s\r\n" % (len(chunk), chunk)
else:
to_send = chunk
t... | [
"def",
"_send_file",
"(",
"self",
",",
"write_timeout",
",",
"exception_handler",
")",
":",
"while",
"True",
":",
"chunk",
"=",
"self",
".",
"queue",
".",
"get",
"(",
")",
"if",
"not",
"self",
".",
"failed",
":",
"if",
"self",
".",
"chunked",
":",
"t... | Method for a file PUT coroutine. | [
"Method",
"for",
"a",
"file",
"PUT",
"coroutine",
"."
] | [
"\"\"\"\n Method for a file PUT coroutine. Takes chunks from a queue and sends\n them down a socket.\n\n If something goes wrong, the \"failed\" attribute will be set to true\n and the exception handler will be called.\n \"\"\"",
"# task_done():每次从queue中get一个数据之后,当处理好相关问题,最后调用该方... | [
{
"param": "self",
"type": null
},
{
"param": "write_timeout",
"type": null
},
{
"param": "exception_handler",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "write_timeout",
"type": null,
"docstring": null,
"docstring_t... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | connect | <not_specific> | def connect(cls, node, part, path, headers, conn_timeout, node_timeout,
logger=None, chunked=False, **kwargs):
"""
Connect to a backend node and send the headers.
:returns: Putter instance
:raises ConnectionTimeout: if initial connection timed out
:raises Respon... |
Connect to a backend node and send the headers.
:returns: Putter instance
:raises ConnectionTimeout: if initial connection timed out
:raises ResponseTimeout: if header retrieval timed out
:raises InsufficientStorage: on 507 response from node
:raises PutterConnectError... | Connect to a backend node and send the headers. | [
"Connect",
"to",
"a",
"backend",
"node",
"and",
"send",
"the",
"headers",
"."
] | def connect(cls, node, part, path, headers, conn_timeout, node_timeout,
logger=None, chunked=False, **kwargs):
conn, expect_resp, final_resp, connect_duration = cls._make_connection(
node, part, path, headers, conn_timeout, node_timeout)
return cls(conn, node, final_resp, pat... | [
"def",
"connect",
"(",
"cls",
",",
"node",
",",
"part",
",",
"path",
",",
"headers",
",",
"conn_timeout",
",",
"node_timeout",
",",
"logger",
"=",
"None",
",",
"chunked",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"conn",
",",
"expect_resp",
",",
"... | Connect to a backend node and send the headers. | [
"Connect",
"to",
"a",
"backend",
"node",
"and",
"send",
"the",
"headers",
"."
] | [
"\"\"\"\n Connect to a backend node and send the headers.\n\n :returns: Putter instance\n\n :raises ConnectionTimeout: if initial connection timed out\n :raises ResponseTimeout: if header retrieval timed out\n :raises InsufficientStorage: on 507 response from node\n :raises... | [
{
"param": "cls",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "part",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "conn_timeout",
"type": null
},
{
"param": "node_tim... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [
{
"docstring": "if initial connection timed out",
"docstring_tokens": [
"if",
"initial",
"connection",
"timed",
"out"
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | end_of_object_data | null | def end_of_object_data(self, footer_metadata=None):
"""
Call when there is no more data to send.
Overrides superclass implementation to send any footer metadata
after object data.
:param footer_metadata: dictionary of metadata items
to be sent as... |
Call when there is no more data to send.
Overrides superclass implementation to send any footer metadata
after object data.
:param footer_metadata: dictionary of metadata items
to be sent as footers.
| Call when there is no more data to send.
Overrides superclass implementation to send any footer metadata
after object data. | [
"Call",
"when",
"there",
"is",
"no",
"more",
"data",
"to",
"send",
".",
"Overrides",
"superclass",
"implementation",
"to",
"send",
"any",
"footer",
"metadata",
"after",
"object",
"data",
"."
] | def end_of_object_data(self, footer_metadata=None):
if self.state == DATA_SENT:
raise ValueError("called end_of_object_data twice")
elif self.state == NO_DATA_SENT and self.mime_boundary:
self._start_object_data()
footer_body = json.dumps(footer_metadata)
footer_m... | [
"def",
"end_of_object_data",
"(",
"self",
",",
"footer_metadata",
"=",
"None",
")",
":",
"if",
"self",
".",
"state",
"==",
"DATA_SENT",
":",
"raise",
"ValueError",
"(",
"\"called end_of_object_data twice\"",
")",
"elif",
"self",
".",
"state",
"==",
"NO_DATA_SENT... | Call when there is no more data to send. | [
"Call",
"when",
"there",
"is",
"no",
"more",
"data",
"to",
"send",
"."
] | [
"\"\"\"\n Call when there is no more data to send.\n\n Overrides superclass implementation to send any footer metadata\n after object data.\n\n :param footer_metadata: dictionary of metadata items\n to be sent as footers.\n \"\"\"",
"# this will be... | [
{
"param": "self",
"type": null
},
{
"param": "footer_metadata",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "footer_metadata",
"type": null,
"docstring": "dictionary of metadat... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | send_commit_confirmation | null | def send_commit_confirmation(self):
"""
Call when there are > quorum 2XX responses received. Send commit
confirmations to all object nodes to finalize the PUT.
"""
if not self.multiphase:
raise ValueError(
"called send_commit_confirmation but multipha... |
Call when there are > quorum 2XX responses received. Send commit
confirmations to all object nodes to finalize the PUT.
| Call when there are > quorum 2XX responses received. Send commit
confirmations to all object nodes to finalize the PUT. | [
"Call",
"when",
"there",
"are",
">",
"quorum",
"2XX",
"responses",
"received",
".",
"Send",
"commit",
"confirmations",
"to",
"all",
"object",
"nodes",
"to",
"finalize",
"the",
"PUT",
"."
] | def send_commit_confirmation(self):
if not self.multiphase:
raise ValueError(
"called send_commit_confirmation but multiphase is False")
if self.state == COMMIT_SENT:
raise ValueError("called send_commit_confirmation twice")
self.state = DATA_ACKED
... | [
"def",
"send_commit_confirmation",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"multiphase",
":",
"raise",
"ValueError",
"(",
"\"called send_commit_confirmation but multiphase is False\"",
")",
"if",
"self",
".",
"state",
"==",
"COMMIT_SENT",
":",
"raise",
"Val... | Call when there are > quorum 2XX responses received. | [
"Call",
"when",
"there",
"are",
">",
"quorum",
"2XX",
"responses",
"received",
"."
] | [
"\"\"\"\n Call when there are > quorum 2XX responses received. Send commit\n confirmations to all object nodes to finalize the PUT.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | connect | <not_specific> | def connect(cls, node, part, req, headers, conn_timeout, node_timeout,
logger=None, need_multiphase=True, **kwargs):
"""
Connect to a backend node and send the headers.
Override superclass method to notify object of need for support for
multipart body with footers and op... |
Connect to a backend node and send the headers.
Override superclass method to notify object of need for support for
multipart body with footers and optionally multiphase commit, and
verify object server's capabilities.
:param need_multiphase: if True then multiphase support is... | Connect to a backend node and send the headers.
Override superclass method to notify object of need for support for
multipart body with footers and optionally multiphase commit, and
verify object server's capabilities. | [
"Connect",
"to",
"a",
"backend",
"node",
"and",
"send",
"the",
"headers",
".",
"Override",
"superclass",
"method",
"to",
"notify",
"object",
"of",
"need",
"for",
"support",
"for",
"multipart",
"body",
"with",
"footers",
"and",
"optionally",
"multiphase",
"comm... | def connect(cls, node, part, req, headers, conn_timeout, node_timeout,
logger=None, need_multiphase=True, **kwargs):
mime_boundary = "%.64x" % random.randint(0, 16 ** 64)
headers = HeaderKeyDict(headers)
headers.setdefault('X-Backend-Obj-Content-Length',
... | [
"def",
"connect",
"(",
"cls",
",",
"node",
",",
"part",
",",
"req",
",",
"headers",
",",
"conn_timeout",
",",
"node_timeout",
",",
"logger",
"=",
"None",
",",
"need_multiphase",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"mime_boundary",
"=",
"\"%.64x\"... | Connect to a backend node and send the headers. | [
"Connect",
"to",
"a",
"backend",
"node",
"and",
"send",
"the",
"headers",
"."
] | [
"\"\"\"\n Connect to a backend node and send the headers.\n\n Override superclass method to notify object of need for support for\n multipart body with footers and optionally multiphase commit, and\n verify object server's capabilities.\n\n :param need_multiphase: if True then mul... | [
{
"param": "cls",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "part",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "headers",
"type": null
},
{
"param": "conn_timeout",
"type": null
},
{
"param": "node_time... | {
"returns": [],
"raises": [
{
"docstring": "if need_metadata_footer is set but\nbackend node can't process footers",
"docstring_tokens": [
"if",
"need_metadata_footer",
"is",
"set",
"but",
"backend",
"node",
"can",
"'",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | chunk_transformer | null | def chunk_transformer(policy):
"""
A generator to transform a source chunk to erasure coded chunks for each
`send` call. The number of erasure coded chunks is as
policy.ec_n_unique_fragments.
"""
segment_size = policy.ec_segment_size
buf = collections.deque() # deque()定义了双端队列,可以从头/尾两端添加或删除... |
A generator to transform a source chunk to erasure coded chunks for each
`send` call. The number of erasure coded chunks is as
policy.ec_n_unique_fragments.
| A generator to transform a source chunk to erasure coded chunks for each
`send` call. The number of erasure coded chunks is as
policy.ec_n_unique_fragments. | [
"A",
"generator",
"to",
"transform",
"a",
"source",
"chunk",
"to",
"erasure",
"coded",
"chunks",
"for",
"each",
"`",
"send",
"`",
"call",
".",
"The",
"number",
"of",
"erasure",
"coded",
"chunks",
"is",
"as",
"policy",
".",
"ec_n_unique_fragments",
"."
] | def chunk_transformer(policy):
segment_size = policy.ec_segment_size
buf = collections.deque()
total_buf_len = 0
chunk = yield
while chunk:
buf.append(chunk)
total_buf_len += len(chunk)
if total_buf_len >= segment_size:
chunks_to_encode = []
while... | [
"def",
"chunk_transformer",
"(",
"policy",
")",
":",
"segment_size",
"=",
"policy",
".",
"ec_segment_size",
"buf",
"=",
"collections",
".",
"deque",
"(",
")",
"total_buf_len",
"=",
"0",
"chunk",
"=",
"yield",
"while",
"chunk",
":",
"buf",
".",
"append",
"(... | A generator to transform a source chunk to erasure coded chunks for each
`send` call. | [
"A",
"generator",
"to",
"transform",
"a",
"source",
"chunk",
"to",
"erasure",
"coded",
"chunks",
"for",
"each",
"`",
"send",
"`",
"call",
"."
] | [
"\"\"\"\n A generator to transform a source chunk to erasure coded chunks for each\n `send` call. The number of erasure coded chunks is as\n policy.ec_n_unique_fragments.\n \"\"\"",
"# deque()定义了双端队列,可以从头/尾两端添加或删除元素",
"# 第一次调用时,在这里暂停",
"# 下次调用 .send(msg) 时,chunk=msg,然后往后运行",
"#头部插入",
"# extrac... | [
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "policy",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | add_response | null | def add_response(self, get, parts_iter):
"""
Add a response to the collection.
:param get: An instance of
:class:`~swift.proxy.controllers.base.ResumingGetter`
:param parts_iter: An iterator over response body parts
:raises ValueError: if the response etag or... |
Add a response to the collection.
:param get: An instance of
:class:`~swift.proxy.controllers.base.ResumingGetter`
:param parts_iter: An iterator over response body parts
:raises ValueError: if the response etag or status code values do not
match any val... | Add a response to the collection. | [
"Add",
"a",
"response",
"to",
"the",
"collection",
"."
] | def add_response(self, get, parts_iter):
headers = get.last_headers
t_data_file = headers.get('X-Backend-Data-Timestamp')
t_obj = headers.get('X-Backend-Timestamp', headers.get('X-Timestamp'))
self._get_bucket(t_data_file or t_obj).add_response(get, parts_iter)
frag_sets = safe_j... | [
"def",
"add_response",
"(",
"self",
",",
"get",
",",
"parts_iter",
")",
":",
"headers",
"=",
"get",
".",
"last_headers",
"t_data_file",
"=",
"headers",
".",
"get",
"(",
"'X-Backend-Data-Timestamp'",
")",
"t_obj",
"=",
"headers",
".",
"get",
"(",
"'X-Backend-... | Add a response to the collection. | [
"Add",
"a",
"response",
"to",
"the",
"collection",
"."
] | [
"\"\"\"\n Add a response to the collection.\n\n :param get: An instance of\n :class:`~swift.proxy.controllers.base.ResumingGetter`\n :param parts_iter: An iterator over response body parts\n :raises ValueError: if the response etag or status code values do not\n ... | [
{
"param": "self",
"type": null
},
{
"param": "get",
"type": null
},
{
"param": "parts_iter",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "if the response etag or status code values do not\nmatch any values previously received for the same timestamp",
"docstring_tokens": [
"if",
"the",
"response",
"etag",
"or",
"status",
"code",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | best_bucket | <not_specific> | def best_bucket(self):
"""
Return the best bucket in the collection.
The "best" bucket is the newest timestamp with sufficient getters, or
the closest to having sufficient getters, unless it is bettered by a
bucket with potential alternate nodes.
:return: An instance of... |
Return the best bucket in the collection.
The "best" bucket is the newest timestamp with sufficient getters, or
the closest to having sufficient getters, unless it is bettered by a
bucket with potential alternate nodes.
:return: An instance of :class:`~ECGetResponseBucket` or ... | Return the best bucket in the collection.
The "best" bucket is the newest timestamp with sufficient getters, or
the closest to having sufficient getters, unless it is bettered by a
bucket with potential alternate nodes. | [
"Return",
"the",
"best",
"bucket",
"in",
"the",
"collection",
".",
"The",
"\"",
"best",
"\"",
"bucket",
"is",
"the",
"newest",
"timestamp",
"with",
"sufficient",
"getters",
"or",
"the",
"closest",
"to",
"having",
"sufficient",
"getters",
"unless",
"it",
"is"... | def best_bucket(self):
sorted_buckets = self._sort_buckets()
if sorted_buckets:
return sorted_buckets[0]
return None | [
"def",
"best_bucket",
"(",
"self",
")",
":",
"sorted_buckets",
"=",
"self",
".",
"_sort_buckets",
"(",
")",
"if",
"sorted_buckets",
":",
"return",
"sorted_buckets",
"[",
"0",
"]",
"return",
"None"
] | Return the best bucket in the collection. | [
"Return",
"the",
"best",
"bucket",
"in",
"the",
"collection",
"."
] | [
"\"\"\"\n Return the best bucket in the collection.\n\n The \"best\" bucket is the newest timestamp with sufficient getters, or\n the closest to having sufficient getters, unless it is bettered by a\n bucket with potential alternate nodes.\n\n :return: An instance of :class:`~ECGe... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "An instance of :class:`~ECGetResponseBucket` or None if there\nare no buckets in the collection.",
"docstring_tokens": [
"An",
"instance",
"of",
":",
"class",
":",
"`",
"~ECGetResponseBucket",
"`",
... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | provide_alternate_node | <not_specific> | def provide_alternate_node(self):
"""
Callback function that is installed in a NodeIter. Called on every call
to NodeIter.next(), which means we can track the number of nodes to
which GET requests have been made and selectively inject an alternate
node, if we have one.
:... |
Callback function that is installed in a NodeIter. Called on every call
to NodeIter.next(), which means we can track the number of nodes to
which GET requests have been made and selectively inject an alternate
node, if we have one.
:return: A dict describing a node to which the... | Callback function that is installed in a NodeIter. Called on every call
to NodeIter.next(), which means we can track the number of nodes to
which GET requests have been made and selectively inject an alternate
node, if we have one. | [
"Callback",
"function",
"that",
"is",
"installed",
"in",
"a",
"NodeIter",
".",
"Called",
"on",
"every",
"call",
"to",
"NodeIter",
".",
"next",
"()",
"which",
"means",
"we",
"can",
"track",
"the",
"number",
"of",
"nodes",
"to",
"which",
"GET",
"requests",
... | def provide_alternate_node(self):
self.node_iter_count += 1
nodes = self._get_alternate_nodes()
if nodes:
return nodes.pop(0).copy() | [
"def",
"provide_alternate_node",
"(",
"self",
")",
":",
"self",
".",
"node_iter_count",
"+=",
"1",
"nodes",
"=",
"self",
".",
"_get_alternate_nodes",
"(",
")",
"if",
"nodes",
":",
"return",
"nodes",
".",
"pop",
"(",
"0",
")",
".",
"copy",
"(",
")"
] | Callback function that is installed in a NodeIter. | [
"Callback",
"function",
"that",
"is",
"installed",
"in",
"a",
"NodeIter",
"."
] | [
"\"\"\"\n Callback function that is installed in a NodeIter. Called on every call\n to NodeIter.next(), which means we can track the number of nodes to\n which GET requests have been made and selectively inject an alternate\n node, if we have one.\n\n :return: A dict describing a ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "A dict describing a node to which the next GET request\nshould be made.",
"docstring_tokens": [
"A",
"dict",
"describing",
"a",
"node",
"to",
"which",
"the",
"next",
"GET",
"request",... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _fragment_GET_request | <not_specific> | def _fragment_GET_request(self, req, node_iter, partition, policy,
header_provider=None):
"""
Makes a GET request for a fragment.
"""
backend_headers = self.generate_request_headers(
req, additional=req.headers)
getter = ResumingGetter(s... |
Makes a GET request for a fragment.
| Makes a GET request for a fragment. | [
"Makes",
"a",
"GET",
"request",
"for",
"a",
"fragment",
"."
] | def _fragment_GET_request(self, req, node_iter, partition, policy,
header_provider=None):
backend_headers = self.generate_request_headers(
req, additional=req.headers)
getter = ResumingGetter(self.app, req, 'Object', node_iter,
pa... | [
"def",
"_fragment_GET_request",
"(",
"self",
",",
"req",
",",
"node_iter",
",",
"partition",
",",
"policy",
",",
"header_provider",
"=",
"None",
")",
":",
"backend_headers",
"=",
"self",
".",
"generate_request_headers",
"(",
"req",
",",
"additional",
"=",
"req... | Makes a GET request for a fragment. | [
"Makes",
"a",
"GET",
"request",
"for",
"a",
"fragment",
"."
] | [
"\"\"\"\n Makes a GET request for a fragment.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "node_iter",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "policy",
"type": null
},
{
"param": "header_provider",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _convert_range | <not_specific> | def _convert_range(self, req, policy):
"""
Take the requested range(s) from the client and convert it to range(s)
to be sent to the object servers.
This includes widening requested ranges to full segments, then
converting those ranges to fragments so that we retrieve the minimum... |
Take the requested range(s) from the client and convert it to range(s)
to be sent to the object servers.
This includes widening requested ranges to full segments, then
converting those ranges to fragments so that we retrieve the minimum
number of fragments from the object serve... | Take the requested range(s) from the client and convert it to range(s)
to be sent to the object servers.
This includes widening requested ranges to full segments, then
converting those ranges to fragments so that we retrieve the minimum
number of fragments from the object server.
Mutates the request passed in.
Retur... | [
"Take",
"the",
"requested",
"range",
"(",
"s",
")",
"from",
"the",
"client",
"and",
"convert",
"it",
"to",
"range",
"(",
"s",
")",
"to",
"be",
"sent",
"to",
"the",
"object",
"servers",
".",
"This",
"includes",
"widening",
"requested",
"ranges",
"to",
"... | def _convert_range(self, req, policy):
segment_size = policy.ec_segment_size
fragment_size = policy.fragment_size
range_specs = []
new_ranges = []
for client_start, client_end in req.range.ranges:
segment_start, segment_end = client_range_to_segment_range(
... | [
"def",
"_convert_range",
"(",
"self",
",",
"req",
",",
"policy",
")",
":",
"segment_size",
"=",
"policy",
".",
"ec_segment_size",
"fragment_size",
"=",
"policy",
".",
"fragment_size",
"range_specs",
"=",
"[",
"]",
"new_ranges",
"=",
"[",
"]",
"for",
"client_... | Take the requested range(s) from the client and convert it to range(s)
to be sent to the object servers. | [
"Take",
"the",
"requested",
"range",
"(",
"s",
")",
"from",
"the",
"client",
"and",
"convert",
"it",
"to",
"range",
"(",
"s",
")",
"to",
"be",
"sent",
"to",
"the",
"object",
"servers",
"."
] | [
"\"\"\"\n Take the requested range(s) from the client and convert it to range(s)\n to be sent to the object servers.\n\n This includes widening requested ranges to full segments, then\n converting those ranges to fragments so that we retrieve the minimum\n number of fragments from... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _determine_chunk_destinations | <not_specific> | def _determine_chunk_destinations(self, putters, policy):
"""
Given a list of putters, return a dict where the key is the putter
and the value is the frag index to use.
This is done so that we line up handoffs using the same frag index
(in the primary part list) as the primary t... |
Given a list of putters, return a dict where the key is the putter
and the value is the frag index to use.
This is done so that we line up handoffs using the same frag index
(in the primary part list) as the primary that the handoff is standing
in for. This lets erasure-code f... | Given a list of putters, return a dict where the key is the putter
and the value is the frag index to use.
This is done so that we line up handoffs using the same frag index
(in the primary part list) as the primary that the handoff is standing
in for. This lets erasure-code fragment archives wind up on the
preferred... | [
"Given",
"a",
"list",
"of",
"putters",
"return",
"a",
"dict",
"where",
"the",
"key",
"is",
"the",
"putter",
"and",
"the",
"value",
"is",
"the",
"frag",
"index",
"to",
"use",
".",
"This",
"is",
"done",
"so",
"that",
"we",
"line",
"up",
"handoffs",
"us... | def _determine_chunk_destinations(self, putters, policy):
For primary nodes, that's just its index (primary 0 gets
chunk 0, primary 1 gets chunk 1, and so on). For handoffs,
we assign the chunk index of a missing primary.
handoff_conns = []
putter_to_frag_index = {}
fo... | [
"def",
"_determine_chunk_destinations",
"(",
"self",
",",
"putters",
",",
"policy",
")",
":",
"handoff_conns",
"=",
"[",
"]",
"putter_to_frag_index",
"=",
"{",
"}",
"for",
"p",
"in",
"putters",
":",
"if",
"p",
".",
"node_index",
"is",
"not",
"None",
":",
... | Given a list of putters, return a dict where the key is the putter
and the value is the frag index to use. | [
"Given",
"a",
"list",
"of",
"putters",
"return",
"a",
"dict",
"where",
"the",
"key",
"is",
"the",
"putter",
"and",
"the",
"value",
"is",
"the",
"frag",
"index",
"to",
"use",
"."
] | [
"\"\"\"\n Given a list of putters, return a dict where the key is the putter\n and the value is the frag index to use.\n\n This is done so that we line up handoffs using the same frag index\n (in the primary part list) as the primary that the handoff is standing\n in for. This le... | [
{
"param": "self",
"type": null
},
{
"param": "putters",
"type": null
},
{
"param": "policy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "putters",
"type": null,
"docstring": "a list of swift.proxy.control... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _transfer_data | <not_specific> | def _transfer_data(self, req, policy, data_source, putters, nodes,
min_conns, etag_hasher):
"""
Transfer data for an erasure coded object.
This method was added in the PUT method extraction change
"""
bytes_transferred = 0
# 生成一个迭代器 chunk_transform... |
Transfer data for an erasure coded object.
This method was added in the PUT method extraction change
| Transfer data for an erasure coded object.
This method was added in the PUT method extraction change | [
"Transfer",
"data",
"for",
"an",
"erasure",
"coded",
"object",
".",
"This",
"method",
"was",
"added",
"in",
"the",
"PUT",
"method",
"extraction",
"change"
] | def _transfer_data(self, req, policy, data_source, putters, nodes,
min_conns, etag_hasher):
bytes_transferred = 0
chunk_transform = chunk_transformer(policy)
chunk_transform.send(None)
frag_hashers = collections.defaultdict(md5)
def send_chunk(chunk):
... | [
"def",
"_transfer_data",
"(",
"self",
",",
"req",
",",
"policy",
",",
"data_source",
",",
"putters",
",",
"nodes",
",",
"min_conns",
",",
"etag_hasher",
")",
":",
"bytes_transferred",
"=",
"0",
"chunk_transform",
"=",
"chunk_transformer",
"(",
"policy",
")",
... | Transfer data for an erasure coded object. | [
"Transfer",
"data",
"for",
"an",
"erasure",
"coded",
"object",
"."
] | [
"\"\"\"\n Transfer data for an erasure coded object.\n\n This method was added in the PUT method extraction change\n \"\"\"",
"# 生成一个迭代器 chunk_transform",
"# 第一次调用 chunk_transformer()并不会执行改函数而是生成一个迭代器",
"# Note: there's two different hashers in here. etag_hasher is",
"# hashing the orig... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "policy",
"type": null
},
{
"param": "data_source",
"type": null
},
{
"param": "putters",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "min_co... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _have_adequate_responses | <not_specific> | def _have_adequate_responses(
self, statuses, min_responses, conditional_func):
"""
Given a list of statuses from several requests, determine if a
satisfactory number of nodes have responded with 1xx or 2xx statuses to
deem the transaction for a successful response to the cli... |
Given a list of statuses from several requests, determine if a
satisfactory number of nodes have responded with 1xx or 2xx statuses to
deem the transaction for a successful response to the client.
:param statuses: list of statuses returned so far
:param min_responses: minimal p... | Given a list of statuses from several requests, determine if a
satisfactory number of nodes have responded with 1xx or 2xx statuses to
deem the transaction for a successful response to the client. | [
"Given",
"a",
"list",
"of",
"statuses",
"from",
"several",
"requests",
"determine",
"if",
"a",
"satisfactory",
"number",
"of",
"nodes",
"have",
"responded",
"with",
"1xx",
"or",
"2xx",
"statuses",
"to",
"deem",
"the",
"transaction",
"for",
"a",
"successful",
... | def _have_adequate_responses(
self, statuses, min_responses, conditional_func):
if sum(1 for s in statuses if (conditional_func(s))) >= min_responses:
return True
return False | [
"def",
"_have_adequate_responses",
"(",
"self",
",",
"statuses",
",",
"min_responses",
",",
"conditional_func",
")",
":",
"if",
"sum",
"(",
"1",
"for",
"s",
"in",
"statuses",
"if",
"(",
"conditional_func",
"(",
"s",
")",
")",
")",
">=",
"min_responses",
":... | Given a list of statuses from several requests, determine if a
satisfactory number of nodes have responded with 1xx or 2xx statuses to
deem the transaction for a successful response to the client. | [
"Given",
"a",
"list",
"of",
"statuses",
"from",
"several",
"requests",
"determine",
"if",
"a",
"satisfactory",
"number",
"of",
"nodes",
"have",
"responded",
"with",
"1xx",
"or",
"2xx",
"statuses",
"to",
"deem",
"the",
"transaction",
"for",
"a",
"successful",
... | [
"\"\"\"\n Given a list of statuses from several requests, determine if a\n satisfactory number of nodes have responded with 1xx or 2xx statuses to\n deem the transaction for a successful response to the client.\n\n :param statuses: list of statuses returned so far\n :param min_res... | [
{
"param": "self",
"type": null
},
{
"param": "statuses",
"type": null
},
{
"param": "min_responses",
"type": null
},
{
"param": "conditional_func",
"type": null
}
] | {
"returns": [
{
"docstring": "True or False, depending on current number of successes",
"docstring_tokens": [
"True",
"or",
"False",
"depending",
"on",
"current",
"number",
"of",
"successes"
],
"type": null
}
],... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _have_adequate_successes | <not_specific> | def _have_adequate_successes(self, statuses, min_responses):
"""
Partial method of _have_adequate_responses for 2xx
"""
return self._have_adequate_responses(
statuses, min_responses, is_success) |
Partial method of _have_adequate_responses for 2xx
| Partial method of _have_adequate_responses for 2xx | [
"Partial",
"method",
"of",
"_have_adequate_responses",
"for",
"2xx"
] | def _have_adequate_successes(self, statuses, min_responses):
return self._have_adequate_responses(
statuses, min_responses, is_success) | [
"def",
"_have_adequate_successes",
"(",
"self",
",",
"statuses",
",",
"min_responses",
")",
":",
"return",
"self",
".",
"_have_adequate_responses",
"(",
"statuses",
",",
"min_responses",
",",
"is_success",
")"
] | Partial method of _have_adequate_responses for 2xx | [
"Partial",
"method",
"of",
"_have_adequate_responses",
"for",
"2xx"
] | [
"\"\"\"\n Partial method of _have_adequate_responses for 2xx\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "statuses",
"type": null
},
{
"param": "min_responses",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "statuses",
"type": null,
"docstring": null,
"docstring_tokens... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _have_adequate_informational | <not_specific> | def _have_adequate_informational(self, statuses, min_responses):
"""
Partial method of _have_adequate_responses for 1xx
"""
return self._have_adequate_responses(
statuses, min_responses, is_informational) |
Partial method of _have_adequate_responses for 1xx
| Partial method of _have_adequate_responses for 1xx | [
"Partial",
"method",
"of",
"_have_adequate_responses",
"for",
"1xx"
] | def _have_adequate_informational(self, statuses, min_responses):
return self._have_adequate_responses(
statuses, min_responses, is_informational) | [
"def",
"_have_adequate_informational",
"(",
"self",
",",
"statuses",
",",
"min_responses",
")",
":",
"return",
"self",
".",
"_have_adequate_responses",
"(",
"statuses",
",",
"min_responses",
",",
"is_informational",
")"
] | Partial method of _have_adequate_responses for 1xx | [
"Partial",
"method",
"of",
"_have_adequate_responses",
"for",
"1xx"
] | [
"\"\"\"\n Partial method of _have_adequate_responses for 1xx\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "statuses",
"type": null
},
{
"param": "min_responses",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "statuses",
"type": null,
"docstring": null,
"docstring_tokens... |
510d1ca6770f8d9fb11c5787f2ce60080b0a8740 | cighao/swift-with-comment | swift/proxy/controllers/obj.py | [
"Apache-2.0"
] | Python | _store_object | <not_specific> | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
"""
Store an erasure coded object.
"""
policy_index = int(req.headers.get('X-Backend-Storage-Policy-Index'))
policy = POLICIES.get_by_index(policy_index)
expected_frag_si... |
Store an erasure coded object.
| Store an erasure coded object. | [
"Store",
"an",
"erasure",
"coded",
"object",
"."
] | def _store_object(self, req, data_source, nodes, partition,
outgoing_headers):
policy_index = int(req.headers.get('X-Backend-Storage-Policy-Index'))
policy = POLICIES.get_by_index(policy_index)
expected_frag_size = None
if req.content_length:
num_fragmen... | [
"def",
"_store_object",
"(",
"self",
",",
"req",
",",
"data_source",
",",
"nodes",
",",
"partition",
",",
"outgoing_headers",
")",
":",
"policy_index",
"=",
"int",
"(",
"req",
".",
"headers",
".",
"get",
"(",
"'X-Backend-Storage-Policy-Index'",
")",
")",
"po... | Store an erasure coded object. | [
"Store",
"an",
"erasure",
"coded",
"object",
"."
] | [
"\"\"\"\n Store an erasure coded object.\n \"\"\"",
"# TODO: PyECLib <= 1.2.0 looks to return the segment info",
"# different from the input for aligned data efficiency but",
"# Swift never does. So calculate the fragment length Swift",
"# will actually send to object server by making two diff... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": null
},
{
"param": "data_source",
"type": null
},
{
"param": "nodes",
"type": null
},
{
"param": "partition",
"type": null
},
{
"param": "outgoing_headers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": []... |
3b9ee55e85a85f9b22651a40501ab84f4e95c1a6 | callumparr/TALON-paper-2020 | plotting_scripts/plot_gene_or_transcript_length_by_DE.py | [
"MIT"
] | Python | violin_plot | null | def violin_plot(data, colname, mode, ymax, fname):
""" Plot a violin plot with the length of each read by novelty category"""
sns.set_context("paper", font_scale=1.3)
#ax = sns.stripplot(x='transcript_novelty', y='read_length', data=data, color="grey", jitter = True)
ax = sns.boxplot(x='DE_type', y=co... | Plot a violin plot with the length of each read by novelty category | Plot a violin plot with the length of each read by novelty category | [
"Plot",
"a",
"violin",
"plot",
"with",
"the",
"length",
"of",
"each",
"read",
"by",
"novelty",
"category"
] | def violin_plot(data, colname, mode, ymax, fname):
sns.set_context("paper", font_scale=1.3)
ax = sns.boxplot(x='DE_type', y=colname, data=data, palette = "Blues")
nobs = list(data.groupby("DE_type").size())
nobs = [str(x) for x in nobs]
nobs = ["n=" + i for i in nobs]
ypos = data.groupby(['DE_ty... | [
"def",
"violin_plot",
"(",
"data",
",",
"colname",
",",
"mode",
",",
"ymax",
",",
"fname",
")",
":",
"sns",
".",
"set_context",
"(",
"\"paper\"",
",",
"font_scale",
"=",
"1.3",
")",
"ax",
"=",
"sns",
".",
"boxplot",
"(",
"x",
"=",
"'DE_type'",
",",
... | Plot a violin plot with the length of each read by novelty category | [
"Plot",
"a",
"violin",
"plot",
"with",
"the",
"length",
"of",
"each",
"read",
"by",
"novelty",
"category"
] | [
"\"\"\" Plot a violin plot with the length of each read by novelty category\"\"\"",
"#ax = sns.stripplot(x='transcript_novelty', y='read_length', data=data, color=\"grey\", jitter = True)",
"#add_stat_annotation(ax, data=data, x='DE_type', y=colname,",
"# box_pairs=[(\"Higher in Illumina\", \"H... | [
{
"param": "data",
"type": null
},
{
"param": "colname",
"type": null
},
{
"param": "mode",
"type": null
},
{
"param": "ymax",
"type": null
},
{
"param": "fname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "colname",
"type": null,
"docstring": null,
"docstring_tokens"... |
fa27bd78a3a1643ee8493c82bb94d5e94f1a7685 | callumparr/TALON-paper-2020 | ebv/talon_GTF_2_transcript_bed.py | [
"MIT"
] | Python | create_BED_entry | <not_specific> | def create_BED_entry(gtf_transcript):
""" Given a GTF transcript (in list form), create a BED entry. This entails:
1. Convert coordinates from 1-based to 0-based
2. Extract unique transcript identifier to use in name field
3. Extract other attributes (ie chromosome, strand) """
chromoso... | Given a GTF transcript (in list form), create a BED entry. This entails:
1. Convert coordinates from 1-based to 0-based
2. Extract unique transcript identifier to use in name field
3. Extract other attributes (ie chromosome, strand) | Given a GTF transcript (in list form), create a BED entry. This entails:
1. Convert coordinates from 1-based to 0-based
2. Extract unique transcript identifier to use in name field
3. Extract other attributes | [
"Given",
"a",
"GTF",
"transcript",
"(",
"in",
"list",
"form",
")",
"create",
"a",
"BED",
"entry",
".",
"This",
"entails",
":",
"1",
".",
"Convert",
"coordinates",
"from",
"1",
"-",
"based",
"to",
"0",
"-",
"based",
"2",
".",
"Extract",
"unique",
"tra... | def create_BED_entry(gtf_transcript):
chromosome = gtf_transcript[0]
start_1b = int(gtf_transcript[3])
end_1b = int(gtf_transcript[4])
strand = gtf_transcript[6]
meta = gtf_transcript[-1]
start_0b = start_1b - 1
end_0b = end_1b
transcript_ID = parse_out_transcript_ID(meta)
bed = [ c... | [
"def",
"create_BED_entry",
"(",
"gtf_transcript",
")",
":",
"chromosome",
"=",
"gtf_transcript",
"[",
"0",
"]",
"start_1b",
"=",
"int",
"(",
"gtf_transcript",
"[",
"3",
"]",
")",
"end_1b",
"=",
"int",
"(",
"gtf_transcript",
"[",
"4",
"]",
")",
"strand",
... | Given a GTF transcript (in list form), create a BED entry. | [
"Given",
"a",
"GTF",
"transcript",
"(",
"in",
"list",
"form",
")",
"create",
"a",
"BED",
"entry",
"."
] | [
"\"\"\" Given a GTF transcript (in list form), create a BED entry. This entails:\n 1. Convert coordinates from 1-based to 0-based\n 2. Extract unique transcript identifier to use in name field\n 3. Extract other attributes (ie chromosome, strand) \"\"\"",
"# Convert coords to 0-based",
"# E... | [
{
"param": "gtf_transcript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gtf_transcript",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.