INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Use the optimized pipeline to predict the target for a feature set. | def predict(self, features):
"""Use the optimized pipeline to predict the target for a feature set.
Parameters
----------
features: array-like {n_samples, n_features}
Feature matrix
Returns
----------
array-like: {n_samples}
Predicted tar... |
Call fit and predict in sequence. | def fit_predict(self, features, target, sample_weight=None, groups=None):
"""Call fit and predict in sequence.
Parameters
----------
features: array-like {n_samples, n_features}
Feature matrix
target: array-like {n_samples}
List of class labels for predic... |
Return the score on the given testing data using the user - specified scoring function. | def score(self, testing_features, testing_target):
"""Return the score on the given testing data using the user-specified scoring function.
Parameters
----------
testing_features: array-like {n_samples, n_features}
Feature matrix of the testing set
testing_target: ar... |
Use the optimized pipeline to estimate the class probabilities for a feature set. | def predict_proba(self, features):
"""Use the optimized pipeline to estimate the class probabilities for a feature set.
Parameters
----------
features: array-like {n_samples, n_features}
Feature matrix of the testing set
Returns
-------
array-like: {... |
Provide a string of the individual without the parameter prefixes. | def clean_pipeline_string(self, individual):
"""Provide a string of the individual without the parameter prefixes.
Parameters
----------
individual: individual
Individual which should be represented by a pretty string
Returns
-------
A string like st... |
If enough time has passed save a new optimized pipeline. Currently used in the per generation hook in the optimization loop. Parameters ---------- gen: int Generation number | def _check_periodic_pipeline(self, gen):
"""If enough time has passed, save a new optimized pipeline. Currently used in the per generation hook in the optimization loop.
Parameters
----------
gen: int
Generation number
Returns
-------
None
"""... |
Export the optimized pipeline as Python code. | def export(self, output_file_name, data_file_path=''):
"""Export the optimized pipeline as Python code.
Parameters
----------
output_file_name: string
String containing the path and file name of the desired output file
data_file_path: string (default: '')
... |
Impute missing values in a feature set. | def _impute_values(self, features):
"""Impute missing values in a feature set.
Parameters
----------
features: array-like {n_samples, n_features}
A feature matrix
Returns
-------
array-like {n_samples, n_features}
"""
if self.verbosit... |
Check if a dataset has a valid feature set and labels. | def _check_dataset(self, features, target, sample_weight=None):
"""Check if a dataset has a valid feature set and labels.
Parameters
----------
features: array-like {n_samples, n_features}
Feature matrix
target: array-like {n_samples} or None
List of clas... |
Compile a DEAP pipeline into a sklearn pipeline. | def _compile_to_sklearn(self, expr):
"""Compile a DEAP pipeline into a sklearn pipeline.
Parameters
----------
expr: DEAP individual
The DEAP pipeline to be compiled
Returns
-------
sklearn_pipeline: sklearn.pipeline.Pipeline
"""
skle... |
Recursively iterate through all objects in the pipeline and set a given parameter. | def _set_param_recursive(self, pipeline_steps, parameter, value):
"""Recursively iterate through all objects in the pipeline and set a given parameter.
Parameters
----------
pipeline_steps: array-like
List of (str, obj) tuples from a scikit-learn pipeline or related object
... |
Stop optimization process once maximum minutes have elapsed. | def _stop_by_max_time_mins(self):
"""Stop optimization process once maximum minutes have elapsed."""
if self.max_time_mins:
total_mins_elapsed = (datetime.now() - self._start_datetime).total_seconds() / 60.
if total_mins_elapsed >= self.max_time_mins:
raise Keyboa... |
Combine the stats with operator count and cv score and preprare to be written to _evaluated_individuals | def _combine_individual_stats(self, operator_count, cv_score, individual_stats):
"""Combine the stats with operator count and cv score and preprare to be written to _evaluated_individuals
Parameters
----------
operator_count: int
number of components in the pipeline
... |
Determine the fit of the provided individuals. | def _evaluate_individuals(self, population, features, target, sample_weight=None, groups=None):
"""Determine the fit of the provided individuals.
Parameters
----------
population: a list of DEAP individual
One individual is a list of pipeline operators and model parameters t... |
Preprocess DEAP individuals before pipeline evaluation. | def _preprocess_individuals(self, individuals):
"""Preprocess DEAP individuals before pipeline evaluation.
Parameters
----------
individuals: a list of DEAP individual
One individual is a list of pipeline operators and model parameters that can be
compiled by DEA... |
Update self. evaluated_individuals_ and error message during pipeline evaluation. | def _update_evaluated_individuals_(self, result_score_list, eval_individuals_str, operator_counts, stats_dicts):
"""Update self.evaluated_individuals_ and error message during pipeline evaluation.
Parameters
----------
result_score_list: list
A list of CV scores for evaluate... |
Update self. _pbar and error message during pipeline evaluation. | def _update_pbar(self, pbar_num=1, pbar_msg=None):
"""Update self._pbar and error message during pipeline evaluation.
Parameters
----------
pbar_num: int
How many pipelines has been processed
pbar_msg: None or string
Error message
Returns
... |
Perform a replacement insertion or shrink mutation on an individual. | def _random_mutation_operator(self, individual, allow_shrink=True):
"""Perform a replacement, insertion, or shrink mutation on an individual.
Parameters
----------
individual: DEAP individual
A list of pipeline operators and model parameters that can be
compiled ... |
Generate an expression where each leaf might have a different depth between min_ and max_. | def _gen_grow_safe(self, pset, min_, max_, type_=None):
"""Generate an expression where each leaf might have a different depth between min_ and max_.
Parameters
----------
pset: PrimitiveSetTyped
Primitive set from which primitives are selected.
min_: int
... |
Count the number of pipeline operators as a measure of pipeline complexity. | def _operator_count(self, individual):
"""Count the number of pipeline operators as a measure of pipeline complexity.
Parameters
----------
individual: list
A grown tree with leaves at possibly different depths
dependending on the condition function.
Ret... |
Update values in the list of result scores and self. _pbar during pipeline evaluation. | def _update_val(self, val, result_score_list):
"""Update values in the list of result scores and self._pbar during pipeline evaluation.
Parameters
----------
val: float or "Timeout"
CV scores
result_score_list: list
A list of CV scores
Returns
... |
Generate a Tree as a list of lists. | def _generate(self, pset, min_, max_, condition, type_=None):
"""Generate a Tree as a list of lists.
The tree is build from the root to the leaves, and it stop growing when
the condition is fulfilled.
Parameters
----------
pset: PrimitiveSetTyped
Primitive s... |
Select categorical features and transform them using OneHotEncoder. | def transform(self, X):
"""Select categorical features and transform them using OneHotEncoder.
Parameters
----------
X: numpy ndarray, {n_samples, n_components}
New data, where n_samples is the number of samples and n_components is the number of components.
Returns
... |
Select continuous features and transform them using PCA. | def transform(self, X):
"""Select continuous features and transform them using PCA.
Parameters
----------
X: numpy ndarray, {n_samples, n_components}
New data, where n_samples is the number of samples and n_components is the number of components.
Returns
---... |
Fit the StackingEstimator meta - transformer. | def fit(self, X, y=None, **fit_params):
"""Fit the StackingEstimator meta-transformer.
Parameters
----------
X: array-like of shape (n_samples, n_features)
The training input samples.
y: array-like, shape (n_samples,)
The target values (integers that corr... |
Transform data by adding two synthetic feature ( s ). | def transform(self, X):
"""Transform data by adding two synthetic feature(s).
Parameters
----------
X: numpy ndarray, {n_samples, n_components}
New data, where n_samples is the number of samples and n_components is the number of components.
Returns
-------
... |
Default scoring function: balanced accuracy. | def balanced_accuracy(y_true, y_pred):
"""Default scoring function: balanced accuracy.
Balanced accuracy computes each class' accuracy on a per-class basis using a
one-vs-rest encoding, then computes an unweighted average of the class accuracies.
Parameters
----------
y_true: numpy.ndarray {n_... |
Transform data by adding two virtual features. | def transform(self, X, y=None):
"""Transform data by adding two virtual features.
Parameters
----------
X: numpy ndarray, {n_samples, n_components}
New data, where n_samples is the number of samples and n_components
is the number of components.
y: None
... |
Decode operator source and import operator class. | def source_decode(sourcecode, verbose=0):
"""Decode operator source and import operator class.
Parameters
----------
sourcecode: string
a string of operator source (e.g 'sklearn.feature_selection.RFE')
verbose: int, optional (default: 0)
How much information TPOT communicates while ... |
Recursively iterates through all objects in the pipeline and sets sample weight. | def set_sample_weight(pipeline_steps, sample_weight=None):
"""Recursively iterates through all objects in the pipeline and sets sample weight.
Parameters
----------
pipeline_steps: array-like
List of (str, obj) tuples from a scikit-learn pipeline or related object
sample_weight: array-like
... |
Dynamically create operator class. | def TPOTOperatorClassFactory(opsourse, opdict, BaseClass=Operator, ArgBaseClass=ARGType, verbose=0):
"""Dynamically create operator class.
Parameters
----------
opsourse: string
operator source in config dictionary (key)
opdict: dictionary
operator params in config dictionary (value... |
Ensure that the provided value is a positive integer. | def positive_integer(value):
"""Ensure that the provided value is a positive integer.
Parameters
----------
value: int
The number to evaluate
Returns
-------
value: int
Returns a positive integer
"""
try:
value = int(value)
except Exception:
rais... |
Ensure that the provided value is a float integer in the range [ 0. 1. ]. | def float_range(value):
"""Ensure that the provided value is a float integer in the range [0., 1.].
Parameters
----------
value: float
The number to evaluate
Returns
-------
value: float
Returns a float in the range (0., 1.)
"""
try:
value = float(value)
... |
Main function that is called when TPOT is run on the command line. | def _get_arg_parser():
"""Main function that is called when TPOT is run on the command line."""
parser = argparse.ArgumentParser(
description=(
'A Python tool that automatically creates and optimizes machine '
'learning pipelines using genetic programming.'
),
add... |
converts mymodule. myfunc in the myfunc object itself so tpot receives a scoring function | def load_scoring_function(scoring_func):
"""
converts mymodule.myfunc in the myfunc
object itself so tpot receives a scoring function
"""
if scoring_func and ("." in scoring_func):
try:
module_name, func_name = scoring_func.rsplit('.', 1)
module_path = os.getcwd()
... |
Perform a TPOT run. | def tpot_driver(args):
"""Perform a TPOT run."""
if args.VERBOSITY >= 2:
_print_args(args)
input_data = _read_data_file(args)
features = input_data.drop(args.TARGET_NAME, axis=1)
training_features, testing_features, training_target, testing_target = \
train_test_split(features, inp... |
Fit FeatureSetSelector for feature selection | def fit(self, X, y=None):
"""Fit FeatureSetSelector for feature selection
Parameters
----------
X: array-like of shape (n_samples, n_features)
The training input samples.
y: array-like, shape (n_samples,)
The target values (integers that correspond to cla... |
Make subset after fit | def transform(self, X):
"""Make subset after fit
Parameters
----------
X: numpy ndarray, {n_samples, n_features}
New data, where n_samples is the number of samples and n_features is the number of features.
Returns
-------
X_transformed: array-like, s... |
Get the boolean mask indicating which features are selected Returns ------- support: boolean array of shape [ # input features ] An element is True iff its corresponding feature is selected for retention. | def _get_support_mask(self):
"""
Get the boolean mask indicating which features are selected
Returns
-------
support : boolean array of shape [# input features]
An element is True iff its corresponding feature is selected for
retention.
"""
... |
Pick two individuals from the population which can do crossover that is they share a primitive. | def pick_two_individuals_eligible_for_crossover(population):
"""Pick two individuals from the population which can do crossover, that is, they share a primitive.
Parameters
----------
population: array of individuals
Returns
----------
tuple: (individual, individual)
Two individual... |
Picks a random individual from the population and performs mutation on a copy of it. | def mutate_random_individual(population, toolbox):
"""Picks a random individual from the population, and performs mutation on a copy of it.
Parameters
----------
population: array of individuals
Returns
----------
individual: individual
An individual which is a mutated copy of one ... |
Part of an evolutionary algorithm applying only the variation part ( crossover mutation ** or ** reproduction ). The modified individuals have their fitness invalidated. The individuals are cloned so returned population is independent of the input population.: param population: A list of individuals to vary.: param too... | def varOr(population, toolbox, lambda_, cxpb, mutpb):
"""Part of an evolutionary algorithm applying only the variation part
(crossover, mutation **or** reproduction). The modified individuals have
their fitness invalidated. The individuals are cloned so returned
population is independent of the input po... |
Initializes the stats dict for individual The statistics initialized are: generation: generation in which the individual was evaluated. Initialized as: 0 mutation_count: number of mutation operations applied to the individual and its predecessor cumulatively. Initialized as: 0 crossover_count: number of crossover opera... | def initialize_stats_dict(individual):
'''
Initializes the stats dict for individual
The statistics initialized are:
'generation': generation in which the individual was evaluated. Initialized as: 0
'mutation_count': number of mutation operations applied to the individual and its predecessor... |
This is the: math: ( \ mu + \ lambda ) evolutionary algorithm.: param population: A list of individuals.: param toolbox: A: class: ~deap. base. Toolbox that contains the evolution operators.: param mu: The number of individuals to select for the next generation.: param lambda \ _: The number of children to produce at e... | def eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, pbar,
stats=None, halloffame=None, verbose=0, per_generation_function=None):
"""This is the :math:`(\mu + \lambda)` evolutionary algorithm.
:param population: A list of individuals.
:param toolbox: A :class:`~deap.bas... |
Randomly select in each individual and exchange each subtree with the point as root between each individual.: param ind1: First tree participating in the crossover.: param ind2: Second tree participating in the crossover.: returns: A tuple of two trees. | def cxOnePoint(ind1, ind2):
"""Randomly select in each individual and exchange each subtree with the
point as root between each individual.
:param ind1: First tree participating in the crossover.
:param ind2: Second tree participating in the crossover.
:returns: A tuple of two trees.
"""
# L... |
Replaces a randomly chosen primitive from * individual * by a randomly chosen primitive no matter if it has the same number of arguments from the: attr: pset attribute of the individual. Parameters ---------- individual: DEAP individual A list of pipeline operators and model parameters that can be compiled by DEAP into... | def mutNodeReplacement(individual, pset):
"""Replaces a randomly chosen primitive from *individual* by a randomly
chosen primitive no matter if it has the same number of arguments from the :attr:`pset`
attribute of the individual.
Parameters
----------
individual: DEAP individual
A list ... |
Fit estimator and compute scores for a given dataset split. | def _wrapped_cross_val_score(sklearn_pipeline, features, target,
cv, scoring_function, sample_weight=None,
groups=None, use_dask=False):
"""Fit estimator and compute scores for a given dataset split.
Parameters
----------
sklearn_pipeline : pipe... |
Return operator class instance by name. | def get_by_name(opname, operators):
"""Return operator class instance by name.
Parameters
----------
opname: str
Name of the sklearn class that belongs to a TPOT operator
operators: list
List of operator classes from operator library
Returns
-------
ret_op_class: class
... |
Generate source code for a TPOT Pipeline. | def export_pipeline(exported_pipeline,
operators, pset,
impute=False, pipeline_score=None,
random_state=None,
data_file_path=''):
"""Generate source code for a TPOT Pipeline.
Parameters
----------
exported_pipeline: deap.cr... |
Convert the unstructured DEAP pipeline into a tree data - structure. | def expr_to_tree(ind, pset):
"""Convert the unstructured DEAP pipeline into a tree data-structure.
Parameters
----------
ind: deap.creator.Individual
The pipeline that is being exported
Returns
-------
pipeline_tree: list
List of operators in the current optimized pipeline
... |
Generate all library import calls for use in TPOT. export (). | def generate_import_code(pipeline, operators, impute=False):
"""Generate all library import calls for use in TPOT.export().
Parameters
----------
pipeline: List
List of operators in the current optimized pipeline
operators:
List of operator class from operator library
impute : b... |
Generate code specific to the construction of the sklearn Pipeline. | def generate_pipeline_code(pipeline_tree, operators):
"""Generate code specific to the construction of the sklearn Pipeline.
Parameters
----------
pipeline_tree: list
List of operators in the current optimized pipeline
Returns
-------
Source code for the sklearn pipeline
"""
... |
Generate code specific to the construction of the sklearn Pipeline for export_pipeline. | def generate_export_pipeline_code(pipeline_tree, operators):
"""Generate code specific to the construction of the sklearn Pipeline for export_pipeline.
Parameters
----------
pipeline_tree: list
List of operators in the current optimized pipeline
Returns
-------
Source code for the ... |
Indent a multiline string by some number of spaces. | def _indent(text, amount):
"""Indent a multiline string by some number of spaces.
Parameters
----------
text: str
The text to be indented
amount: int
The number of spaces to indent the text
Returns
-------
indented_text
"""
indentation = amount * ' '
return... |
Get the next value in the page. | def next(self):
"""Get the next value in the page."""
item = six.next(self._item_iter)
result = self._item_to_value(self._parent, item)
# Since we've successfully got the next value from the
# iterator, we update the number of remaining.
self._remaining -= 1
retur... |
Verifies the parameters don t use any reserved parameter. | def _verify_params(self):
"""Verifies the parameters don't use any reserved parameter.
Raises:
ValueError: If a reserved parameter is used.
"""
reserved_in_use = self._RESERVED_PARAMS.intersection(self.extra_params)
if reserved_in_use:
raise ValueError("U... |
Get the next page in the iterator. | def _next_page(self):
"""Get the next page in the iterator.
Returns:
Optional[Page]: The next page in the iterator or :data:`None` if
there are no pages left.
"""
if self._has_next_page():
response = self._get_next_page_response()
item... |
Getter for query parameters for the next request. | def _get_query_params(self):
"""Getter for query parameters for the next request.
Returns:
dict: A dictionary of query parameters.
"""
result = {}
if self.next_page_token is not None:
result[self._PAGE_TOKEN] = self.next_page_token
if self.max_res... |
Requests the next page from the path provided. | def _get_next_page_response(self):
"""Requests the next page from the path provided.
Returns:
dict: The parsed JSON response of the next page's contents.
Raises:
ValueError: If the HTTP method is not ``GET`` or ``POST``.
"""
params = self._get_query_para... |
Get the next page in the iterator. | def _next_page(self):
"""Get the next page in the iterator.
Wraps the response from the :class:`~google.gax.PageIterator` in a
:class:`Page` instance and captures some state at each page.
Returns:
Optional[Page]: The next page in the iterator or :data:`None` if
... |
Get the next page in the iterator. | def _next_page(self):
"""Get the next page in the iterator.
Returns:
Page: The next page in the iterator or :data:`None` if
there are no pages left.
"""
if not self._has_next_page():
return None
if self.next_page_token is not None:
... |
Determines whether or not there are more pages with results. | def _has_next_page(self):
"""Determines whether or not there are more pages with results.
Returns:
bool: Whether the iterator has more pages.
"""
if self.page_number == 0:
return True
if self.max_results is not None:
if self.num_results >= se... |
Main comparison function for all Firestore types. | def compare(cls, left, right):
"""
Main comparison function for all Firestore types.
@return -1 is left < right, 0 if left == right, otherwise 1
"""
# First compare the types.
leftType = TypeOrder.from_value(left).value
rightType = TypeOrder.from_value(right).valu... |
Service that performs image detection and annotation for a batch of files. Now only application/ pdf image/ tiff and image/ gif are supported. | def batch_annotate_files(
self,
requests,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Service that performs image detection and annotation for a batch of files.
Now only "applica... |
Run asynchronous image detection and annotation for a list of images. | def async_batch_annotate_images(
self,
requests,
output_config,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Run asynchronous image detection and annotation for a list of images.
... |
Run asynchronous image detection and annotation for a list of generic files such as PDF files which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the google. longrunning. Operations interface. Operation. metadata contains OperationMetadata ( metadata ). Operation... | def async_batch_annotate_files(
self,
requests,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Run asynchronous image detection and annotation for a list of generic
files, such as P... |
Called by IPython when this module is loaded as an IPython extension. | def load_ipython_extension(ipython):
"""Called by IPython when this module is loaded as an IPython extension."""
from google.cloud.bigquery.magics import _cell_magic
ipython.register_magic_function(
_cell_magic, magic_kind="cell", magic_name="bigquery"
) |
Create a: class: GoogleAPICallError from an HTTP status code. | def from_http_status(status_code, message, **kwargs):
"""Create a :class:`GoogleAPICallError` from an HTTP status code.
Args:
status_code (int): The HTTP status code.
message (str): The exception message.
kwargs: Additional arguments passed to the :class:`GoogleAPICallError`
... |
Create a: class: GoogleAPICallError from a: class: requests. Response. | def from_http_response(response):
"""Create a :class:`GoogleAPICallError` from a :class:`requests.Response`.
Args:
response (requests.Response): The HTTP response.
Returns:
GoogleAPICallError: An instance of the appropriate subclass of
:class:`GoogleAPICallError`, with the mess... |
Create a: class: GoogleAPICallError from a: class: grpc. StatusCode. | def from_grpc_status(status_code, message, **kwargs):
"""Create a :class:`GoogleAPICallError` from a :class:`grpc.StatusCode`.
Args:
status_code (grpc.StatusCode): The gRPC status code.
message (str): The exception message.
kwargs: Additional arguments passed to the :class:`GoogleAPICal... |
Create a: class: GoogleAPICallError from a: class: grpc. RpcError. | def from_grpc_error(rpc_exc):
"""Create a :class:`GoogleAPICallError` from a :class:`grpc.RpcError`.
Args:
rpc_exc (grpc.RpcError): The gRPC error.
Returns:
GoogleAPICallError: An instance of the appropriate subclass of
:class:`GoogleAPICallError`.
"""
if isinstance(rpc... |
Make a request over the Http transport to the Cloud Datastore API. | def _request(http, project, method, data, base_url):
"""Make a request over the Http transport to the Cloud Datastore API.
:type http: :class:`requests.Session`
:param http: HTTP object to make requests.
:type project: str
:param project: The project to make the request for.
:type method: str... |
Make a protobuf RPC request. | def _rpc(http, project, method, base_url, request_pb, response_pb_cls):
"""Make a protobuf RPC request.
:type http: :class:`requests.Session`
:param http: HTTP object to make requests.
:type project: str
:param project: The project to connect to. This is
usually your project na... |
Construct the URL for a particular API call. | def build_api_url(project, method, base_url):
"""Construct the URL for a particular API call.
This method is used internally to come up with the URL to use when
making RPCs to the Cloud Datastore API.
:type project: str
:param project: The project to connect to. This is
usually... |
Perform a lookup request. | def lookup(self, project_id, keys, read_options=None):
"""Perform a ``lookup`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
:type keys: List[.entity_pb2.Key]
:para... |
Perform a runQuery request. | def run_query(
self, project_id, partition_id, read_options=None, query=None, gql_query=None
):
"""Perform a ``runQuery`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
... |
Perform a beginTransaction request. | def begin_transaction(self, project_id, transaction_options=None):
"""Perform a ``beginTransaction`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
:type transaction_options... |
Perform a commit request. | def commit(self, project_id, mode, mutations, transaction=None):
"""Perform a ``commit`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
:type mode: :class:`.gapic.datastore.... |
Perform a rollback request. | def rollback(self, project_id, transaction):
"""Perform a ``rollback`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
:type transaction: bytes
:param transaction: Th... |
Perform an allocateIds request. | def allocate_ids(self, project_id, keys):
"""Perform an ``allocateIds`` request.
:type project_id: str
:param project_id: The project to connect to. This is
usually your project name in the cloud console.
:type keys: List[.entity_pb2.Key]
:param keys:... |
Creates a request to read rows in a table. | def _create_row_request(
table_name,
start_key=None,
end_key=None,
filter_=None,
limit=None,
end_inclusive=False,
app_profile_id=None,
row_set=None,
):
"""Creates a request to read rows in a table.
:type table_name: str
:param table_name: The name of the table to read from.
... |
Creates a request to mutate rows in a table. | def _mutate_rows_request(table_name, rows, app_profile_id=None):
"""Creates a request to mutate rows in a table.
:type table_name: str
:param table_name: The name of the table to write to.
:type rows: list
:param rows: List or other iterable of :class:`.DirectRow` instances.
:type: app_profil... |
Checks that a row belongs to a table. | def _check_row_table_name(table_name, row):
"""Checks that a row belongs to a table.
:type table_name: str
:param table_name: The name of the table.
:type row: :class:`~google.cloud.bigtable.row.Row`
:param row: An instance of :class:`~google.cloud.bigtable.row.Row`
subclasses.
... |
Table name used in requests. | def name(self):
"""Table name used in requests.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_table_name]
:end-before: [END bigtable_table_name]
.. note::
This property will not change if ``table_id`` does not, but ... |
Factory to create a row associated with this table. | def row(self, row_key, filter_=None, append=False):
"""Factory to create a row associated with this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_table_row]
:end-before: [END bigtable_table_row]
.. warning::
... |
Creates this table. | def create(self, initial_split_keys=[], column_families={}):
"""Creates this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_create_table]
:end-before: [END bigtable_create_table]
.. note::
A create request r... |
Check whether the table exists. | def exists(self):
"""Check whether the table exists.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_check_table_exists]
:end-before: [END bigtable_check_table_exists]
:rtype: bool
:returns: True if the table exists, els... |
Delete this table. | def delete(self):
"""Delete this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_delete_table]
:end-before: [END bigtable_delete_table]
"""
table_client = self._instance._client.table_admin_client
table_cl... |
List the column families owned by this table. | def list_column_families(self):
"""List the column families owned by this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_list_column_families]
:end-before: [END bigtable_list_column_families]
:rtype: dict
:return... |
List the cluster states owned by this table. | def get_cluster_states(self):
"""List the cluster states owned by this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_get_cluster_states]
:end-before: [END bigtable_get_cluster_states]
:rtype: dict
:returns: Dict... |
Read a single row from this table. | def read_row(self, row_key, filter_=None):
"""Read a single row from this table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_read_row]
:end-before: [END bigtable_read_row]
:type row_key: bytes
:param row_key: The key... |
Read rows from this table. | def read_rows(
self,
start_key=None,
end_key=None,
limit=None,
filter_=None,
end_inclusive=False,
row_set=None,
retry=DEFAULT_RETRY_READ_ROWS,
):
"""Read rows from this table.
For example:
.. literalinclude:: snippets_table.py... |
Read rows from this table. | def yield_rows(self, **kwargs):
"""Read rows from this table.
.. warning::
This method will be removed in future releases. Please use
``read_rows`` instead.
:type start_key: bytes
:param start_key: (Optional) The beginning of a range of row keys to
... |
Mutates multiple rows in bulk. | def mutate_rows(self, rows, retry=DEFAULT_RETRY):
"""Mutates multiple rows in bulk.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_mutate_rows]
:end-before: [END bigtable_mutate_rows]
The method tries to update all specified ro... |
Read a sample of row keys in the table. | def sample_row_keys(self):
"""Read a sample of row keys in the table.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_sample_row_keys]
:end-before: [END bigtable_sample_row_keys]
The returned row keys will delimit contiguous sec... |
Truncate the table | def truncate(self, timeout=None):
"""Truncate the table
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_truncate_table]
:end-before: [END bigtable_truncate_table]
:type timeout: float
:param timeout: (Optional) The amoun... |
Factory to create a mutation batcher associated with this instance. | def mutations_batcher(self, flush_count=FLUSH_COUNT, max_row_bytes=MAX_ROW_BYTES):
"""Factory to create a mutation batcher associated with this instance.
For example:
.. literalinclude:: snippets_table.py
:start-after: [START bigtable_mutations_batcher]
:end-before: [EN... |
Mutate all the rows that are eligible for retry. | def _do_mutate_retryable_rows(self):
"""Mutate all the rows that are eligible for retry.
A row is eligible for retry if it has not been tried or if it resulted
in a transient error in a previous call.
:rtype: list
:return: The responses statuses, which is a list of
... |
Periodically send heartbeats. | def heartbeat(self):
"""Periodically send heartbeats."""
while self._manager.is_active and not self._stop_event.is_set():
self._manager.heartbeat()
_LOGGER.debug("Sent heartbeat.")
self._stop_event.wait(timeout=self._period)
_LOGGER.info("%s exiting.", _HEART... |
Report an individual error event. | def report_error_event(
self,
project_name,
event,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Report an individual error event.
Example:
>>> from google.clo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.