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 _RunParallelTasks(
target_arg_tuples,
max_concurrency,
get_task_manager,
parallel_exception_class,
post_task_delay=0,
):
"""Executes function calls concurrently in separate threads or processes.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains th... | Executes function calls concurrently in separate threads or processes.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains the function to call and the arguments to pass it.
max_concurrency: int or None. The maximum number of concurrent new threads
or processes.
... | _RunParallelTasks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_tasks.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_tasks.py | Apache-2.0 |
def RunParallelThreads(target_arg_tuples, max_concurrency, post_task_delay=0):
"""Executes function calls concurrently in separate threads.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains the function to call and the arguments to pass it.
max_concurrency: int or No... | Executes function calls concurrently in separate threads.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains the function to call and the arguments to pass it.
max_concurrency: int or None. The maximum number of concurrent new threads.
post_task_delay: Delay in seco... | RunParallelThreads | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_tasks.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_tasks.py | Apache-2.0 |
def RunThreaded(
target, thread_params, max_concurrent_threads=None, post_task_delay=0
):
"""Runs the target method in parallel threads.
The method starts up threads with one arg from thread_params as the first arg.
Args:
target: The method to invoke in the thread.
thread_params: A thread is launche... | Runs the target method in parallel threads.
The method starts up threads with one arg from thread_params as the first arg.
Args:
target: The method to invoke in the thread.
thread_params: A thread is launched for each value in the list. The items in
the list can either be a singleton or a (args, kwa... | RunThreaded | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_tasks.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_tasks.py | Apache-2.0 |
def RunParallelProcesses(
target_arg_tuples, max_concurrency, post_process_delay=0
):
"""Executes function calls concurrently in separate processes.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains the function to call and the arguments to pass it.
max_concurren... | Executes function calls concurrently in separate processes.
Args:
target_arg_tuples: list of (target, args, kwargs) tuples. Each tuple
contains the function to call and the arguments to pass it.
max_concurrency: int or None. The maximum number of concurrent new
processes. If None, it will default... | RunParallelProcesses | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_tasks.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_tasks.py | Apache-2.0 |
def Start(vm):
"""Starts the background workload on this VM."""
vm.RemoteCommand(
'nohup sysbench --num-threads=%s --test=cpu --cpu-max-prime=10000000 '
'run 1> /dev/null 2> /dev/null &'
% vm.background_cpu_threads
) | Starts the background workload on this VM. | Start | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_workload.py | Apache-2.0 |
def Stop(vm):
"""Stops the background workload on this VM."""
vm.RemoteCommand('kill -9 ' + vm.client_pid)
vm.RemoteCommand('kill -9 ' + vm.server_pid) | Stops the background workload on this VM. | Stop | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/background_workload.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/background_workload.py | Apache-2.0 |
def InitializeBeamRepo(benchmark_spec):
"""Ensures environment is prepared for running Beam benchmarks.
In the absence of FLAGS.beam_location, initializes the beam source code base
by checking out the repository from github. Specific branch selection is
supported.
Args:
benchmark_spec: The PKB spec for ... | Ensures environment is prepared for running Beam benchmarks.
In the absence of FLAGS.beam_location, initializes the beam source code base
by checking out the repository from github. Specific branch selection is
supported.
Args:
benchmark_spec: The PKB spec for the benchmark to run.
| InitializeBeamRepo | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_benchmark_helper.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_benchmark_helper.py | Apache-2.0 |
def _PrebuildBeam():
"""Rebuild beam if it was not build earlier."""
if not FLAGS.beam_prebuilt:
gradle_prebuild_tasks = ['clean', 'assemble']
gradle_prebuild_flags = ['--stacktrace', '--info']
build_command = [_GetGradleCommand()]
build_command.extend(gradle_prebuild_flags)
for task in gradle_... | Rebuild beam if it was not build earlier. | _PrebuildBeam | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_benchmark_helper.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_benchmark_helper.py | Apache-2.0 |
def BuildBeamCommand(benchmark_spec, classname, job_arguments):
"""Constructs a Beam execution command for the benchmark.
Args:
benchmark_spec: The PKB spec for the benchmark to run.
classname: The classname of the class to run.
job_arguments: The additional job arguments provided for the run.
Retur... | Constructs a Beam execution command for the benchmark.
Args:
benchmark_spec: The PKB spec for the benchmark to run.
classname: The classname of the class to run.
job_arguments: The additional job arguments provided for the run.
Returns:
cmd: Array containing the built command.
beam_dir: The di... | BuildBeamCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_benchmark_helper.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_benchmark_helper.py | Apache-2.0 |
def _BuildGradleCommand(classname, job_arguments):
"""Constructs a Gradle command for the benchmark.
Args:
classname: The classname of the class to run.
job_arguments: The additional job arguments provided for the run.
Returns:
cmd: Array containing the built command.
"""
cmd = []
gradle_exec... | Constructs a Gradle command for the benchmark.
Args:
classname: The classname of the class to run.
job_arguments: The additional job arguments provided for the run.
Returns:
cmd: Array containing the built command.
| _BuildGradleCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_benchmark_helper.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_benchmark_helper.py | Apache-2.0 |
def GetStaticPipelineOptions(options_list):
"""Takes the dictionary loaded from the yaml configuration file and returns it
in a form consistent with the others in GenerateAllPipelineOptions: a list of
(pipeline_option_name, pipeline_option_value) tuples.
The options in the options_list are a dict:
Key is ... | Takes the dictionary loaded from the yaml configuration file and returns it
in a form consistent with the others in GenerateAllPipelineOptions: a list of
(pipeline_option_name, pipeline_option_value) tuples.
The options in the options_list are a dict:
Key is the name of the pipeline option to pass to beam
... | GetStaticPipelineOptions | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_pipeline_options.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_pipeline_options.py | Apache-2.0 |
def EvaluateDynamicPipelineOptions(dynamic_options):
"""Takes the user's dynamic args and retrieves the information to fill them in.
dynamic_args is a python map of argument name -> {type, kubernetesSelector,
*format}
returns a list of tuples containing (argName, argValue)
if optional format it passed, argV... | Takes the user's dynamic args and retrieves the information to fill them in.
dynamic_args is a python map of argument name -> {type, kubernetesSelector,
*format}
returns a list of tuples containing (argName, argValue)
if optional format it passed, argValue is equal to format with "{{type}}"
being replaced w... | EvaluateDynamicPipelineOptions | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_pipeline_options.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_pipeline_options.py | Apache-2.0 |
def GenerateAllPipelineOptions(
it_args, it_options, static_pipeline_options, dynamic_pipeline_options
):
""":param it_args: options list passed in via FLAGS.beam_it_args
:param it_options: options list passed in via FLAGS.beam_it_options
:param static_pipeline_options: options list loaded from the yaml conf... | :param it_args: options list passed in via FLAGS.beam_it_args
:param it_options: options list passed in via FLAGS.beam_it_options
:param static_pipeline_options: options list loaded from the yaml config file
:param dynamic_pipeline_options: options list loaded from the yaml config file
:return: a list of value... | GenerateAllPipelineOptions | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_pipeline_options.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_pipeline_options.py | Apache-2.0 |
def ReadPipelineOptionConfigFile():
"""Reads the path to the config file from FLAGS, then loads the static and
dynamic pipeline options from it.
"""
dynamic_pipeline_options = []
static_pipeline_options = []
if FLAGS.beam_options_config_file:
with open(FLAGS.beam_options_config_file) as file_stream:
... | Reads the path to the config file from FLAGS, then loads the static and
dynamic pipeline options from it.
| ReadPipelineOptionConfigFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/beam_pipeline_options.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/beam_pipeline_options.py | Apache-2.0 |
def SetBenchmarkModuleFunction(function):
"""Sets the function called by BenchmarkModule; See benchmark_sets.py."""
global _global_benchmark_module_function
_global_benchmark_module_function = function | Sets the function called by BenchmarkModule; See benchmark_sets.py. | SetBenchmarkModuleFunction | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_lookup.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_lookup.py | Apache-2.0 |
def BenchmarkModule(benchmark_name):
"""Finds the module for a benchmark by name.
Args:
benchmark_name: The name of the benchmark.
Returns:
The benchmark's module, or None if the benchmark is invalid.
"""
if not _global_benchmark_module_function:
raise errors.Setup.InvalidSetupError(
'Ca... | Finds the module for a benchmark by name.
Args:
benchmark_name: The name of the benchmark.
Returns:
The benchmark's module, or None if the benchmark is invalid.
| BenchmarkModule | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_lookup.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_lookup.py | Apache-2.0 |
def _GetValidBenchmarks():
"""Returns a dict mapping valid benchmark names to their modules."""
if _GetBenchmarkOsType() == CONTAINER:
return {'cluster_boot': linux_benchmarks.VALID_BENCHMARKS['cluster_boot']}
elif _GetBenchmarkOsType() == WINDOWS:
return windows_benchmarks.VALID_BENCHMARKS
return linux... | Returns a dict mapping valid benchmark names to their modules. | _GetValidBenchmarks | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_sets.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_sets.py | Apache-2.0 |
def _GetValidPackages():
"""Returns a dict mapping valid package names to their modules."""
if _GetBenchmarkOsType() == CONTAINER:
return {}
elif _GetBenchmarkOsType() == WINDOWS:
return windows_packages.PACKAGES
return linux_packages.PACKAGES | Returns a dict mapping valid package names to their modules. | _GetValidPackages | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_sets.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_sets.py | Apache-2.0 |
def _GetBenchmarksFromUserConfig(user_config):
"""Returns a list of benchmark module, config tuples."""
benchmarks = user_config.get('benchmarks', [])
valid_benchmarks = _GetValidBenchmarks()
benchmark_config_list = []
for entry in benchmarks:
name, user_config = entry.popitem()
try:
benchmark_... | Returns a list of benchmark module, config tuples. | _GetBenchmarksFromUserConfig | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_sets.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_sets.py | Apache-2.0 |
def _AssertFlagMatrixAndZipDefsExist(
benchmark_config, flag_matrix_name, flag_zip_name
):
"""Asserts that specified flag_matrix and flag_zip exist.
Both flag_matrix_name and flag_zip_name can be None, meaning that the user
(or the benchmark_config) did not specify them.
Args:
benchmark_config: benchm... | Asserts that specified flag_matrix and flag_zip exist.
Both flag_matrix_name and flag_zip_name can be None, meaning that the user
(or the benchmark_config) did not specify them.
Args:
benchmark_config: benchmark_config
flag_matrix_name: name of the flag_matrix_def specified by the user via a
flag,... | _AssertFlagMatrixAndZipDefsExist | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_sets.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_sets.py | Apache-2.0 |
def GetBenchmarksFromFlags():
"""Returns a list of benchmarks to run based on the benchmarks flag.
If no benchmarks (or sets) are specified, this will return the standard set.
If multiple sets or mixes of sets and benchmarks are specified, this will
return the union of all sets and individual benchmarks.
Ra... | Returns a list of benchmarks to run based on the benchmarks flag.
If no benchmarks (or sets) are specified, this will return the standard set.
If multiple sets or mixes of sets and benchmarks are specified, this will
return the union of all sets and individual benchmarks.
Raises:
ValueError: when benchmar... | GetBenchmarksFromFlags | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_sets.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_sets.py | Apache-2.0 |
def __init__(
self,
benchmark_module: Any,
benchmark_config: benchmark_config_spec.BenchmarkConfigSpec,
benchmark_uid: str,
):
"""Initialize a BenchmarkSpec object.
Args:
benchmark_module: The benchmark module object.
benchmark_config: BenchmarkConfigSpec. The configuratio... | Initialize a BenchmarkSpec object.
Args:
benchmark_module: The benchmark module object.
benchmark_config: BenchmarkConfigSpec. The configuration for the
benchmark.
benchmark_uid: An identifier unique to this run of the benchmark even if
the same benchmark is run multiple times wit... | __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _InitializeFromSpec(
self,
attribute_name: str,
resource_spec: freeze_restore_spec.FreezeRestoreSpec,
) -> bool:
"""Initializes the BenchmarkSpec attribute from the restore_spec.
Args:
attribute_name: The attribute to restore.
resource_spec: The spec class corresponding to t... | Initializes the BenchmarkSpec attribute from the restore_spec.
Args:
attribute_name: The attribute to restore.
resource_spec: The spec class corresponding to the resource to be
restored.
Returns:
True if successful, False otherwise.
| _InitializeFromSpec | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructResources(self):
"""Constructs the resources for the benchmark."""
self.ConstructContainerCluster()
self.ConstructContainerRegistry()
# dpb service needs to go first, because it adds some vms.
self.ConstructDpbService()
self.ConstructCluster()
self.ConstructVirtualMachines()
... | Constructs the resources for the benchmark. | ConstructResources | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructDpbService(self):
"""Create the dpb_service object and create groups for its vms."""
if self.config.dpb_service is None:
return
dpb_service_spec = self.config.dpb_service
dpb_service_cloud = dpb_service_spec.worker_group.cloud
dpb_service_spec.worker_group.vm_count = dpb_service_s... | Create the dpb_service object and create groups for its vms. | ConstructDpbService | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructRelationalDb(self):
"""Creates the relational db and create groups for its vms."""
if self.config.relational_db is None:
return
if self._InitializeFromSpec('relational_db', self.config.relational_db):
return
cloud = self.config.relational_db.cloud
is_managed_db = self.config... | Creates the relational db and create groups for its vms. | ConstructRelationalDb | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructTpuGroup(self, group_spec):
"""Constructs the BenchmarkSpec's cloud TPU objects."""
if group_spec is None:
return
cloud = group_spec.cloud
providers.LoadProvider(cloud)
tpu_class = cloud_tpu.GetTpuClass(cloud)
return tpu_class(group_spec) # pytype: disable=not-instantiable | Constructs the BenchmarkSpec's cloud TPU objects. | ConstructTpuGroup | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructExampleResource(self):
"""Create an example_resource object. Also call this from pkb.py."""
if self.config.example_resource is None:
return
example_resource_type = self.config.example_resource.example_type
example_resource_class = example_resource.GetExampleResourceClass(
exam... | Create an example_resource object. Also call this from pkb.py. | ConstructExampleResource | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructBaseJob(self):
"""Create an instance of the base job.It is also called from pkb.py."""
if self.config.base_job is None:
return
job_type = self.config.base_job.job_type
cloud = self.config.base_job.CLOUD
providers.LoadProvider(cloud)
job_class = base_job.GetJobClass(job_type)
... | Create an instance of the base job.It is also called from pkb.py. | ConstructBaseJob | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructNfsService(self):
"""Construct the NFS service object.
Creates an NFS Service only if an NFS disk is found in the disk_specs.
"""
if self.nfs_service:
logging.info('NFS service already created: %s', self.nfs_service)
return
for group_spec in self.vms_to_boot.values():
... | Construct the NFS service object.
Creates an NFS Service only if an NFS disk is found in the disk_specs.
| ConstructNfsService | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructSmbService(self):
"""Construct the SMB service object.
Creates an SMB Service only if an SMB disk is found in the disk_specs.
"""
if self.smb_service:
logging.info('SMB service already created: %s', self.smb_service)
return
for group_spec in self.vms_to_boot.values():
... | Construct the SMB service object.
Creates an SMB Service only if an SMB disk is found in the disk_specs.
| ConstructSmbService | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructVirtualMachineGroup(
self, group_name, group_spec
) -> list[virtual_machine.VirtualMachine]:
"""Construct the virtual machine(s) needed for a group."""
vms = []
vm_count = group_spec.vm_count
# First create the Static VM objects.
if group_spec.static_vms:
specs = [
... | Construct the virtual machine(s) needed for a group. | ConstructVirtualMachineGroup | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructCapacityReservations(self):
"""Construct capacity reservations for each VM group."""
if not FLAGS.use_capacity_reservations:
return
for vm_group in self.vm_groups.values():
cloud = vm_group[0].CLOUD
providers.LoadProvider(cloud)
capacity_reservation_class = capacity_rese... | Construct capacity reservations for each VM group. | ConstructCapacityReservations | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _CheckBenchmarkSupport(self, cloud):
"""Throw an exception if the benchmark isn't supported."""
if FLAGS.benchmark_compatibility_checking == SKIP_CHECK:
return
provider_info_class = provider_info.GetProviderInfoClass(cloud)
benchmark_ok = provider_info_class.IsBenchmarkSupported(self.name)
... | Throw an exception if the benchmark isn't supported. | _CheckBenchmarkSupport | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _ConstructJujuController(
self, group_spec
) -> virtual_machine.VirtualMachine:
"""Construct a VirtualMachine object for a Juju controller."""
juju_spec = copy.copy(group_spec)
juju_spec.vm_count = 1
jujuvms = self.ConstructVirtualMachineGroup('juju', juju_spec)
if len(jujuvms):
ju... | Construct a VirtualMachine object for a Juju controller. | _ConstructJujuController | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def ConstructMessagingService(self):
"""Create the messaging_service object.
Assumes VMs are already constructed.
"""
if self.config.messaging_service is None:
return
cloud = self.config.messaging_service.cloud
delivery = self.config.messaging_service.delivery
providers.LoadProvider(c... | Create the messaging_service object.
Assumes VMs are already constructed.
| ConstructMessagingService | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def Provision(self):
"""Prepares the VMs and networks necessary for the benchmark to run."""
should_restore = (
hasattr(self, 'restore_spec') and self.restore_spec is not None
)
# Create capacity reservations if the cloud supports it. Note that the
# capacity reservation class may update the... | Prepares the VMs and networks necessary for the benchmark to run. | Provision | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def GetSamples(self):
"""Returns samples created from benchmark resources."""
samples = []
for resource in self.resources:
samples.extend(resource.GetSamples())
return samples | Returns samples created from benchmark resources. | GetSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _GetResourceDict(self, time_format, timeout_minutes=None):
"""Gets a list of tags to be used to tag resources."""
now_utc = datetime.datetime.utcnow()
if not timeout_minutes:
timeout_minutes = FLAGS.timeout_minutes
timeout_utc = now_utc + datetime.timedelta(minutes=timeout_minutes)
tags... | Gets a list of tags to be used to tag resources. | _GetResourceDict | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _CreatePlacementGroup(self, placement_group_spec, cloud):
"""Create a placement group in zone.
Args:
placement_group_spec: A placement_group.BasePlacementGroupSpec object.
cloud: The cloud for the placement group. See the flag of the same name
for more information.
Returns:
A... | Create a placement group in zone.
Args:
placement_group_spec: A placement_group.BasePlacementGroupSpec object.
cloud: The cloud for the placement group. See the flag of the same name
for more information.
Returns:
A placement_group.BasePlacementGroup object.
| _CreatePlacementGroup | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _CreateVirtualMachine(self, vm_spec, os_type, cloud):
"""Create a vm in zone.
Args:
vm_spec: A virtual_machine.BaseVmSpec object.
os_type: The type of operating system for the VM. See the flag of the same
name for more information.
cloud: The cloud for the VM. See the flag of the ... | Create a vm in zone.
Args:
vm_spec: A virtual_machine.BaseVmSpec object.
os_type: The type of operating system for the VM. See the flag of the same
name for more information.
cloud: The cloud for the VM. See the flag of the same name for more
information.
Returns:
A vir... | _CreateVirtualMachine | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def Pickle(self, filename=None):
"""Pickles the spec so that it can be unpickled on a subsequent run."""
with open(
filename or self._GetPickleFilename(self.uid), 'wb'
) as pickle_file:
pickle.dump(self, pickle_file, 2) | Pickles the spec so that it can be unpickled on a subsequent run. | Pickle | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def Freeze(self):
"""Pickles the spec to a destination, defaulting to tempdir if not found."""
if not self.freeze_path:
return
logging.info('Freezing benchmark_spec to %s', self.freeze_path)
try:
self.Pickle(self.freeze_path)
except FileNotFoundError:
default_path = f'{vm_util.GetT... | Pickles the spec to a destination, defaulting to tempdir if not found. | Freeze | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def GetBenchmarkSpec(cls, benchmark_module, config, uid):
"""Unpickles or creates a BenchmarkSpec and returns it.
Args:
benchmark_module: The benchmark module object.
config: BenchmarkConfigSpec. The configuration for the benchmark.
uid: An identifier unique to this run of the benchmark even ... | Unpickles or creates a BenchmarkSpec and returns it.
Args:
benchmark_module: The benchmark module object.
config: BenchmarkConfigSpec. The configuration for the benchmark.
uid: An identifier unique to this run of the benchmark even if the same
benchmark is run multiple times with differen... | GetBenchmarkSpec | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_spec.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_spec.py | Apache-2.0 |
def _CreateSummaryTable(benchmark_specs):
"""Converts statuses of benchmark runs into a formatted string table.
Args:
benchmark_specs: List of BenchmarkSpecs.
Returns:
string. Multi-line string summarizing benchmark success statuses. Example:
-----------------------------------------------------... | Converts statuses of benchmark runs into a formatted string table.
Args:
benchmark_specs: List of BenchmarkSpecs.
Returns:
string. Multi-line string summarizing benchmark success statuses. Example:
--------------------------------------------------------
Name UID Status... | _CreateSummaryTable | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_status.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_status.py | Apache-2.0 |
def CreateSummary(benchmark_specs):
"""Logs a summary of benchmark run statuses.
Args:
benchmark_specs: List of BenchmarkSpecs.
Returns:
string. Multi-line string summarizing benchmark success statuses. Example:
Benchmark run statuses:
----------------------------------------------------... | Logs a summary of benchmark run statuses.
Args:
benchmark_specs: List of BenchmarkSpecs.
Returns:
string. Multi-line string summarizing benchmark success statuses. Example:
Benchmark run statuses:
--------------------------------------------------------
Name UID ... | CreateSummary | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/benchmark_status.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/benchmark_status.py | Apache-2.0 |
def GetSaveCommand() -> str:
"""Returns the cloudharmony command to save benchmark reports."""
return (
f' --db_and_csv --store {STORE.value} --store_key {KEY.value} '
f' --store_secret {SECRET.value} --store_container {BUCKET.value} '
) | Returns the cloudharmony command to save benchmark reports. | GetSaveCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_harmony_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_harmony_util.py | Apache-2.0 |
def ParseCsvResultsIntoMetadata(
vm: virtual_machine.BaseVirtualMachine, path: str
) -> List[Dict[str, Any]]:
"""Loads the CSV created by cloud harmony at path in the VM into metadata.
The CSV located by path inside of virtual machine VM will be loaded. For each
row of results, a set of key/value pairs is cr... | Loads the CSV created by cloud harmony at path in the VM into metadata.
The CSV located by path inside of virtual machine VM will be loaded. For each
row of results, a set of key/value pairs is created. The keys will all be
prepended with `cloudharmony` or similar.
Args:
vm: the Virtual Machine that has ... | ParseCsvResultsIntoMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_harmony_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_harmony_util.py | Apache-2.0 |
def ParseCsvResultsFromString(
csv_string: str, prefix: str = ''
) -> List[Dict[str, Any]]:
"""Loads the CSV created by cloud harmony in csv_string.
The CSV will be loaded into a pandas data frame.
For every row of results - we will create a set of key/value pairs
representing that row of results. The key... | Loads the CSV created by cloud harmony in csv_string.
The CSV will be loaded into a pandas data frame.
For every row of results - we will create a set of key/value pairs
representing that row of results. The keys will all be prepended with
prefix.
Args:
csv_string: a string of the CSV which was produ... | ParseCsvResultsFromString | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_harmony_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_harmony_util.py | Apache-2.0 |
def GetCommonMetadata(custom_metadata: Dict[str, Any] | None = None) -> str:
"""Returns pkb metadata associated with this run as cloudharmony metadata.
Cloudharmony benchmarks take in benchmark setup configurations as inputs and
include them in the output as metadata for the run. This function creates a
string... | Returns pkb metadata associated with this run as cloudharmony metadata.
Cloudharmony benchmarks take in benchmark setup configurations as inputs and
include them in the output as metadata for the run. This function creates a
string of input metadata from pkb flags to be included as run parameter for
cloudharmo... | GetCommonMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_harmony_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_harmony_util.py | Apache-2.0 |
def GetMetadataSamples(
cloud_harmony_metadata: List[Dict[Any, Any]],
) -> List[sample.Sample]:
"""Returns the cloudharmony metadata as a list of samples.
This function is commonly used across all cloudharmony benchmarks.
Args:
cloud_harmony_metadata: list of metadata outputs to save in samples.
Retu... | Returns the cloudharmony metadata as a list of samples.
This function is commonly used across all cloudharmony benchmarks.
Args:
cloud_harmony_metadata: list of metadata outputs to save in samples.
Returns:
A list of sample.Sample objects of cloudharmony metadata, where one sample
represents one ro... | GetMetadataSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_harmony_util.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_harmony_util.py | Apache-2.0 |
def __init__(self, tpu_spec):
"""Initialize the TPU object.
Args:
tpu_spec: spec of the TPU.
"""
super().__init__()
self.spec = tpu_spec | Initialize the TPU object.
Args:
tpu_spec: spec of the TPU.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cloud_tpu.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cloud_tpu.py | Apache-2.0 |
def _ApplyFlags(cls, config_values, flag_values):
"""Overrides config values with flag values.
Can be overridden by derived classes to add support for specific flags.
Args:
config_values: dict mapping config option names to provided values. Is
modified by this function.
flag_values: fl... | Overrides config values with flag values.
Can be overridden by derived classes to add support for specific flags.
Args:
config_values: dict mapping config option names to provided values. Is
modified by this function.
flag_values: flags.FlagValues. Runtime flags that may override the
... | _ApplyFlags | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def _GetOptionDecoderConstructions(cls):
"""Gets decoder classes and constructor args for each configurable option.
Can be overridden by derived classes to add options or impose additional
requirements on existing options.
Returns:
dict. Maps option name string to a (ConfigOptionDecoder class, d... | Gets decoder classes and constructor args for each configurable option.
Can be overridden by derived classes to add options or impose additional
requirements on existing options.
Returns:
dict. Maps option name string to a (ConfigOptionDecoder class, dict) pair.
The pair specifies a decode... | _GetOptionDecoderConstructions | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def GetClusterClass(cloud: str):
"""Returns the cluster spec class corresponding to the given service."""
if UNMANAGED.value:
return BaseCluster
return resource.GetResourceClass(BaseCluster, CLOUD=cloud, TYPE=TYPE.value) | Returns the cluster spec class corresponding to the given service. | GetClusterClass | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def __init__(self, cluster_spec: BaseClusterSpec):
"""Initialize BaseCluster class.
Args:
cluster_spec: cluster.BaseBaseClusterSpec object.
"""
super().__init__()
self.zone: str = cluster_spec.workers.vm_spec.zone
self.machine_type: str = cluster_spec.workers.vm_spec.machine_type
self... | Initialize BaseCluster class.
Args:
cluster_spec: cluster.BaseBaseClusterSpec object.
| __init__ | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def RemoteCommand(
self,
command: str,
ignore_failure: bool = False,
timeout: float | None = None,
**kwargs,
) -> Tuple[str, str]:
"""Runs a command on the VM.
Derived classes may add additional kwargs if necessary, but they should not
be used outside of the class itself sin... | Runs a command on the VM.
Derived classes may add additional kwargs if necessary, but they should not
be used outside of the class itself since they are non standard.
Args:
command: A valid bash command.
ignore_failure: Ignore any failure if set to true.
timeout: The time to wait in seco... | RemoteCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def RobustRemoteCommand(
self,
command: str,
timeout: float | None = None,
ignore_failure: bool = False,
) -> Tuple[str, str]:
"""Runs a command on the VM in a more robust way than RemoteCommand.
The default should be to call RemoteCommand and log that it is not yet
implemented. T... | Runs a command on the VM in a more robust way than RemoteCommand.
The default should be to call RemoteCommand and log that it is not yet
implemented. This function should be overwritten it is decendents.
Args:
command: The command to run.
timeout: The timeout for the command in seconds.
... | RobustRemoteCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def TryRemoteCommand(self, command: str, **kwargs):
"""Runs a remote command and returns True iff it succeeded."""
try:
self.RemoteCommand(command, **kwargs)
return True
except errors.VirtualMachine.RemoteCommandError:
return False | Runs a remote command and returns True iff it succeeded. | TryRemoteCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def BackfillVm(
self,
vm_spec: virtual_machine.BaseVmSpec,
fn: Callable[[virtual_machine.BaseVirtualMachine], None],
):
"""Create and backfill a VM object created using cluster resource.
Args:
vm_spec: VM spec to be used to find corresponding VM class.
fn: The function to be cal... | Create and backfill a VM object created using cluster resource.
Args:
vm_spec: VM spec to be used to find corresponding VM class.
fn: The function to be called on the newly created VM.
Returns:
The newly created VM object.
| BackfillVm | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def ExportVmGroupsForUnmanagedProvision(self):
"""Export VmGroups for unmanaged provisioning.
Returns:
Dictionary of VmGroupSpec for provisioning in BenchmarkSpec object.
"""
if not self.unmanaged:
return {}
logging.info('Provisioning cluster resources with unmanaged VM creation.')
... | Export VmGroups for unmanaged provisioning.
Returns:
Dictionary of VmGroupSpec for provisioning in BenchmarkSpec object.
| ExportVmGroupsForUnmanagedProvision | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def ImportVmGroups(self, headnode, workers):
"""Imports VMGroups from unmanaged provision.
After VMs being created from unmanaged codepath. Add corresponding vm_groups
back to cluster object. So the benchmark hopefully do not care about
how underlying resources being created.
Args:
headnode:... | Imports VMGroups from unmanaged provision.
After VMs being created from unmanaged codepath. Add corresponding vm_groups
back to cluster object. So the benchmark hopefully do not care about
how underlying resources being created.
Args:
headnode: VirtualMachine object representing a headnode.
... | ImportVmGroups | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/cluster.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/cluster.py | Apache-2.0 |
def RunCommand(
self,
command: str | list[str],
ignore_failure: bool = False,
should_pre_log: bool = True,
stack_level: int = 1,
timeout: float | None = None,
**kwargs,
) -> Tuple[str, str, int]:
"""Runs a command.
Additional args can be supplied & are passed to lowe... | Runs a command.
Additional args can be supplied & are passed to lower level functions but
aren't required.
Args:
command: A valid bash command in string or list form.
ignore_failure: Ignore any failure if set to true.
should_pre_log: Whether to print the command being run or not.
s... | RunCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/command_interface.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/command_interface.py | Apache-2.0 |
def PrepareResourcePath(
self, resource_name: str, search_user_paths: bool = True
) -> str:
"""Prepares a resource from local loaders & returns path on machine.
Loaders are searched in order until the resource is found.
If no loader provides 'resource_name', an exception is thrown.
If 'search_... | Prepares a resource from local loaders & returns path on machine.
Loaders are searched in order until the resource is found.
If no loader provides 'resource_name', an exception is thrown.
If 'search_user_paths' is true, the directories specified by
"--data_search_paths" are consulted before the defaul... | PrepareResourcePath | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/command_interface.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/command_interface.py | Apache-2.0 |
def RunCommand(
self,
command: str | list[str],
ignore_failure: bool = False,
should_pre_log: bool = True,
stack_level: int = 1,
timeout: float | None = None,
**kwargs,
) -> Tuple[str, str, int]:
"""Runs a command.
Additional args can be supplied & are passed to lowe... | Runs a command.
Additional args can be supplied & are passed to lower level functions but
aren't required.
Args:
command: A valid bash command in string or list form.
ignore_failure: Ignore any failure if set to true.
should_pre_log: Whether to print the command being run or not.
s... | RunCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/command_interface.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/command_interface.py | Apache-2.0 |
def WriteTemporaryFile(self, file_contents: str) -> str:
"""Writes a temporary file to the VM.
Args:
file_contents: The contents of the file.
Returns:
The full filename.
"""
with vm_util.NamedTemporaryFile(mode='w', delete=False) as tf:
tf.write(file_contents)
tf.close()
... | Writes a temporary file to the VM.
Args:
file_contents: The contents of the file.
Returns:
The full filename.
| WriteTemporaryFile | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/command_interface.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/command_interface.py | Apache-2.0 |
def RunRetryableKubectlCommand(
run_cmd: list[str], timeout: int | None = None, **kwargs
) -> tuple[str, str, int]:
"""Runs a kubectl command, retrying somewhat exepected errors."""
if 'raise_on_timeout' in kwargs and kwargs['raise_on_timeout']:
raise ValueError(
'RunRetryableKubectlCommand does not... | Runs a kubectl command, retrying somewhat exepected errors. | RunRetryableKubectlCommand | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _RunRetryablePart(run_cmd: list[str], **kwargs):
"""Inner function retries command so timeout can be passed to decorator."""
kwargs['stack_level'] += 1
return RunKubectlCommand(run_cmd, raise_on_timeout=True, **kwargs) | Inner function retries command so timeout can be passed to decorator. | _RunRetryablePart | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def LocalBuildAndPush(self, image: ContainerImage):
"""Build the image locally and push to registry.
Assumes we are already authenticated with the registry from self.Login.
Building and pushing done in one command to support multiarch images
https://github.com/docker/buildx/issues/59
Args:
i... | Build the image locally and push to registry.
Assumes we are already authenticated with the registry from self.Login.
Building and pushing done in one command to support multiarch images
https://github.com/docker/buildx/issues/59
Args:
image: The image to build.
| LocalBuildAndPush | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetOrBuild(self, image: str):
"""Finds the image in the registry or builds it.
TODO(pclay): Add support for build ARGs.
Args:
image: The PKB name for the image (string).
Returns:
The full image name (including the registry).
"""
full_image = self.GetFullRegistryTag(image)
... | Finds the image in the registry or builds it.
TODO(pclay): Add support for build ARGs.
Args:
image: The PKB name for the image (string).
Returns:
The full image name (including the registry).
| GetOrBuild | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _Build(self, image: str):
"""Builds the image and pushes it to the registry if necessary.
Args:
image: The PKB name for the image (string).
"""
image = ContainerImage(image)
if not FLAGS.local_container_build:
try:
build_start = time.time()
# Build the image remotely... | Builds the image and pushes it to the registry if necessary.
Args:
image: The PKB name for the image (string).
| _Build | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _SetKubeConfig(unused_sender, benchmark_spec: BenchmarkSpec):
"""Sets the value for the kubeconfig flag if it's unspecified."""
if not FLAGS.kubeconfig:
FLAGS.kubeconfig = vm_util.PrependTempDir(
'kubeconfig' + str(benchmark_spec.sequence_number)
)
# Store the value for subsequent run stages... | Sets the value for the kubeconfig flag if it's unspecified. | _SetKubeConfig | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def NodePoolName(name: str) -> str:
"""Clean node pool names to be usable by all providers."""
# GKE (or k8s?) requires nodepools use alphanumerics and hyphens
# AKS requires full alphanumeric
# PKB likes to use underscores strip them out.
return name.replace('_', '') | Clean node pool names to be usable by all providers. | NodePoolName | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def InitializeNodePoolForCloud(
self,
vm_config: virtual_machine.BaseVirtualMachine,
nodepool_config: BaseNodePoolConfig,
):
"""Override to initialize cloud specific configs."""
pass | Override to initialize cloud specific configs. | InitializeNodePoolForCloud | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetSamples(self):
"""Return samples with information about deployment times."""
samples = super().GetSamples()
for container in itertools.chain(*list(self.containers.values())):
metadata = {'image': container.image.split('/')[-1]}
if container.resource_ready_time and container.create_start_t... | Return samples with information about deployment times. | GetSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _GetPod(self) -> dict[str, Any]:
"""Gets a representation of the POD and returns it."""
stdout, _, _ = RunKubectlCommand(['get', 'pod', self.name, '-o', 'yaml'])
pod = yaml.safe_load(stdout)
self.ip_address = pod.get('status', {}).get('podIP')
return pod | Gets a representation of the POD and returns it. | _GetPod | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _ValidatePodHasNotFailed(self, status: dict[str, Any]):
"""Raises an exception if the pod has failed."""
# Inspect the pod's status to determine if it succeeded, has failed, or is
# doomed to fail.
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/
phase = status['phase']
if... | Raises an exception if the pod has failed. | _ValidatePodHasNotFailed | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _IsReady(self):
"""Returns true if the container has stopped pending."""
status = self._GetPod()['status']
super()._ValidatePodHasNotFailed(status)
return status['phase'] != 'Pending' | Returns true if the container has stopped pending. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _GetIpAddress(self):
"""Attempts to set the Service's ip address."""
ingress_name = '%s-ingress' % self.name
get_cmd = [
'get',
'ing',
ingress_name,
'-o',
'jsonpath={.status.loadBalancer.ingress[*].ip}',
]
stdout, _, _ = RunKubectlCommand(get_cmd)
ip_a... | Attempts to set the Service's ip address. | _GetIpAddress | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _IsReady(self):
"""Returns True if the Service is ready."""
if self.ip_address is None:
self._GetIpAddress()
if self.ip_address is not None:
url = 'http://%s' % (self.ip_address)
r = requests.get(url)
if r.status_code == 200:
return True
return False | Returns True if the Service is ready. | _IsReady | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _DeleteAllFromDefaultNamespace():
"""Deletes all resources from a namespace.
Since StatefulSets do not reclaim PVCs upon deletion, they are explicitly
deleted here to prevent dynamically provisioned PDs from leaking once the
cluster has been deleted.
"""
try:
# Delete deployments firs... | Deletes all resources from a namespace.
Since StatefulSets do not reclaim PVCs upon deletion, they are explicitly
deleted here to prevent dynamically provisioned PDs from leaking once the
cluster has been deleted.
| _DeleteAllFromDefaultNamespace | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def ApplyManifest(
manifest_file: str, should_log_file: bool = True, **kwargs
) -> Iterator[str]:
"""Applies a declarative Kubernetes manifest; possibly with jinja.
Args:
manifest_file: The name of the YAML file or YAML template.
should_log_file: Whether to log the rendered manifest to stdo... | Applies a declarative Kubernetes manifest; possibly with jinja.
Args:
manifest_file: The name of the YAML file or YAML template.
should_log_file: Whether to log the rendered manifest to stdout or not.
**kwargs: Arguments to the jinja template.
Returns:
Names of the resources, e.g. [dep... | ApplyManifest | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _ParseApplyOutput(stdout: str) -> Iterator[str]:
"""Parses the output of kubectl apply to get the name of the resource."""
# Example input: deployment.apps/pkb123 created
for line in stdout.splitlines():
match = re.search(r'([^\s/]+/[^\s/]+) created', line)
if match:
yiel... | Parses the output of kubectl apply to get the name of the resource. | _ParseApplyOutput | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def WaitForResource(
resource_name: str,
condition_name: str,
namespace: str | None = None,
timeout: int = vm_util.DEFAULT_TIMEOUT,
wait_for_all: bool = False,
condition_type='condition=',
extra_args: list[str] | None = None,
):
"""Waits for a condition on a Kubernetes re... | Waits for a condition on a Kubernetes resource (eg: deployment, pod). | WaitForResource | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def WaitForSucceeded(
resource_name: str,
namespace: str | None = None,
timeout: int = vm_util.DEFAULT_TIMEOUT,
raise_on_failure: bool = True,
) -> tuple[str, str, int]:
"""Waits for a resource to complete (i.e. .status.phase=='Succeeded')."""
run_cmd = [
'wait',
'--for... | Waits for a resource to complete (i.e. .status.phase=='Succeeded'). | WaitForSucceeded | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def WaitForRollout(
resource_name: str, timeout: int = vm_util.DEFAULT_TIMEOUT
):
"""Blocks until a Kubernetes rollout is completed."""
run_cmd = [
'rollout',
'status',
'--timeout=%ds' % timeout,
resource_name,
]
RunRetryableKubectlCommand(
run_cmd,
... | Blocks until a Kubernetes rollout is completed. | WaitForRollout | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetLoadBalancerIP(service_name: str):
"""Returns the IP address of a LoadBalancer service when ready."""
get_cmd = [
'get',
'service',
service_name,
'-o',
'jsonpath={.status.loadBalancer.ingress[0].ip}',
]
stdout, _, _ = RunKubectlCommand(get_cmd)
try:
... | Returns the IP address of a LoadBalancer service when ready. | GetLoadBalancerIP | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetClusterIP(service_name: str) -> str:
"""Returns the IP address of a ClusterIP service when ready."""
get_cmd = [
'get',
'service',
service_name,
'-o',
'jsonpath={.spec.clusterIP}',
]
stdout, _, _ = RunKubectlCommand(get_cmd)
if not stdout:
raise... | Returns the IP address of a ClusterIP service when ready. | GetClusterIP | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetNumNodesSamples() -> list[Sample]:
"""Returns a count of nodes in each state for the cluster.
The number of ready, unready, and unknown nodes should always sum to the
total nodes.
Returns:
A List of the (total nodes, ready nodes, unready nodes, unknown nodes)
for this cluster as `Sa... | Returns a count of nodes in each state for the cluster.
The number of ready, unready, and unknown nodes should always sum to the
total nodes.
Returns:
A List of the (total nodes, ready nodes, unready nodes, unknown nodes)
for this cluster as `Sample`s.
| GetNumNodesSamples | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def CreateConfigMap(name: str, from_file_dir: str):
"""Creates a Kubernetes ConfigMap.
Args:
name: The name of the ConfigMap to create
from_file_dir: The directory name containing files that will be key/values
in the ConfigMap
"""
RunKubectlCommand(
['create', 'configmap', n... | Creates a Kubernetes ConfigMap.
Args:
name: The name of the ConfigMap to create
from_file_dir: The directory name containing files that will be key/values
in the ConfigMap
| CreateConfigMap | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def CreateServiceAccount(
name: str, clusterrole: str | None = None, namespace='default'
):
"""Create a k8s service account and cluster-role-binding."""
RunKubectlCommand(
['create', 'serviceaccount', name, '--namespace', namespace]
)
if clusterrole:
# TODO(pclay): Support customer... | Create a k8s service account and cluster-role-binding. | CreateServiceAccount | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetPodIpsByLabel(pod_label_key, pod_label_value) -> list[str]:
"""Returns a list of internal IPs for pod label key-value.
Args:
pod_label_key: The pod label name
pod_label_value: The pod label value
"""
get_cmd = [
'get',
'pods',
'-l',
f'{pod_label_key}={... | Returns a list of internal IPs for pod label key-value.
Args:
pod_label_key: The pod label name
pod_label_value: The pod label value
| GetPodIpsByLabel | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetPodIps(resource_name) -> list[str]:
"""Returns a list of internal IPs for a pod name.
Args:
resource_name: The pod resource name
"""
pod_label = KubernetesClusterCommands.GetPodLabel(resource_name)
return KubernetesClusterCommands.GetPodIpsByLabel('app', pod_label) | Returns a list of internal IPs for a pod name.
Args:
resource_name: The pod resource name
| GetPodIps | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetAllNamesForResourceType(resource_type: str) -> list[str]:
"""Get all names for the specified resource. Type should be plural."""
stdout, _, _ = RunKubectlCommand(
['get', resource_type, '-o', 'jsonpath={.items[*].metadata.name}']
)
return stdout.split() | Get all names for the specified resource. Type should be plural. | GetAllNamesForResourceType | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _GetEvents(**kwargs) -> set['KubernetesEvent']:
"""Get the events for the cluster."""
stdout, _, _ = RunKubectlCommand(['get', 'events', '-o', 'yaml'], **kwargs)
k8s_events = set()
for item in yaml.safe_load(stdout)['items']:
k8s_event = KubernetesEvent.FromDict(item)
if k8s_event:
... | Get the events for the cluster. | _GetEvents | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def _PollForEvents(
self,
queue: multiprocessing.Queue,
stop_polling: synchronize.Event,
):
"""Polls for events & (ideally asynchronously) waits to poll again.
Results are appended to the queue. Timeouts are ignored.
Args:
queue: The queue to append events to.
stop_polling:... | Polls for events & (ideally asynchronously) waits to poll again.
Results are appended to the queue. Timeouts are ignored.
Args:
queue: The queue to append events to.
stop_polling: Stop polling when set.
| _PollForEvents | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def StopPolling(self):
"""Stops polling for events, joining the poller process."""
logging.info('Stopping event poller')
self.stop_polling.set()
while not self.event_queue.empty():
self.polled_events.add(self.event_queue.get())
self.event_poller.join(timeout=30)
if self.event_poller.is_ali... | Stops polling for events, joining the poller process. | StopPolling | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetEvents(self) -> set['KubernetesEvent']:
"""Gets the events for the cluster, including previously polled events."""
k8s_events = self.get_events_fn()
self.polled_events.update(k8s_events)
while not self.event_queue.empty():
self.polled_events.add(self.event_queue.get())
return self.polle... | Gets the events for the cluster, including previously polled events. | GetEvents | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def GetResourceMetadata(self):
"""Returns a dict containing metadata about the cluster."""
result = super().GetResourceMetadata()
if self.created:
result['version'] = self.k8s_version
return result | Returns a dict containing metadata about the cluster. | GetResourceMetadata | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
def DeployContainer(
self, name: str, container_spec: container_spec_lib.ContainerSpec
):
"""Deploys Containers according to the ContainerSpec."""
base_name = name
name = base_name + str(len(self.containers[base_name]))
container = KubernetesContainer(container_spec=container_spec, name=name)
... | Deploys Containers according to the ContainerSpec. | DeployContainer | python | GoogleCloudPlatform/PerfKitBenchmarker | perfkitbenchmarker/container_service.py | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/container_service.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.