Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def _fill_from_default(self, default_job_config): if self._job_type != default_job_config._job_type: raise TypeError( "attempted to merge two incompatible job types: " + repr(self._job_type) + ", " ...
[ "Merge this job config with a default job config.\n\n The keys in this object take precedence over the keys in the default\n config. The merge is done at the top-level as well as for keys one\n level below the job type.\n\n Arguments:\n default_job_config (google.cloud.bigquer...
Please provide a description of the function:def from_api_repr(cls, resource): config = cls() config._properties = copy.deepcopy(resource) return config
[ "Factory: construct a job configuration given its API representation\n\n :type resource: dict\n :param resource:\n An extract job configuration in the same representation as is\n returned from the API.\n\n :rtype: :class:`google.cloud.bigquery.job._JobConfig`\n :ret...
Please provide a description of the function:def destination_encryption_configuration(self): prop = self._get_sub_prop("destinationEncryptionConfiguration") if prop is not None: prop = EncryptionConfiguration.from_api_repr(prop) return prop
[ "google.cloud.bigquery.table.EncryptionConfiguration: Custom\n encryption configuration for the destination table.\n\n Custom encryption configuration (e.g., Cloud KMS keys) or :data:`None`\n if using default encryption.\n\n See\n https://cloud.google.com/bigquery/docs/reference/r...
Please provide a description of the function:def schema(self): schema = _helpers._get_sub_prop(self._properties, ["load", "schema", "fields"]) if schema is None: return return [SchemaField.from_api_repr(field) for field in schema]
[ "List[google.cloud.bigquery.schema.SchemaField]: Schema of the\n destination table.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.schema\n " ]
Please provide a description of the function:def time_partitioning(self): prop = self._get_sub_prop("timePartitioning") if prop is not None: prop = TimePartitioning.from_api_repr(prop) return prop
[ "google.cloud.bigquery.table.TimePartitioning: Specifies time-based\n partitioning for the destination table.\n " ]
Please provide a description of the function:def to_api_repr(self): configuration = self._configuration.to_api_repr() if self.source_uris is not None: _helpers._set_sub_prop( configuration, ["load", "sourceUris"], self.source_uris ) _helpers._set_...
[ "Generate a resource for :meth:`_begin`." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): config_resource = resource.get("configuration", {}) config = LoadJobConfig.from_api_repr(config_resource) # A load job requires a destination table. dest_config = config_resource["load"]["dest...
[ "Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :type c...
Please provide a description of the function:def to_api_repr(self): source_refs = [ { "projectId": table.project, "datasetId": table.dataset_id, "tableId": table.table_id, } for table in self.sources ] ...
[ "Generate a resource for :meth:`_begin`." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): job_id, config_resource = cls._get_resource_config(resource) config = CopyJobConfig.from_api_repr(config_resource) # Copy required fields to the job. copy_resource = config_resource["copy"] ...
[ "Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :type c...
Please provide a description of the function:def destination_uri_file_counts(self): counts = self._job_statistics().get("destinationUriFileCounts") if counts is not None: return [int(count) for count in counts] return None
[ "Return file counts from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.extract.destinationUriFileCounts\n\n Returns:\n a list of integer counts, each representing the number of files\n per destination URI or...
Please provide a description of the function:def to_api_repr(self): source_ref = { "projectId": self.source.project, "datasetId": self.source.dataset_id, "tableId": self.source.table_id, } configuration = self._configuration.to_api_repr() _h...
[ "Generate a resource for :meth:`_begin`." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): job_id, config_resource = cls._get_resource_config(resource) config = ExtractJobConfig.from_api_repr(config_resource) source_config = _helpers._get_sub_prop( config_resource, ["extract", "...
[ "Factory: construct a job given its API representation\n\n .. note:\n\n This method assumes that the project found in the resource matches\n the client's project.\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :type c...
Please provide a description of the function:def default_dataset(self): prop = self._get_sub_prop("defaultDataset") if prop is not None: prop = DatasetReference.from_api_repr(prop) return prop
[ "google.cloud.bigquery.dataset.DatasetReference: the default dataset\n to use for unqualified table names in the query or :data:`None` if not\n set.\n\n The ``default_dataset`` setter accepts:\n\n - a :class:`~google.cloud.bigquery.dataset.Dataset`, or\n - a :class:`~google.cloud....
Please provide a description of the function:def destination(self): prop = self._get_sub_prop("destinationTable") if prop is not None: prop = TableReference.from_api_repr(prop) return prop
[ "google.cloud.bigquery.table.TableReference: table where results are\n written or :data:`None` if not set.\n\n The ``destination`` setter accepts:\n\n - a :class:`~google.cloud.bigquery.table.Table`, or\n - a :class:`~google.cloud.bigquery.table.TableReference`, or\n - a :class:`s...
Please provide a description of the function:def table_definitions(self): prop = self._get_sub_prop("tableDefinitions") if prop is not None: prop = _from_api_repr_table_defs(prop) return prop
[ "Dict[str, google.cloud.bigquery.external_config.ExternalConfig]:\n Definitions for external tables or :data:`None` if not set.\n\n See\n https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions\n " ]
Please provide a description of the function:def to_api_repr(self): resource = copy.deepcopy(self._properties) # Query parameters have an addition property associated with them # to indicate if the query is using named or positional parameters. query_parameters = resource["quer...
[ "Build an API representation of the query job config.\n\n Returns:\n dict: A dictionary in the format used by the BigQuery API.\n " ]
Please provide a description of the function:def to_api_repr(self): configuration = self._configuration.to_api_repr() resource = { "jobReference": self._properties["jobReference"], "configuration": configuration, } configuration["query"]["query"] = self....
[ "Generate a resource for :meth:`_begin`." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): job_id, config = cls._get_resource_config(resource) query = config["query"]["query"] job = cls(job_id, query, client=client) job._set_properties(resource) return job
[ "Factory: construct a job given its API representation\n\n :type resource: dict\n :param resource: dataset job representation returned from the API\n\n :type client: :class:`google.cloud.bigquery.client.Client`\n :param client: Client which holds credentials and project\n ...
Please provide a description of the function:def query_plan(self): plan_entries = self._job_statistics().get("queryPlan", ()) return [QueryPlanEntry.from_api_repr(entry) for entry in plan_entries]
[ "Return query plan from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.queryPlan\n\n :rtype: list of :class:`QueryPlanEntry`\n :returns: mappings describing the query plan, or an empty list\n if the q...
Please provide a description of the function:def timeline(self): raw = self._job_statistics().get("timeline", ()) return [TimelineEntry.from_api_repr(entry) for entry in raw]
[ "List(TimelineEntry): Return the query execution timeline\n from job statistics.\n " ]
Please provide a description of the function:def total_bytes_processed(self): result = self._job_statistics().get("totalBytesProcessed") if result is not None: result = int(result) return result
[ "Return total bytes processed from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesProcessed\n\n :rtype: int or None\n :returns: total bytes processed by the job, or None if job is not\n yet ...
Please provide a description of the function:def total_bytes_billed(self): result = self._job_statistics().get("totalBytesBilled") if result is not None: result = int(result) return result
[ "Return total bytes billed from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesBilled\n\n :rtype: int or None\n :returns: total bytes processed by the job, or None if job is not\n yet comple...
Please provide a description of the function:def ddl_target_table(self): prop = self._job_statistics().get("ddlTargetTable") if prop is not None: prop = TableReference.from_api_repr(prop) return prop
[ "Optional[TableReference]: Return the DDL target table, present\n for CREATE/DROP TABLE/VIEW queries.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.ddlTargetTable\n " ]
Please provide a description of the function:def num_dml_affected_rows(self): result = self._job_statistics().get("numDmlAffectedRows") if result is not None: result = int(result) return result
[ "Return the number of DML rows affected by the job.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.numDmlAffectedRows\n\n :rtype: int or None\n :returns: number of DML rows affected by the job, or None if job is not\n yet comple...
Please provide a description of the function:def referenced_tables(self): tables = [] datasets_by_project_name = {} for table in self._job_statistics().get("referencedTables", ()): t_project = table["projectId"] ds_id = table["datasetId"] t_dataset...
[ "Return referenced tables from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.referencedTables\n\n :rtype: list of dict\n :returns: mappings describing the query plan, or an empty list\n if the query ...
Please provide a description of the function:def undeclared_query_parameters(self): parameters = [] undeclared = self._job_statistics().get("undeclaredQueryParameters", ()) for parameter in undeclared: p_type = parameter["parameterType"] if "arrayType" in p_typ...
[ "Return undeclared query parameters from job statistics, if present.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.undeclaredQueryParameters\n\n :rtype:\n list of\n :class:`~google.cloud.bigquery.ArrayQueryParameter`,\n ...
Please provide a description of the function:def estimated_bytes_processed(self): result = self._job_statistics().get("estimatedBytesProcessed") if result is not None: result = int(result) return result
[ "Return the estimated number of bytes processed by the query.\n\n See:\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.estimatedBytesProcessed\n\n :rtype: int or None\n :returns: number of DML rows affected by the job, or None if job is not\n ...
Please provide a description of the function:def done(self, retry=DEFAULT_RETRY): # Since the API to getQueryResults can hang up to the timeout value # (default of 10 seconds), set the timeout parameter to ensure that # the timeout from the futures API is respected. See: # https...
[ "Refresh the job and checks if it is complete.\n\n :rtype: bool\n :returns: True if the job is complete, False otherwise.\n " ]
Please provide a description of the function:def result(self, timeout=None, retry=DEFAULT_RETRY): super(QueryJob, self).result(timeout=timeout) # Return an iterator instead of returning the job. if not self._query_results: self._query_results = self._client._get_query_result...
[ "Start the job and wait for it to complete and get the result.\n\n :type timeout: float\n :param timeout:\n How long (in seconds) to wait for job to complete before raising\n a :class:`concurrent.futures.TimeoutError`.\n\n :type retry: :class:`google.api_core.retry.Retry`\...
Please provide a description of the function:def to_dataframe(self, bqstorage_client=None, dtypes=None, progress_bar_type=None): return self.result().to_dataframe( bqstorage_client=bqstorage_client, dtypes=dtypes, progress_bar_type=progress_bar_type, )
[ "Return a pandas DataFrame from a QueryJob\n\n Args:\n bqstorage_client ( \\\n google.cloud.bigquery_storage_v1beta1.BigQueryStorageClient \\\n ):\n **Alpha Feature** Optional. A BigQuery Storage API client. If\n supplied, use the faster BigQ...
Please provide a description of the function:def from_api_repr(cls, resource): return cls(kind=resource.get("kind"), substeps=resource.get("substeps", ()))
[ "Factory: construct instance from the JSON repr.\n\n :type resource: dict\n :param resource: JSON representation of the entry\n\n :rtype: :class:`QueryPlanEntryStep`\n :return: new instance built from the resource\n " ]
Please provide a description of the function:def start(self): if self._properties.get("startMs") is None: return None return _helpers._datetime_from_microseconds( int(self._properties.get("startMs")) * 1000.0 )
[ "Union[Datetime, None]: Datetime when the stage started." ]
Please provide a description of the function:def end(self): if self._properties.get("endMs") is None: return None return _helpers._datetime_from_microseconds( int(self._properties.get("endMs")) * 1000.0 )
[ "Union[Datetime, None]: Datetime when the stage ended." ]
Please provide a description of the function:def input_stages(self): if self._properties.get("inputStages") is None: return [] return [ _helpers._int_or_none(entry) for entry in self._properties.get("inputStages") ]
[ "List(int): Entry IDs for stages that were inputs for this stage." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): job_ref_properties = resource.get("jobReference", {"projectId": client.project}) job_ref = _JobReference._from_api_repr(job_ref_properties) job = cls(job_ref, client) # Populate the job refere...
[ "Construct an UnknownJob from the JSON representation.\n\n Args:\n resource (dict): JSON representation of a job.\n client (google.cloud.bigquery.client.Client):\n Client connected to BigQuery API.\n\n Returns:\n UnknownJob: Job corresponding to the reso...
Please provide a description of the function:def from_api_repr(cls, resource, client): name = resource.get("name") dns_name = resource.get("dnsName") if name is None or dns_name is None: raise KeyError( "Resource lacks required identity information:" '["name"...
[ "Factory: construct a zone given its API representation\n\n :type resource: dict\n :param resource: zone resource representation returned from the API\n\n :type client: :class:`google.cloud.dns.client.Client`\n :param client: Client which holds credentials and project\n ...
Please provide a description of the function:def description(self, value): if not isinstance(value, six.string_types) and value is not None: raise ValueError("Pass a string, or None") self._properties["description"] = value
[ "Update description of the zone.\n\n :type value: str\n :param value: (Optional) new description\n\n :raises: ValueError for invalid value types.\n " ]
Please provide a description of the function:def name_server_set(self, value): if not isinstance(value, six.string_types) and value is not None: raise ValueError("Pass a string, or None") self._properties["nameServerSet"] = value
[ "Update named set of DNS name servers.\n\n :type value: str\n :param value: (Optional) new title\n\n :raises: ValueError for invalid value types.\n " ]
Please provide a description of the function:def resource_record_set(self, name, record_type, ttl, rrdatas): return ResourceRecordSet(name, record_type, ttl, rrdatas, zone=self)
[ "Construct a resource record set bound to this zone.\n\n :type name: str\n :param name: Name of the record set.\n\n :type record_type: str\n :param record_type: RR type\n\n :type ttl: int\n :param ttl: TTL for the RR, in seconds\n\n :type rrdatas: list of string\n ...
Please provide a description of the function:def _set_properties(self, api_response): self._properties.clear() cleaned = api_response.copy() self.dns_name = cleaned.pop("dnsName", None) if "creationTime" in cleaned: cleaned["creationTime"] = _rfc3339_to_datetime(clea...
[ "Update properties from resource in body of ``api_response``\n\n :type api_response: dict\n :param api_response: response returned from an API call\n " ]
Please provide a description of the function:def _build_resource(self): resource = {"name": self.name} if self.dns_name is not None: resource["dnsName"] = self.dns_name if self.description is not None: resource["description"] = self.description if self...
[ "Generate a resource for ``create`` or ``update``." ]
Please provide a description of the function:def create(self, client=None): client = self._require_client(client) path = "/projects/%s/managedZones" % (self.project,) api_response = client._connection.api_request( method="POST", path=path, data=self._build_resource() ...
[ "API call: create the zone via a PUT request\n\n See\n https://cloud.google.com/dns/api/v1/managedZones/create\n\n :type client: :class:`google.cloud.dns.client.Client`\n :param client:\n (Optional) the client to use. If not passed, falls back to the\n ``client`` ...
Please provide a description of the function:def delete(self, client=None): client = self._require_client(client) client._connection.api_request(method="DELETE", path=self.path)
[ "API call: delete the zone via a DELETE request\n\n See\n https://cloud.google.com/dns/api/v1/managedZones/delete\n\n :type client: :class:`google.cloud.dns.client.Client`\n :param client:\n (Optional) the client to use. If not passed, falls back to the\n ``client...
Please provide a description of the function:def list_resource_record_sets(self, max_results=None, page_token=None, client=None): client = self._require_client(client) path = "/projects/%s/managedZones/%s/rrsets" % (self.project, self.name) iterator = page_iterator.HTTPIterator( ...
[ "List resource record sets for this zone.\n\n See\n https://cloud.google.com/dns/api/v1/resourceRecordSets/list\n\n :type max_results: int\n :param max_results: Optional. The maximum number of resource record\n sets to return. Defaults to a sensible value\n ...
Please provide a description of the function:def annotate_image(self, request, retry=None, timeout=None): # If the image is a file handler, set the content. image = protobuf.get(request, "image") if hasattr(image, "read"): img_bytes = image.read() protobuf.set(re...
[ "Run image detection and annotation for an image.\n\n Example:\n >>> from google.cloud.vision_v1 import ImageAnnotatorClient\n >>> client = ImageAnnotatorClient()\n >>> request = {\n ... 'image': {\n ... 'source': {'image_uri': 'https://foo.c...
Please provide a description of the function:def delete_model(client, model_id): # [START bigquery_delete_model] from google.cloud import bigquery # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client() # TODO(developer): Set model_id to the ID of the model to fet...
[ "Sample ID: go/samples-tracker/1534" ]
Please provide a description of the function:def list_models(client, dataset_id): # [START bigquery_list_models] from google.cloud import bigquery # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client() # TODO(developer): Set dataset_id to the ID of the dataset th...
[ "Sample ID: go/samples-tracker/1512" ]
Please provide a description of the function:def job_path(cls, project, jobs): return google.api_core.path_template.expand( "projects/{project}/jobs/{jobs}", project=project, jobs=jobs )
[ "Return a fully-qualified job string." ]
Please provide a description of the function:def create_job( self, parent, job, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout logi...
[ "\n Creates a new job.\n\n Typically, the job becomes searchable within 10 seconds, but it may take\n up to 5 minutes.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.JobServiceClient()\n >>>\n ...
Please provide a description of the function:def get_job( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout logic. if "get...
[ "\n Retrieves the specified job, whose status is OPEN or recently EXPIRED\n within the last 90 days.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.JobServiceClient()\n >>>\n >>> name = client...
Please provide a description of the function:def batch_delete_jobs( self, parent, filter_, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and t...
[ "\n Deletes a list of ``Job``\\ s by filter.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.JobServiceClient()\n >>>\n >>> parent = client.project_path('[PROJECT]')\n >>>\n >>> ...
Please provide a description of the function:def search_jobs( self, parent, request_metadata, search_mode=None, job_query=None, enable_broadening=None, require_precise_result_size=None, histogram_queries=None, job_view=None, offset=None, ...
[ "\n Searches for jobs using the provided ``SearchJobsRequest``.\n\n This call constrains the ``visibility`` of jobs present in the database,\n and only returns jobs that the caller has permission to search against.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n ...
Please provide a description of the function:def _compute_type_url(klass, prefix=_GOOGLE_APIS_PREFIX): name = klass.DESCRIPTOR.full_name return "%s/%s" % (prefix, name)
[ "Compute a type URL for a klass.\n\n :type klass: type\n :param klass: class to be used as a factory for the given type\n\n :type prefix: str\n :param prefix: URL prefix for the type\n\n :rtype: str\n :returns: the URL, prefixed as appropriate\n " ]
Please provide a description of the function:def register_type(klass, type_url=None): if type_url is None: type_url = _compute_type_url(klass) if type_url in _TYPE_URL_MAP: if _TYPE_URL_MAP[type_url] is not klass: raise ValueError("Conflict: %s" % (_TYPE_URL_MAP[type_url],)) ...
[ "Register a klass as the factory for a given type URL.\n\n :type klass: :class:`type`\n :param klass: class to be used as a factory for the given type\n\n :type type_url: str\n :param type_url: (Optional) URL naming the type. If not provided,\n infers the URL from the type descriptor...
Please provide a description of the function:def _from_any(any_pb): klass = _TYPE_URL_MAP[any_pb.type_url] return klass.FromString(any_pb.value)
[ "Convert an ``Any`` protobuf into the actual class.\n\n Uses the type URL to do the conversion.\n\n .. note::\n\n This assumes that the type URL is already registered.\n\n :type any_pb: :class:`google.protobuf.any_pb2.Any`\n :param any_pb: An any object to be converted.\n\n :rtype: object\n ...
Please provide a description of the function:def from_pb(cls, operation_pb, client, **caller_metadata): result = cls(operation_pb.name, client, **caller_metadata) result._update_state(operation_pb) result._from_grpc = True return result
[ "Factory: construct an instance from a protobuf.\n\n :type operation_pb:\n :class:`~google.longrunning.operations_pb2.Operation`\n :param operation_pb: Protobuf to be parsed.\n\n :type client: object: must provide ``_operations_stub`` accessor.\n :param client: The client use...
Please provide a description of the function:def from_dict(cls, operation, client, **caller_metadata): operation_pb = json_format.ParseDict(operation, operations_pb2.Operation()) result = cls(operation_pb.name, client, **caller_metadata) result._update_state(operation_pb) result...
[ "Factory: construct an instance from a dictionary.\n\n :type operation: dict\n :param operation: Operation as a JSON object.\n\n :type client: :class:`~google.cloud.client.Client`\n :param client: The client used to poll for the status of the operation.\n\n :type caller_metadata: ...
Please provide a description of the function:def _get_operation_rpc(self): request_pb = operations_pb2.GetOperationRequest(name=self.name) return self.client._operations_stub.GetOperation(request_pb)
[ "Polls the status of the current operation.\n\n Uses gRPC request to check.\n\n :rtype: :class:`~google.longrunning.operations_pb2.Operation`\n :returns: The latest status of the current operation.\n " ]
Please provide a description of the function:def _get_operation_http(self): path = "operations/%s" % (self.name,) api_response = self.client._connection.api_request(method="GET", path=path) return json_format.ParseDict(api_response, operations_pb2.Operation())
[ "Checks the status of the current operation.\n\n Uses HTTP request to check.\n\n :rtype: :class:`~google.longrunning.operations_pb2.Operation`\n :returns: The latest status of the current operation.\n " ]
Please provide a description of the function:def _update_state(self, operation_pb): if operation_pb.done: self._complete = True if operation_pb.HasField("metadata"): self.metadata = _from_any(operation_pb.metadata) result_type = operation_pb.WhichOneof("result"...
[ "Update the state of the current object based on operation.\n\n :type operation_pb:\n :class:`~google.longrunning.operations_pb2.Operation`\n :param operation_pb: Protobuf to be parsed.\n " ]
Please provide a description of the function:def poll(self): if self.complete: raise ValueError("The operation has completed.") operation_pb = self._get_operation() self._update_state(operation_pb) return self.complete
[ "Check if the operation has finished.\n\n :rtype: bool\n :returns: A boolean indicating if the current operation has completed.\n :raises ValueError: if the operation\n has already completed.\n " ]
Please provide a description of the function:def _parse_rmw_row_response(row_response): result = {} for column_family in row_response.row.families: column_family_id, curr_family = _parse_family_pb(column_family) result[column_family_id] = curr_family return result
[ "Parses the response to a ``ReadModifyWriteRow`` request.\n\n :type row_response: :class:`.data_v2_pb2.Row`\n :param row_response: The response row (with only modified cells) from a\n ``ReadModifyWriteRow`` request.\n\n :rtype: dict\n :returns: The new contents of all modified ce...
Please provide a description of the function:def _parse_family_pb(family_pb): result = {} for column in family_pb.columns: result[column.qualifier] = cells = [] for cell in column.cells: val_pair = (cell.value, _datetime_from_microseconds(cell.timestamp_micros)) cell...
[ "Parses a Family protobuf into a dictionary.\n\n :type family_pb: :class:`._generated.data_pb2.Family`\n :param family_pb: A protobuf\n\n :rtype: tuple\n :returns: A string and dictionary. The string is the name of the\n column family and the dictionary has column names (within the\n ...
Please provide a description of the function:def _set_cell(self, column_family_id, column, value, timestamp=None, state=None): column = _to_bytes(column) if isinstance(value, six.integer_types): value = _PACK_I64(value) value = _to_bytes(value) if timestamp is None: ...
[ "Helper for :meth:`set_cell`\n\n Adds a mutation to set the value in a specific cell.\n\n ``state`` is unused by :class:`DirectRow` but is used by\n subclasses.\n\n :type column_family_id: str\n :param column_family_id: The column family that contains the column.\n ...
Please provide a description of the function:def _delete(self, state=None): mutation_val = data_v2_pb2.Mutation.DeleteFromRow() mutation_pb = data_v2_pb2.Mutation(delete_from_row=mutation_val) self._get_mutations(state).append(mutation_pb)
[ "Helper for :meth:`delete`\n\n Adds a delete mutation (for the entire row) to the accumulated\n mutations.\n\n ``state`` is unused by :class:`DirectRow` but is used by\n subclasses.\n\n :type state: bool\n :param state: (Optional) The state that is passed along to\n ...
Please provide a description of the function:def _delete_cells(self, column_family_id, columns, time_range=None, state=None): mutations_list = self._get_mutations(state) if columns is self.ALL_COLUMNS: mutation_val = data_v2_pb2.Mutation.DeleteFromFamily( family_name...
[ "Helper for :meth:`delete_cell` and :meth:`delete_cells`.\n\n ``state`` is unused by :class:`DirectRow` but is used by\n subclasses.\n\n :type column_family_id: str\n :param column_family_id: The column family that contains the column\n or columns with cel...
Please provide a description of the function:def get_mutations_size(self): mutation_size = 0 for mutation in self._get_mutations(): mutation_size += mutation.ByteSize() return mutation_size
[ " Gets the total mutations size for current row\n\n For example:\n\n .. literalinclude:: snippets_table.py\n :start-after: [START bigtable_row_get_mutations_size]\n :end-before: [END bigtable_row_get_mutations_size]\n\n " ]
Please provide a description of the function:def set_cell(self, column_family_id, column, value, timestamp=None): self._set_cell(column_family_id, column, value, timestamp=timestamp, state=None)
[ "Sets a value in this row.\n\n The cell is determined by the ``row_key`` of this :class:`DirectRow`\n and the ``column``. The ``column`` must be in an existing\n :class:`.ColumnFamily` (as determined by ``column_family_id``).\n\n .. note::\n\n This method adds a mutation to th...
Please provide a description of the function:def delete_cell(self, column_family_id, column, time_range=None): self._delete_cells( column_family_id, [column], time_range=time_range, state=None )
[ "Deletes cell in this row.\n\n .. note::\n\n This method adds a mutation to the accumulated mutations on this\n row, but does not make an API request. To actually\n send an API request (with the mutations) to the Google Cloud\n Bigtable API, call :meth:`commit`.\n\...
Please provide a description of the function:def delete_cells(self, column_family_id, columns, time_range=None): self._delete_cells(column_family_id, columns, time_range=time_range, state=None)
[ "Deletes cells in this row.\n\n .. note::\n\n This method adds a mutation to the accumulated mutations on this\n row, but does not make an API request. To actually\n send an API request (with the mutations) to the Google Cloud\n Bigtable API, call :meth:`commit`.\n...
Please provide a description of the function:def commit(self): true_mutations = self._get_mutations(state=True) false_mutations = self._get_mutations(state=False) num_true_mutations = len(true_mutations) num_false_mutations = len(false_mutations) if num_true_mutations ==...
[ "Makes a ``CheckAndMutateRow`` API request.\n\n If no mutations have been created in the row, no request is made.\n\n The mutations will be applied conditionally, based on whether the\n filter matches any cells in the :class:`ConditionalRow` or not. (Each\n method which adds a mutation h...
Please provide a description of the function:def append_cell_value(self, column_family_id, column, value): column = _to_bytes(column) value = _to_bytes(value) rule_pb = data_v2_pb2.ReadModifyWriteRule( family_name=column_family_id, column_qualifier=column, append_value=value...
[ "Appends a value to an existing cell.\n\n .. note::\n\n This method adds a read-modify rule protobuf to the accumulated\n read-modify rules on this row, but does not make an API\n request. To actually send an API request (with the rules) to the\n Google Cloud Bigta...
Please provide a description of the function:def increment_cell_value(self, column_family_id, column, int_value): column = _to_bytes(column) rule_pb = data_v2_pb2.ReadModifyWriteRule( family_name=column_family_id, column_qualifier=column, increment_amount=int...
[ "Increments a value in an existing cell.\n\n Assumes the value in the cell is stored as a 64 bit integer\n serialized to bytes.\n\n .. note::\n\n This method adds a read-modify rule protobuf to the accumulated\n read-modify rules on this row, but does not make an API\n ...
Please provide a description of the function:def commit(self): num_mutations = len(self._rule_pb_list) if num_mutations == 0: return {} if num_mutations > MAX_MUTATIONS: raise ValueError( "%d total append mutations exceed the maximum " ...
[ "Makes a ``ReadModifyWriteRow`` API request.\n\n This commits modifications made by :meth:`append_cell_value` and\n :meth:`increment_cell_value`. If no modifications were made, makes\n no API request and just returns ``{}``.\n\n Modifies a row atomically, reading the latest existing\n ...
Please provide a description of the function:def _retry_from_retry_config(retry_params, retry_codes): exception_classes = [ _exception_class_for_grpc_status_name(code) for code in retry_codes ] return retry.Retry( retry.if_exception_type(*exception_classes), initial=(retry_param...
[ "Creates a Retry object given a gapic retry configuration.\n\n Args:\n retry_params (dict): The retry parameter values, for example::\n\n {\n \"initial_retry_delay_millis\": 1000,\n \"retry_delay_multiplier\": 2.5,\n \"max_retry_delay_millis\": 12000...
Please provide a description of the function:def _timeout_from_retry_config(retry_params): return timeout.ExponentialTimeout( initial=(retry_params["initial_rpc_timeout_millis"] / _MILLIS_PER_SECOND), maximum=(retry_params["max_rpc_timeout_millis"] / _MILLIS_PER_SECOND), multiplier=retr...
[ "Creates a ExponentialTimeout object given a gapic retry configuration.\n\n Args:\n retry_params (dict): The retry parameter values, for example::\n\n {\n \"initial_retry_delay_millis\": 1000,\n \"retry_delay_multiplier\": 2.5,\n \"max_retry_delay_mi...
Please provide a description of the function:def parse_method_configs(interface_config): # Grab all the retry codes retry_codes_map = { name: retry_codes for name, retry_codes in six.iteritems(interface_config.get("retry_codes", {})) } # Grab all of the retry params retry_param...
[ "Creates default retry and timeout objects for each method in a gapic\n interface config.\n\n Args:\n interface_config (Mapping): The interface config section of the full\n gapic library config. For example, If the full configuration has\n an interface named ``google.example.v1.Ex...
Please provide a description of the function:def done(self): return self._exception != self._SENTINEL or self._result != self._SENTINEL
[ "Return True the future is done, False otherwise.\n\n This still returns True in failure cases; checking :meth:`result` or\n :meth:`exception` is the canonical way to assess success or failure.\n " ]
Please provide a description of the function:def exception(self, timeout=None): # Wait until the future is done. if not self._completed.wait(timeout=timeout): raise exceptions.TimeoutError("Timed out waiting for result.") # If the batch completed successfully, this should r...
[ "Return the exception raised by the call, if any.\n\n This blocks until the message has successfully been published, and\n returns the exception. If the call succeeded, return None.\n\n Args:\n timeout (Union[int, float]): The number of seconds before this call\n times...
Please provide a description of the function:def add_done_callback(self, fn): if self.done(): return fn(self) self._callbacks.append(fn)
[ "Attach the provided callable to the future.\n\n The provided function is called, with this future as its only argument,\n when the future finishes running.\n " ]
Please provide a description of the function:def set_result(self, result): # Sanity check: A future can only complete once. if self.done(): raise RuntimeError("set_result can only be called once.") # Set the result and trigger the future. self._result = result ...
[ "Set the result of the future to the provided result.\n\n Args:\n result (Any): The result\n " ]
Please provide a description of the function:def set_exception(self, exception): # Sanity check: A future can only complete once. if self.done(): raise RuntimeError("set_exception can only be called once.") # Set the exception and trigger the future. self._exception...
[ "Set the result of the future to the given exception.\n\n Args:\n exception (:exc:`Exception`): The exception raised.\n " ]
Please provide a description of the function:def _trigger(self): self._completed.set() for callback in self._callbacks: callback(self)
[ "Trigger all callbacks registered to this Future.\n\n This method is called internally by the batch once the batch\n completes.\n\n Args:\n message_id (str): The message ID, as a string.\n " ]
Please provide a description of the function:def send( self, record, message, resource=None, labels=None, trace=None, span_id=None ): info = {"message": message, "python_logger": record.name} self.logger.log_struct( info, severity=record.levelname, ...
[ "Overrides transport.send().\n\n :type record: :class:`logging.LogRecord`\n :param record: Python log record that the handler was called with.\n\n :type message: str\n :param message: The message from the ``LogRecord`` after being\n formatted by the associated log ...
Please provide a description of the function:def create_read_session( self, table_reference, parent, table_modifiers=None, requested_streams=None, read_options=None, format_=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_co...
[ "\n Creates a new read session. A read session divides the contents of a\n BigQuery table into one or more streams, which can then be used to read\n data from the table. The read session also specifies properties of the\n data to be read, such as a list of columns or a push-down filter d...
Please provide a description of the function:def read_rows( self, read_position, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout logic. ...
[ "\n Reads rows from the table in the format prescribed by the read session.\n Each response contains one or more table rows, up to a maximum of 10 MiB\n per response; read requests which attempt to read individual rows larger\n than this will fail.\n\n Each request also returns a ...
Please provide a description of the function:def batch_create_read_session_streams( self, session, requested_streams, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transpor...
[ "\n Creates additional streams for a ReadSession. This API can be used to\n dynamically adjust the parallelism of a batch processing task upwards by\n adding additional workers.\n\n Example:\n >>> from google.cloud import bigquery_storage_v1beta1\n >>>\n ...
Please provide a description of the function:def qualifier_encoded(self): prop = self._properties.get("qualifierEncoded") if prop is None: return None return base64.standard_b64decode(_to_bytes(prop))
[ "Union[str, bytes]: The qualifier encoded in binary.\n\n The type is ``str`` (Python 2.x) or ``bytes`` (Python 3.x). The module\n will handle base64 encoding for you.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.%28key%29.bi...
Please provide a description of the function:def columns(self): prop = self._properties.get("columns", []) return [BigtableColumn.from_api_repr(col) for col in prop]
[ "List[:class:`~.external_config.BigtableColumn`]: Lists of columns\n that should be exposed as individual fields.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).bigtableOptions.columnFamilies.columns\n https://cloud.goog...
Please provide a description of the function:def column_families(self): prop = self._properties.get("columnFamilies", []) return [BigtableColumnFamily.from_api_repr(cf) for cf in prop]
[ "List[:class:`~.external_config.BigtableColumnFamily`]: List of\n column families to expose in the table schema along with their types.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).bigtableOptions.columnFamilies\n http...
Please provide a description of the function:def schema(self): prop = self._properties.get("schema", {}) return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])]
[ "List[:class:`~google.cloud.bigquery.schema.SchemaField`]: The schema\n for the data.\n\n See\n https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).schema\n https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#externalDataCo...
Please provide a description of the function:def to_api_repr(self): config = copy.deepcopy(self._properties) if self.options is not None: r = self.options.to_api_repr() if r != {}: config[self.options._RESOURCE_NAME] = r return config
[ "Build an API representation of this object.\n\n Returns:\n Dict[str, Any]:\n A dictionary in the format used by the BigQuery API.\n " ]
Please provide a description of the function:def from_api_repr(cls, resource): config = cls(resource["sourceFormat"]) for optcls in _OPTION_CLASSES: opts = resource.get(optcls._RESOURCE_NAME) if opts is not None: config._options = optcls.from_api_repr(opt...
[ "Factory: construct an :class:`~.external_config.ExternalConfig`\n instance given its API representation.\n\n Args:\n resource (Dict[str, Any]):\n Definition of an :class:`~.external_config.ExternalConfig`\n instance in the same representation as is returned fr...
Please provide a description of the function:def lint(session): session.install('flake8', *LOCAL_DEPS) session.install('-e', '.') session.run( 'flake8', os.path.join('google', 'cloud', 'bigquery_storage_v1beta1')) session.run('flake8', 'tests')
[ "Run linters.\n Returns a failure if the linters find linting errors or sufficiently\n serious code quality issues.\n " ]
Please provide a description of the function:def system(session): # Sanity check: Only run system tests if the environment variable is set. if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): session.skip('Credentials must be set via environment variable.') # Install all test depende...
[ "Run the system test suite." ]
Please provide a description of the function:def docs(session): session.install('sphinx', 'sphinx_rtd_theme') session.install('-e', '.[pandas,fastavro]') shutil.rmtree(os.path.join('docs', '_build'), ignore_errors=True) session.run( 'sphinx-build', '-W', # warnings as errors ...
[ "Build the docs." ]
Please provide a description of the function:def _enum_from_op_string(op_string): try: return _COMPARISON_OPERATORS[op_string] except KeyError: choices = ", ".join(sorted(_COMPARISON_OPERATORS.keys())) msg = _BAD_OP_STRING.format(op_string, choices) raise ValueError(msg)
[ "Convert a string representation of a binary operator to an enum.\n\n These enums come from the protobuf message definition\n ``StructuredQuery.FieldFilter.Operator``.\n\n Args:\n op_string (str): A comparison operation in the form of a string.\n Acceptable values are ``<``, ``<=``, ``==`...
Please provide a description of the function:def _enum_from_direction(direction): if isinstance(direction, int): return direction if direction == Query.ASCENDING: return enums.StructuredQuery.Direction.ASCENDING elif direction == Query.DESCENDING: return enums.StructuredQuery.D...
[ "Convert a string representation of a direction to an enum.\n\n Args:\n direction (str): A direction to order by. Must be one of\n :attr:`~.firestore.Query.ASCENDING` or\n :attr:`~.firestore.Query.DESCENDING`.\n\n Returns:\n int: The enum corresponding to ``direction``.\n\n...
Please provide a description of the function:def _filter_pb(field_or_unary): if isinstance(field_or_unary, query_pb2.StructuredQuery.FieldFilter): return query_pb2.StructuredQuery.Filter(field_filter=field_or_unary) elif isinstance(field_or_unary, query_pb2.StructuredQuery.UnaryFilter): ret...
[ "Convert a specific protobuf filter to the generic filter type.\n\n Args:\n field_or_unary (Union[google.cloud.proto.firestore.v1beta1.\\\n query_pb2.StructuredQuery.FieldFilter, google.cloud.proto.\\\n firestore.v1beta1.query_pb2.StructuredQuery.FieldFilter]): A\n field o...
Please provide a description of the function:def _cursor_pb(cursor_pair): if cursor_pair is not None: data, before = cursor_pair value_pbs = [_helpers.encode_value(value) for value in data] return query_pb2.Cursor(values=value_pbs, before=before)
[ "Convert a cursor pair to a protobuf.\n\n If ``cursor_pair`` is :data:`None`, just returns :data:`None`.\n\n Args:\n cursor_pair (Optional[Tuple[list, bool]]): Two-tuple of\n\n * a list of field values.\n * a ``before`` flag\n\n Returns:\n Optional[google.cloud.firestore...