code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _AllocateLocalDisks(self, disk_spec):
"""Allocate the VM's local disks (included with the VM), as a data disk(s).
A local disk can only be allocated once per data disk.
Args:
disk_spec: virtual_machine.BaseDiskSpec object of the disk.
"""
block_devices = self._GetBlockDevices()
free_... | Allocate the VM's local disks (included with the VM), as a data disk(s).
A local disk can only be allocated once per data disk.
Args:
disk_spec: virtual_machine.BaseDiskSpec object of the disk.
| _AllocateLocalDisks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _AllocateRemoteDisks(self, disk_spec):
"""Creates and allocates Rackspace Cloud Block Storage volumes as
as data disks.
Args:
disk_spec: virtual_machine.BaseDiskSpec object of the disk.
"""
scratch_disks = []
for disk_num in range(disk_spec.num_striped_disks):
volume_name = '%s... | Creates and allocates Rackspace Cloud Block Storage volumes as
as data disks.
Args:
disk_spec: virtual_machine.BaseDiskSpec object of the disk.
| _AllocateRemoteDisks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _GetFreeBlockDevices(self, block_devices, disk_spec):
"""Returns available block devices that are not in used as data disk or as
a boot disk.
Args:
block_devices: list of dict containing information about all block devices
in the VM.
disk_spec: virtual_machine.BaseDiskSpec of the d... | Returns available block devices that are not in used as data disk or as
a boot disk.
Args:
block_devices: list of dict containing information about all block devices
in the VM.
disk_spec: virtual_machine.BaseDiskSpec of the disk.
Returns:
list of dicts of only block devices that... | _GetFreeBlockDevices | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _GetBlockDevices(self):
"""Execute command on VM to gather all block devices in the VM.
Returns:
list of dicts block devices in the VM.
"""
stdout, _ = self.RemoteCommand(
'sudo lsblk -o NAME,MODEL,SIZE,TYPE,MOUNTPOINT,LABEL -n -b -P'
)
lines = stdout.splitlines()
groups =... | Execute command on VM to gather all block devices in the VM.
Returns:
list of dicts block devices in the VM.
| _GetBlockDevices | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _GetBootDevice(self):
"""Returns backing block device where '/' is mounted on.
Returns:
dict blk device data
Raises:
errors.Error indicates that could not find block device with '/'.
"""
blk_devices = self._GetBlockDevices()
boot_blk_device = None
for dev in blk_devices:
... | Returns backing block device where '/' is mounted on.
Returns:
dict blk device data
Raises:
errors.Error indicates that could not find block device with '/'.
| _GetBootDevice | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _FindBootBlockDevice(self, blk_devices, boot_blk_device):
"""Helper method to search for backing block device of a partition."""
blk_device_name = boot_blk_device['name'].rstrip('0123456789')
for dev in blk_devices:
if dev['type'] == 'disk' and dev['name'] == blk_device_name:
boot_blk_devi... | Helper method to search for backing block device of a partition. | _FindBootBlockDevice | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def _IsDiskAvailable(self, blk_device):
"""Returns True if a block device is available.
An available disk, is a disk that has not been allocated previously as
a data disk, or is not being used as boot disk.
"""
return (
blk_device['type'] != 'part'
and blk_device['name'] != self.boo... | Returns True if a block device is available.
An available disk, is a disk that has not been allocated previously as
a data disk, or is not being used as boot disk.
| _IsDiskAvailable | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/rackspace_virtual_machine.py | Apache-2.0 |
def __init__(self, resource, *args):
"""Initialize a RackCLICommand with the provided args and common flags.
Args:
resource: A Rackspace resource of type BaseResource.
*args: sequence of strings. Positional args to pass to rack cli, typically
specifying an operation to perform. (e.g. ['serv... | Initialize a RackCLICommand with the provided args and common flags.
Args:
resource: A Rackspace resource of type BaseResource.
*args: sequence of strings. Positional args to pass to rack cli, typically
specifying an operation to perform. (e.g. ['servers', 'image', 'list']
to list avail... | __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/util.py | Apache-2.0 |
def Issue(self, **kwargs):
"""Tries running the rack cli command once.
Args:
**kwargs: Keyword arguments to forward to vm_util.IssueCommand when
issuing the rack cli command.
Returns:
A tuple of stdout, stderr, and retcode from running the rack cli command.
"""
if 'raise_on_fai... | Tries running the rack cli command once.
Args:
**kwargs: Keyword arguments to forward to vm_util.IssueCommand when
issuing the rack cli command.
Returns:
A tuple of stdout, stderr, and retcode from running the rack cli command.
| Issue | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/util.py | Apache-2.0 |
def _AddCommonFlags(self, resource):
"""Adds common flags to the command.
Adds common rack cli flags derived from the PKB flags and provided resource.
Args:
resource: A Rackspace resource of type BaseResource.
"""
self.flags['output'] = 'json'
if hasattr(resource, 'profile') and resource... | Adds common flags to the command.
Adds common rack cli flags derived from the PKB flags and provided resource.
Args:
resource: A Rackspace resource of type BaseResource.
| _AddCommonFlags | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/util.py | Apache-2.0 |
def _GetCommand(self):
"""Generates the rack cli command.
Returns:
list of strings. When joined by spaces, form the rack cli command.
"""
cmd = [FLAGS.rack_path]
cmd.extend(self.args)
self._AddCommonFlags(self.resource)
for flag_name, value in self.flags.items():
flag_name_str... | Generates the rack cli command.
Returns:
list of strings. When joined by spaces, form the rack cli command.
| _GetCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/rackspace/util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/rackspace/util.py | Apache-2.0 |
def Prepare(self, package_name: str) -> None:
"""Prepares the client vm to execute query.
Installs a java client application that uses the JDBC driver for connecting
to a database server.
https://docs.snowflake.com/en/user-guide/jdbc.html
Args:
package_name: String name of the package defin... | Prepares the client vm to execute query.
Installs a java client application that uses the JDBC driver for connecting
to a database server.
https://docs.snowflake.com/en/user-guide/jdbc.html
Args:
package_name: String name of the package defining the preprovisioned data
(certificates, et... | Prepare | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def GetSnowflakeClientInterface(
warehouse: str, database: str, schema: str, cloud: str
) -> JdbcClientInterface:
"""Builds and Returns the requested Snowflake client Interface.
Args:
warehouse: String name of the Snowflake virtual warehouse to use during the
benchmark
database: String name of th... | Builds and Returns the requested Snowflake client Interface.
Args:
warehouse: String name of the Snowflake virtual warehouse to use during the
benchmark
database: String name of the Snowflake database to use during the benchmark
schema: String name of the Snowflake schema to use during the benchm... | GetSnowflakeClientInterface | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def RemoveDataset(self, dataset: Union[str, None] = None):
"""Removes a dataset.
Args:
dataset: Optional name of the dataset. If none, will be determined by the
service.
"""
if dataset is None:
dataset = f'pkb_{FLAGS.run_uri}_snowflake_autoname'
query = f'DROP SCHEMA {dataset}'
... | Removes a dataset.
Args:
dataset: Optional name of the dataset. If none, will be determined by the
service.
| RemoveDataset | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def CreateDataset(
self,
dataset: Union[str, None] = None,
description: Union[str, None] = None,
):
"""Create a new dataset.
For Snowflake, we define a 'dataset' to be a 'schema', Snowflake's second
level division of data, below 'database'. This is analogous to the
GCP project/datas... | Create a new dataset.
For Snowflake, we define a 'dataset' to be a 'schema', Snowflake's second
level division of data, below 'database'. This is analogous to the
GCP project/dataset hierarchy in BigQuery.
Args:
dataset: Optional name of the dataset. If none, will be determined by the
se... | CreateDataset | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def CopyTable(self, copy_table_name: str, to_dataset: str) -> None:
"""Copy a table from the active dataset to the specified dataset.
Copies a table between datasets, from the active (current) dataset to
another named dataset in the same project.
Args:
copy_table_name: Name of the table to copy ... | Copy a table from the active dataset to the specified dataset.
Copies a table between datasets, from the active (current) dataset to
another named dataset in the same project.
Args:
copy_table_name: Name of the table to copy from the loaded dataset to the
copy dataset.
to_dataset: Name... | CopyTable | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def _CreateLikeTable(self, table_name: str, dataset: str) -> None:
"""Create a table in the specified dataset with the same name and schema.
Args:
table_name: Name of the table to create a schema-copy of in the target
dataset. Must be an extant table in the active dataset.
dataset: The data... | Create a table in the specified dataset with the same name and schema.
Args:
table_name: Name of the table to create a schema-copy of in the target
dataset. Must be an extant table in the active dataset.
dataset: The dataset to create a table in.
| _CreateLikeTable | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def _CopyData(
self, database, copy_table_name: str, to_dataset: str, from_dataset: str
) -> None:
"""Copy data from a table in dataset to same name table in other dataset.
Args:
database: The database that contains the to and from datasets.
copy_table_name: Name of the table to copy from t... | Copy data from a table in dataset to same name table in other dataset.
Args:
database: The database that contains the to and from datasets.
copy_table_name: Name of the table to copy from the loaded dataset to the
copy dataset.
to_dataset: Name of the dataset to copy the table into.
... | _CopyData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def _RunConfigurationStatement(self, stmt_name: str, query_text: str) -> None:
"""Run the provided statement on the Snowflake instance, and return results.
Does not time the specified statement.
Args:
stmt_name: A name for the provided statement
query_text: The query text of the statement that... | Run the provided statement on the Snowflake instance, and return results.
Does not time the specified statement.
Args:
stmt_name: A name for the provided statement
query_text: The query text of the statement that should be run.
Returns:
Results returned in response to running the provided... | _RunConfigurationStatement | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def GetMetadata(self):
"""Return a metadata dictionary of the benchmarked Snowflake cluster."""
basic_data = super().GetMetadata()
basic_data['warehouse'] = self.warehouse
basic_data['database'] = self.database
basic_data['schema'] = self.schema
basic_data.update(self.client_interface.GetMetadat... | Return a metadata dictionary of the benchmarked Snowflake cluster. | GetMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/snowflake/snowflake.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/snowflake/snowflake.py | Apache-2.0 |
def _GenerateName(self) -> str:
"""Generates a unique name for the job.
Locking the counter variable allows for each created job name to be
unique within the python process.
Returns:
The newly generated name.
"""
with self._job_counter_lock:
self.job_number: int = self._job_counter... | Generates a unique name for the job.
Locking the counter variable allows for each created job name to be
unique within the python process.
Returns:
The newly generated name.
| _GenerateName | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/base_job.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/base_job.py | Apache-2.0 |
def GetExampleResourceClass(
example_type: str,
) -> resource.AutoRegisterResourceMeta | None:
"""Gets the example resource class corresponding to 'example_type'."""
return resource.GetResourceClass(
BaseExampleResource, EXAMPLE_TYPE=example_type
) | Gets the example resource class corresponding to 'example_type'. | GetExampleResourceClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/example_resource.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/example_resource.py | Apache-2.0 |
def GetExampleResourceSpecClass(
example_type: str,
) -> spec.BaseSpecMetaClass | None:
"""Gets the example spec class corresponding to 'example_type'."""
return spec.GetSpecClass(BaseExampleResourceSpec, EXAMPLE_TYPE=example_type) | Gets the example spec class corresponding to 'example_type'. | GetExampleResourceSpecClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/example_resource_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/example_resource_spec.py | Apache-2.0 |
def _CreateDependencies(self):
"""Adds metadata about whether this is the first model in the region."""
num_endpoints = len(self.ListExistingEndpoints())
no_other_models = num_endpoints == 0
self.metadata.update({'First Model': no_other_models}) | Adds metadata about whether this is the first model in the region. | _CreateDependencies | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def GetRegionFromZone(self, zone: str) -> str:
"""Returns the region a zone is in."""
raise NotImplementedError(
'GetRegionFromZone is not implemented for this model type.'
) | Returns the region a zone is in. | GetRegionFromZone | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def ListExistingEndpoints(self, region: str | None = None) -> list[str]:
"""Returns a list of existing endpoints in the same region.
Args:
region: If not provided, uses self.region.
Returns:
List of endpoint names. Endpoints can actually serve traffic.
"""
raise NotImplementedError(
... | Returns a list of existing endpoints in the same region.
Args:
region: If not provided, uses self.region.
Returns:
List of endpoint names. Endpoints can actually serve traffic.
| ListExistingEndpoints | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def _IsReady(self):
"""Return true if the underlying resource is ready.
Supplying this method is optional. Use it when a resource can exist
without being ready. If the subclass does not implement
it then it just returns true.
Returns:
True if the resource was ready in time, False if the wa... | Return true if the underlying resource is ready.
Supplying this method is optional. Use it when a resource can exist
without being ready. If the subclass does not implement
it then it just returns true.
Returns:
True if the resource was ready in time, False if the wait timed out.
| _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def SendPrompt(
self, prompt: str, max_tokens: int, temperature: float, **kwargs: Any
) -> list[str]:
"""Sends a prompt to the model, times it, and returns the response.
Args:
prompt: The prompt to send.
max_tokens: The max tokens to return.
temperature: The temperature to use.
... | Sends a prompt to the model, times it, and returns the response.
Args:
prompt: The prompt to send.
max_tokens: The max tokens to return.
temperature: The temperature to use.
**kwargs: Additional arguments to pass to _SendPrompt.
Throws:
errors.Resource.GetError if the prompt fail... | SendPrompt | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def GetPromptCommand(self, prompt: str, max_tokens: int, temperature: float):
"""Returns the command needed to send a prompt to the model."""
raise NotImplementedError(
'GetPromptCommand is not implemented for this model type.'
) | Returns the command needed to send a prompt to the model. | GetPromptCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def GetManagedAiModelClass(
cloud: str,
interface: str,
) -> resource.AutoRegisterResourceMeta | None:
"""Gets the managed AI model class for the given cloud."""
return resource.GetResourceClass(
BaseManagedAiModel, CLOUD=cloud, INTERFACE=interface
) | Gets the managed AI model class for the given cloud. | GetManagedAiModelClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model.py | Apache-2.0 |
def GetManagedAiModelSpecClass(
cloud: str, model_name: str, model_size: str
) -> spec.BaseSpecMetaClass | None:
"""Gets the example spec class corresponding to the given attributes."""
return spec.GetSpecClass(
BaseManagedAiModelSpec,
CLOUD=cloud,
MODEL_NAME=model_name,
MODEL_SIZE=model... | Gets the example spec class corresponding to the given attributes. | GetManagedAiModelSpecClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/managed_ai_model_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/managed_ai_model_spec.py | Apache-2.0 |
def CreateDisks(disk_specs, vm_name):
"""Creates instances of KubernetesDisk child classes."""
# Depending on scratch disk type.
scratch_disks = []
for disk_num, disk_spec in enumerate(disk_specs):
disk_class = GetKubernetesDiskClass(disk_spec.disk_type)
scratch_disk = disk_class(disk_num, disk_spec, vm... | Creates instances of KubernetesDisk child classes. | CreateDisks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | Apache-2.0 |
def _Create(self):
"""Creates Rados Block Device volumes and installs filesystem on them."""
cmd = [
'rbd',
'-p',
FLAGS.rbd_pool,
'create',
self.name,
'--size',
str(1024 * self.disk_size),
]
_, stderr, retcode = vm_util.IssueCommand(cmd, raise_on_f... | Creates Rados Block Device volumes and installs filesystem on them. | _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | Apache-2.0 |
def SetDevicePath(self, vm):
"""Retrieves the path to scratch disk device."""
cmd = "mount | grep %s | tr -s ' ' | cut -f 1 -d ' '" % self.mount_point
device, _ = vm.RemoteCommand(cmd)
self.device_path = device.rstrip() | Retrieves the path to scratch disk device. | SetDevicePath | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | Apache-2.0 |
def _WaitForPVCBoundCompletion(self):
"""Need to wait for the PVC to get up."""
# PVC may take some time to be ready(Bound).
exists_cmd = [
FLAGS.kubectl,
'--kubeconfig=%s' % FLAGS.kubeconfig,
'get',
'pvc',
'-o=json',
self.name,
]
logging.info('Waiting... | Need to wait for the PVC to get up. | _WaitForPVCBoundCompletion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_disk.py | Apache-2.0 |
def Decode(self, value, component_full_name, flag_values):
"""Decodes the kubernetes resources spec.
Args:
value: a dict containing 'cpus' and 'memory' keys.
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flag... | Decodes the kubernetes resources spec.
Args:
value: a dict containing 'cpus' and 'memory' keys.
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.FlagValues. Runtime flag values to be propagated to
Base... | Decode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_resources_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_resources_spec.py | Apache-2.0 |
def _IsKubectlErrorEphemeral(retcode: int, stderr: str) -> bool:
"""Determine if kubectl error is retriable."""
return retcode == 1 and any(
error in stderr for error in container_service.RETRYABLE_KUBECTL_ERRORS
) | Determine if kubectl error is retriable. | _IsKubectlErrorEphemeral | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def __init__(self, vm_spec: kubernetes_pod_spec.KubernetesPodSpec):
"""Initialize a Kubernetes virtual machine.
Args:
vm_spec: KubernetesPodSpec object of the vm.
"""
super().__init__(vm_spec)
self.name: str = self.name.replace('_', '-')
self.user_name: str = FLAGS.username
self.image... | Initialize a Kubernetes virtual machine.
Args:
vm_spec: KubernetesPodSpec object of the vm.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _Create(self):
"""Creates a POD (Docker container with optional volumes)."""
create_rc_body = self._BuildPodBody()
logging.info('About to create a pod with the following configuration:')
logging.info(create_rc_body)
kubernetes_helper.CreateResource(create_rc_body) | Creates a POD (Docker container with optional volumes). | _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _IsReady(self) -> bool:
"""Need to wait for the PODs to get up, they're created with a little delay."""
exists_cmd = [
FLAGS.kubectl,
'--kubeconfig=%s' % FLAGS.kubeconfig,
'get',
'pod',
'-o=json',
self.name,
]
logging.info('Waiting for POD %s', self.na... | Need to wait for the PODs to get up, they're created with a little delay. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _Exists(self) -> bool:
"""POD should have been already created but this is a double check."""
exists_cmd = [
FLAGS.kubectl,
'--kubeconfig=%s' % FLAGS.kubeconfig,
'get',
'pod',
'-o=json',
self.name,
]
pod_info, _, _ = vm_util.IssueCommand(exists_cmd, ra... | POD should have been already created but this is a double check. | _Exists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _GetInternalIp(self):
"""Gets the POD's internal ip address."""
pod_ip = kubernetes_helper.Get('pods', self.name, '', '.status.podIP')
if not pod_ip:
raise Exception('Internal POD IP address not found. Retrying.')
self.internal_ip = pod_ip
self.ip_address = pod_ip
if self.sriov_netwo... | Gets the POD's internal ip address. | _GetInternalIp | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _ConfigureProxy(self):
"""Configures Proxy.
In Docker containers environment variables from /etc/environment
are not sourced - this results in connection problems when running
behind proxy. Prepending proxy environment variables to bashrc
solves the problem. Note: APPENDING to bashrc will not w... | Configures Proxy.
In Docker containers environment variables from /etc/environment
are not sourced - this results in connection problems when running
behind proxy. Prepending proxy environment variables to bashrc
solves the problem. Note: APPENDING to bashrc will not work because
the script exits w... | _ConfigureProxy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _BuildPodBody(self) -> str:
"""Builds a JSON.
This will be passed as a body of POST request Kuberneres API in order to
create a POD.
Returns:
json string for POD creation.
"""
container = self._BuildContainerBody()
volumes = self._BuildVolumesBody()
template = {
'ki... | Builds a JSON.
This will be passed as a body of POST request Kuberneres API in order to
create a POD.
Returns:
json string for POD creation.
| _BuildPodBody | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _BuildVolumesBody(self) -> list[dict[str, Any]]:
"""Constructs volumes-related part of POST request to create POD."""
volumes = []
for scratch_disk in self.scratch_disks:
scratch_disk.AttachVolumeInfo(volumes)
return volumes | Constructs volumes-related part of POST request to create POD. | _BuildVolumesBody | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _BuildContainerBody(self) -> dict[str, Any]:
"""Constructs containers-related part of POST request to create POD."""
registry = getattr(context.GetThreadBenchmarkSpec(), 'registry', None)
if not FLAGS.static_container_image and registry is not None:
image = registry.GetFullRegistryTag(self.image)
... | Constructs containers-related part of POST request to create POD. | _BuildContainerBody | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def RemoteHostCommandWithReturnCode(
self,
command: str,
retries: int | None = None,
ignore_failure: bool = False,
login_shell: bool = False,
timeout: float | None = None,
ip_address: str | None = None,
should_pre_log: bool = True,
stack_level: int = 1,
):
"""... | Runs a command in the Kubernetes container using kubectl.
Args:
command: A bash command string.
retries: The maximum number of times to retry SSHing 255 errors.
ignore_failure: If true, ignores failures rather than raising an
Exception.
login_shell: If true, runs commands in a login... | RemoteHostCommandWithReturnCode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def RemoteHostCopy(
self,
file_path: str,
remote_path: str = '',
copy_to: bool = True,
retries: int | None = None,
):
"""Copies a file to or from the VM.
Args:
file_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_... | Copies a file to or from the VM.
Args:
file_path: Local path to file.
remote_path: Optional path of where to copy file on remote host.
copy_to: True to copy to vm, False to copy from vm.
retries: Number of attempts for the copy
Raises:
RemoteCommandError: If there was a problem c... | RemoteHostCopy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def DownloadPreprovisionedData(
self,
install_path: str,
module_name: str,
filename: str,
timeout: int = virtual_machine.PREPROVISIONED_DATA_TIMEOUT,
):
"""Downloads a preprovisioned data file.
This function works by looking up the VirtualMachine class which matches
the clou... | Downloads a preprovisioned data file.
This function works by looking up the VirtualMachine class which matches
the cloud we are running on. Each cloud's VM module has a function to
generate the preprovisioned data command, which we run from here.
Note that this implementation is specific to Debian OS ... | DownloadPreprovisionedData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _InstallPrepareVmEnvironmentDependencies(self):
"""Installs sudo and other packages assumed by SetupVmEnvironment."""
# The canonical ubuntu images as well as the nvidia/cuda
# image do not have sudo installed so install it and configure
# the sudoers file such that the root user's environment is
... | Installs sudo and other packages assumed by SetupVmEnvironment. | _InstallPrepareVmEnvironmentDependencies | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/kubernetes/kubernetes_virtual_machine.py | Apache-2.0 |
def _GetAPIKeyFromFile(self) -> str:
"""Get the API key from a file."""
return vm_util.IssueCommand(
['cat', pinecone_flags.PINECONE_API_KEY_PATH.value]
)[0].strip() | Get the API key from a file. | _GetAPIKeyFromFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/pinecone/pinecone.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/pinecone/pinecone.py | Apache-2.0 |
def GetPineconeResourceClass(
cloud: str,
) -> resource.AutoRegisterResourceMeta | None:
"""Gets the pinecone server class for the given cloud."""
return resource.GetResourceClass(PineconeServer, CLOUD=cloud) | Gets the pinecone server class for the given cloud. | GetPineconeResourceClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/pinecone/pinecone.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/pinecone/pinecone.py | Apache-2.0 |
def Decode(self, value, component_full_name, flag_values):
"""Decodes the pinecone resources spec.
Args:
value: a dict containing 'cpus' and 'memory' keys.
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.... | Decodes the pinecone resources spec.
Args:
value: a dict containing 'cpus' and 'memory' keys.
component_full_name: string. Fully qualified name of the configurable
component containing the config option.
flag_values: flags.FlagValues. Runtime flag values to be propagated to
BaseSp... | Decode | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/resources/pinecone/pinecone_resource_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resources/pinecone/pinecone_resource_spec.py | Apache-2.0 |
def GetModel():
"""Gets an existing model as a python object."""
assert _ENDPOINT_NAME.value
kwargs = {
'region': _REGION.value,
'model_id': _MODEL_ID.value,
}
if _MODEL_VERSION.value:
kwargs['model_version'] = _MODEL_VERSION.value
return predictor_lib.retrieve_default(
_ENDPOINT_NAME.... | Gets an existing model as a python object. | GetModel | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/aws_jump_start_runner.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/aws_jump_start_runner.py | Apache-2.0 |
def SendPrompt(predictor: predictor_lib.Predictor):
"""Sends prompt given flags to the predictor."""
assert _PAYLOAD_JSON.value
def PrintDialog(response):
print('got back response:')
print(response)
if 'generated_text' in response:
output = response['generated_text']
else:
if 'choices... | Sends prompt given flags to the predictor. | SendPrompt | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/aws_jump_start_runner.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/aws_jump_start_runner.py | Apache-2.0 |
def wait_for_maintenance(
callback,
metadata_field='instance/maintenance-event',
timeout_min=DEFAULT_TIMEOUT_MIN,
):
"""Pull events from GCE meta-data server."""
url = METADATA_URL + metadata_field
last_maintenance_event = None
# [START hanging_get]
last_etag = '0'
should_break = False
end_ti... | Pull events from GCE meta-data server. | wait_for_maintenance | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gce_maintenance_notice.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gce_maintenance_notice.py | Apache-2.0 |
def maintenance_callback(event):
"""Callback function when an event is received."""
now = datetime.datetime.now().timestamp()
if event:
print('Host_maintenance_start _at_ {}'.format(now))
else:
print('Host_maintenance_end _at_ {}'.format(now))
return event is None | Callback function when an event is received. | maintenance_callback | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gce_maintenance_notice.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gce_maintenance_notice.py | Apache-2.0 |
def Run(server: str) -> None:
"""tests the latency between 2 GPU in 2 VMs using TensorFlow gPRC server."""
server = f'grpc://{server}'
with tf.compat.v1.Session(server) as sess:
devices = sess.list_devices()
gpus = [device for device in devices if device.name.endswith('device:GPU:0')]
sender, recver = gp... | tests the latency between 2 GPU in 2 VMs using TensorFlow gPRC server. | Run | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gpu_pingpong_test.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gpu_pingpong_test.py | Apache-2.0 |
def get_files_in_directory_sorted(directory):
"""Returns a list of files in directory, sorted alphabetically."""
return sorted([
os.path.join(directory, name)
for name in os.listdir(directory)
if os.path.isfile(os.path.join(directory, name))
]) | Returns a list of files in directory, sorted alphabetically. | get_files_in_directory_sorted | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | Apache-2.0 |
def classify_random_image(self):
"""Chooses a random image and sends a prediction request to the server.
If a response is receieved before the requests timesout, its latency is
saved, and the request is counted as successful. If the request timesout
or otherwise errors, its latency is discarded, and it... | Chooses a random image and sends a prediction request to the server.
If a response is receieved before the requests timesout, its latency is
saved, and the request is counted as successful. If the request timesout
or otherwise errors, its latency is discarded, and it is counted as a
failed request.
... | classify_random_image | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | Apache-2.0 |
def start(self):
"""Creates and launches worker threads and waits for them to finish."""
threads = []
for _ in range(FLAGS.num_threads):
threads.append(threading.Thread(target=self.run_worker_thread))
self.start_time = datetime.now()
for t in threads:
t.start()
for t in threads:
... | Creates and launches worker threads and waits for them to finish. | start | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | Apache-2.0 |
def print_results(self, out=sys.stdout):
"""Prints tests results, to stdout by default."""
actual_runtime = (self.end_time - self.start_time).total_seconds()
req_per_second = self.num_completed_requests / actual_runtime
out.write('Completed requests: %s\n' % self.num_completed_requests)
out.write('F... | Prints tests results, to stdout by default. | print_results | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | Apache-2.0 |
def main(argv):
"""Runs the test and prints results to stdout."""
del argv
load_test = TfServingClientWorkload()
load_test.start()
load_test.print_results() | Runs the test and prints results to stdout. | main | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/tensorflow_serving_client_workload.py | Apache-2.0 |
def main(argv):
"""Sends the load with command line flags & writes results to a file."""
del argv
start_time = time.time()
Run()
logging.info(
'Took %s seconds to Run & write responses. throughput_load_driver is'
' done.',
time.time() - start_time,
)
# Exit even if some processes are sti... | Sends the load with command line flags & writes results to a file. | main | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def ReadJsonResponses(burst_requests: int) -> list[CommandResponse]:
"""Reads the json responses from the file."""
with open(GetOutputFilePath(burst_requests), 'r') as f:
loaded_json = json.load(f)
responses_dicts = loaded_json['responses']
responses = [
CommandResponse(**response_dict) for response... | Reads the json responses from the file. | ReadJsonResponses | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def GetExpectedNumberResponses(
burst_requests: int,
total_duration: int,
time_between_bursts: float,
) -> int:
"""Returns the expected number of responses for the given parameters."""
return math.floor(total_duration / time_between_bursts) * burst_requests | Returns the expected number of responses for the given parameters. | GetExpectedNumberResponses | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def BurstRequestsOverTime(
command: str,
burst_requests: int,
total_duration: int,
time_between_bursts: float = 1.0,
) -> list[CommandResponse]:
"""Sends X requests to the model in parallel over total_duration seconds."""
start_time = time.time()
goal_bursts = math.floor(total_duration / time_betw... | Sends X requests to the model in parallel over total_duration seconds. | BurstRequestsOverTime | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def _EmptyQueue(output_queue: multiprocessing.Queue) -> list[CommandResponse]:
"""Empties the queue, with a timeout & returns the results."""
logging.info('Waiting for all queued results')
results = []
queue_start_time = time.time()
queue_duration = 0
while not output_queue.empty():
results.append(outpu... | Empties the queue, with a timeout & returns the results. | _EmptyQueue | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def _WaitForProcesses(processes: list[multiprocessing.Process]):
"""Waits for processes to finish, terminating any after waiting too long."""
process_start_time = time.time()
process_duration = 0
original_process_count = len(processes)
num_joined = 0
while processes:
process = processes.pop()
if pro... | Waits for processes to finish, terminating any after waiting too long. | _WaitForProcesses | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def _SendParallelRequests(
command: str,
requests: int,
output_queue: multiprocessing.Queue,
) -> list[multiprocessing.Process]:
"""Sends X requests to the model in parallel."""
logging.info('Sending %s requests in parallel', requests)
processes = []
for _ in range(requests):
p = multiprocessing... | Sends X requests to the model in parallel. | _SendParallelRequests | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def _TimeCommand(
command: str,
output_queue: multiprocessing.Queue,
):
"""Times the command & stores length + output in the queue."""
start_time = time.time()
response, err, status = _RunCommand(command)
end_time = time.time()
output_queue.put(CommandResponse(start_time, end_time, response, err, stat... | Times the command & stores length + output in the queue. | _TimeCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def _RunCommand(
command: str,
) -> tuple[str, str, int]:
"""Runs a command and returns stdout, stderr, and return code."""
result = subprocess.run(
command.split(' '), check=False, capture_output=True, text=True
)
return result.stdout, result.stderr, result.returncode | Runs a command and returns stdout, stderr, and return code. | _RunCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/throughput_load_driver.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/throughput_load_driver.py | Apache-2.0 |
def get_dataset_from_bigquery(dataset_project_id, dataset_id, table_id):
"""Reads data from BigQuery and returns it as a TensorFlow dataset."""
(selected_fields, output_types) = get_dataset_schema(
dataset_project_id, dataset_id, table_id
)
client = BigQueryClient()
read_session = client.read_session(... | Reads data from BigQuery and returns it as a TensorFlow dataset. | get_dataset_from_bigquery | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/bigquery_tensorflow_connector_test_scripts/test_runner.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/bigquery_tensorflow_connector_test_scripts/test_runner.py | Apache-2.0 |
def driver(argv):
"""Driver initiates sysbench run with different thread counts.
If running this wrapper module with a bash script the print statement can be
used to capture the run_uri. This allows user to provision and prepare the
database and client VM less frequently which is advantageous when the
specif... | Driver initiates sysbench run with different thread counts.
If running this wrapper module with a bash script the print statement can be
used to capture the run_uri. This allows user to provision and prepare the
database and client VM less frequently which is advantageous when the
specifications contain larger... | driver | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _provision_prepare_pkb():
"""Run provision and prepare stage of PKB benchmark.
Returns:
run_uri: (string)
"""
pkb_cmd = PKB + STAGE_FLAG + PROVISION + ',' + PREPARE
pkb_cmd += (
BOOT_DISK_SIZE_FLAG
+ FLAGS.gce_boot_disk_size
+ BOOT_DISK_TYPE_FLAG
+ FLAGS.gce_boot_disk_type
... | Run provision and prepare stage of PKB benchmark.
Returns:
run_uri: (string)
| _provision_prepare_pkb | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _run(run_uri):
"""Run stage of PKB benchmark.
Args:
run_uri: (string).
"""
if FLAGS.per_second_graphs:
logging.info('Will generate per second logs for this run.')
plotter = plot_sysbench_results.Plotter(
FLAGS.sysbench_run_seconds, FLAGS.sysbench_report_interval, run_uri
)
run_ite... | Run stage of PKB benchmark.
Args:
run_uri: (string).
| _run | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _cleanup_teardown_pkb(run_uri):
"""Run cleanup stage of PKB benchmark.
Args:
run_uri: (string)
"""
logging.info('Run phase complete. Starting cleanup/teardown.')
pkb_cmd = PKB + STAGE_FLAG + CLEANUP + ',' + TEARDOWN + URI_FLAG + run_uri
logging.info(
'Cleanup, teardown sysbench with the follo... | Run cleanup stage of PKB benchmark.
Args:
run_uri: (string)
| _cleanup_teardown_pkb | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _execute_pkb_cmd(pkb_cmd, stdout_filename, stderr_filename):
"""Given pkb run command, execute.
Args:
pkb_cmd: (str)
stdout_filename: (str) filename string.
stderr_filename: (str) filename_str
Raises:
CallFailureError: Popen call failed.
"""
stdout_file = open(stdout_filename, 'w+')
st... | Given pkb run command, execute.
Args:
pkb_cmd: (str)
stdout_filename: (str) filename string.
stderr_filename: (str) filename_str
Raises:
CallFailureError: Popen call failed.
| _execute_pkb_cmd | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _get_run_uri(filename):
"""Grab the last lines of file and return the first match with URI_REGEX.
Args:
filename: (string)
Returns:
run_uri: (string) Run identifier from file.
Raises:
Exception: No match with regular expression. Unexpected output to filename.
"""
grab_file_tail_cmd = ['tai... | Grab the last lines of file and return the first match with URI_REGEX.
Args:
filename: (string)
Returns:
run_uri: (string) Run identifier from file.
Raises:
Exception: No match with regular expression. Unexpected output to filename.
| _get_run_uri | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _append_additional_flags(pkb_cmd):
"""Appends additional flags to the end of pkb_cmd.
Args:
pkb_cmd: (string) Current pkb command.
Returns:
pkb_cmd: (string) PKB command with additional flags.
"""
for flag in FLAGS.additional_flags:
pkb_cmd += ' ' + flag
return pkb_cmd | Appends additional flags to the end of pkb_cmd.
Args:
pkb_cmd: (string) Current pkb command.
Returns:
pkb_cmd: (string) PKB command with additional flags.
| _append_additional_flags | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _generate_filenames(run_stage, thread_number):
"""Generate filenames for STDOUT and STDERR based on phase and time.
Args:
run_stage: Current stage of sysbench.
thread_number: (int) Number of sysbench threads for run iteration.
Returns:
[stdout_filename, stderr_filename]: list of filename strings... | Generate filenames for STDOUT and STDERR based on phase and time.
Args:
run_stage: Current stage of sysbench.
thread_number: (int) Number of sysbench threads for run iteration.
Returns:
[stdout_filename, stderr_filename]: list of filename strings.
| _generate_filenames | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/launch_mysql_service.py | Apache-2.0 |
def _generate_filenames(self, run_uri):
"""Sets filename (with path) of gnuplot input and chart.
Args:
run_uri: (string) run identifier.
"""
date_string = DATETIME_FORMAT.format(datetime.datetime.now())
date_title_string = DATETIME_TITLE_FORMAT.format(datetime.datetime.now())
self.chart_t... | Sets filename (with path) of gnuplot input and chart.
Args:
run_uri: (string) run identifier.
| _generate_filenames | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_scatter_points.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_scatter_points.py | Apache-2.0 |
def create_file(self):
"""Generates a gnuplot info file.
Returns:
output_file (string): Name of gnuplot output file.
output_chart (string): Name of output chart file.
"""
color = '38761d'
# Titles for the data series
title = self.title or 'Cloud SQL Prod'
output_file = open(se... | Generates a gnuplot info file.
Returns:
output_file (string): Name of gnuplot output file.
output_chart (string): Name of output chart file.
| create_file | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_scatter_points.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_scatter_points.py | Apache-2.0 |
def __init__(self, run_seconds, report_interval, run_uri):
"""Initialize a Plotter.
Args:
run_seconds: (integer) length of run phase.
report_interval: (integer) seconds between TPS reports.
run_uri: (string) run identifier.
"""
self.run_uri = run_uri
self.data_entries_per_file = r... | Initialize a Plotter.
Args:
run_seconds: (integer) length of run phase.
report_interval: (integer) seconds between TPS reports.
run_uri: (string) run identifier.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def _generate_filename(self):
"""Generates filename for parsed data.
Returns:
(string): Filename for gnuplot data (tps numbers).
"""
date_string = DATETIME_FORMAT.format(datetime.datetime.now())
filename = date_string + self.run_uri + FILENAME_SUFFIX
return filename | Generates filename for parsed data.
Returns:
(string): Filename for gnuplot data (tps numbers).
| _generate_filename | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def add_file(self, filename):
"""Given STDERR filename for ONE run with a given thread count, add data.
Args:
filename: (string) Name of file to be parsed.
Raises:
STDERRFileDoesNotExistError:
"""
try:
f = open(filename, 'r')
except:
raise STDERRFileDoesNotExistError((
... | Given STDERR filename for ONE run with a given thread count, add data.
Args:
filename: (string) Name of file to be parsed.
Raises:
STDERRFileDoesNotExistError:
| add_file | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def _parse_file(self, f):
"""Parses stderr file, f, extracts list of TPS values.
Assumes no warmup phase and only one report per file.
Method will need to be updated if Sysbench output format changes. Assumes
Sysbench 0.5.
Args:
f: (file object) file to be parsed.
Returns:
(list): ... | Parses stderr file, f, extracts list of TPS values.
Assumes no warmup phase and only one report per file.
Method will need to be updated if Sysbench output format changes. Assumes
Sysbench 0.5.
Args:
f: (file object) file to be parsed.
Returns:
(list): list of TPS values.
Raises:
... | _parse_file | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def _add_data(self, data):
"""Given data, adds to self.filename.
Args:
data: list of tps values.
"""
with open(self.filename, 'a') as f:
for d in data:
f.write(str(d) + '\n') | Given data, adds to self.filename.
Args:
data: list of tps values.
| _add_data | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def plot(self):
"""Generates a graph using gnuplot and data from filename."""
p = plot_scatter_points.GnuplotInfo(
self.filename,
self.data_entries_per_file,
self.run_uri,
self.max_tps,
self.iterations,
)
output_gnuplot_file, _ = p.create_file()
subprocess.Pop... | Generates a graph using gnuplot and data from filename. | plot | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/database_scripts/plot_sysbench_results.py | Apache-2.0 |
def OpenFile(self):
"""Opens a Gfile or a file in the file system mounted by gcsfuse.
Returns:
An opened file or Gfile.
"""
if self.mountpoint:
file_name = self.object_name.replace("gs://", self.mountpoint)
return open(file_name, "rb")
else:
return tf.io.gfile.GFile(self.obj... | Opens a Gfile or a file in the file system mounted by gcsfuse.
Returns:
An opened file or Gfile.
| OpenFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | Apache-2.0 |
def ReadFull(self):
"""Reads the entire file and returns the bytes read.
Returns:
The number of bytes read from the file.
"""
bytes_read = 0
with self.OpenFile() as f:
while True:
data = f.read(2 * 1024 * 1024)
if data:
bytes_read += len(data)
else:
... | Reads the entire file and returns the bytes read.
Returns:
The number of bytes read from the file.
| ReadFull | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | Apache-2.0 |
def Run(self) -> None:
"""Run the benchmark N times, printing all the metrics per iteration."""
for it in range(self.iterations):
total_mb, duration_sec = self.RunAllReaders()
self.PrintResult(it, total_mb, duration_sec)
self.executor.shutdown() | Run the benchmark N times, printing all the metrics per iteration. | Run | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | Apache-2.0 |
def RunAllReaders(self) -> Tuple[float, float]:
"""Read all files, returning bytes read and duration.
Returns:
A tuple including a total number of Megabyes read, and duration taken in
seconds.
"""
start = time.time()
size_list = list(self.executor.map(lambda r: r.ReadFull(), self.reader... | Read all files, returning bytes read and duration.
Returns:
A tuple including a total number of Megabyes read, and duration taken in
seconds.
| RunAllReaders | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | Apache-2.0 |
def PrintResult(
self, iteration: int, total_mb: float, duration_sec: float
) -> None:
"""Print the benchmark result.
Args:
iteration: An int N indicates this result comes from N-th iteration.
total_mb: Total amount of data being read in the iteration, in Megabytes.
duration_sec: The ... | Print the benchmark result.
Args:
iteration: An int N indicates this result comes from N-th iteration.
total_mb: Total amount of data being read in the iteration, in Megabytes.
duration_sec: The seconds it took to finish this iteration.
| PrintResult | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/gcsfuse_scripts/read.py | Apache-2.0 |
def purge_messages(self) -> None:
"""Purges all the messages for the underlying service."""
self.queue.purge()
# Waiting 1 minute, as per
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sqs.html#SQS.Queue.purge
time.sleep(self.PURGE_WAIT_TIME) | Purges all the messages for the underlying service. | purge_messages | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/aws/aws_sqs_client.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/aws/aws_sqs_client.py | Apache-2.0 |
def get_instance(cls) -> 'App':
"""Gets the App instance.
On the first call, it creates the instance. For subsequent calls, it just
returns that instance.
Returns:
The App instance.
"""
if cls.instance is None:
cls.instance = cls()
return cls.instance | Gets the App instance.
On the first call, it creates the instance. For subsequent calls, it just
returns that instance.
Returns:
The App instance.
| get_instance | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | Apache-2.0 |
def for_client(
cls, client_cls: Type[client.BaseMessagingServiceClient]
) -> 'App':
"""Gets the app instance and configures it to use the passed client class.
Args:
client_cls: A BaseMessagingServiceClient class.
Returns:
The App instance.
"""
instance = cls.get_instance()
... | Gets the app instance and configures it to use the passed client class.
Args:
client_cls: A BaseMessagingServiceClient class.
Returns:
The App instance.
| for_client | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | Apache-2.0 |
def __init__(self):
"""Private constructor. Outside this class, use get_instance instead."""
self.client_cls = None
self.runner_registry = {} | Private constructor. Outside this class, use get_instance instead. | __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | Apache-2.0 |
def __call__(self, _):
"""Runs the benchmark for the flags passed to the script.
Implementing this magic method allows you to pass this instance directly to
absl.app.run.
Args:
_: Unused. Just for compatibility with absl.app.run.
"""
self._register_runners()
runner = self.get_runner(... | Runs the benchmark for the flags passed to the script.
Implementing this magic method allows you to pass this instance directly to
absl.app.run.
Args:
_: Unused. Just for compatibility with absl.app.run.
| __call__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | Apache-2.0 |
def get_runner(self) -> runners.BaseRunner:
"""Creates a client instance, using the client class registered.
Returns:
A BaseMessagingServiceClient instance.
Raises:
Exception: No client class has been registered.
"""
client_class = self.get_client_class()
runner_class = self.get_ru... | Creates a client instance, using the client class registered.
Returns:
A BaseMessagingServiceClient instance.
Raises:
Exception: No client class has been registered.
| get_runner | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.