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 _GetNetworksFromSpec(self, network_spec: GceNetworkSpec) -> Set[str]:
"""Returns a list of distinct CIDR networks for this benchmark.
All GCP networks that aren't set explicitly with a vm_group cidr property
are assigned to the default network. The default network is either
specified as a single re... | Returns a list of distinct CIDR networks for this benchmark.
All GCP networks that aren't set explicitly with a vm_group cidr property
are assigned to the default network. The default network is either
specified as a single region with the gce_subnet_region and
gce_subnet_addr flags, or assigned to an ... | _GetNetworksFromSpec | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_network.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py | Apache-2.0 |
def _MakeGceNetworkName(
self,
net_type: str | None = None,
cidr: str | None = None,
uri: str | None = None,
) -> str:
"""Build the current network's name string.
Uses current instance properties if none provided.
Must match regex: r'(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
Arg... | Build the current network's name string.
Uses current instance properties if none provided.
Must match regex: r'(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
Args:
net_type: One of ['default', 'single', 'multi']
cidr: The CIDR range of this network.
uri: A network suffix (if different than FLAG... | _MakeGceNetworkName | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_network.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py | Apache-2.0 |
def _MakeGceFWRuleName(
self,
net_type: str | None = None,
src_cidr: str | None = None,
dst_cidr: str | None = None,
port_range_lo: str | None = None,
port_range_hi: str | None = None,
uri: str | None = None,
) -> str:
"""Build a firewall name string.
Firewall rule n... | Build a firewall name string.
Firewall rule names must be unique within a project so we include source
and destination nets to disambiguate.
Args:
net_type: One of ['default', 'single', 'multi']
src_cidr: The CIDR range of this network.
dst_cidr: The CIDR range of the remote network.
... | _MakeGceFWRuleName | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_network.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py | Apache-2.0 |
def _GetNumberVms(self) -> int:
"""Counts the number of VMs to be used in this benchmark.
Cannot do a len(benchmark_spec.vms) as that hasn't been populated yet. Go
through all the group_specs and sum up the vm_counts.
Returns:
Count of the number of VMs in the benchmark.
"""
benchmark_s... | Counts the number of VMs to be used in this benchmark.
Cannot do a len(benchmark_spec.vms) as that hasn't been populated yet. Go
through all the group_specs and sum up the vm_counts.
Returns:
Count of the number of VMs in the benchmark.
| _GetNumberVms | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_network.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_network.py | Apache-2.0 |
def __init__(self, gce_placement_group_spec):
"""Init method for GcePlacementGroup.
Args:
gce_placement_group_spec: Object containing the information needed to
create an GcePlacementGroup.
"""
super().__init__(gce_placement_group_spec)
self.project = gce_placement_group_spec.project
... | Init method for GcePlacementGroup.
Args:
gce_placement_group_spec: Object containing the information needed to
create an GcePlacementGroup.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_placement_group.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_placement_group.py | Apache-2.0 |
def _Exists(self):
"""Returns True if the node template exists."""
cmd = util.GcloudCommand(
self, 'compute', 'sole-tenancy', 'node-templates', 'describe', self.name
)
cmd.flags['region'] = self.region
_, _, retcode = cmd.Issue(raise_on_failure=False)
return not retcode | Returns True if the node template exists. | _Exists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _Exists(self):
"""Returns True if the host exists."""
cmd = util.GcloudCommand(
self, 'compute', 'sole-tenancy', 'node-groups', 'describe', self.name
)
_, _, retcode = cmd.Issue(raise_on_failure=False)
return not retcode | Returns True if the host exists. | _Exists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _IsReady(self) -> bool:
"""Returns True if the node-group is ready."""
cmd = util.GcloudCommand(
self, 'compute', 'sole-tenancy', 'node-groups', 'describe', self.name
)
stdout, _, _ = cmd.Issue(raise_on_failure=False)
return json.loads(stdout).get('status') == 'READY' | Returns True if the node-group is ready. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GenerateAcceleratorSpecString(accelerator_type, accelerator_count):
"""Generates a string to be used to attach accelerators to a VM using gcloud.
This function takes a cloud-agnostic accelerator type (k80, p100, etc.) and
returns a gce-specific accelerator name (nvidia-tesla-k80, etc).
If FLAGS.gce_accele... | Generates a string to be used to attach accelerators to a VM using gcloud.
This function takes a cloud-agnostic accelerator type (k80, p100, etc.) and
returns a gce-specific accelerator name (nvidia-tesla-k80, etc).
If FLAGS.gce_accelerator_type_override is specified, the value of said flag
will be used as th... | GenerateAcceleratorSpecString | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def __init__(self, vm_spec):
"""Initialize a GCE virtual machine.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
Raises:
errors.Config.MissingOption: If the spec does not include a "machine_type"
or both "cpus" and "memory".
errors.Config.InvalidValue: If the spec ... | Initialize a GCE virtual machine.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
Raises:
errors.Config.MissingOption: If the spec does not include a "machine_type"
or both "cpus" and "memory".
errors.Config.InvalidValue: If the spec contains both "machine_type" and
... | __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _GenerateCreateCommand(self, ssh_keys_path):
"""Generates a command to create the VM instance.
Args:
ssh_keys_path: string. Path to a file containing the sshKeys metadata.
Returns:
GcloudCommand. gcloud command to issue in order to create the VM instance.
"""
args = ['compute', 'in... | Generates a command to create the VM instance.
Args:
ssh_keys_path: string. Path to a file containing the sshKeys metadata.
Returns:
GcloudCommand. gcloud command to issue in order to create the VM instance.
| _GenerateCreateCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _ParseCreateErrors(
self, cmd_rate_limited: bool, stderr: str, retcode: int
):
"""Parse error messages from a command in order to classify a failure."""
num_hosts = len(self.host_list)
if (
self.use_dedicated_host
and retcode
and _INSUFFICIENT_HOST_CAPACITY in stderr
... | Parse error messages from a command in order to classify a failure. | _ParseCreateErrors | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _ParseDescribeResponse(self, describe_response):
"""Sets the ID and IP addresses from a response to the describe command.
Args:
describe_response: JSON-loaded response to the describe gcloud command.
Raises:
KeyError, IndexError: If the ID and IP addresses cannot be parsed.
"""
sel... | Sets the ID and IP addresses from a response to the describe command.
Args:
describe_response: JSON-loaded response to the describe gcloud command.
Raises:
KeyError, IndexError: If the ID and IP addresses cannot be parsed.
| _ParseDescribeResponse | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _NeedsToParseDescribeResponse(self):
"""Returns whether the ID and IP addresses still need to be set."""
return (
not self.id
or not self.GetInternalIPs()
or (self.assign_external_ip and not self.ip_address)
) | Returns whether the ID and IP addresses still need to be set. | _NeedsToParseDescribeResponse | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _WaitUntilRunning(self):
"""Waits until the VM instances create command completes."""
getoperation_cmd = util.GcloudCommand(
self, 'compute', 'operations', 'describe', self.create_operation_name
)
if gcp_flags.GCE_CREATE_LOG_HTTP.value:
getoperation_cmd.flags['log-http'] = True
st... | Waits until the VM instances create command completes. | _WaitUntilRunning | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def ReleaseIpReservation(self, ip_address_name: str) -> None:
"""Releases existing IP reservation.
Args:
ip_address_name: name of the IP reservation to be released.
"""
reserv_ip_address = gce_network.GceIPAddress(
self.project,
util.GetRegionFromZone(self.zone),
ip_addres... | Releases existing IP reservation.
Args:
ip_address_name: name of the IP reservation to be released.
| ReleaseIpReservation | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def SimulateMaintenanceWithLog(self):
"""Create a json file with information related to the vm."""
simulate_maintenance_json = {
'current_time': datetime.datetime.now().timestamp() * 1000,
'instance_id': self.id,
'project': self.project,
'instance_name': self.name,
'zone'... | Create a json file with information related to the vm. | SimulateMaintenanceWithLog | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def SimulateMaintenanceEvent(self):
"""Simulates a maintenance event on the VM."""
cmd = util.GcloudCommand(
self,
'compute',
'instances',
'simulate-maintenance-event',
self.name,
'--async',
)
logcmd = util.GcloudCommand(
None,
'logging',
... | Simulates a maintenance event on the VM. | SimulateMaintenanceEvent | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def SetupLMNotification(self):
"""Prepare environment for /scripts/gce_maintenance_notify.py script."""
self.Install('pip')
self.RemoteCommand('sudo pip3 install requests')
self.PushDataFile(self._LM_NOTICE_SCRIPT, vm_util.VM_TMP_DIR) | Prepare environment for /scripts/gce_maintenance_notify.py script. | SetupLMNotification | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _GetLMNotificationCommand(self):
"""Return Remote python execution command for LM notify script."""
vm_path = posixpath.join(vm_util.VM_TMP_DIR, self._LM_NOTICE_SCRIPT)
server_log = self._LM_NOTICE_LOG
return (
f'python3 {vm_path} {gcp_flags.LM_NOTIFICATION_METADATA_NAME.value} >'
f'... | Return Remote python execution command for LM notify script. | _GetLMNotificationCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def StartLMNotification(self):
"""Start meta-data server notification subscription."""
def _Subscribe():
self.RemoteCommand(
self._GetLMNotificationCommand(),
timeout=LM_NOTIFICATION_TIMEOUT_SECONDS,
ignore_failure=True,
)
self._PullLMNoticeLog()
logging.in... | Start meta-data server notification subscription. | StartLMNotification | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def WaitLMNotificationRelease(self):
"""Block main thread until LM ended."""
logging.info('[LM Notify] Wait for live migration to finish.')
self._LM_TIMES_SEMAPHORE.acquire()
logging.info('[LM Notify] Live migration is done.') | Block main thread until LM ended. | WaitLMNotificationRelease | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def CollectLMNotificationsTime(self):
"""Extract LM notifications from log file.
Sample Log file to parse:
Host_maintenance_start _at_ 1656555520.78123
Host_maintenance_end _at_ 1656557227.63631
Returns:
Live migration events timing info dictionary
"""
lm_total_time_key = 'LM_tot... | Extract LM notifications from log file.
Sample Log file to parse:
Host_maintenance_start _at_ 1656555520.78123
Host_maintenance_end _at_ 1656557227.63631
Returns:
Live migration events timing info dictionary
| CollectLMNotificationsTime | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def DownloadPreprovisionedData(
self,
install_path,
module_name,
filename,
timeout=virtual_machine.PREPROVISIONED_DATA_TIMEOUT,
):
"""Downloads a data file from a GCS bucket with pre-provisioned data.
Use --gce_preprovisioned_data_bucket to specify the name of the bucket.
A... | Downloads a data file from a GCS bucket with pre-provisioned data.
Use --gce_preprovisioned_data_bucket to specify the name of the bucket.
Args:
install_path: The install path on this VM.
module_name: Name of the module associated with this data file.
filename: The name of the file that was ... | DownloadPreprovisionedData | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def UpdateInterruptibleVmStatus(self, use_api=False):
"""Updates the interruptible status if the VM was preempted."""
if not self.IsInterruptible():
return
if self.WasInterrupted():
return
try:
self._UpdateInterruptibleVmStatusThroughMetadataService()
except errors.VirtualMachine.R... | Updates the interruptible status if the VM was preempted. | UpdateInterruptibleVmStatus | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GetNumTeardownSkippedVms(self) -> int:
"""Returns the number of lingering VMs in this VM's project and zone."""
# compute instances list doesn't accept a --zone flag, so we need to drop
# the zone from the VM object and pass in --zones instead.
vm_without_zone = copy.copy(self)
vm_without_zone.z... | Returns the number of lingering VMs in this VM's project and zone. | GetNumTeardownSkippedVms | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def UpdateTimeoutMetadata(self):
"""Updates the timeout metadata for the VM."""
new_timeout = datetime.datetime.now(datetime.UTC) + datetime.timedelta(
minutes=pkb_flags.SKIP_TEARDOWN_KEEP_UP_MINUTES.value
)
new_timeout = new_timeout.strftime(resource.METADATA_TIME_FORMAT)
args = ['compute',... | Updates the timeout metadata for the VM. | UpdateTimeoutMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GetGvnicVersion(self) -> str | None:
"""Returns the gvnic network driver version."""
if not gcp_flags.GCE_NIC_RECORD_VERSION.value:
return
all_device_properties = {}
for device_name in self._get_network_device_mtus():
device = self._GetNetworkDeviceProperties(device_name)
all_devi... | Returns the gvnic network driver version. | GetGvnicVersion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def _GetNetworkDeviceProperties(self, device_name: str) -> Dict[str, str]:
"""Returns a dict of the network device properties."""
# ethtool can exist under /usr/sbin or needs to be installed (debian9)
if self.HasPackage('ethtool'):
self.InstallPackages('ethtool')
try:
stdout, _ = self.Remote... | Returns a dict of the network device properties. | _GetNetworkDeviceProperties | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GenerateAndCaptureSerialPortOutput(self, local_path: str) -> bool:
"""Generates and captures the serial port output for the remote VM.
Args:
local_path: The path to store the serial port output on the caller's
machine.
Returns:
True if the serial port output was successfully genera... | Generates and captures the serial port output for the remote VM.
Args:
local_path: The path to store the serial port output on the caller's
machine.
Returns:
True if the serial port output was successfully generated and captured;
False otherwise.
| GenerateAndCaptureSerialPortOutput | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GenerateDownloadPreprovisionedDataCommand(
install_path: str, module_name: str, filename: str
) -> str:
"""Returns a string used to download preprovisioned data.
Args:
install_path: Path to install the module.
module_name: Name of the module to download.
filename: Filename of the module. Usuall... | Returns a string used to download preprovisioned data.
Args:
install_path: Path to install the module.
module_name: Name of the module to download.
filename: Filename of the module. Usually a zip file.
Returns:
The gcloud command to run.
| GenerateDownloadPreprovisionedDataCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def GenerateStatPreprovisionedDataCommand(
module_name: str, filename: str
) -> str:
"""Returns a string used to download preprovisioned data.
Args:
module_name: Name of the module to download.
filename: Filename of the module. Usually a zip file.
Returns:
The gcloud command to run.
"""
retu... | Returns a string used to download preprovisioned data.
Args:
module_name: Name of the module to download.
filename: Filename of the module. Usually a zip file.
Returns:
The gcloud command to run.
| GenerateStatPreprovisionedDataCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_virtual_machine.py | Apache-2.0 |
def __init__(self, vm_spec):
"""Initialize a Windows GCE virtual machine.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
"""
super().__init__(vm_spec)
self.boot_metadata['windows-startup-script-ps1'] = (
windows_virtual_machine.STARTUP_SCRIPT + UPDATE_NETWORK_DRIVERS
... | Initialize a Windows GCE virtual machine.
Args:
vm_spec: virtual_machine.BaseVmSpec object of the vm.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | Apache-2.0 |
def _GetWindowsPassword(self):
"""Generates a command to get a VM user's password.
Returns:
Password for the windows user.
"""
cmd = util.GcloudCommand(
self, 'compute', 'reset-windows-password', self.name
)
cmd.flags['user'] = self.user_name
stdout, _ = cmd.IssueRetryable()
... | Generates a command to get a VM user's password.
Returns:
Password for the windows user.
| _GetWindowsPassword | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | Apache-2.0 |
def Create(self, restore: bool = False) -> None:
"""Get the windows password from the VM after VM is ready."""
super().Create(restore=restore)
self.password = self._GetWindowsPassword() | Get the windows password from the VM after VM is ready. | Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | Apache-2.0 |
def DisableRSS(self):
"""Disables RSS on the GCE VM.
Raises:
GceDriverDoesntSupportFeatureError: If RSS is not supported.
GceUnexpectedWindowsAdapterOutputError: If querying the RSS state
returns unexpected output.
"""
# First ensure that the driver supports interrupt moderation
... | Disables RSS on the GCE VM.
Raises:
GceDriverDoesntSupportFeatureError: If RSS is not supported.
GceUnexpectedWindowsAdapterOutputError: If querying the RSS state
returns unexpected output.
| DisableRSS | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | Apache-2.0 |
def _PullLMNoticeLog(self):
"""Pull the LM Notice Log onto the local VM."""
self.PullFile(
f'{vm_util.GetTempDir()}/{self._LM_NOTICE_LOG}',
f'{self.temp_dir}\\{self._LM_NOTICE_LOG}',
) | Pull the LM Notice Log onto the local VM. | _PullLMNoticeLog | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gce_windows_virtual_machine.py | Apache-2.0 |
def _Create(self) -> None:
"""Creates the Cloud SQL instance and authorizes traffic from anywhere.
Raises:
UnsupportedDatabaseEngineError:
if the database is unmanaged and the engine isn't MYSQL.
Exception: if an invalid MySQL flag was used.
"""
# Create a database cluster
cmd_s... | Creates the Cloud SQL instance and authorizes traffic from anywhere.
Raises:
UnsupportedDatabaseEngineError:
if the database is unmanaged and the engine isn't MYSQL.
Exception: if an invalid MySQL flag was used.
| _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | Apache-2.0 |
def _PostCreate(self) -> None:
"""Creates the PKB user and sets the password."""
super()._PostCreate()
columnar_engine_size = None
if _COLUMNAR_ENGINE.value:
columnar_engine_size = _COLUMNAR_ENGINE_SIZE.value
self.UpdateAlloyDBFlags(
columnar_engine_size,
_ENABLE_COLUMNAR_RECOM... | Creates the PKB user and sets the password. | _PostCreate | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | Apache-2.0 |
def _UpdateLabels(self, labels: Dict[str, Any]) -> None:
"""Updates the labels of the current instance."""
header = {'Authorization': f'Bearer {util.GetAccessToken()}'}
url = (
'https://alloydb.googleapis.com/v1/'
f'projects/{self.project}/locations/{self.region}/clusters/{self.cluster_id}'
... | Updates the labels of the current instance. | _UpdateLabels | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | Apache-2.0 |
def _IsReady(self) -> bool:
"""Return true if the underlying resource is ready."""
cluster = self._DescribeCluster()
return cluster['state'] == 'READY' | Return true if the underlying resource is ready. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_alloy_db.py | Apache-2.0 |
def _ValidateConfig(cls, config_values) -> None:
"""Verifies correct usage of the bigtable config options."""
if config_values.get(
'multicluster_routing', False
) and not config_values.get('replication_cluster', False):
raise errors.Config.InvalidValue(
'bigtable_replication_cluster... | Verifies correct usage of the bigtable config options. | _ValidateConfig | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def _BuildClusterConfigs(self) -> List[str]:
"""Return flag values for --cluster_config when creating an instance.
Returns:
List of strings for repeated --cluster_config flag values.
"""
flag_values = []
cluster_config = {
'id': f'{self.name}-0',
'zone': self.zone,
'no... | Return flag values for --cluster_config when creating an instance.
Returns:
List of strings for repeated --cluster_config flag values.
| _BuildClusterConfigs | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def _Exists(self):
"""Returns true if the instance exists."""
instance = self._DescribeInstance()
if not instance:
return False
return instance['state'] == 'READY' | Returns true if the instance exists. | _Exists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def _UpdateNodes(self, nodes: int) -> None:
"""Updates clusters to the specified node count and waits until ready."""
# User managed instances currently aren't supported since instance
# attributes aren't discovered after initialization.
if self.user_managed:
return
clusters = self._GetCluster... | Updates clusters to the specified node count and waits until ready. | _UpdateNodes | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def GetAverageCpuUsage(
self, duration_minutes: int, end_time: datetime.datetime
) -> float:
"""Gets the average CPU usage for the instance.
Note that there is a delay for the API to get data, so this returns the
average CPU usage in the period ending at `end_time` with missing data
in the last... | Gets the average CPU usage for the instance.
Note that there is a delay for the API to get data, so this returns the
average CPU usage in the period ending at `end_time` with missing data
in the last CPU_API_DELAY_SECONDS.
Args:
duration_minutes: The time duration for which to measure the averag... | GetAverageCpuUsage | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def CalculateTheoreticalMaxThroughput(
self, read_proportion: float, write_proportion: float
) -> int:
"""Returns the theoretical max throughput based on the workload and nodes.
Args:
read_proportion: The proportion of reads between 0 and 1.
write_proportion: The proportion of writes betwee... | Returns the theoretical max throughput based on the workload and nodes.
Args:
read_proportion: The proportion of reads between 0 and 1.
write_proportion: The proportion of writes between 0 and 1.
Returns:
The theoretical max throughput for the instance.
| CalculateTheoreticalMaxThroughput | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def _GetBigtableGcloudCommand(instance, *args) -> util.GcloudCommand:
"""Returns gcloud bigtable commmand without the zone argument."""
cmd = util.GcloudCommand(instance, *args)
# The zone flag makes this command fail.
cmd.flags['zone'] = []
return cmd | Returns gcloud bigtable commmand without the zone argument. | _GetBigtableGcloudCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def GetClustersDescription(instance_name, project):
"""Gets descriptions of all the clusters given the instance and project.
This is a module function to allow getting description of clusters not created
by pkb.
Args:
instance_name: Instance to get cluster descriptions for.
project: Project where inst... | Gets descriptions of all the clusters given the instance and project.
This is a module function to allow getting description of clusters not created
by pkb.
Args:
instance_name: Instance to get cluster descriptions for.
project: Project where instance is in.
Returns:
A list of cluster description... | GetClustersDescription | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_bigtable.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_bigtable.py | Apache-2.0 |
def _GetTier(self) -> str | None:
"""Returns the tier of the instance."""
# See https://cloud.google.com/memorystore/docs/redis/redis-tiers."""
if self.clustered:
return None
if self.failover_style == managed_memory_store.Failover.FAILOVER_NONE:
return BASIC_TIER
return STANDARD_TIER | Returns the tier of the instance. | _GetTier | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def GetReadableVersion(self):
"""Parses Redis major and minor version number."""
if self.version.count('_') < 2:
logging.info(
(
'Could not parse version string correctly, '
'full Redis version returned: %s'
),
self.version,
)
return se... | Parses Redis major and minor version number. | GetReadableVersion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def _CreateServiceConnectionPolicy(self) -> None:
"""Creates a service connection policy for the VPC."""
cmd = util.GcloudCommand(
self,
'network-connectivity',
'service-connection-policies',
'create',
f'pkb-{FLAGS.run_uri}-policy',
)
cmd.flags['service-class'] = ... | Creates a service connection policy for the VPC. | _CreateServiceConnectionPolicy | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def _GetClusterCreateCommand(self) -> util.GcloudCommand:
"""Returns the command used to create the cluster."""
cmd = util.GcloudCommand(self, 'redis', 'clusters', 'create', self.name)
# Add labels when supported
cmd.flags['shard-count'] = self.shard_count
cmd.flags['replica-count'] = self.replicas_... | Returns the command used to create the cluster. | _GetClusterCreateCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def _GetCreateCommand(self) -> util.GcloudCommand:
"""Returns the command used to create the instance."""
cmd = util.GcloudCommand(self, 'redis', 'instances', 'create', self.name)
cmd.flags['zone'] = FLAGS.zone[0]
cmd.flags['network'] = self.network
cmd.flags['tier'] = self.tier
cmd.flags['size'... | Returns the command used to create the instance. | _GetCreateCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def DescribeInstance(self):
"""Calls describe instance using the gcloud tool.
Returns:
stdout, stderr, and retcode.
"""
cmd = util.GcloudCommand(self, 'redis', 'instances', 'describe', self.name)
if self.clustered:
cmd = util.GcloudCommand(self, 'redis', 'clusters', 'describe', self.nam... | Calls describe instance using the gcloud tool.
Returns:
stdout, stderr, and retcode.
| DescribeInstance | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def _PopulateEndpoint(self):
"""Populates endpoint information about the instance.
Raises:
errors.Resource.RetryableGetError:
Failed to retrieve information on instance
"""
stdout, _, retcode = self.DescribeInstance()
if retcode != 0:
raise errors.Resource.RetryableGetError(
... | Populates endpoint information about the instance.
Raises:
errors.Resource.RetryableGetError:
Failed to retrieve information on instance
| _PopulateEndpoint | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def MeasureCpuUtilization(self, interval_length): # pytype: disable=signature-mismatch # overriding-parameter-count-checks
"""Measure the average CPU utilization on GCP instance in percentage."""
now = time.time()
seconds = int(now)
interval = monitoring_v3.TimeInterval()
interval.end_time.seconds... | Measure the average CPU utilization on GCP instance in percentage. | MeasureCpuUtilization | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def _ParseMonitoringTimeSeries(self, time_series):
"""Parses time series data and returns average CPU across intervals in %.
For example, an interval of 3 minutes would be represented as [x, y, z],
where x, y, and z are cpu seconds.
average CPU usage per minute in cpu seconds = (x + y + z) / 3
aver... | Parses time series data and returns average CPU across intervals in %.
For example, an interval of 3 minutes would be represented as [x, y, z],
where x, y, and z are cpu seconds.
average CPU usage per minute in cpu seconds = (x + y + z) / 3
average cpu usage in percentage = [(x + y + z) / 3] / 60
... | _ParseMonitoringTimeSeries | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_redis.py | Apache-2.0 |
def GetReadableVersion(self):
"""Parses Valkey major and minor version number."""
if self.version.count('_') < 2:
logging.info(
(
'Could not parse version string correctly, '
'full Valkey version returned: %s'
),
self.version,
)
return ... | Parses Valkey major and minor version number. | GetReadableVersion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cloud_valkey.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cloud_valkey.py | Apache-2.0 |
def __init__(self, cluster_spec: GceClusterSpec):
"""Initialize GceCluster class.
Args:
cluster_spec: cluster.GceClusterSpec object.
"""
super().__init__(cluster_spec)
self.project: str = cluster_spec.workers.vm_spec.project
self._config_path: str = os.path.join(
vm_util.GetTempDi... | Initialize GceCluster class.
Args:
cluster_spec: cluster.GceClusterSpec object.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cluster.py | Apache-2.0 |
def _Create(self):
"""Create GCP cluster with cluster toolkit."""
with open(self._config_path, 'w') as config_file:
config_file.write(self._config)
vm_util.IssueCommand([
flags.GCLUSTER_PATH.value,
'deploy',
self._config_path,
'--force',
'--auto-approve',
... | Create GCP cluster with cluster toolkit. | _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cluster.py | Apache-2.0 |
def _PostCreate(self):
"""Post create actions after GCP cluster is created.
The method does the following:
1. Create VM objects and backfill VM information based on VM name.
2. Prepare VM environment.
3. Configure SSH on both headnode and workers.
"""
def _UpdateHeadNode(vm):
vm.name... | Post create actions after GCP cluster is created.
The method does the following:
1. Create VM objects and backfill VM information based on VM name.
2. Prepare VM environment.
3. Configure SSH on both headnode and workers.
| _PostCreate | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cluster.py | Apache-2.0 |
def _Delete(self):
"""Delete GCP cluster with cluster toolkit."""
vm_util.IssueCommand([
flags.GCLUSTER_PATH.value,
'destroy',
f'{vm_util.GetTempDir()}/{self.name}',
'--auto-approve',
]) | Delete GCP cluster with cluster toolkit. | _Delete | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cluster.py | Apache-2.0 |
def AuthenticateVM(self):
"""Authenticate all VMs in the cluster to access each other."""
for vm in self.vms:
if vm.has_private_key:
continue
vm.RemoteHostCopy(
vm_util.GetPrivateKeyPath(), linux_virtual_machine.REMOTE_KEY_PATH
)
vm.RemoteCommand(
'echo "Host ... | Authenticate all VMs in the cluster to access each other. | AuthenticateVM | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_cluster.py | Apache-2.0 |
def _FillMetadata(self) -> None:
"""Get a dict to initialize this DPB service instance's metadata."""
self.metadata['dpb_dataflow_runner'] = FLAGS.dpb_dataflow_runner
self.metadata['dpb_dataflow_sdk'] = FLAGS.dpb_dataflow_sdk
self.metadata['dpb_job_id'] = self.job_id
self.metadata['dpb_dataflow_enab... | Get a dict to initialize this DPB service instance's metadata. | _FillMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def job_stats(self):
"""Collect series of relevant performance and cost stats."""
stats = {}
# vCPU-hr
stats['total_vcpu_time'] = self.GetMetricValue('TotalVcpuTime') / 3600
# GB-hr
stats['total_mem_usage'] = (
self.GetMetricValue('TotalMemoryUsage') / 1024 / 3600
)
# GB-hr
s... | Collect series of relevant performance and cost stats. | job_stats | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def _PullJobMetrics(self, force_refresh=False):
"""Retrieve and cache all job metrics from Dataflow API."""
# Skip if job metrics is already populated unless force_refresh is True
if self.job_metrics is not None and not force_refresh:
return
# Raise exception if job id not available
if self.jo... | Retrieve and cache all job metrics from Dataflow API. | _PullJobMetrics | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def GetMetricValue(self, name, metric_type=METRIC_TYPE_COUNTER):
"""Get value of a job's metric.
Args:
name: The name of the metric.
metric_type: Either METRIC_TYPE_COUNTER or METRIC_TYPE_DISTRIBUTION.
Returns:
An int if metric is of type counter or a dict if metric is of
type dist... | Get value of a job's metric.
Args:
name: The name of the metric.
metric_type: Either METRIC_TYPE_COUNTER or METRIC_TYPE_DISTRIBUTION.
Returns:
An int if metric is of type counter or a dict if metric is of
type distribution. The dictionary contains keys such as
count/max/mean/min/... | GetMetricValue | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def GetAvgCpuUtilization(
self, start_time: datetime.datetime, end_time: datetime.datetime
):
"""Get average cpu utilization across all pipeline workers.
Args:
start_time: datetime specifying the beginning of the time interval.
end_time: datetime specifying the end of the time interval.
... | Get average cpu utilization across all pipeline workers.
Args:
start_time: datetime specifying the beginning of the time interval.
end_time: datetime specifying the end of the time interval.
Returns:
Average value across time interval
| GetAvgCpuUtilization | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def GetMaxOutputThroughput(
self,
ptransform: str,
start_time: datetime.datetime,
end_time: datetime.datetime,
):
"""Get max throughput from a particular pTransform during job run interval.
Args:
ptransform: name of pipeline's PTransform to get output throughput from.
star... | Get max throughput from a particular pTransform during job run interval.
Args:
ptransform: name of pipeline's PTransform to get output throughput from.
start_time: datetime specifying the beginning of the time interval.
end_time: datetime specifying the end of the time interval.
Returns:
... | GetMaxOutputThroughput | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def _GetAvgValueFromTimeSeries(
self, time_series: types.ListTimeSeriesResponse
):
"""Parses time series data and returns average across intervals.
Args:
time_series: time series data returned by monitoring.
Returns:
Average value across intervals
"""
points = []
for time_i... | Parses time series data and returns average across intervals.
Args:
time_series: time series data returned by monitoring.
Returns:
Average value across intervals
| _GetAvgValueFromTimeSeries | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def _GetMaxValueFromTimeSeries(
self, time_series: types.ListTimeSeriesResponse
):
"""Parses time series data and returns maximum across intervals.
Args:
time_series: time series data returned by monitoring.
Returns:
Maximum value across intervals
"""
points = []
for time_i... | Parses time series data and returns maximum across intervals.
Args:
time_series: time series data returned by monitoring.
Returns:
Maximum value across intervals
| _GetMaxValueFromTimeSeries | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def _GetLastValueFromTimeSeries(
self, time_series: types.ListTimeSeriesResponse
):
"""Parses time series data and returns last value in last interval.
Args:
time_series: time series data returned by monitoring.
Returns:
Last value across intervals
"""
try:
return list(ti... | Parses time series data and returns last value in last interval.
Args:
time_series: time series data returned by monitoring.
Returns:
Last value across intervals
| _GetLastValueFromTimeSeries | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataflow.py | Apache-2.0 |
def _ParseTime(state_time: str) -> datetime.datetime:
"""Parses time from json output.
Args:
state_time: string. the state start time.
Returns:
Parsed datetime.
"""
try:
return datetime.datetime.strptime(state_time, '%Y-%m-%dT%H:%M:%S.%fZ')
except ValueError:
return dat... | Parses time from json output.
Args:
state_time: string. the state start time.
Returns:
Parsed datetime.
| _ParseTime | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | Apache-2.0 |
def MigrateCrossCloud(
self, source_location, destination_location, dest_cloud='AWS'
):
"""Method to copy data cross cloud using a distributed job on the cluster.
Currently the only supported destination cloud is AWS.
TODO(user): Add support for other destination clouds.
Args:
source_loc... | Method to copy data cross cloud using a distributed job on the cluster.
Currently the only supported destination cloud is AWS.
TODO(user): Add support for other destination clouds.
Args:
source_location: The source GCS path to migrate.
destination_location: The destination path.
dest_clo... | MigrateCrossCloud | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | Apache-2.0 |
def GetClusterCreateTime(self) -> float | None:
"""Returns the cluster creation time.
On this implementation, the time returned is based on the timestamps
reported by the Dataproc API (which is stored in the _cluster_create_time
attribute).
Returns:
A float representing the creation time in ... | Returns the cluster creation time.
On this implementation, the time returned is based on the timestamps
reported by the Dataproc API (which is stored in the _cluster_create_time
attribute).
Returns:
A float representing the creation time in seconds or None.
| GetClusterCreateTime | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | Apache-2.0 |
def _ParseClusterCreateTime(
cls, stdout: str
) -> Tuple[float | None, float | None]:
"""Parses the cluster create & ready time from a raw API response."""
try:
creation_data = json.loads(stdout)
except json.JSONDecodeError:
creation_data = {}
can_parse = creation_data.get('status', ... | Parses the cluster create & ready time from a raw API response. | _ParseClusterCreateTime | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | Apache-2.0 |
def _GetCluster(self) -> Dict[str, Any] | None:
"""Gets the cluster resource in a dict."""
cmd = self.DataprocGcloudCommand('clusters', 'describe', self.cluster_id)
stdout, _, retcode = cmd.Issue(raise_on_failure=False)
if not retcode:
return json.loads(stdout) | Gets the cluster resource in a dict. | _GetCluster | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_dpb_dataproc.py | Apache-2.0 |
def _Create(self) -> None:
"""Creates the key in an existing keyring."""
cmd = util.GcloudCommand(self, 'kms', 'keys', 'create', self.name)
cmd.flags['keyring'] = self.keyring_name
cmd.flags['location'] = self.location
cmd.flags['purpose'] = self.purpose
cmd.flags['protection-level'] = self.prot... | Creates the key in an existing keyring. | _Create | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_key.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_key.py | Apache-2.0 |
def _Exists(self) -> bool:
"""Returns true if the key exists."""
cmd = util.GcloudCommand(self, 'kms', 'keys', 'versions', 'describe', '1')
cmd.flags['keyring'] = self.keyring_name
cmd.flags['location'] = self.location
cmd.flags['key'] = self.name
# Do not log error or warning when checking exis... | Returns true if the key exists. | _Exists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_key.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_key.py | Apache-2.0 |
def GetResourceMetadata(self) -> Dict[Any, Any]:
"""Returns useful metadata about the key."""
return {
'gcp_kms_key_name': self.name,
'gcp_kms_key_purpose': self.purpose,
'gcp_kms_key_protection_level': self.protection_level,
'gcp_kms_key_algorithm': self.algorithm,
'gcp_... | Returns useful metadata about the key. | GetResourceMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_key.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_key.py | Apache-2.0 |
def Run(
self,
benchmark_scenario: str,
number_of_messages: int,
message_size: int,
warmup_messages: int,
streaming_pull: bool = False,
) -> Dict[str, Any]:
"""Runs a benchmark on GCP PubSub from the client VM.
Runs a benchmark based on the configuration specified through ... | Runs a benchmark on GCP PubSub from the client VM.
Runs a benchmark based on the configuration specified through the arguments:
benchmark_scenario, number_of_messages, and message_size. This contains
the GCP specific command that we need to run on the client VM to run the
benchmark.
Args:
be... | Run | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _CreateTopic(self):
"""Handles topic creation on GCP Pub/Sub."""
cmd = util.GcloudCommand(
self, 'pubsub', 'topics', 'create', self.pubsub_topic
)
_, stderr, retcode = cmd.Issue(raise_on_failure=False)
if retcode != 0:
logging.error('Creation of GCP PubSub topic failed.')
rai... | Handles topic creation on GCP Pub/Sub. | _CreateTopic | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _TopicExists(self) -> bool:
"""Check if subscription exists on GCP Pub/Sub."""
cmd = util.GcloudCommand(
self, 'pubsub', 'topics', 'describe', self.pubsub_topic
)
_, _, retcode = cmd.Issue(raise_on_failure=False)
return retcode == 0 | Check if subscription exists on GCP Pub/Sub. | _TopicExists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _DeleteTopic(self):
"""Handles topic deletion on GCP Pub/Sub."""
cmd = util.GcloudCommand(
self, 'pubsub', 'topics', 'delete', self.pubsub_topic
)
cmd.Issue(raise_on_failure=False) | Handles topic deletion on GCP Pub/Sub. | _DeleteTopic | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _CreateSubscription(self):
"""Handles Subscription creation on GCP Pub/Sub."""
cmd = util.GcloudCommand(
self, 'pubsub', 'subscriptions', 'create', self.pubsub_subscription
)
cmd.flags['topic'] = self.pubsub_topic
cmd.flags['topic-project'] = self.project
_, stderr, retcode = cmd.Iss... | Handles Subscription creation on GCP Pub/Sub. | _CreateSubscription | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _SubscriptionExists(self) -> bool:
"""Check if subscription exists on GCP Pub/Sub.."""
cmd = util.GcloudCommand(
self, 'pubsub', 'subscriptions', 'describe', self.pubsub_subscription
)
_, _, retcode = cmd.Issue(raise_on_failure=False)
return retcode == 0 | Check if subscription exists on GCP Pub/Sub.. | _SubscriptionExists | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _DeleteSubscription(self):
"""Handles subscription deletion on GCP Pub/Sub."""
cmd = util.GcloudCommand(
self, 'pubsub', 'subscriptions', 'delete', self.pubsub_subscription
)
cmd.Issue(raise_on_failure=False) | Handles subscription deletion on GCP Pub/Sub. | _DeleteSubscription | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_pubsub.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_pubsub.py | Apache-2.0 |
def _GetNetwork(self) -> str:
"""Returns the client VM network named used for peering."""
return (
self._GetClientVm().network.network_resource.name
if not gcp_flags.GCE_NETWORK_NAMES.value
else gcp_flags.GCE_NETWORK_NAMES.value[0]
) | Returns the client VM network named used for peering. | _GetNetwork | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _CreateVpcPeeringRequest(self):
"""Creates a VPC peering request for the Redis Enterprise instance."""
payload = {
'provider': 'GCP',
'vpcProjectUid': self.project,
'vpcNetworkName': self._GetNetwork(),
}
logging.info('Create peering request payload: %s', payload)
result ... | Creates a VPC peering request for the Redis Enterprise instance. | _CreateVpcPeeringRequest | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _GetTask(self, task_id: str) -> dict[str, Any]:
"""Returns the API task with the given task ID."""
logging.info('Getting task: %s', task_id)
result = requests.get(
f'{_REDIS_API_URL}/tasks/{task_id}',
headers=self.request_headers,
)
logging.info('Get task response: %s', result.te... | Returns the API task with the given task ID. | _GetTask | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _WaitForTaskCompletion(
self, task_id: str, wait_until_status: str | None = None
) -> _Json:
"""Waits for the API task with the given task ID to complete."""
logging.info('Waiting for task %s to finish', task_id)
while True:
task = self._GetTask(task_id)
status = task.get('status', N... | Waits for the API task with the given task ID to complete. | _WaitForTaskCompletion | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _GetCreateArgs(self) -> _Json:
"""Returns the payload to use for creating the instance."""
region_config = {
'region': self.redis_region,
'multipleAvailabilityZones': self.multi_az,
'networking': {'deploymentCIDR': '192.168.0.0/24'},
}
if self.zones:
region_config['pref... | Returns the payload to use for creating the instance. | _GetCreateArgs | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _GetDatabase(self):
"""Returns the database associated with the subscription."""
return requests.get(
f'{_REDIS_API_URL}/subscriptions/{self.subscription_id}/databases/{self.database_id}',
headers=self.request_headers,
).json() | Returns the database associated with the subscription. | _GetDatabase | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _GetSubscription(self):
"""Returns the subscription associated with the subscription."""
return requests.get(
f'{_REDIS_API_URL}/subscriptions/{self.subscription_id}',
headers=self.request_headers,
).json() | Returns the subscription associated with the subscription. | _GetSubscription | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _WaitForSubscriptionToIncludePricing(self):
"""Waits for the subscription to include pricing information."""
subscription = self._GetSubscription()
for pricing_detail in subscription['subscriptionPricing']:
if pricing_detail['type'] == 'Shards':
logging.info(
'Subscription has ... | Waits for the subscription to include pricing information. | _WaitForSubscriptionToIncludePricing | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _GetShardType(
self, subscription_json: _Json, database_json: _Json
) -> _ShardConfiguration:
"""Returns the shard type of the subscription."""
shard = _ShardConfiguration()
pricing_details = subscription_json['subscriptionPricing']
for pricing_detail in pricing_details:
if pricing_det... | Returns the shard type of the subscription. | _GetShardType | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _WaitUntilCompleteOrSubscriptionDeleted(self, result: _Json) -> None:
"""Waits until the task is complete or the subscription is deleted."""
delete_task = self._WaitForTaskCompletion(
result['taskId'], wait_until_status='processing-error'
)
if delete_task['status'] == 'processing-error' and ... | Waits until the task is complete or the subscription is deleted. | _WaitUntilCompleteOrSubscriptionDeleted | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _DeleteDatabase(self):
"""Deletes the database associated with the subscription."""
result = requests.delete(
f'{_REDIS_API_URL}/subscriptions/{self.subscription_id}/databases/{self.database_id}',
headers=self.request_headers,
)
logging.info('Attempting to delete database: %s', resul... | Deletes the database associated with the subscription. | _DeleteDatabase | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
def _IsReady(self) -> bool:
"""Returns true if the instance is ready."""
if not self.subscription_id or not self.database_id:
return False
result = requests.get(
f'{_REDIS_API_URL}/subscriptions/{self.subscription_id}/databases/{self.database_id}',
headers=self.request_headers,
)
... | Returns true if the instance is ready. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.