partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
write
Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0
hiddenlayer/utils.py
def write(*args): """Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0 """ s = "" for a in args: # Convert tensors ...
def write(*args): """Like print(), but recognizes tensors and arrays and show more details about them. Example: hl.write("My Tensor", my_tensor) Prints: My Tensor float32 (10, 3, 224, 224) min: 0.0 max: 1.0 """ s = "" for a in args: # Convert tensors ...
[ "Like", "print", "()", "but", "recognizes", "tensors", "and", "arrays", "and", "show", "more", "details", "about", "them", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/utils.py#L38-L64
[ "def", "write", "(", "*", "args", ")", ":", "s", "=", "\"\"", "for", "a", "in", "args", ":", "# Convert tensors to Numpy arrays", "a", "=", "to_data", "(", "a", ")", "if", "isinstance", "(", "a", ",", "np", ".", "ndarray", ")", ":", "# Numpy Array", ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
norm
Normalize an image to [0, 1] range.
hiddenlayer/canvas.py
def norm(image): """Normalize an image to [0, 1] range.""" min_value = image.min() max_value = image.max() if min_value == max_value: return image - min_value return (image - min_value) / (max_value - min_value)
def norm(image): """Normalize an image to [0, 1] range.""" min_value = image.min() max_value = image.max() if min_value == max_value: return image - min_value return (image - min_value) / (max_value - min_value)
[ "Normalize", "an", "image", "to", "[", "0", "1", "]", "range", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L27-L33
[ "def", "norm", "(", "image", ")", ":", "min_value", "=", "image", ".", "min", "(", ")", "max_value", "=", "image", ".", "max", "(", ")", "if", "min_value", "==", "max_value", ":", "return", "image", "-", "min_value", "return", "(", "image", "-", "min...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
show_images
images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image.
hiddenlayer/canvas.py
def show_images(images, titles=None, cols=5, **kwargs): """ images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image. """ ...
def show_images(images, titles=None, cols=5, **kwargs): """ images: A list of images. I can be either: - A list of Numpy arrays. Each array represents an image. - A list of lists of Numpy arrays. In this case, the images in the inner lists are concatentated to make one image. """ ...
[ "images", ":", "A", "list", "of", "images", ".", "I", "can", "be", "either", ":", "-", "A", "list", "of", "Numpy", "arrays", ".", "Each", "array", "represents", "an", "image", ".", "-", "A", "list", "of", "lists", "of", "Numpy", "arrays", ".", "In"...
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L37-L63
[ "def", "show_images", "(", "images", ",", "titles", "=", "None", ",", "cols", "=", "5", ",", "*", "*", "kwargs", ")", ":", "# The images param can be a list or an array", "titles", "=", "titles", "or", "[", "\"\"", "]", "*", "len", "(", "images", ")", "r...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
Canvas.draw_summary
Inserts a text summary at the top that lists the number of steps and total training time.
hiddenlayer/canvas.py
def draw_summary(self, history, title=""): """Inserts a text summary at the top that lists the number of steps and total training time.""" # Generate summary string time_str = str(history.get_total_time()).split(".")[0] # remove microseconds summary = "Step: {} Time: {}".fo...
def draw_summary(self, history, title=""): """Inserts a text summary at the top that lists the number of steps and total training time.""" # Generate summary string time_str = str(history.get_total_time()).split(".")[0] # remove microseconds summary = "Step: {} Time: {}".fo...
[ "Inserts", "a", "text", "summary", "at", "the", "top", "that", "lists", "the", "number", "of", "steps", "and", "total", "training", "time", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L161-L169
[ "def", "draw_summary", "(", "self", ",", "history", ",", "title", "=", "\"\"", ")", ":", "# Generate summary string", "time_str", "=", "str", "(", "history", ".", "get_total_time", "(", ")", ")", ".", "split", "(", "\".\"", ")", "[", "0", "]", "# remove ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
Canvas.draw_plot
metrics: One or more metrics parameters. Each represents the history of one metric.
hiddenlayer/canvas.py
def draw_plot(self, metrics, labels=None, ylabel=""): """ metrics: One or more metrics parameters. Each represents the history of one metric. """ metrics = metrics if isinstance(metrics, list) else [metrics] # Loop through metrics title = "" for i, m i...
def draw_plot(self, metrics, labels=None, ylabel=""): """ metrics: One or more metrics parameters. Each represents the history of one metric. """ metrics = metrics if isinstance(metrics, list) else [metrics] # Loop through metrics title = "" for i, m i...
[ "metrics", ":", "One", "or", "more", "metrics", "parameters", ".", "Each", "represents", "the", "history", "of", "one", "metric", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L171-L188
[ "def", "draw_plot", "(", "self", ",", "metrics", ",", "labels", "=", "None", ",", "ylabel", "=", "\"\"", ")", ":", "metrics", "=", "metrics", "if", "isinstance", "(", "metrics", ",", "list", ")", "else", "[", "metrics", "]", "# Loop through metrics", "ti...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
Canvas.draw_image
Display a series of images at different time steps.
hiddenlayer/canvas.py
def draw_image(self, metric, limit=5): """Display a series of images at different time steps.""" rows = 1 cols = limit self.ax.axis("off") # Take the Axes gridspec and divide it into a grid gs = matplotlib.gridspec.GridSpecFromSubplotSpec( rows, cols, subplot_...
def draw_image(self, metric, limit=5): """Display a series of images at different time steps.""" rows = 1 cols = limit self.ax.axis("off") # Take the Axes gridspec and divide it into a grid gs = matplotlib.gridspec.GridSpecFromSubplotSpec( rows, cols, subplot_...
[ "Display", "a", "series", "of", "images", "at", "different", "time", "steps", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L191-L204
[ "def", "draw_image", "(", "self", ",", "metric", ",", "limit", "=", "5", ")", ":", "rows", "=", "1", "cols", "=", "limit", "self", ".", "ax", ".", "axis", "(", "\"off\"", ")", "# Take the Axes gridspec and divide it into a grid", "gs", "=", "matplotlib", "...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
Canvas.draw_hist
Draw a series of histograms of the selected keys over different training steps.
hiddenlayer/canvas.py
def draw_hist(self, metric, title=""): """Draw a series of histograms of the selected keys over different training steps. """ # TODO: assert isinstance(list(values.values())[0], np.ndarray) rows = 1 cols = 1 limit = 10 # max steps to show # We need a 3D...
def draw_hist(self, metric, title=""): """Draw a series of histograms of the selected keys over different training steps. """ # TODO: assert isinstance(list(values.values())[0], np.ndarray) rows = 1 cols = 1 limit = 10 # max steps to show # We need a 3D...
[ "Draw", "a", "series", "of", "histograms", "of", "the", "selected", "keys", "over", "different", "training", "steps", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/canvas.py#L206-L257
[ "def", "draw_hist", "(", "self", ",", "metric", ",", "title", "=", "\"\"", ")", ":", "# TODO: assert isinstance(list(values.values())[0], np.ndarray)", "rows", "=", "1", "cols", "=", "1", "limit", "=", "10", "# max steps to show", "# We need a 3D projection Subplot, so ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
CIFAR10._load
Load the data in memory. Args: dataset: string in ['train', 'test']
demos/tf_cifar10.py
def _load(self, dataset='train'): """Load the data in memory. Args: dataset: string in ['train', 'test'] """ data, labels = None, None if dataset is 'train': files = [os.path.join(self.cifar10_dir, 'data_batch_%d' % i) for i in range(1, 6)] else: ...
def _load(self, dataset='train'): """Load the data in memory. Args: dataset: string in ['train', 'test'] """ data, labels = None, None if dataset is 'train': files = [os.path.join(self.cifar10_dir, 'data_batch_%d' % i) for i in range(1, 6)] else: ...
[ "Load", "the", "data", "in", "memory", ".", "Args", ":", "dataset", ":", "string", "in", "[", "train", "test", "]" ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L78-L119
[ "def", "_load", "(", "self", ",", "dataset", "=", "'train'", ")", ":", "data", ",", "labels", "=", "None", ",", "None", "if", "dataset", "is", "'train'", ":", "files", "=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "cifar10_dir", ",", ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
CIFAR10.model
Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: Best score Step: 7015 - Epoch: 18/20 ...
demos/tf_cifar10.py
def model(self, inputs, mode='train'): """Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: ...
def model(self, inputs, mode='train'): """Build a simple convnet (BN before ReLU). Args: inputs: a tensor of size [batch_size, height, width, channels] mode: string in ['train', 'test'] Returns: the last op containing the predictions Note: ...
[ "Build", "a", "simple", "convnet", "(", "BN", "before", "ReLU", ")", ".", "Args", ":", "inputs", ":", "a", "tensor", "of", "size", "[", "batch_size", "height", "width", "channels", "]", "mode", ":", "string", "in", "[", "train", "test", "]", "Returns",...
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L121-L169
[ "def", "model", "(", "self", ",", "inputs", ",", "mode", "=", "'train'", ")", ":", "# Extract features", "training", "=", "(", "mode", "==", "'train'", ")", "with", "tf", ".", "variable_scope", "(", "'conv1'", ")", "as", "scope", ":", "conv", "=", "tf"...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
CIFAR10.maybe_download_and_extract
Download and extract the tarball from Alex Krizhevsky's website.
demos/tf_cifar10.py
def maybe_download_and_extract(self): """Download and extract the tarball from Alex Krizhevsky's website.""" if not os.path.exists(self.cifar10_dir): if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) def _progress(count, block_size, total_size): ...
def maybe_download_and_extract(self): """Download and extract the tarball from Alex Krizhevsky's website.""" if not os.path.exists(self.cifar10_dir): if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) def _progress(count, block_size, total_size): ...
[ "Download", "and", "extract", "the", "tarball", "from", "Alex", "Krizhevsky", "s", "website", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/demos/tf_cifar10.py#L215-L232
[ "def", "maybe_download_and_extract", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "cifar10_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "data_dir", ")", ":", "os", ".", ...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
dump_pytorch_graph
List all the nodes in a PyTorch graph.
hiddenlayer/pytorch_builder.py
def dump_pytorch_graph(graph): """List all the nodes in a PyTorch graph.""" f = "{:25} {:40} {} -> {}" print(f.format("kind", "scopeName", "inputs", "outputs")) for node in graph.nodes(): print(f.format(node.kind(), node.scopeName(), [i.unique() for i in node.inputs()], ...
def dump_pytorch_graph(graph): """List all the nodes in a PyTorch graph.""" f = "{:25} {:40} {} -> {}" print(f.format("kind", "scopeName", "inputs", "outputs")) for node in graph.nodes(): print(f.format(node.kind(), node.scopeName(), [i.unique() for i in node.inputs()], ...
[ "List", "all", "the", "nodes", "in", "a", "PyTorch", "graph", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L30-L38
[ "def", "dump_pytorch_graph", "(", "graph", ")", ":", "f", "=", "\"{:25} {:40} {} -> {}\"", "print", "(", "f", ".", "format", "(", "\"kind\"", ",", "\"scopeName\"", ",", "\"inputs\"", ",", "\"outputs\"", ")", ")", "for", "node", "in", "graph", ".", "nodes",...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
pytorch_id
Returns a unique ID for a node.
hiddenlayer/pytorch_builder.py
def pytorch_id(node): """Returns a unique ID for a node.""" # After ONNX simplification, the scopeName is not unique anymore # so append node outputs to guarantee uniqueness return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
def pytorch_id(node): """Returns a unique ID for a node.""" # After ONNX simplification, the scopeName is not unique anymore # so append node outputs to guarantee uniqueness return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
[ "Returns", "a", "unique", "ID", "for", "a", "node", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L41-L45
[ "def", "pytorch_id", "(", "node", ")", ":", "# After ONNX simplification, the scopeName is not unique anymore", "# so append node outputs to guarantee uniqueness", "return", "node", ".", "scopeName", "(", ")", "+", "\"/outputs/\"", "+", "\"/\"", ".", "join", "(", "[", "o"...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
get_shape
Return the output shape of the given Pytorch node.
hiddenlayer/pytorch_builder.py
def get_shape(torch_node): """Return the output shape of the given Pytorch node.""" # Extract node output shape from the node string representation # This is a hack because there doesn't seem to be an official way to do it. # See my quesiton in the PyTorch forum: # https://discuss.pytorch.org/t/node...
def get_shape(torch_node): """Return the output shape of the given Pytorch node.""" # Extract node output shape from the node string representation # This is a hack because there doesn't seem to be an official way to do it. # See my quesiton in the PyTorch forum: # https://discuss.pytorch.org/t/node...
[ "Return", "the", "output", "shape", "of", "the", "given", "Pytorch", "node", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/pytorch_builder.py#L48-L63
[ "def", "get_shape", "(", "torch_node", ")", ":", "# Extract node output shape from the node string representation", "# This is a hack because there doesn't seem to be an official way to do it.", "# See my quesiton in the PyTorch forum:", "# https://discuss.pytorch.org/t/node-output-shape-from-trac...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
dump_tf_graph
List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object.
hiddenlayer/tf_builder.py
def dump_tf_graph(tfgraph, tfgraphdef): """List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object. """ print("Nodes ({})".format(len(tfgraphdef.node))) f = "{:15} {:59} {:20} {}" print(f.format("kind", "scopeName", "shape", "inputs")) for node in t...
def dump_tf_graph(tfgraph, tfgraphdef): """List all the nodes in a TF graph. tfgraph: A TF Graph object. tfgraphdef: A TF GraphDef object. """ print("Nodes ({})".format(len(tfgraphdef.node))) f = "{:15} {:59} {:20} {}" print(f.format("kind", "scopeName", "shape", "inputs")) for node in t...
[ "List", "all", "the", "nodes", "in", "a", "TF", "graph", ".", "tfgraph", ":", "A", "TF", "Graph", "object", ".", "tfgraphdef", ":", "A", "TF", "GraphDef", "object", "." ]
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/tf_builder.py#L46-L59
[ "def", "dump_tf_graph", "(", "tfgraph", ",", "tfgraphdef", ")", ":", "print", "(", "\"Nodes ({})\"", ".", "format", "(", "len", "(", "tfgraphdef", ".", "node", ")", ")", ")", "f", "=", "\"{:15} {:59} {:20} {}\"", "print", "(", "f", ".", "format", "(", "\...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
import_graph
Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output
hiddenlayer/tf_builder.py
def import_graph(hl_graph, tf_graph, output=None, verbose=False): """Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output """ # Get clean(er) list of nodes graph_def = tf_graph.as_graph_def(add_sh...
def import_graph(hl_graph, tf_graph, output=None, verbose=False): """Convert TF graph to directed graph tfgraph: A TF Graph object. output: Name of the output node (string). verbose: Set to True for debug print output """ # Get clean(er) list of nodes graph_def = tf_graph.as_graph_def(add_sh...
[ "Convert", "TF", "graph", "to", "directed", "graph", "tfgraph", ":", "A", "TF", "Graph", "object", ".", "output", ":", "Name", "of", "the", "output", "node", "(", "string", ")", ".", "verbose", ":", "Set", "to", "True", "for", "debug", "print", "output...
waleedka/hiddenlayer
python
https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/tf_builder.py#L62-L95
[ "def", "import_graph", "(", "hl_graph", ",", "tf_graph", ",", "output", "=", "None", ",", "verbose", "=", "False", ")", ":", "# Get clean(er) list of nodes", "graph_def", "=", "tf_graph", ".", "as_graph_def", "(", "add_shapes", "=", "True", ")", "graph_def", "...
294f8732b271cbdd6310c55bdf5ce855cbf61c75
train
Fetcher.send_fetches
Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse
kafka/consumer/fetcher.py
def send_fetches(self): """Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse """ futures = [] for node_id, request in six.iterite...
def send_fetches(self): """Send FetchRequests for all assigned partitions that do not already have an in-flight fetch or pending fetch data. Returns: List of Futures: each future resolves to a FetchResponse """ futures = [] for node_id, request in six.iterite...
[ "Send", "FetchRequests", "for", "all", "assigned", "partitions", "that", "do", "not", "already", "have", "an", "in", "-", "flight", "fetch", "or", "pending", "fetch", "data", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L115-L132
[ "def", "send_fetches", "(", "self", ")", ":", "futures", "=", "[", "]", "for", "node_id", ",", "request", "in", "six", ".", "iteritems", "(", "self", ".", "_create_fetch_requests", "(", ")", ")", ":", "if", "self", ".", "_client", ".", "ready", "(", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher.reset_offsets_if_needed
Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset
kafka/consumer/fetcher.py
def reset_offsets_if_needed(self, partitions): """Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset """ for tp in partitions: # TODO: If there are severa...
def reset_offsets_if_needed(self, partitions): """Lookup and set offsets for any partitions which are awaiting an explicit reset. Arguments: partitions (set of TopicPartitions): the partitions to reset """ for tp in partitions: # TODO: If there are severa...
[ "Lookup", "and", "set", "offsets", "for", "any", "partitions", "which", "are", "awaiting", "an", "explicit", "reset", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L134-L144
[ "def", "reset_offsets_if_needed", "(", "self", ",", "partitions", ")", ":", "for", "tp", "in", "partitions", ":", "# TODO: If there are several offsets to reset, we could submit offset requests in parallel", "if", "self", ".", "_subscriptions", ".", "is_assigned", "(", "tp"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher.update_fetch_positions
Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition and no reset policy is available
kafka/consumer/fetcher.py
def update_fetch_positions(self, partitions): """Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition...
def update_fetch_positions(self, partitions): """Update the fetch positions for the provided partitions. Arguments: partitions (list of TopicPartitions): partitions to update Raises: NoOffsetForPartitionError: if no offset is stored for a given partition...
[ "Update", "the", "fetch", "positions", "for", "the", "provided", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L159-L191
[ "def", "update_fetch_positions", "(", "self", ",", "partitions", ")", ":", "# reset the fetch position to the committed position", "for", "tp", "in", "partitions", ":", "if", "not", "self", ".", "_subscriptions", ".", "is_assigned", "(", "tp", ")", ":", "log", "."...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._reset_offset
Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined
kafka/consumer/fetcher.py
def _reset_offset(self, partition): """Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined "...
def _reset_offset(self, partition): """Reset offsets for the given partition using the offset reset strategy. Arguments: partition (TopicPartition): the partition that needs reset offset Raises: NoOffsetForPartitionError: if no offset reset strategy is defined "...
[ "Reset", "offsets", "for", "the", "given", "partition", "using", "the", "offset", "reset", "strategy", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L218-L245
[ "def", "_reset_offset", "(", "self", ",", "partition", ")", ":", "timestamp", "=", "self", ".", "_subscriptions", ".", "assignment", "[", "partition", "]", ".", "reset_strategy", "if", "timestamp", "is", "OffsetResetStrategy", ".", "EARLIEST", ":", "strategy", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._retrieve_offsets
Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} dict with timestamps to fetch offsets by. -1 for the latest av...
kafka/consumer/fetcher.py
def _retrieve_offsets(self, timestamps, timeout_ms=float("inf")): """Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} d...
def _retrieve_offsets(self, timestamps, timeout_ms=float("inf")): """Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} d...
[ "Fetch", "offset", "for", "each", "partition", "passed", "in", "timestamps", "map", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L247-L293
[ "def", "_retrieve_offsets", "(", "self", ",", "timestamps", ",", "timeout_ms", "=", "float", "(", "\"inf\"", ")", ")", ":", "if", "not", "timestamps", ":", "return", "{", "}", "start_time", "=", "time", ".", "time", "(", ")", "remaining_ms", "=", "timeou...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher.fetched_records
Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: if no subscription offset_reset_strategy Cor...
kafka/consumer/fetcher.py
def fetched_records(self, max_records=None): """Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: ...
def fetched_records(self, max_records=None): """Returns previously fetched records and updates consumed offsets. Arguments: max_records (int): Maximum number of records returned. Defaults to max_poll_records configuration. Raises: OffsetOutOfRangeError: ...
[ "Returns", "previously", "fetched", "records", "and", "updates", "consumed", "offsets", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L295-L334
[ "def", "fetched_records", "(", "self", ",", "max_records", "=", "None", ")", ":", "if", "max_records", "is", "None", ":", "max_records", "=", "self", ".", "config", "[", "'max_poll_records'", "]", "assert", "max_records", ">", "0", "drained", "=", "collectio...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._message_generator
Iterate over fetched_records
kafka/consumer/fetcher.py
def _message_generator(self): """Iterate over fetched_records""" while self._next_partition_records or self._completed_fetches: if not self._next_partition_records: completion = self._completed_fetches.popleft() self._next_partition_records = self._parse_fetc...
def _message_generator(self): """Iterate over fetched_records""" while self._next_partition_records or self._completed_fetches: if not self._next_partition_records: completion = self._completed_fetches.popleft() self._next_partition_records = self._parse_fetc...
[ "Iterate", "over", "fetched_records" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L382-L436
[ "def", "_message_generator", "(", "self", ")", ":", "while", "self", ".", "_next_partition_records", "or", "self", ".", "_completed_fetches", ":", "if", "not", "self", ".", "_next_partition_records", ":", "completion", "=", "self", ".", "_completed_fetches", ".", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._send_offset_requests
Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. Returns: Future: resolves to a mapping...
kafka/consumer/fetcher.py
def _send_offset_requests(self, timestamps): """Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. ...
def _send_offset_requests(self, timestamps): """Fetch offsets for each partition in timestamps dict. This may send request to multiple nodes, based on who is Leader for partition. Arguments: timestamps (dict): {TopicPartition: int} mapping of fetching timestamps. ...
[ "Fetch", "offsets", "for", "each", "partition", "in", "timestamps", "dict", ".", "This", "may", "send", "request", "to", "multiple", "nodes", "based", "on", "who", "is", "Leader", "for", "partition", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L494-L542
[ "def", "_send_offset_requests", "(", "self", ",", "timestamps", ")", ":", "timestamps_by_node", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "partition", ",", "timestamp", "in", "six", ".", "iteritems", "(", "timestamps", ")", ":", "node_id...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._handle_offset_response
Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if response does not match partition
kafka/consumer/fetcher.py
def _handle_offset_response(self, future, response): """Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if...
def _handle_offset_response(self, future, response): """Callback for the response of the list offset call above. Arguments: future (Future): the future to update based on response response (OffsetResponse): response from the server Raises: AssertionError: if...
[ "Callback", "for", "the", "response", "of", "the", "list", "offset", "call", "above", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L568-L627
[ "def", "_handle_offset_response", "(", "self", ",", "future", ",", "response", ")", ":", "timestamp_offset_map", "=", "{", "}", "for", "topic", ",", "part_data", "in", "response", ".", "topics", ":", "for", "partition_info", "in", "part_data", ":", "partition"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._create_fetch_requests
Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version)
kafka/consumer/fetcher.py
def _create_fetch_requests(self): """Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version) """ # create the ...
def _create_fetch_requests(self): """Create fetch requests for all assigned partitions, grouped by node. FetchRequests skipped if no leader, or node has requests in flight Returns: dict: {node_id: FetchRequest, ...} (version depends on api_version) """ # create the ...
[ "Create", "fetch", "requests", "for", "all", "assigned", "partitions", "grouped", "by", "node", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L640-L729
[ "def", "_create_fetch_requests", "(", "self", ")", ":", "# create the fetch info as a dict of lists of partition info tuples", "# which can be passed to FetchRequest() via .items()", "fetchable", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "collections", ".", "def...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Fetcher._handle_fetch_response
The callback for fetch completion
kafka/consumer/fetcher.py
def _handle_fetch_response(self, request, send_time, response): """The callback for fetch completion""" fetch_offsets = {} for topic, partitions in request.topics: for partition_data in partitions: partition, offset = partition_data[:2] fetch_offsets[T...
def _handle_fetch_response(self, request, send_time, response): """The callback for fetch completion""" fetch_offsets = {} for topic, partitions in request.topics: for partition_data in partitions: partition, offset = partition_data[:2] fetch_offsets[T...
[ "The", "callback", "for", "fetch", "completion" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L731-L760
[ "def", "_handle_fetch_response", "(", "self", ",", "request", ",", "send_time", ",", "response", ")", ":", "fetch_offsets", "=", "{", "}", "for", "topic", ",", "partitions", "in", "request", ".", "topics", ":", "for", "partition_data", "in", "partitions", ":...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
FetchResponseMetricAggregator.record
After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric.
kafka/consumer/fetcher.py
def record(self, partition, num_bytes, num_records): """ After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric. """ self.unrecorded_partitions.remove(p...
def record(self, partition, num_bytes, num_records): """ After each partition is parsed, we update the current metric totals with the total bytes and number of records parsed. After all partitions have reported, we write the metric. """ self.unrecorded_partitions.remove(p...
[ "After", "each", "partition", "is", "parsed", "we", "update", "the", "current", "metric", "totals", "with", "the", "total", "bytes", "and", "number", "of", "records", "parsed", ".", "After", "all", "partitions", "have", "reported", "we", "write", "the", "met...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L906-L919
[ "def", "record", "(", "self", ",", "partition", ",", "num_bytes", ",", "num_records", ")", ":", "self", ".", "unrecorded_partitions", ".", "remove", "(", "partition", ")", "self", ".", "total_bytes", "+=", "num_bytes", "self", ".", "total_records", "+=", "nu...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Consumer._auto_commit
Check if we have to commit based on number of messages and commit
kafka/consumer/base.py
def _auto_commit(self): """ Check if we have to commit based on number of messages and commit """ # Check if we are supposed to do an auto-commit if not self.auto_commit or self.auto_commit_every_n is None: return if self.count_since_commit >= self.auto_comm...
def _auto_commit(self): """ Check if we have to commit based on number of messages and commit """ # Check if we are supposed to do an auto-commit if not self.auto_commit or self.auto_commit_every_n is None: return if self.count_since_commit >= self.auto_comm...
[ "Check", "if", "we", "have", "to", "commit", "based", "on", "number", "of", "messages", "and", "commit" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/base.py#L172-L182
[ "def", "_auto_commit", "(", "self", ")", ":", "# Check if we are supposed to do an auto-commit", "if", "not", "self", ".", "auto_commit", "or", "self", ".", "auto_commit_every_n", "is", "None", ":", "return", "if", "self", ".", "count_since_commit", ">=", "self", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Consumer.pending
Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all
kafka/consumer/base.py
def pending(self, partitions=None): """ Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all """ if partitions is None: partitions = self.offsets.keys() total = 0 re...
def pending(self, partitions=None): """ Gets the pending message count Keyword Arguments: partitions (list): list of partitions to check for, default is to check all """ if partitions is None: partitions = self.offsets.keys() total = 0 re...
[ "Gets", "the", "pending", "message", "count" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/base.py#L209-L232
[ "def", "pending", "(", "self", ",", "partitions", "=", "None", ")", ":", "if", "partitions", "is", "None", ":", "partitions", "=", "self", ".", "offsets", ".", "keys", "(", ")", "total", "=", "0", "reqs", "=", "[", "]", "for", "partition", "in", "p...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
murmur2
Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data
kafka/partitioner/hashed.py
def murmur2(data): """Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data """ # Python2 bytes is really a str, causing the bitwise operations below to fail # so conv...
def murmur2(data): """Pure-python Murmur2 implementation. Based on java client, see org.apache.kafka.common.utils.Utils.murmur2 Args: data (bytes): opaque bytes Returns: MurmurHash2 of data """ # Python2 bytes is really a str, causing the bitwise operations below to fail # so conv...
[ "Pure", "-", "python", "Murmur2", "implementation", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/partitioner/hashed.py#L52-L118
[ "def", "murmur2", "(", "data", ")", ":", "# Python2 bytes is really a str, causing the bitwise operations below to fail", "# so convert to bytearray.", "if", "six", ".", "PY2", ":", "data", "=", "bytearray", "(", "bytes", "(", "data", ")", ")", "length", "=", "len", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
MultiProcessConsumer.get_messages
Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block is a positive integer the API will block until that many mes...
kafka/consumer/multiprocess.py
def get_messages(self, count=1, block=True, timeout=10): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block...
def get_messages(self, count=1, block=True, timeout=10): """ Fetch the specified number of messages Keyword Arguments: count: Indicates the maximum number of messages to be fetched block: If True, the API will block till all messages are fetched. If block...
[ "Fetch", "the", "specified", "number", "of", "messages" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/multiprocess.py#L238-L295
[ "def", "get_messages", "(", "self", ",", "count", "=", "1", ",", "block", "=", "True", ",", "timeout", "=", "10", ")", ":", "messages", "=", "[", "]", "# Give a size hint to the consumers. Each consumer process will fetch", "# a maximum of \"count\" messages. This will ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
OffsetCommitContext.mark
Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info()
kafka/context.py
def mark(self, partition, offset): """ Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info() """ ...
def mark(self, partition, offset): """ Set the high-water mark in the current context. In order to know the current partition, it is helpful to initialize the consumer to provide partition info via: .. code:: python consumer.provide_partition_info() """ ...
[ "Set", "the", "high", "-", "water", "mark", "in", "the", "current", "context", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L58-L75
[ "def", "mark", "(", "self", ",", "partition", ",", "offset", ")", ":", "max_offset", "=", "max", "(", "offset", "+", "1", ",", "self", ".", "high_water_mark", ".", "get", "(", "partition", ",", "0", ")", ")", "self", ".", "logger", ".", "debug", "(...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
OffsetCommitContext.commit
Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets.
kafka/context.py
def commit(self): """ Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets. """ if self.high_water_mark: sel...
def commit(self): """ Commit this context's offsets: - If the high-water mark has moved, commit up to and position the consumer at the high-water mark. - Otherwise, reset to the consumer to the initial offsets. """ if self.high_water_mark: sel...
[ "Commit", "this", "context", "s", "offsets", ":" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L114-L127
[ "def", "commit", "(", "self", ")", ":", "if", "self", ".", "high_water_mark", ":", "self", ".", "logger", ".", "info", "(", "\"Committing offsets: %s\"", ",", "self", ".", "high_water_mark", ")", "self", ".", "commit_partition_offsets", "(", "self", ".", "hi...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
OffsetCommitContext.rollback
Rollback this context: - Position the consumer at the initial offsets.
kafka/context.py
def rollback(self): """ Rollback this context: - Position the consumer at the initial offsets. """ self.logger.info("Rolling back context: %s", self.initial_offsets) self.update_consumer_offsets(self.initial_offsets)
def rollback(self): """ Rollback this context: - Position the consumer at the initial offsets. """ self.logger.info("Rolling back context: %s", self.initial_offsets) self.update_consumer_offsets(self.initial_offsets)
[ "Rollback", "this", "context", ":" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L129-L136
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Rolling back context: %s\"", ",", "self", ".", "initial_offsets", ")", "self", ".", "update_consumer_offsets", "(", "self", ".", "initial_offsets", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
OffsetCommitContext.commit_partition_offsets
Commit explicit partition/offset pairs.
kafka/context.py
def commit_partition_offsets(self, partition_offsets): """ Commit explicit partition/offset pairs. """ self.logger.debug("Committing partition offsets: %s", partition_offsets) commit_requests = [ OffsetCommitRequestPayload(self.consumer.topic, partition, offset, None...
def commit_partition_offsets(self, partition_offsets): """ Commit explicit partition/offset pairs. """ self.logger.debug("Committing partition offsets: %s", partition_offsets) commit_requests = [ OffsetCommitRequestPayload(self.consumer.topic, partition, offset, None...
[ "Commit", "explicit", "partition", "/", "offset", "pairs", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L138-L153
[ "def", "commit_partition_offsets", "(", "self", ",", "partition_offsets", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Committing partition offsets: %s\"", ",", "partition_offsets", ")", "commit_requests", "=", "[", "OffsetCommitRequestPayload", "(", "self", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
OffsetCommitContext.update_consumer_offsets
Update consumer offsets to explicit positions.
kafka/context.py
def update_consumer_offsets(self, partition_offsets): """ Update consumer offsets to explicit positions. """ self.logger.debug("Updating consumer offsets to: %s", partition_offsets) for partition, offset in partition_offsets.items(): self.consumer.offsets[partition] ...
def update_consumer_offsets(self, partition_offsets): """ Update consumer offsets to explicit positions. """ self.logger.debug("Updating consumer offsets to: %s", partition_offsets) for partition, offset in partition_offsets.items(): self.consumer.offsets[partition] ...
[ "Update", "consumer", "offsets", "to", "explicit", "positions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/context.py#L155-L167
[ "def", "update_consumer_offsets", "(", "self", ",", "partition_offsets", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Updating consumer offsets to: %s\"", ",", "partition_offsets", ")", "for", "partition", ",", "offset", "in", "partition_offsets", ".", "it...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.coordinator
Get the current coordinator Returns: the current coordinator id or None if it is unknown
kafka/coordinator/base.py
def coordinator(self): """Get the current coordinator Returns: the current coordinator id or None if it is unknown """ if self.coordinator_id is None: return None elif self._client.is_disconnected(self.coordinator_id): self.coordinator_dead('Node Disconne...
def coordinator(self): """Get the current coordinator Returns: the current coordinator id or None if it is unknown """ if self.coordinator_id is None: return None elif self._client.is_disconnected(self.coordinator_id): self.coordinator_dead('Node Disconne...
[ "Get", "the", "current", "coordinator" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L229-L240
[ "def", "coordinator", "(", "self", ")", ":", "if", "self", ".", "coordinator_id", "is", "None", ":", "return", "None", "elif", "self", ".", "_client", ".", "is_disconnected", "(", "self", ".", "coordinator_id", ")", ":", "self", ".", "coordinator_dead", "(...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.ensure_coordinator_ready
Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue).
kafka/coordinator/base.py
def ensure_coordinator_ready(self): """Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue). """ with self._client._lock, self._lock: while self.coordinator_unknown(): # Prior to 0.8.2 there w...
def ensure_coordinator_ready(self): """Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue). """ with self._client._lock, self._lock: while self.coordinator_unknown(): # Prior to 0.8.2 there w...
[ "Block", "until", "the", "coordinator", "for", "this", "group", "is", "known", "(", "and", "we", "have", "an", "active", "connection", "--", "java", "client", "uses", "unsent", "queue", ")", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L242-L270
[ "def", "ensure_coordinator_ready", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "while", "self", ".", "coordinator_unknown", "(", ")", ":", "# Prior to 0.8.2 there was no group coordinator", "# so we will just ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.poll_heartbeat
Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time longer than the provided rebalance tim...
kafka/coordinator/base.py
def poll_heartbeat(self): """ Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time ...
def poll_heartbeat(self): """ Check the status of the heartbeat thread (if it is active) and indicate the liveness of the client. This must be called periodically after joining with :meth:`.ensure_active_group` to ensure that the member stays in the group. If an interval of time ...
[ "Check", "the", "status", "of", "the", "heartbeat", "thread", "(", "if", "it", "is", "active", ")", "and", "indicate", "the", "liveness", "of", "the", "client", ".", "This", "must", "be", "called", "periodically", "after", "joining", "with", ":", "meth", ...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L297-L321
[ "def", "poll_heartbeat", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_heartbeat_thread", "is", "not", "None", ":", "if", "self", ".", "_heartbeat_thread", ".", "failed", ":", "# set the heartbeat thread to None and raise an except...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.ensure_active_group
Ensure that the group is active (i.e. joined and synced)
kafka/coordinator/base.py
def ensure_active_group(self): """Ensure that the group is active (i.e. joined and synced)""" with self._client._lock, self._lock: if self._heartbeat_thread is None: self._start_heartbeat_thread() while self.need_rejoin() or self._rejoin_incomplete(): ...
def ensure_active_group(self): """Ensure that the group is active (i.e. joined and synced)""" with self._client._lock, self._lock: if self._heartbeat_thread is None: self._start_heartbeat_thread() while self.need_rejoin() or self._rejoin_incomplete(): ...
[ "Ensure", "that", "the", "group", "is", "active", "(", "i", ".", "e", ".", "joined", "and", "synced", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L343-L423
[ "def", "ensure_active_group", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "if", "self", ".", "_heartbeat_thread", "is", "None", ":", "self", ".", "_start_heartbeat_thread", "(", ")", "while", "self",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator._send_join_group_request
Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the encoded-bytes assignment returned from the ...
kafka/coordinator/base.py
def _send_join_group_request(self): """Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the enc...
def _send_join_group_request(self): """Join the group and return the assignment for the next generation. This function handles both JoinGroup and SyncGroup, delegating to :meth:`._perform_assignment` if elected leader by the coordinator. Returns: Future: resolves to the enc...
[ "Join", "the", "group", "and", "return", "the", "assignment", "for", "the", "next", "generation", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L428-L485
[ "def", "_send_join_group_request", "(", "self", ")", ":", "if", "self", ".", "coordinator_unknown", "(", ")", ":", "e", "=", "Errors", ".", "GroupCoordinatorNotAvailableError", "(", "self", ".", "coordinator_id", ")", "return", "Future", "(", ")", ".", "failur...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator._on_join_leader
Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-bytes
kafka/coordinator/base.py
def _on_join_leader(self, response): """ Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-by...
def _on_join_leader(self, response): """ Perform leader synchronization and send back the assignment for the group via SyncGroupRequest Arguments: response (JoinResponse): broker response to parse Returns: Future: resolves to member assignment encoded-by...
[ "Perform", "leader", "synchronization", "and", "send", "back", "the", "assignment", "for", "the", "group", "via", "SyncGroupRequest" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L569-L598
[ "def", "_on_join_leader", "(", "self", ",", "response", ")", ":", "try", ":", "group_assignment", "=", "self", ".", "_perform_assignment", "(", "response", ".", "leader_id", ",", "response", ".", "group_protocol", ",", "response", ".", "members", ")", "except"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator._send_group_coordinator_request
Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator
kafka/coordinator/base.py
def _send_group_coordinator_request(self): """Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator """ node_id = self._client.least_loaded_node() if node_id is None: return Future().failure(Errors.NoB...
def _send_group_coordinator_request(self): """Discover the current coordinator for the group. Returns: Future: resolves to the node id of the coordinator """ node_id = self._client.least_loaded_node() if node_id is None: return Future().failure(Errors.NoB...
[ "Discover", "the", "current", "coordinator", "for", "the", "group", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L650-L671
[ "def", "_send_group_coordinator_request", "(", "self", ")", ":", "node_id", "=", "self", ".", "_client", ".", "least_loaded_node", "(", ")", "if", "node_id", "is", "None", ":", "return", "Future", "(", ")", ".", "failure", "(", "Errors", ".", "NoBrokersAvail...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.coordinator_dead
Mark the current coordinator as dead.
kafka/coordinator/base.py
def coordinator_dead(self, error): """Mark the current coordinator as dead.""" if self.coordinator_id is not None: log.warning("Marking the coordinator dead (node %s) for group %s: %s.", self.coordinator_id, self.group_id, error) self.coordinator_id = None
def coordinator_dead(self, error): """Mark the current coordinator as dead.""" if self.coordinator_id is not None: log.warning("Marking the coordinator dead (node %s) for group %s: %s.", self.coordinator_id, self.group_id, error) self.coordinator_id = None
[ "Mark", "the", "current", "coordinator", "as", "dead", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L706-L711
[ "def", "coordinator_dead", "(", "self", ",", "error", ")", ":", "if", "self", ".", "coordinator_id", "is", "not", "None", ":", "log", ".", "warning", "(", "\"Marking the coordinator dead (node %s) for group %s: %s.\"", ",", "self", ".", "coordinator_id", ",", "sel...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.generation
Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing
kafka/coordinator/base.py
def generation(self): """Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing """ with self._lock: if self.state is not MemberState.STABLE: return None return self._g...
def generation(self): """Get the current generation state if the group is stable. Returns: the current generation or None if the group is unjoined/rebalancing """ with self._lock: if self.state is not MemberState.STABLE: return None return self._g...
[ "Get", "the", "current", "generation", "state", "if", "the", "group", "is", "stable", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L713-L721
[ "def", "generation", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "state", "is", "not", "MemberState", ".", "STABLE", ":", "return", "None", "return", "self", ".", "_generation" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.reset_generation
Reset the generation and memberId because we have fallen out of the group.
kafka/coordinator/base.py
def reset_generation(self): """Reset the generation and memberId because we have fallen out of the group.""" with self._lock: self._generation = Generation.NO_GENERATION self.rejoin_needed = True self.state = MemberState.UNJOINED
def reset_generation(self): """Reset the generation and memberId because we have fallen out of the group.""" with self._lock: self._generation = Generation.NO_GENERATION self.rejoin_needed = True self.state = MemberState.UNJOINED
[ "Reset", "the", "generation", "and", "memberId", "because", "we", "have", "fallen", "out", "of", "the", "group", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L723-L728
[ "def", "reset_generation", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_generation", "=", "Generation", ".", "NO_GENERATION", "self", ".", "rejoin_needed", "=", "True", "self", ".", "state", "=", "MemberState", ".", "UNJOINED" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator.maybe_leave_group
Leave the current group and reset local generation/memberId.
kafka/coordinator/base.py
def maybe_leave_group(self): """Leave the current group and reset local generation/memberId.""" with self._client._lock, self._lock: if (not self.coordinator_unknown() and self.state is not MemberState.UNJOINED and self._generation is not Generation.NO_GENERAT...
def maybe_leave_group(self): """Leave the current group and reset local generation/memberId.""" with self._client._lock, self._lock: if (not self.coordinator_unknown() and self.state is not MemberState.UNJOINED and self._generation is not Generation.NO_GENERAT...
[ "Leave", "the", "current", "group", "and", "reset", "local", "generation", "/", "memberId", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L758-L775
[ "def", "maybe_leave_group", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "if", "(", "not", "self", ".", "coordinator_unknown", "(", ")", "and", "self", ".", "state", "is", "not", "MemberState", "....
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
BaseCoordinator._send_heartbeat_request
Send a heartbeat request
kafka/coordinator/base.py
def _send_heartbeat_request(self): """Send a heartbeat request""" if self.coordinator_unknown(): e = Errors.GroupCoordinatorNotAvailableError(self.coordinator_id) return Future().failure(e) elif not self._client.ready(self.coordinator_id, metadata_priority=False): ...
def _send_heartbeat_request(self): """Send a heartbeat request""" if self.coordinator_unknown(): e = Errors.GroupCoordinatorNotAvailableError(self.coordinator_id) return Future().failure(e) elif not self._client.ready(self.coordinator_id, metadata_priority=False): ...
[ "Send", "a", "heartbeat", "request" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L786-L806
[ "def", "_send_heartbeat_request", "(", "self", ")", ":", "if", "self", ".", "coordinator_unknown", "(", ")", ":", "e", "=", "Errors", ".", "GroupCoordinatorNotAvailableError", "(", "self", ".", "coordinator_id", ")", "return", "Future", "(", ")", ".", "failure...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.metric_name
Create a MetricName with the given name, group, description and tags, plus default tags specified in the metric configuration. Tag in tags takes precedence if the same tag key is specified in the default metric configuration. Arguments: name (str): The name of the metric ...
kafka/metrics/metrics.py
def metric_name(self, name, group, description='', tags=None): """ Create a MetricName with the given name, group, description and tags, plus default tags specified in the metric configuration. Tag in tags takes precedence if the same tag key is specified in the default metric co...
def metric_name(self, name, group, description='', tags=None): """ Create a MetricName with the given name, group, description and tags, plus default tags specified in the metric configuration. Tag in tags takes precedence if the same tag key is specified in the default metric co...
[ "Create", "a", "MetricName", "with", "the", "given", "name", "group", "description", "and", "tags", "plus", "default", "tags", "specified", "in", "the", "metric", "configuration", ".", "Tag", "in", "tags", "takes", "precedence", "if", "the", "same", "tag", "...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L85-L103
[ "def", "metric_name", "(", "self", ",", "name", ",", "group", ",", "description", "=", "''", ",", "tags", "=", "None", ")", ":", "combined_tags", "=", "dict", "(", "self", ".", "config", ".", "tags", ")", "combined_tags", ".", "update", "(", "tags", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.sensor
Get or create a sensor with the given unique name and zero or more parent sensors. All parent sensors will receive every value recorded with this sensor. Arguments: name (str): The name of the sensor config (MetricConfig, optional): A default configuration to use ...
kafka/metrics/metrics.py
def sensor(self, name, config=None, inactive_sensor_expiration_time_seconds=sys.maxsize, parents=None): """ Get or create a sensor with the given unique name and zero or more parent sensors. All parent sensors will receive every value recorded with this sens...
def sensor(self, name, config=None, inactive_sensor_expiration_time_seconds=sys.maxsize, parents=None): """ Get or create a sensor with the given unique name and zero or more parent sensors. All parent sensors will receive every value recorded with this sens...
[ "Get", "or", "create", "a", "sensor", "with", "the", "given", "unique", "name", "and", "zero", "or", "more", "parent", "sensors", ".", "All", "parent", "sensors", "will", "receive", "every", "value", "recorded", "with", "this", "sensor", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L119-L157
[ "def", "sensor", "(", "self", ",", "name", ",", "config", "=", "None", ",", "inactive_sensor_expiration_time_seconds", "=", "sys", ".", "maxsize", ",", "parents", "=", "None", ")", ":", "sensor", "=", "self", ".", "get_sensor", "(", "name", ")", "if", "s...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.remove_sensor
Remove a sensor (if it exists), associated metrics and its children. Arguments: name (str): The name of the sensor to be removed
kafka/metrics/metrics.py
def remove_sensor(self, name): """ Remove a sensor (if it exists), associated metrics and its children. Arguments: name (str): The name of the sensor to be removed """ sensor = self._sensors.get(name) if sensor: child_sensors = None wi...
def remove_sensor(self, name): """ Remove a sensor (if it exists), associated metrics and its children. Arguments: name (str): The name of the sensor to be removed """ sensor = self._sensors.get(name) if sensor: child_sensors = None wi...
[ "Remove", "a", "sensor", "(", "if", "it", "exists", ")", "associated", "metrics", "and", "its", "children", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L159-L179
[ "def", "remove_sensor", "(", "self", ",", "name", ")", ":", "sensor", "=", "self", ".", "_sensors", ".", "get", "(", "name", ")", "if", "sensor", ":", "child_sensors", "=", "None", "with", "sensor", ".", "_lock", ":", "with", "self", ".", "_lock", ":...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.add_metric
Add a metric to monitor an object that implements measurable. This metric won't be associated with any sensor. This is a way to expose existing values as metrics. Arguments: metricName (MetricName): The name of the metric measurable (AbstractMeasurable): The measurable t...
kafka/metrics/metrics.py
def add_metric(self, metric_name, measurable, config=None): """ Add a metric to monitor an object that implements measurable. This metric won't be associated with any sensor. This is a way to expose existing values as metrics. Arguments: metricName (MetricName): The ...
def add_metric(self, metric_name, measurable, config=None): """ Add a metric to monitor an object that implements measurable. This metric won't be associated with any sensor. This is a way to expose existing values as metrics. Arguments: metricName (MetricName): The ...
[ "Add", "a", "metric", "to", "monitor", "an", "object", "that", "implements", "measurable", ".", "This", "metric", "won", "t", "be", "associated", "with", "any", "sensor", ".", "This", "is", "a", "way", "to", "expose", "existing", "values", "as", "metrics",...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L181-L196
[ "def", "add_metric", "(", "self", ",", "metric_name", ",", "measurable", ",", "config", "=", "None", ")", ":", "# NOTE there was a lock here, but i don't think it's needed", "metric", "=", "KafkaMetric", "(", "metric_name", ",", "measurable", ",", "config", "or", "s...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.remove_metric
Remove a metric if it exists and return it. Return None otherwise. If a metric is removed, `metric_removal` will be invoked for each reporter. Arguments: metric_name (MetricName): The name of the metric Returns: KafkaMetric: the removed `KafkaMetric` or None if ...
kafka/metrics/metrics.py
def remove_metric(self, metric_name): """ Remove a metric if it exists and return it. Return None otherwise. If a metric is removed, `metric_removal` will be invoked for each reporter. Arguments: metric_name (MetricName): The name of the metric Returns: ...
def remove_metric(self, metric_name): """ Remove a metric if it exists and return it. Return None otherwise. If a metric is removed, `metric_removal` will be invoked for each reporter. Arguments: metric_name (MetricName): The name of the metric Returns: ...
[ "Remove", "a", "metric", "if", "it", "exists", "and", "return", "it", ".", "Return", "None", "otherwise", ".", "If", "a", "metric", "is", "removed", "metric_removal", "will", "be", "invoked", "for", "each", "reporter", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L198-L216
[ "def", "remove_metric", "(", "self", ",", "metric_name", ")", ":", "with", "self", ".", "_lock", ":", "metric", "=", "self", ".", "_metrics", ".", "pop", "(", "metric_name", ",", "None", ")", "if", "metric", ":", "for", "reporter", "in", "self", ".", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.add_reporter
Add a MetricReporter
kafka/metrics/metrics.py
def add_reporter(self, reporter): """Add a MetricReporter""" with self._lock: reporter.init(list(self.metrics.values())) self._reporters.append(reporter)
def add_reporter(self, reporter): """Add a MetricReporter""" with self._lock: reporter.init(list(self.metrics.values())) self._reporters.append(reporter)
[ "Add", "a", "MetricReporter" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L218-L222
[ "def", "add_reporter", "(", "self", ",", "reporter", ")", ":", "with", "self", ".", "_lock", ":", "reporter", ".", "init", "(", "list", "(", "self", ".", "metrics", ".", "values", "(", ")", ")", ")", "self", ".", "_reporters", ".", "append", "(", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Metrics.close
Close this metrics repository.
kafka/metrics/metrics.py
def close(self): """Close this metrics repository.""" for reporter in self._reporters: reporter.close() self._metrics.clear()
def close(self): """Close this metrics repository.""" for reporter in self._reporters: reporter.close() self._metrics.clear()
[ "Close", "this", "metrics", "repository", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/metrics.py#L256-L261
[ "def", "close", "(", "self", ")", ":", "for", "reporter", "in", "self", ".", "_reporters", ":", "reporter", ".", "close", "(", ")", "self", ".", "_metrics", ".", "clear", "(", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
create_snappy_message
Construct a Snappy Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to Kafka key: bytes, a key used for partition routing (optional)
kafka/protocol/legacy.py
def create_snappy_message(payloads, key=None): """ Construct a Snappy Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to Kafka key:...
def create_snappy_message(payloads, key=None): """ Construct a Snappy Message containing multiple Messages The given payloads will be encoded, compressed, and sent as a single atomic message to Kafka. Arguments: payloads: list(bytes), a list of payload to send be sent to Kafka key:...
[ "Construct", "a", "Snappy", "Message", "containing", "multiple", "Messages" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L440-L458
[ "def", "create_snappy_message", "(", "payloads", ",", "key", "=", "None", ")", ":", "message_set", "=", "KafkaProtocol", ".", "_encode_message_set", "(", "[", "create_message", "(", "payload", ",", "pl_key", ")", "for", "payload", ",", "pl_key", "in", "payload...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
create_message_set
Create a message set using the given codec. If codec is CODEC_NONE, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message.
kafka/protocol/legacy.py
def create_message_set(messages, codec=CODEC_NONE, key=None, compresslevel=None): """Create a message set using the given codec. If codec is CODEC_NONE, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message. """ if codec == CODEC_NONE: retur...
def create_message_set(messages, codec=CODEC_NONE, key=None, compresslevel=None): """Create a message set using the given codec. If codec is CODEC_NONE, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message. """ if codec == CODEC_NONE: retur...
[ "Create", "a", "message", "set", "using", "the", "given", "codec", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L461-L474
[ "def", "create_message_set", "(", "messages", ",", "codec", "=", "CODEC_NONE", ",", "key", "=", "None", ",", "compresslevel", "=", "None", ")", ":", "if", "codec", "==", "CODEC_NONE", ":", "return", "[", "create_message", "(", "m", ",", "k", ")", "for", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol._encode_message_header
Encode the common request envelope
kafka/protocol/legacy.py
def _encode_message_header(cls, client_id, correlation_id, request_key, version=0): """ Encode the common request envelope """ return struct.pack('>hhih%ds' % len(client_id), request_key, # ApiKey ...
def _encode_message_header(cls, client_id, correlation_id, request_key, version=0): """ Encode the common request envelope """ return struct.pack('>hhih%ds' % len(client_id), request_key, # ApiKey ...
[ "Encode", "the", "common", "request", "envelope" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L52-L62
[ "def", "_encode_message_header", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "request_key", ",", "version", "=", "0", ")", ":", "return", "struct", ".", "pack", "(", "'>hhih%ds'", "%", "len", "(", "client_id", ")", ",", "request_key", ",", "#...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol._encode_message_set
Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed Format ====== MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32
kafka/protocol/legacy.py
def _encode_message_set(cls, messages): """ Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed Format ====== MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32 """ ...
def _encode_message_set(cls, messages): """ Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed Format ====== MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32 """ ...
[ "Encode", "a", "MessageSet", ".", "Unlike", "other", "arrays", "in", "the", "protocol", "MessageSets", "are", "not", "length", "-", "prefixed" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L65-L82
[ "def", "_encode_message_set", "(", "cls", ",", "messages", ")", ":", "message_set", "=", "[", "]", "for", "message", "in", "messages", ":", "encoded_message", "=", "KafkaProtocol", ".", "_encode_message", "(", "message", ")", "message_set", ".", "append", "(",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_produce_request
Encode a ProduceRequest struct Arguments: payloads: list of ProduceRequestPayload acks: How "acky" you want the request to be 1: written to disk by the leader 0: immediate response -1: waits for all replicas to be in sync timeo...
kafka/protocol/legacy.py
def encode_produce_request(cls, payloads=(), acks=1, timeout=1000): """ Encode a ProduceRequest struct Arguments: payloads: list of ProduceRequestPayload acks: How "acky" you want the request to be 1: written to disk by the leader 0: immed...
def encode_produce_request(cls, payloads=(), acks=1, timeout=1000): """ Encode a ProduceRequest struct Arguments: payloads: list of ProduceRequestPayload acks: How "acky" you want the request to be 1: written to disk by the leader 0: immed...
[ "Encode", "a", "ProduceRequest", "struct" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L118-L155
[ "def", "encode_produce_request", "(", "cls", ",", "payloads", "=", "(", ")", ",", "acks", "=", "1", ",", "timeout", "=", "1000", ")", ":", "if", "acks", "not", "in", "(", "1", ",", "0", ",", "-", "1", ")", ":", "raise", "ValueError", "(", "'Produ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_produce_response
Decode ProduceResponse to ProduceResponsePayload Arguments: response: ProduceResponse Return: list of ProduceResponsePayload
kafka/protocol/legacy.py
def decode_produce_response(cls, response): """ Decode ProduceResponse to ProduceResponsePayload Arguments: response: ProduceResponse Return: list of ProduceResponsePayload """ return [ kafka.structs.ProduceResponsePayload(topic, partition, error...
def decode_produce_response(cls, response): """ Decode ProduceResponse to ProduceResponsePayload Arguments: response: ProduceResponse Return: list of ProduceResponsePayload """ return [ kafka.structs.ProduceResponsePayload(topic, partition, error...
[ "Decode", "ProduceResponse", "to", "ProduceResponsePayload" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L158-L171
[ "def", "decode_produce_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "ProduceResponsePayload", "(", "topic", ",", "partition", ",", "error", ",", "offset", ")", "for", "topic", ",", "partitions", "in", "respon...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_fetch_request
Encodes a FetchRequest struct Arguments: payloads: list of FetchRequestPayload max_wait_time (int, optional): ms to block waiting for min_bytes data. Defaults to 100. min_bytes (int, optional): minimum bytes required to return before max_wait_...
kafka/protocol/legacy.py
def encode_fetch_request(cls, payloads=(), max_wait_time=100, min_bytes=4096): """ Encodes a FetchRequest struct Arguments: payloads: list of FetchRequestPayload max_wait_time (int, optional): ms to block waiting for min_bytes data. Defaults to 100. ...
def encode_fetch_request(cls, payloads=(), max_wait_time=100, min_bytes=4096): """ Encodes a FetchRequest struct Arguments: payloads: list of FetchRequestPayload max_wait_time (int, optional): ms to block waiting for min_bytes data. Defaults to 100. ...
[ "Encodes", "a", "FetchRequest", "struct" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L174-L198
[ "def", "encode_fetch_request", "(", "cls", ",", "payloads", "=", "(", ")", ",", "max_wait_time", "=", "100", ",", "min_bytes", "=", "4096", ")", ":", "return", "kafka", ".", "protocol", ".", "fetch", ".", "FetchRequest", "[", "0", "]", "(", "replica_id",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_fetch_response
Decode FetchResponse struct to FetchResponsePayloads Arguments: response: FetchResponse
kafka/protocol/legacy.py
def decode_fetch_response(cls, response): """ Decode FetchResponse struct to FetchResponsePayloads Arguments: response: FetchResponse """ return [ kafka.structs.FetchResponsePayload( topic, partition, error, highwater_offset, [ ...
def decode_fetch_response(cls, response): """ Decode FetchResponse struct to FetchResponsePayloads Arguments: response: FetchResponse """ return [ kafka.structs.FetchResponsePayload( topic, partition, error, highwater_offset, [ ...
[ "Decode", "FetchResponse", "struct", "to", "FetchResponsePayloads" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L201-L215
[ "def", "decode_fetch_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "FetchResponsePayload", "(", "topic", ",", "partition", ",", "error", ",", "highwater_offset", ",", "[", "offset_and_msg", "for", "offset_and_msg"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_offset_response
Decode OffsetResponse into OffsetResponsePayloads Arguments: response: OffsetResponse Returns: list of OffsetResponsePayloads
kafka/protocol/legacy.py
def decode_offset_response(cls, response): """ Decode OffsetResponse into OffsetResponsePayloads Arguments: response: OffsetResponse Returns: list of OffsetResponsePayloads """ return [ kafka.structs.OffsetResponsePayload(topic, partition, error,...
def decode_offset_response(cls, response): """ Decode OffsetResponse into OffsetResponsePayloads Arguments: response: OffsetResponse Returns: list of OffsetResponsePayloads """ return [ kafka.structs.OffsetResponsePayload(topic, partition, error,...
[ "Decode", "OffsetResponse", "into", "OffsetResponsePayloads" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L242-L255
[ "def", "decode_offset_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "OffsetResponsePayload", "(", "topic", ",", "partition", ",", "error", ",", "tuple", "(", "offsets", ")", ")", "for", "topic", ",", "partit...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_list_offset_response
Decode OffsetResponse_v2 into ListOffsetResponsePayloads Arguments: response: OffsetResponse_v2 Returns: list of ListOffsetResponsePayloads
kafka/protocol/legacy.py
def decode_list_offset_response(cls, response): """ Decode OffsetResponse_v2 into ListOffsetResponsePayloads Arguments: response: OffsetResponse_v2 Returns: list of ListOffsetResponsePayloads """ return [ kafka.structs.ListOffsetResponsePayload(t...
def decode_list_offset_response(cls, response): """ Decode OffsetResponse_v2 into ListOffsetResponsePayloads Arguments: response: OffsetResponse_v2 Returns: list of ListOffsetResponsePayloads """ return [ kafka.structs.ListOffsetResponsePayload(t...
[ "Decode", "OffsetResponse_v2", "into", "ListOffsetResponsePayloads" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L270-L283
[ "def", "decode_list_offset_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "ListOffsetResponsePayload", "(", "topic", ",", "partition", ",", "error", ",", "timestamp", ",", "offset", ")", "for", "topic", ",", "p...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_metadata_request
Encode a MetadataRequest Arguments: topics: list of strings
kafka/protocol/legacy.py
def encode_metadata_request(cls, topics=(), payloads=None): """ Encode a MetadataRequest Arguments: topics: list of strings """ if payloads is not None: topics = payloads return kafka.protocol.metadata.MetadataRequest[0](topics)
def encode_metadata_request(cls, topics=(), payloads=None): """ Encode a MetadataRequest Arguments: topics: list of strings """ if payloads is not None: topics = payloads return kafka.protocol.metadata.MetadataRequest[0](topics)
[ "Encode", "a", "MetadataRequest" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L287-L297
[ "def", "encode_metadata_request", "(", "cls", ",", "topics", "=", "(", ")", ",", "payloads", "=", "None", ")", ":", "if", "payloads", "is", "not", "None", ":", "topics", "=", "payloads", "return", "kafka", ".", "protocol", ".", "metadata", ".", "Metadata...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_consumer_metadata_request
Encode a ConsumerMetadataRequest Arguments: client_id: string correlation_id: int payloads: string (consumer group)
kafka/protocol/legacy.py
def encode_consumer_metadata_request(cls, client_id, correlation_id, payloads): """ Encode a ConsumerMetadataRequest Arguments: client_id: string correlation_id: int payloads: string (consumer group) """ message = [] message.append(cls...
def encode_consumer_metadata_request(cls, client_id, correlation_id, payloads): """ Encode a ConsumerMetadataRequest Arguments: client_id: string correlation_id: int payloads: string (consumer group) """ message = [] message.append(cls...
[ "Encode", "a", "ConsumerMetadataRequest" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L304-L319
[ "def", "encode_consumer_metadata_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "payloads", ")", ":", "message", "=", "[", "]", "message", ".", "append", "(", "cls", ".", "_encode_message_header", "(", "client_id", ",", "correlation_id", ","...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_consumer_metadata_response
Decode bytes to a kafka.structs.ConsumerMetadataResponse Arguments: data: bytes to decode
kafka/protocol/legacy.py
def decode_consumer_metadata_response(cls, data): """ Decode bytes to a kafka.structs.ConsumerMetadataResponse Arguments: data: bytes to decode """ ((correlation_id, error, nodeId), cur) = relative_unpack('>ihi', data, 0) (host, cur) = read_short_string(data,...
def decode_consumer_metadata_response(cls, data): """ Decode bytes to a kafka.structs.ConsumerMetadataResponse Arguments: data: bytes to decode """ ((correlation_id, error, nodeId), cur) = relative_unpack('>ihi', data, 0) (host, cur) = read_short_string(data,...
[ "Decode", "bytes", "to", "a", "kafka", ".", "structs", ".", "ConsumerMetadataResponse" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L322-L333
[ "def", "decode_consumer_metadata_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "error", ",", "nodeId", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ihi'", ",", "data", ",", "0", ")", "(", "host", ",", "cur", ")...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_offset_commit_request
Encode an OffsetCommitRequest struct Arguments: group: string, the consumer group you are committing offsets for payloads: list of OffsetCommitRequestPayload
kafka/protocol/legacy.py
def encode_offset_commit_request(cls, group, payloads): """ Encode an OffsetCommitRequest struct Arguments: group: string, the consumer group you are committing offsets for payloads: list of OffsetCommitRequestPayload """ return kafka.protocol.commit.Offs...
def encode_offset_commit_request(cls, group, payloads): """ Encode an OffsetCommitRequest struct Arguments: group: string, the consumer group you are committing offsets for payloads: list of OffsetCommitRequestPayload """ return kafka.protocol.commit.Offs...
[ "Encode", "an", "OffsetCommitRequest", "struct" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L336-L353
[ "def", "encode_offset_commit_request", "(", "cls", ",", "group", ",", "payloads", ")", ":", "return", "kafka", ".", "protocol", ".", "commit", ".", "OffsetCommitRequest", "[", "0", "]", "(", "consumer_group", "=", "group", ",", "topics", "=", "[", "(", "to...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_offset_commit_response
Decode OffsetCommitResponse to an OffsetCommitResponsePayload Arguments: response: OffsetCommitResponse
kafka/protocol/legacy.py
def decode_offset_commit_response(cls, response): """ Decode OffsetCommitResponse to an OffsetCommitResponsePayload Arguments: response: OffsetCommitResponse """ return [ kafka.structs.OffsetCommitResponsePayload(topic, partition, error) for t...
def decode_offset_commit_response(cls, response): """ Decode OffsetCommitResponse to an OffsetCommitResponsePayload Arguments: response: OffsetCommitResponse """ return [ kafka.structs.OffsetCommitResponsePayload(topic, partition, error) for t...
[ "Decode", "OffsetCommitResponse", "to", "an", "OffsetCommitResponsePayload" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L356-L367
[ "def", "decode_offset_commit_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "OffsetCommitResponsePayload", "(", "topic", ",", "partition", ",", "error", ")", "for", "topic", ",", "partitions", "in", "response", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.encode_offset_fetch_request
Encode an OffsetFetchRequest struct. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. It is encoded using version 1 otherwise, indicating a request for Kafka offsets. Arguments: group: string, the consumer group you a...
kafka/protocol/legacy.py
def encode_offset_fetch_request(cls, group, payloads, from_kafka=False): """ Encode an OffsetFetchRequest struct. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. It is encoded using version 1 otherwise, indicating a request ...
def encode_offset_fetch_request(cls, group, payloads, from_kafka=False): """ Encode an OffsetFetchRequest struct. The request is encoded using version 0 if from_kafka is false, indicating a request for Zookeeper offsets. It is encoded using version 1 otherwise, indicating a request ...
[ "Encode", "an", "OffsetFetchRequest", "struct", ".", "The", "request", "is", "encoded", "using", "version", "0", "if", "from_kafka", "is", "false", "indicating", "a", "request", "for", "Zookeeper", "offsets", ".", "It", "is", "encoded", "using", "version", "1"...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L370-L388
[ "def", "encode_offset_fetch_request", "(", "cls", ",", "group", ",", "payloads", ",", "from_kafka", "=", "False", ")", ":", "version", "=", "1", "if", "from_kafka", "else", "0", "return", "kafka", ".", "protocol", ".", "commit", ".", "OffsetFetchRequest", "[...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
KafkaProtocol.decode_offset_fetch_response
Decode OffsetFetchResponse to OffsetFetchResponsePayloads Arguments: response: OffsetFetchResponse
kafka/protocol/legacy.py
def decode_offset_fetch_response(cls, response): """ Decode OffsetFetchResponse to OffsetFetchResponsePayloads Arguments: response: OffsetFetchResponse """ return [ kafka.structs.OffsetFetchResponsePayload( topic, partition, offset, metada...
def decode_offset_fetch_response(cls, response): """ Decode OffsetFetchResponse to OffsetFetchResponsePayloads Arguments: response: OffsetFetchResponse """ return [ kafka.structs.OffsetFetchResponsePayload( topic, partition, offset, metada...
[ "Decode", "OffsetFetchResponse", "to", "OffsetFetchResponsePayloads" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/protocol/legacy.py#L391-L404
[ "def", "decode_offset_fetch_response", "(", "cls", ",", "response", ")", ":", "return", "[", "kafka", ".", "structs", ".", "OffsetFetchResponsePayload", "(", "topic", ",", "partition", ",", "offset", ",", "metadata", ",", "error", ")", "for", "topic", ",", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
_BaseSelectorImpl._fileobj_lookup
Return a file descriptor from a file object. This wraps _fileobj_to_fd() to do an exhaustive search in case the object is invalid but we still have it in our map. This is used by unregister() so we can unregister an object that was previously registered even if it is closed. It is als...
kafka/vendor/selectors34.py
def _fileobj_lookup(self, fileobj): """Return a file descriptor from a file object. This wraps _fileobj_to_fd() to do an exhaustive search in case the object is invalid but we still have it in our map. This is used by unregister() so we can unregister an object that was previou...
def _fileobj_lookup(self, fileobj): """Return a file descriptor from a file object. This wraps _fileobj_to_fd() to do an exhaustive search in case the object is invalid but we still have it in our map. This is used by unregister() so we can unregister an object that was previou...
[ "Return", "a", "file", "descriptor", "from", "a", "file", "object", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/vendor/selectors34.py#L233-L250
[ "def", "_fileobj_lookup", "(", "self", ",", "fileobj", ")", ":", "try", ":", "return", "_fileobj_to_fd", "(", "fileobj", ")", "except", "ValueError", ":", "# Do an exhaustive search.", "for", "key", "in", "self", ".", "_fd_to_key", ".", "values", "(", ")", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sensor._check_forest
Validate that this sensor doesn't end up referencing itself.
kafka/metrics/stats/sensor.py
def _check_forest(self, sensors): """Validate that this sensor doesn't end up referencing itself.""" if self in sensors: raise ValueError('Circular dependency in sensors: %s is its own' 'parent.' % (self.name,)) sensors.add(self) for parent in sel...
def _check_forest(self, sensors): """Validate that this sensor doesn't end up referencing itself.""" if self in sensors: raise ValueError('Circular dependency in sensors: %s is its own' 'parent.' % (self.name,)) sensors.add(self) for parent in sel...
[ "Validate", "that", "this", "sensor", "doesn", "t", "end", "up", "referencing", "itself", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L34-L41
[ "def", "_check_forest", "(", "self", ",", "sensors", ")", ":", "if", "self", "in", "sensors", ":", "raise", "ValueError", "(", "'Circular dependency in sensors: %s is its own'", "'parent.'", "%", "(", "self", ".", "name", ",", ")", ")", "sensors", ".", "add", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sensor.record
Record a value at a known time. Arguments: value (double): The value we are recording time_ms (int): A POSIX timestamp in milliseconds. Default: The time when record() is evaluated (now) Raises: QuotaViolationException: if recording this value moves a...
kafka/metrics/stats/sensor.py
def record(self, value=1.0, time_ms=None): """ Record a value at a known time. Arguments: value (double): The value we are recording time_ms (int): A POSIX timestamp in milliseconds. Default: The time when record() is evaluated (now) Raises: ...
def record(self, value=1.0, time_ms=None): """ Record a value at a known time. Arguments: value (double): The value we are recording time_ms (int): A POSIX timestamp in milliseconds. Default: The time when record() is evaluated (now) Raises: ...
[ "Record", "a", "value", "at", "a", "known", "time", ".", "Arguments", ":", "value", "(", "double", ")", ":", "The", "value", "we", "are", "recording", "time_ms", "(", "int", ")", ":", "A", "POSIX", "timestamp", "in", "milliseconds", ".", "Default", ":"...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L55-L76
[ "def", "record", "(", "self", ",", "value", "=", "1.0", ",", "time_ms", "=", "None", ")", ":", "if", "time_ms", "is", "None", ":", "time_ms", "=", "time", ".", "time", "(", ")", "*", "1000", "self", ".", "_last_record_time", "=", "time_ms", "with", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sensor._check_quotas
Check if we have violated our quota for any metric that has a configured quota
kafka/metrics/stats/sensor.py
def _check_quotas(self, time_ms): """ Check if we have violated our quota for any metric that has a configured quota """ for metric in self._metrics: if metric.config and metric.config.quota: value = metric.value(time_ms) if not metric....
def _check_quotas(self, time_ms): """ Check if we have violated our quota for any metric that has a configured quota """ for metric in self._metrics: if metric.config and metric.config.quota: value = metric.value(time_ms) if not metric....
[ "Check", "if", "we", "have", "violated", "our", "quota", "for", "any", "metric", "that", "has", "a", "configured", "quota" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L78-L91
[ "def", "_check_quotas", "(", "self", ",", "time_ms", ")", ":", "for", "metric", "in", "self", ".", "_metrics", ":", "if", "metric", ".", "config", "and", "metric", ".", "config", ".", "quota", ":", "value", "=", "metric", ".", "value", "(", "time_ms", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sensor.add_compound
Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram) Arguments: stat (AbstractCompoundStat): The stat to register config (MetricConfig): The configuration for this stat. If None then the stat will use the d...
kafka/metrics/stats/sensor.py
def add_compound(self, compound_stat, config=None): """ Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram) Arguments: stat (AbstractCompoundStat): The stat to register config (MetricConfig): The configura...
def add_compound(self, compound_stat, config=None): """ Register a compound statistic with this sensor which yields multiple measurable quantities (like a histogram) Arguments: stat (AbstractCompoundStat): The stat to register config (MetricConfig): The configura...
[ "Register", "a", "compound", "statistic", "with", "this", "sensor", "which", "yields", "multiple", "measurable", "quantities", "(", "like", "a", "histogram", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L93-L111
[ "def", "add_compound", "(", "self", ",", "compound_stat", ",", "config", "=", "None", ")", ":", "if", "not", "compound_stat", ":", "raise", "ValueError", "(", "'compound stat must be non-empty'", ")", "self", ".", "_stats", ".", "append", "(", "compound_stat", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
Sensor.add
Register a metric with this sensor Arguments: metric_name (MetricName): The name of the metric stat (AbstractMeasurableStat): The statistic to keep config (MetricConfig): A special configuration for this metric. If None use the sensor default configuration.
kafka/metrics/stats/sensor.py
def add(self, metric_name, stat, config=None): """ Register a metric with this sensor Arguments: metric_name (MetricName): The name of the metric stat (AbstractMeasurableStat): The statistic to keep config (MetricConfig): A special configuration for this metr...
def add(self, metric_name, stat, config=None): """ Register a metric with this sensor Arguments: metric_name (MetricName): The name of the metric stat (AbstractMeasurableStat): The statistic to keep config (MetricConfig): A special configuration for this metr...
[ "Register", "a", "metric", "with", "this", "sensor" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/metrics/stats/sensor.py#L113-L127
[ "def", "add", "(", "self", ",", "metric_name", ",", "stat", ",", "config", "=", "None", ")", ":", "with", "self", ".", "_lock", ":", "metric", "=", "KafkaMetric", "(", "metric_name", ",", "stat", ",", "config", "or", "self", ".", "_config", ")", "sel...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.group_protocols
Returns list of preferred (protocols, metadata)
kafka/coordinator/consumer.py
def group_protocols(self): """Returns list of preferred (protocols, metadata)""" if self._subscription.subscription is None: raise Errors.IllegalStateError('Consumer has not subscribed to topics') # dpkp note: I really dislike this. # why? because we are using this strange me...
def group_protocols(self): """Returns list of preferred (protocols, metadata)""" if self._subscription.subscription is None: raise Errors.IllegalStateError('Consumer has not subscribed to topics') # dpkp note: I really dislike this. # why? because we are using this strange me...
[ "Returns", "list", "of", "preferred", "(", "protocols", "metadata", ")" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L136-L156
[ "def", "group_protocols", "(", "self", ")", ":", "if", "self", ".", "_subscription", ".", "subscription", "is", "None", ":", "raise", "Errors", ".", "IllegalStateError", "(", "'Consumer has not subscribed to topics'", ")", "# dpkp note: I really dislike this.", "# why? ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.poll
Poll for coordinator events. Only applicable if group_id is set, and broker version supports GroupCoordinators. This ensures that the coordinator is known, and if using automatic partition assignment, ensures that the consumer has joined the group. This also handles periodic offset commi...
kafka/coordinator/consumer.py
def poll(self): """ Poll for coordinator events. Only applicable if group_id is set, and broker version supports GroupCoordinators. This ensures that the coordinator is known, and if using automatic partition assignment, ensures that the consumer has joined the group. This also h...
def poll(self): """ Poll for coordinator events. Only applicable if group_id is set, and broker version supports GroupCoordinators. This ensures that the coordinator is known, and if using automatic partition assignment, ensures that the consumer has joined the group. This also h...
[ "Poll", "for", "coordinator", "events", ".", "Only", "applicable", "if", "group_id", "is", "set", "and", "broker", "version", "supports", "GroupCoordinators", ".", "This", "ensures", "that", "the", "coordinator", "is", "known", "and", "if", "using", "automatic",...
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L251-L286
[ "def", "poll", "(", "self", ")", ":", "if", "self", ".", "group_id", "is", "None", "or", "self", ".", "config", "[", "'api_version'", "]", "<", "(", "0", ",", "8", ",", "2", ")", ":", "return", "self", ".", "_invoke_completed_offset_commit_callbacks", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.time_to_next_poll
Return seconds (float) remaining until :meth:`.poll` should be called again
kafka/coordinator/consumer.py
def time_to_next_poll(self): """Return seconds (float) remaining until :meth:`.poll` should be called again""" if not self.config['enable_auto_commit']: return self.time_to_next_heartbeat() if time.time() > self.next_auto_commit_deadline: return 0 return min(sel...
def time_to_next_poll(self): """Return seconds (float) remaining until :meth:`.poll` should be called again""" if not self.config['enable_auto_commit']: return self.time_to_next_heartbeat() if time.time() > self.next_auto_commit_deadline: return 0 return min(sel...
[ "Return", "seconds", "(", "float", ")", "remaining", "until", ":", "meth", ":", ".", "poll", "should", "be", "called", "again" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L288-L297
[ "def", "time_to_next_poll", "(", "self", ")", ":", "if", "not", "self", ".", "config", "[", "'enable_auto_commit'", "]", ":", "return", "self", ".", "time_to_next_heartbeat", "(", ")", "if", "time", ".", "time", "(", ")", ">", "self", ".", "next_auto_commi...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.need_rejoin
Check whether the group should be rejoined Returns: bool: True if consumer should rejoin group, False otherwise
kafka/coordinator/consumer.py
def need_rejoin(self): """Check whether the group should be rejoined Returns: bool: True if consumer should rejoin group, False otherwise """ if not self._subscription.partitions_auto_assigned(): return False if self._auto_assign_all_partitions(): ...
def need_rejoin(self): """Check whether the group should be rejoined Returns: bool: True if consumer should rejoin group, False otherwise """ if not self._subscription.partitions_auto_assigned(): return False if self._auto_assign_all_partitions(): ...
[ "Check", "whether", "the", "group", "should", "be", "rejoined" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L355-L377
[ "def", "need_rejoin", "(", "self", ")", ":", "if", "not", "self", ".", "_subscription", ".", "partitions_auto_assigned", "(", ")", ":", "return", "False", "if", "self", ".", "_auto_assign_all_partitions", "(", ")", ":", "return", "False", "# we need to rejoin if...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.refresh_committed_offsets_if_needed
Fetch committed offsets for assigned partitions.
kafka/coordinator/consumer.py
def refresh_committed_offsets_if_needed(self): """Fetch committed offsets for assigned partitions.""" if self._subscription.needs_fetch_committed_offsets: offsets = self.fetch_committed_offsets(self._subscription.assigned_partitions()) for partition, offset in six.iteritems(offse...
def refresh_committed_offsets_if_needed(self): """Fetch committed offsets for assigned partitions.""" if self._subscription.needs_fetch_committed_offsets: offsets = self.fetch_committed_offsets(self._subscription.assigned_partitions()) for partition, offset in six.iteritems(offse...
[ "Fetch", "committed", "offsets", "for", "assigned", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L379-L387
[ "def", "refresh_committed_offsets_if_needed", "(", "self", ")", ":", "if", "self", ".", "_subscription", ".", "needs_fetch_committed_offsets", ":", "offsets", "=", "self", ".", "fetch_committed_offsets", "(", "self", ".", "_subscription", ".", "assigned_partitions", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.fetch_committed_offsets
Fetch the current committed offsets for specified partitions Arguments: partitions (list of TopicPartition): partitions to fetch Returns: dict: {TopicPartition: OffsetAndMetadata}
kafka/coordinator/consumer.py
def fetch_committed_offsets(self, partitions): """Fetch the current committed offsets for specified partitions Arguments: partitions (list of TopicPartition): partitions to fetch Returns: dict: {TopicPartition: OffsetAndMetadata} """ if not partitions: ...
def fetch_committed_offsets(self, partitions): """Fetch the current committed offsets for specified partitions Arguments: partitions (list of TopicPartition): partitions to fetch Returns: dict: {TopicPartition: OffsetAndMetadata} """ if not partitions: ...
[ "Fetch", "the", "current", "committed", "offsets", "for", "specified", "partitions" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L389-L414
[ "def", "fetch_committed_offsets", "(", "self", ",", "partitions", ")", ":", "if", "not", "partitions", ":", "return", "{", "}", "while", "True", ":", "self", ".", "ensure_coordinator_ready", "(", ")", "# contact coordinator to fetch committed offsets", "future", "="...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.close
Close the coordinator, leave the current group, and reset local generation / member_id. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to commit any pending consumed offs...
kafka/coordinator/consumer.py
def close(self, autocommit=True): """Close the coordinator, leave the current group, and reset local generation / member_id. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to com...
def close(self, autocommit=True): """Close the coordinator, leave the current group, and reset local generation / member_id. Keyword Arguments: autocommit (bool): If auto-commit is configured for this consumer, this optional flag causes the consumer to attempt to com...
[ "Close", "the", "coordinator", "leave", "the", "current", "group", "and", "reset", "local", "generation", "/", "member_id", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L416-L429
[ "def", "close", "(", "self", ",", "autocommit", "=", "True", ")", ":", "try", ":", "if", "autocommit", ":", "self", ".", "_maybe_auto_commit_offsets_sync", "(", ")", "finally", ":", "super", "(", "ConsumerCoordinator", ",", "self", ")", ".", "close", "(", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.commit_offsets_async
Commit specific offsets asynchronously. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit callback (callable, optional): called as callback(offsets, response) response will be either an Exception or a OffsetCommitResponse struc...
kafka/coordinator/consumer.py
def commit_offsets_async(self, offsets, callback=None): """Commit specific offsets asynchronously. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit callback (callable, optional): called as callback(offsets, response) response will be ...
def commit_offsets_async(self, offsets, callback=None): """Commit specific offsets asynchronously. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit callback (callable, optional): called as callback(offsets, response) response will be ...
[ "Commit", "specific", "offsets", "asynchronously", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L436-L471
[ "def", "commit_offsets_async", "(", "self", ",", "offsets", ",", "callback", "=", "None", ")", ":", "self", ".", "_invoke_completed_offset_commit_callbacks", "(", ")", "if", "not", "self", ".", "coordinator_unknown", "(", ")", ":", "future", "=", "self", ".", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator.commit_offsets_sync
Commit specific offsets synchronously. This method will retry until the commit completes successfully or an unrecoverable error is encountered. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit Raises error on failure
kafka/coordinator/consumer.py
def commit_offsets_sync(self, offsets): """Commit specific offsets synchronously. This method will retry until the commit completes successfully or an unrecoverable error is encountered. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit ...
def commit_offsets_sync(self, offsets): """Commit specific offsets synchronously. This method will retry until the commit completes successfully or an unrecoverable error is encountered. Arguments: offsets (dict {TopicPartition: OffsetAndMetadata}): what to commit ...
[ "Commit", "specific", "offsets", "synchronously", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L485-L516
[ "def", "commit_offsets_sync", "(", "self", ",", "offsets", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Unsupported Broker API'", "assert", "all", "(", "map", "(", "lambda", "k", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator._send_offset_commit_request
Commit offsets for the specified list of topics and partitions. This is a non-blocking call which returns a request future that can be polled in the case of a synchronous commit or ignored in the asynchronous case. Arguments: offsets (dict of {TopicPartition: OffsetAndMetad...
kafka/coordinator/consumer.py
def _send_offset_commit_request(self, offsets): """Commit offsets for the specified list of topics and partitions. This is a non-blocking call which returns a request future that can be polled in the case of a synchronous commit or ignored in the asynchronous case. Arguments: ...
def _send_offset_commit_request(self, offsets): """Commit offsets for the specified list of topics and partitions. This is a non-blocking call which returns a request future that can be polled in the case of a synchronous commit or ignored in the asynchronous case. Arguments: ...
[ "Commit", "offsets", "for", "the", "specified", "list", "of", "topics", "and", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L535-L623
[ "def", "_send_offset_commit_request", "(", "self", ",", "offsets", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Unsupported Broker API'", "assert", "all", "(", "map", "(", "lambda", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
ConsumerCoordinator._send_offset_fetch_request
Fetch the committed offsets for a set of partitions. This is a non-blocking call. The returned future can be polled to get the actual offsets returned from the broker. Arguments: partitions (list of TopicPartition): the partitions to fetch Returns: Future: reso...
kafka/coordinator/consumer.py
def _send_offset_fetch_request(self, partitions): """Fetch the committed offsets for a set of partitions. This is a non-blocking call. The returned future can be polled to get the actual offsets returned from the broker. Arguments: partitions (list of TopicPartition): the p...
def _send_offset_fetch_request(self, partitions): """Fetch the committed offsets for a set of partitions. This is a non-blocking call. The returned future can be polled to get the actual offsets returned from the broker. Arguments: partitions (list of TopicPartition): the p...
[ "Fetch", "the", "committed", "offsets", "for", "a", "set", "of", "partitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L693-L743
[ "def", "_send_offset_fetch_request", "(", "self", ",", "partitions", ")", ":", "assert", "self", ".", "config", "[", "'api_version'", "]", ">=", "(", "0", ",", "8", ",", "1", ")", ",", "'Unsupported Broker API'", "assert", "all", "(", "map", "(", "lambda",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.subscribe
Subscribe to a list of topics, or a topic regex pattern. Partitions will be dynamically assigned via a group coordinator. Topic subscriptions are not incremental: this list will replace the current assignment (if there is one). This method is incompatible with assign_from_user() ...
kafka/consumer/subscription_state.py
def subscribe(self, topics=(), pattern=None, listener=None): """Subscribe to a list of topics, or a topic regex pattern. Partitions will be dynamically assigned via a group coordinator. Topic subscriptions are not incremental: this list will replace the current assignment (if there is o...
def subscribe(self, topics=(), pattern=None, listener=None): """Subscribe to a list of topics, or a topic regex pattern. Partitions will be dynamically assigned via a group coordinator. Topic subscriptions are not incremental: this list will replace the current assignment (if there is o...
[ "Subscribe", "to", "a", "list", "of", "topics", "or", "a", "topic", "regex", "pattern", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L76-L124
[ "def", "subscribe", "(", "self", ",", "topics", "=", "(", ")", ",", "pattern", "=", "None", ",", "listener", "=", "None", ")", ":", "if", "self", ".", "_user_assignment", "or", "(", "topics", "and", "pattern", ")", ":", "raise", "IllegalStateError", "(...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState._ensure_valid_topic_name
Ensures that the topic name is valid according to the kafka source.
kafka/consumer/subscription_state.py
def _ensure_valid_topic_name(self, topic): """ Ensures that the topic name is valid according to the kafka source. """ # See Kafka Source: # https://github.com/apache/kafka/blob/39eb31feaeebfb184d98cc5d94da9148c2319d81/clients/src/main/java/org/apache/kafka/common/internals/Topic.java i...
def _ensure_valid_topic_name(self, topic): """ Ensures that the topic name is valid according to the kafka source. """ # See Kafka Source: # https://github.com/apache/kafka/blob/39eb31feaeebfb184d98cc5d94da9148c2319d81/clients/src/main/java/org/apache/kafka/common/internals/Topic.java i...
[ "Ensures", "that", "the", "topic", "name", "is", "valid", "according", "to", "the", "kafka", "source", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L126-L142
[ "def", "_ensure_valid_topic_name", "(", "self", ",", "topic", ")", ":", "# See Kafka Source:", "# https://github.com/apache/kafka/blob/39eb31feaeebfb184d98cc5d94da9148c2319d81/clients/src/main/java/org/apache/kafka/common/internals/Topic.java", "if", "topic", "is", "None", ":", "raise"...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.change_subscription
Change the topic subscription. Arguments: topics (list of str): topics for subscription Raises: IllegalStateErrror: if assign_from_user has been used already TypeError: if a topic is None or a non-str ValueError: if a topic is an empty string or ...
kafka/consumer/subscription_state.py
def change_subscription(self, topics): """Change the topic subscription. Arguments: topics (list of str): topics for subscription Raises: IllegalStateErrror: if assign_from_user has been used already TypeError: if a topic is None or a non-str Val...
def change_subscription(self, topics): """Change the topic subscription. Arguments: topics (list of str): topics for subscription Raises: IllegalStateErrror: if assign_from_user has been used already TypeError: if a topic is None or a non-str Val...
[ "Change", "the", "topic", "subscription", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L144-L178
[ "def", "change_subscription", "(", "self", ",", "topics", ")", ":", "if", "self", ".", "_user_assignment", ":", "raise", "IllegalStateError", "(", "self", ".", "_SUBSCRIPTION_EXCEPTION_MESSAGE", ")", "if", "isinstance", "(", "topics", ",", "six", ".", "string_ty...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.group_subscribe
Add topics to the current group subscription. This is used by the group leader to ensure that it receives metadata updates for all topics that any member of the group is subscribed to. Arguments: topics (list of str): topics to add to the group subscription
kafka/consumer/subscription_state.py
def group_subscribe(self, topics): """Add topics to the current group subscription. This is used by the group leader to ensure that it receives metadata updates for all topics that any member of the group is subscribed to. Arguments: topics (list of str): topics to add to t...
def group_subscribe(self, topics): """Add topics to the current group subscription. This is used by the group leader to ensure that it receives metadata updates for all topics that any member of the group is subscribed to. Arguments: topics (list of str): topics to add to t...
[ "Add", "topics", "to", "the", "current", "group", "subscription", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L180-L191
[ "def", "group_subscribe", "(", "self", ",", "topics", ")", ":", "if", "self", ".", "_user_assignment", ":", "raise", "IllegalStateError", "(", "self", ".", "_SUBSCRIPTION_EXCEPTION_MESSAGE", ")", "self", ".", "_group_subscription", ".", "update", "(", "topics", ...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.reset_group_subscription
Reset the group's subscription to only contain topics subscribed by this consumer.
kafka/consumer/subscription_state.py
def reset_group_subscription(self): """Reset the group's subscription to only contain topics subscribed by this consumer.""" if self._user_assignment: raise IllegalStateError(self._SUBSCRIPTION_EXCEPTION_MESSAGE) assert self.subscription is not None, 'Subscription required' s...
def reset_group_subscription(self): """Reset the group's subscription to only contain topics subscribed by this consumer.""" if self._user_assignment: raise IllegalStateError(self._SUBSCRIPTION_EXCEPTION_MESSAGE) assert self.subscription is not None, 'Subscription required' s...
[ "Reset", "the", "group", "s", "subscription", "to", "only", "contain", "topics", "subscribed", "by", "this", "consumer", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L193-L198
[ "def", "reset_group_subscription", "(", "self", ")", ":", "if", "self", ".", "_user_assignment", ":", "raise", "IllegalStateError", "(", "self", ".", "_SUBSCRIPTION_EXCEPTION_MESSAGE", ")", "assert", "self", ".", "subscription", "is", "not", "None", ",", "'Subscri...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.assign_from_user
Manually assign a list of TopicPartitions to this consumer. This interface does not allow for incremental assignment and will replace the previous assignment (if there was one). Manual topic assignment through this method does not use the consumer's group management functionality. As s...
kafka/consumer/subscription_state.py
def assign_from_user(self, partitions): """Manually assign a list of TopicPartitions to this consumer. This interface does not allow for incremental assignment and will replace the previous assignment (if there was one). Manual topic assignment through this method does not use the cons...
def assign_from_user(self, partitions): """Manually assign a list of TopicPartitions to this consumer. This interface does not allow for incremental assignment and will replace the previous assignment (if there was one). Manual topic assignment through this method does not use the cons...
[ "Manually", "assign", "a", "list", "of", "TopicPartitions", "to", "this", "consumer", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L200-L231
[ "def", "assign_from_user", "(", "self", ",", "partitions", ")", ":", "if", "self", ".", "subscription", "is", "not", "None", ":", "raise", "IllegalStateError", "(", "self", ".", "_SUBSCRIPTION_EXCEPTION_MESSAGE", ")", "if", "self", ".", "_user_assignment", "!=",...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.assign_from_subscribed
Update the assignment to the specified partitions This method is called by the coordinator to dynamically assign partitions based on the consumer's topic subscription. This is different from assign_from_user() which directly sets the assignment from a user-supplied TopicPartition list. ...
kafka/consumer/subscription_state.py
def assign_from_subscribed(self, assignments): """Update the assignment to the specified partitions This method is called by the coordinator to dynamically assign partitions based on the consumer's topic subscription. This is different from assign_from_user() which directly sets the ass...
def assign_from_subscribed(self, assignments): """Update the assignment to the specified partitions This method is called by the coordinator to dynamically assign partitions based on the consumer's topic subscription. This is different from assign_from_user() which directly sets the ass...
[ "Update", "the", "assignment", "to", "the", "specified", "partitions" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L233-L257
[ "def", "assign_from_subscribed", "(", "self", ",", "assignments", ")", ":", "if", "not", "self", ".", "partitions_auto_assigned", "(", ")", ":", "raise", "IllegalStateError", "(", "self", ".", "_SUBSCRIPTION_EXCEPTION_MESSAGE", ")", "for", "tp", "in", "assignments...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.unsubscribe
Clear all topic subscriptions and partition assignments
kafka/consumer/subscription_state.py
def unsubscribe(self): """Clear all topic subscriptions and partition assignments""" self.subscription = None self._user_assignment.clear() self.assignment.clear() self.subscribed_pattern = None
def unsubscribe(self): """Clear all topic subscriptions and partition assignments""" self.subscription = None self._user_assignment.clear() self.assignment.clear() self.subscribed_pattern = None
[ "Clear", "all", "topic", "subscriptions", "and", "partition", "assignments" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L259-L264
[ "def", "unsubscribe", "(", "self", ")", ":", "self", ".", "subscription", "=", "None", "self", ".", "_user_assignment", ".", "clear", "(", ")", "self", ".", "assignment", ".", "clear", "(", ")", "self", ".", "subscribed_pattern", "=", "None" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.paused_partitions
Return current set of paused TopicPartitions.
kafka/consumer/subscription_state.py
def paused_partitions(self): """Return current set of paused TopicPartitions.""" return set(partition for partition in self.assignment if self.is_paused(partition))
def paused_partitions(self): """Return current set of paused TopicPartitions.""" return set(partition for partition in self.assignment if self.is_paused(partition))
[ "Return", "current", "set", "of", "paused", "TopicPartitions", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L300-L303
[ "def", "paused_partitions", "(", "self", ")", ":", "return", "set", "(", "partition", "for", "partition", "in", "self", ".", "assignment", "if", "self", ".", "is_paused", "(", "partition", ")", ")" ]
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.fetchable_partitions
Return set of TopicPartitions that should be Fetched.
kafka/consumer/subscription_state.py
def fetchable_partitions(self): """Return set of TopicPartitions that should be Fetched.""" fetchable = set() for partition, state in six.iteritems(self.assignment): if state.is_fetchable(): fetchable.add(partition) return fetchable
def fetchable_partitions(self): """Return set of TopicPartitions that should be Fetched.""" fetchable = set() for partition, state in six.iteritems(self.assignment): if state.is_fetchable(): fetchable.add(partition) return fetchable
[ "Return", "set", "of", "TopicPartitions", "that", "should", "be", "Fetched", "." ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L305-L311
[ "def", "fetchable_partitions", "(", "self", ")", ":", "fetchable", "=", "set", "(", ")", "for", "partition", ",", "state", "in", "six", ".", "iteritems", "(", "self", ".", "assignment", ")", ":", "if", "state", ".", "is_fetchable", "(", ")", ":", "fetc...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5
train
SubscriptionState.all_consumed_offsets
Returns consumed offsets as {TopicPartition: OffsetAndMetadata}
kafka/consumer/subscription_state.py
def all_consumed_offsets(self): """Returns consumed offsets as {TopicPartition: OffsetAndMetadata}""" all_consumed = {} for partition, state in six.iteritems(self.assignment): if state.has_valid_position: all_consumed[partition] = OffsetAndMetadata(state.position, '')...
def all_consumed_offsets(self): """Returns consumed offsets as {TopicPartition: OffsetAndMetadata}""" all_consumed = {} for partition, state in six.iteritems(self.assignment): if state.has_valid_position: all_consumed[partition] = OffsetAndMetadata(state.position, '')...
[ "Returns", "consumed", "offsets", "as", "{", "TopicPartition", ":", "OffsetAndMetadata", "}" ]
dpkp/kafka-python
python
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L317-L323
[ "def", "all_consumed_offsets", "(", "self", ")", ":", "all_consumed", "=", "{", "}", "for", "partition", ",", "state", "in", "six", ".", "iteritems", "(", "self", ".", "assignment", ")", ":", "if", "state", ".", "has_valid_position", ":", "all_consumed", "...
f6a8a38937688ea2cc5dc13d3d1039493be5c9b5