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 ExecuteQuery( self, query_name: str, print_results: bool = False ) -> tuple[float, dict[str, Any]]: """Executes a query and returns performance details. Args: query_name: String name of the query to execute print_results: Whether to include query results in execution details. Retur...
Executes a query and returns performance details. Args: query_name: String name of the query to execute print_results: Whether to include query results in execution details. Returns: A tuple of (execution_time, execution details) execution_time: A Float variable set to the query's comp...
ExecuteQuery
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def ExecuteSimultaneous( self, submission_interval: int, queries: List[str] ) -> str: """Executes queries simultaneously on client and return performance details. Simultaneous app expects queries as white space separated query file names. Response format: {"simultaneous_end":1601145943197,"si...
Executes queries simultaneously on client and return performance details. Simultaneous app expects queries as white space separated query file names. Response format: {"simultaneous_end":1601145943197,"simultaneous_start":1601145940113, "stream_performance_array":[{"query_wall_time_in_secs":2.079, ...
ExecuteSimultaneous
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def ExecuteThroughput( self, concurrency_streams: List[List[str]], labels: dict[str, str] | None = None, ) -> str: """Executes a throughput test and returns performance details. Response format: {"throughput_start":1601666911596,"throughput_end":1601666916139, "throughput_wall...
Executes a throughput test and returns performance details. Response format: {"throughput_start":1601666911596,"throughput_end":1601666916139, "throughput_wall_time_in_secs":4.543, "all_streams_performance_array":[ {"stream_start":1601666911597,"stream_end":1601666916139, ...
ExecuteThroughput
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def WarmUpQuery(self): """Executes a service-agnostic query that can detect cold start issues.""" if self.client_vm is None: raise ValueError('SetProvisionedAttributes() not called') with open(SAMPLE_QUERY_PATH, 'w+') as f: f.write(SAMPLE_QUERY) self.client_vm.PushFile(SAMPLE_QUERY_PATH) ...
Executes a service-agnostic query that can detect cold start issues.
WarmUpQuery
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def __init__(self, edw_service_spec): """Initialize the edw service object. Args: edw_service_spec: spec of the edw service. """ # Hand over the actual creation to the resource module, which assumes the # resource is pkb managed by default is_user_managed = self.IsUserManaged(edw_service_...
Initialize the edw service object. Args: edw_service_spec: spec of the edw service.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def GetClusterIdentifier(self, edw_service_spec): """Returns a string name of the Cluster Identifier. Args: edw_service_spec: spec of the edw service. Returns: A string, set to the name of the cluster identifier. """ if self.IsUserManaged(edw_service_spec): return edw_service_spe...
Returns a string name of the Cluster Identifier. Args: edw_service_spec: spec of the edw service. Returns: A string, set to the name of the cluster identifier.
GetClusterIdentifier
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def GetMetadata(self): """Return a dictionary of the metadata for this edw service.""" basic_data = { 'edw_service_type': self.spec.type, 'edw_cluster_identifier': self.cluster_identifier, 'edw_cluster_node_type': self.node_type, 'edw_cluster_node_count': self.node_count, } ...
Return a dictionary of the metadata for this edw service.
GetMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def GenerateLifecycleStageScriptName(self, lifecycle_stage): """Computes the default name for script implementing an edw lifecycle stage. Args: lifecycle_stage: Stage for which the corresponding sql script is desired. Returns: script name for implementing the argument lifecycle_stage. """ ...
Computes the default name for script implementing an edw lifecycle stage. Args: lifecycle_stage: Stage for which the corresponding sql script is desired. Returns: script name for implementing the argument lifecycle_stage.
GenerateLifecycleStageScriptName
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def ExtractDataset( self, dest_bucket, dataset=None, tables=None, dest_format='CSV' ): """Extract all tables in a dataset to object storage. Args: dest_bucket: Name of the bucket to extract the data to. Should already exist. dataset: Optional name of the dataset. If none, will be de...
Extract all tables in a dataset to object storage. Args: dest_bucket: Name of the bucket to extract the data to. Should already exist. dataset: Optional name of the dataset. If none, will be determined by the service. tables: Optional list of table names to extract. If none, all t...
ExtractDataset
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/edw_service.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/edw_service.py
Apache-2.0
def FromDebugInfo(cls, info, error_message): """Create VirtualMachineError class from debug information. Args: info: A dictionary containing debug information (such as traceroute info). error_message: the error message from the originating code. Returns: a cls excep...
Create VirtualMachineError class from debug information. Args: info: A dictionary containing debug information (such as traceroute info). error_message: the error message from the originating code. Returns: a cls exception class Raises: TypeError: if info i...
FromDebugInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/errors.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/errors.py
Apache-2.0
def FormatDebugInfo(info, error_message): """A function to return a string in human readable format. Args: info: A dictionary containing debug information (such as traceroute info). error_message: the error message from the originating code. Returns: A human readabl...
A function to return a string in human readable format. Args: info: A dictionary containing debug information (such as traceroute info). error_message: the error message from the originating code. Returns: A human readable string of debug information.
FormatDebugInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/errors.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/errors.py
Apache-2.0
def GetCurrentUser(): """Get the current user name. On some systems the current user information may be unavailable. In these cases we just need a string to tag the created resources with. It should not be a fatal error. Returns: User name OR default string if user name not available. """ try: r...
Get the current user name. On some systems the current user information may be unavailable. In these cases we just need a string to tag the created resources with. It should not be a fatal error. Returns: User name OR default string if user name not available.
GetCurrentUser
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flags.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flags.py
Apache-2.0
def _GetMultiStringFromList(flag: str, args: str) -> List[str]: """Gets multi string args from a comma-delineated string.""" items = args.strip('=').split(',') return [f'--{flag}={item}' for item in items]
Gets multi string args from a comma-delineated string.
_GetMultiStringFromList
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_alias.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_alias.py
Apache-2.0
def AliasFlagsFromArgs( argv: List[str], alias_dict: List[Dict[str, str]] = ALL_TRANSLATIONS ) -> List[str]: """Alias flags to support backwards compatibility.""" original_to_translation = _FlattenTranslationsDicts(alias_dict) new_argv = [] for arg in argv: result = [arg] for original in original_to...
Alias flags to support backwards compatibility.
AliasFlagsFromArgs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_alias.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_alias.py
Apache-2.0
def _IsNonIncreasing(result, val): """Determines if result would be non-increasing if val is appended. Args: result: list integers and/or range tuples. val: integer or range tuple to append. Returns: bool indicating if the appended list is non-increasing. """ if result: if isinstance(result[...
Determines if result would be non-increasing if val is appended. Args: result: list integers and/or range tuples. val: integer or range tuple to append. Returns: bool indicating if the appended list is non-increasing.
_IsNonIncreasing
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def parse(self, inp): """Parse an integer list. Args: inp: a string, a list, or an IntegerList. Returns: An iterable of integers. Raises: ValueError: if inp doesn't follow a format it recognizes. """ if isinstance(inp, IntegerList): return inp elif isinstance(inp,...
Parse an integer list. Args: inp: a string, a list, or an IntegerList. Returns: An iterable of integers. Raises: ValueError: if inp doesn't follow a format it recognizes.
parse
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def DEFINE_integerlist( name, default, help, on_nonincreasing=None, flag_values=FLAGS, **kwargs ): """Register a flag whose value must be an integer list.""" parser = IntegerListParser(on_nonincreasing=on_nonincreasing) serializer = IntegerListSerializer() flags.DEFINE(parser, name, default, help, flag_va...
Register a flag whose value must be an integer list.
DEFINE_integerlist
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def __init__( self, flag_values, config_dict, alias=flag_alias.ALL_TRANSLATIONS ): """Initializes an OverrideFlags context manager. Args: flag_values: FlagValues that is temporarily modified so that any options in config_dict that are not 'present' in flag_values are applied to fl...
Initializes an OverrideFlags context manager. Args: flag_values: FlagValues that is temporarily modified so that any options in config_dict that are not 'present' in flag_values are applied to flag_values. Upon exit, flag_values will be restored to its original state. config_dic...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def __init__(self, convertible_to): """Initialize the UnitsParser. Args: convertible_to: Either an individual unit specification or a series of unit specifications, where each unit specification is either a string (e.g. 'byte') or a units.Unit. The parser input must be convertible to ...
Initialize the UnitsParser. Args: convertible_to: Either an individual unit specification or a series of unit specifications, where each unit specification is either a string (e.g. 'byte') or a units.Unit. The parser input must be convertible to at least one of the specified Units, or...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def parse(self, inp): """Parse the input. Args: inp: a string or a units.Quantity. If a string, it has the format "<number><units>", as in "12KB", or "2.5GB". Returns: A units.Quantity. Raises: ValueError: If the input cannot be parsed, or if it parses to a value with ...
Parse the input. Args: inp: a string or a units.Quantity. If a string, it has the format "<number><units>", as in "12KB", or "2.5GB". Returns: A units.Quantity. Raises: ValueError: If the input cannot be parsed, or if it parses to a value with improper units.
parse
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def DEFINE_units( name, default, help, convertible_to, flag_values=flags.FLAGS, **kwargs ): """Register a flag whose value is a units expression. Args: name: string. The name of the flag. default: units.Quantity. The default value. help: string. A help message for the user. convertible_to: Eith...
Register a flag whose value is a units expression. Args: name: string. The name of the flag. default: units.Quantity. The default value. help: string. A help message for the user. convertible_to: Either an individual unit specification or a series of unit specifications, where each unit specifi...
DEFINE_units
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def StringToBytes(string): """Convert an object size, represented as a string, to bytes. Args: string: the object size, as a string with a quantity and a unit. Returns: an integer. The number of bytes in the size. Raises: ValueError, if either the string does not represent an object size or i...
Convert an object size, represented as a string, to bytes. Args: string: the object size, as a string with a quantity and a unit. Returns: an integer. The number of bytes in the size. Raises: ValueError, if either the string does not represent an object size or if the size does not contain an i...
StringToBytes
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def StringToRawPercent(string): """Convert a string to a raw percentage value. Args: string: the percentage, with '%' on the end. Returns: A floating-point number, holding the percentage value. Raises: ValueError, if the string can't be read as a percentage. """ if len(string) <= 1: rais...
Convert a string to a raw percentage value. Args: string: the percentage, with '%' on the end. Returns: A floating-point number, holding the percentage value. Raises: ValueError, if the string can't be read as a percentage.
StringToRawPercent
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def parse(self, inp): """Parse the input. Args: inp: A string or the result of yaml.safe_load. If a string, should be a valid YAML document. """ if isinstance(inp, str): # This will work unless the user writes a config with a quoted # string that, if unquoted, would be parsed...
Parse the input. Args: inp: A string or the result of yaml.safe_load. If a string, should be a valid YAML document.
parse
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def DEFINE_yaml(name, default, help, flag_values=flags.FLAGS, **kwargs): """Register a flag whose value is a YAML expression. Args: name: string. The name of the flag. default: object. The default value of the flag. help: string. A help message for the user. flag_values: the absl.flags.FlagValues o...
Register a flag whose value is a YAML expression. Args: name: string. The name of the flag. default: object. The default value of the flag. help: string. A help message for the user. flag_values: the absl.flags.FlagValues object to define the flag in. kwargs: extra arguments to pass to absl.flags...
DEFINE_yaml
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def ParseKeyValuePairs(strings): """Parses colon separated key value pairs from a list of strings. Pairs should be separated by a comma and key and value by a colon, e.g., ['k1:v1', 'k2:v2,k3:v3']. Args: strings: A list of strings. Returns: A dict populated with keys and values from the flag. """...
Parses colon separated key value pairs from a list of strings. Pairs should be separated by a comma and key and value by a colon, e.g., ['k1:v1', 'k2:v2,k3:v3']. Args: strings: A list of strings. Returns: A dict populated with keys and values from the flag.
ParseKeyValuePairs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def GetProvidedCommandLineFlags(): """Return flag names and values that were specified on the command line. Returns: A dictionary of provided flags in the form: {flag_name: flag_value}. """ def _GetSerializeableValue(v): if isinstance(v, enum.Enum): return v.name return v return { k...
Return flag names and values that were specified on the command line. Returns: A dictionary of provided flags in the form: {flag_name: flag_value}.
GetProvidedCommandLineFlags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/flag_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/flag_util.py
Apache-2.0
def CreateMachineFile( vms, num_slots=lambda vm: vm.NumCpusForBenchmark(), remote_path='MACHINEFILE', mpi_vendor='openmpi', ): """Create a file with the IP of each machine in the cluster on its own line. The file is then pushed to the provided path on the master vm. Pass in "num_slots=lambda vm:...
Create a file with the IP of each machine in the cluster on its own line. The file is then pushed to the provided path on the master vm. Pass in "num_slots=lambda vm: 0" to create a machine file without a defined number of slots. OpenMPI's format: "<host> slots=<slots>" https://www.open-mpi.org/faq/?cate...
CreateMachineFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/hpc_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/hpc_util.py
Apache-2.0
def __init__(self, relational_db_spec): """Initialize the IAAS relational database object. Args: relational_db_spec: spec of the managed database. Raises: UnsupportedError: if high availability is requested for an unmanaged db. """ super().__init__(relational_db_spec) self.spec.da...
Initialize the IAAS relational database object. Args: relational_db_spec: spec of the managed database. Raises: UnsupportedError: if high availability is requested for an unmanaged db.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def server_vm(self): """Server VM for hosting a managed database. Raises: RelationalDbPropertyNotSetError: if the server_vm is missing. Returns: The server_vm. """ if not hasattr(self, '_server_vm'): raise relational_db.RelationalDbPropertyNotSetError( 'server_vm is not...
Server VM for hosting a managed database. Raises: RelationalDbPropertyNotSetError: if the server_vm is missing. Returns: The server_vm.
server_vm
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def _SetupUnmanagedDatabase(self): """Installs unmanaged databases on server vm.""" if self.server_vm.OS_TYPE in os_types.WINDOWS_OS_TYPES: self._SetupWindowsUnamangedDatabase() else: self._SetupLinuxUnmanagedDatabase()
Installs unmanaged databases on server vm.
_SetupUnmanagedDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def _SetupWindowsUnamangedDatabase(self): """Installs unmanaged databases on server vm for Windows.""" raise NotImplementedError( f'OS Type is not supported {self.server_vm.OS_TYPE}' )
Installs unmanaged databases on server vm for Windows.
_SetupWindowsUnamangedDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def _SetupLinuxUnmanagedDatabase(self): """Installs unmanaged databases on server vm for Linux.""" self.server_vm_query_tools.InstallPackages() self.server_vm.Install('rsync') if relational_db.OPTIMIZE_DB_SYSCTL_CONFIG.value: if self.client_vm.IS_REBOOTABLE: self.client_vm.ApplySysctlPers...
Installs unmanaged databases on server vm for Linux.
_SetupLinuxUnmanagedDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def GetDefaultEngineVersion(engine): """Returns the default version of a given database engine. Args: engine (string): type of database (my_sql or postgres). Returns: (string): Default version for the given database engine. """ raise NotImplementedError( 'Default engine not spe...
Returns the default version of a given database engine. Args: engine (string): type of database (my_sql or postgres). Returns: (string): Default version for the given database engine.
GetDefaultEngineVersion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/iaas_relational_db.py
Apache-2.0
def LoadModulesForPath(path, package_prefix=None): """Recursively load all modules on 'path', with prefix 'package_prefix'. Example usage: LoadModulesForPath(__path__, __name__) Args: path: Path containing python modules. package_prefix: prefix (e.g., package name) to prefix all modules. 'path' ...
Recursively load all modules on 'path', with prefix 'package_prefix'. Example usage: LoadModulesForPath(__path__, __name__) Args: path: Path containing python modules. package_prefix: prefix (e.g., package name) to prefix all modules. 'path' and 'package_prefix' will be joined with a '.'. Yie...
LoadModulesForPath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/import_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/import_util.py
Apache-2.0
def _GetOptionDecoderConstructions(cls): """Gets decoder classes and constructor args for each configurable option.""" result = super()._GetOptionDecoderConstructions() result.update({ 'cloud': ( option_decoders.EnumDecoder, { # Uncomment when there are other ...
Gets decoder classes and constructor args for each configurable option.
_GetOptionDecoderConstructions
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/key.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/key.py
Apache-2.0
def CreateRenderedManifestFile(filename, config): """Returns a file containing a rendered Jinja manifest (.j2) template.""" manifest_filename = data.ResourcePath(filename) environment = jinja2.Environment(undefined=jinja2.StrictUndefined) with open(manifest_filename) as manifest_file: manifest_template = en...
Returns a file containing a rendered Jinja manifest (.j2) template.
CreateRenderedManifestFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/kubernetes_helper.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/kubernetes_helper.py
Apache-2.0
def ParseRangeList(csv_list: str) -> set[int]: """Parses a comma separated list of numbers and/or ranges into a set of ints. Args: csv_list: The CSV list to parse. Returns: A set of integers. """ if not csv_list: return set() answer: set[int] = set() if ',' in csv_list: items_to_convert...
Parses a comma separated list of numbers and/or ranges into a set of ints. Args: csv_list: The CSV list to parse. Returns: A set of integers.
ParseRangeList
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AddLine(self, full_line: str) -> None: """Parses a line of output from the cpu/vulnerabilities/* files.""" if not full_line: return file_path, line = full_line.split(':', 1) file_name = posixpath.basename(file_path) if self._AddMitigation(file_name, line): return if self._AddVuln...
Parses a line of output from the cpu/vulnerabilities/* files.
AddLine
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def asdict(self) -> Dict[str, str]: """Returns the parsed CPU vulnerabilities as a dict.""" ret = {} if self.mitigations: ret['mitigations'] = ','.join(sorted(self.mitigations)) for key, value in self.mitigations.items(): ret[f'mitigation_{key}'] = value if self.vulnerabilities: ...
Returns the parsed CPU vulnerabilities as a dict.
asdict
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def __init__(self, uname: str): """KernelVersion Constructor. Args: uname: A string in the format of "uname -r" command """ # example format would be: "4.5.0-96-generic" # or "3.10.0-514.26.2.el7.x86_64" for centos # major.minor.Rest # in this example, major = 4, minor = 5 self.n...
KernelVersion Constructor. Args: uname: A string in the format of "uname -r" command
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AtLeast(self, major, minor): """Check If the kernel version meets a minimum bar. The kernel version needs to be at least as high as the major.minor specified in args. Args: major: The major number to test, as an integer minor: The minor number to test, as an integer Returns: ...
Check If the kernel version meets a minimum bar. The kernel version needs to be at least as high as the major.minor specified in args. Args: major: The major number to test, as an integer minor: The minor number to test, as an integer Returns: True if the kernel version is at least ...
AtLeast
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _SetTransparentHugepages(self): """Sets transparent hugepages based on --enable_transparent_hugepages. If the flag is unset (None), this is a nop. """ if FLAGS.enable_transparent_hugepages is None: return setting = 'always' if FLAGS.enable_transparent_hugepages else 'never' self.Remot...
Sets transparent hugepages based on --enable_transparent_hugepages. If the flag is unset (None), this is a nop.
_SetTransparentHugepages
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _DisableCstates(self): """Disable cstates that either match or deeper than the given cstate.""" cstate = _DISABLE_CSTATE_BY_NAME_AND_DEEPER.value if not cstate: return cstates = self._GetOrderedCstates() if not cstates: raise ValueError( 'No cstates found, the system does n...
Disable cstates that either match or deeper than the given cstate.
_DisableCstates
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _GetOrderedCstates(self) -> list[str] | None: """Returns the ordered cstates by querying the sysfs cpuidle path. The ordering is obtained by the alphabetical wildcard expansion. """ query_paths = f'{_SYSFS_CPU_PATH}/cpu0/cpuidle/state*/name' if not self._RemoteFileExists(query_paths): ret...
Returns the ordered cstates by querying the sysfs cpuidle path. The ordering is obtained by the alphabetical wildcard expansion.
_GetOrderedCstates
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _SetupRobustCommand(self): """Sets up the RobustRemoteCommand tooling. This includes installing python3 and pushing scripts required by RobustRemoteCommand to this VM. There is a check to skip if previously installed. """ with self._remote_command_script_upload_lock: if not self._has...
Sets up the RobustRemoteCommand tooling. This includes installing python3 and pushing scripts required by RobustRemoteCommand to this VM. There is a check to skip if previously installed.
_SetupRobustCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.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. This is used for long-running commands that might experience network issues that woul...
Runs a command on the VM in a more robust way than RemoteCommand. This is used for long-running commands that might experience network issues that would normally interrupt a RemoteCommand and fail to provide results. Executes a command via a pair of scripts on the VM: * EXECUTE_COMMAND, which runs 'co...
RobustRemoteCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def SetupRemoteFirewall(self): """Sets up IP table configurations on the VM.""" self.RemoteHostCommand('sudo iptables -A INPUT -j ACCEPT') self.RemoteHostCommand('sudo iptables -A OUTPUT -j ACCEPT')
Sets up IP table configurations on the VM.
SetupRemoteFirewall
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def SetupProxy(self): """Sets up proxy configuration variables for the cloud environment.""" env_file = '/etc/environment' commands = [] if FLAGS.http_proxy: commands.append( "echo 'http_proxy=%s' | sudo tee -a %s" % (FLAGS.http_proxy, env_file) ) if FLAGS.https_proxy: ...
Sets up proxy configuration variables for the cloud environment.
SetupProxy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _DisableCpus(self): """Apply num_disable_cpus to the VM. Raises: ValueError: if num_disable_cpus is outside of (0 ... num_cpus-1) inclusive """ if not FLAGS.num_disable_cpus: return self.num_disable_cpus = FLAGS.num_disable_cpus if self.num_disable_cpus <= 0 ...
Apply num_disable_cpus to the VM. Raises: ValueError: if num_disable_cpus is outside of (0 ... num_cpus-1) inclusive
_DisableCpus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _GetNextCPUToDisable(num_disable_cpus): """Get the next CPU id to disable.""" numa_nodes = list(cpu_mapping) while num_disable_cpus: for numa in sorted(numa_nodes, reverse=True): cpu_id, _ = cpu_mapping[numa].pop() num_disable_cpus -= 1 yield cpu_id ...
Get the next CPU id to disable.
_GetNextCPUToDisable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def FillDisk(self): """Fills the primary scratch disk with a zeros file.""" if FLAGS.disk_fill_size: out_file = posixpath.join(self.scratch_disks[0].mount_point, 'fill_file') self.RobustRemoteCommand( 'dd if=/dev/zero of={out_file} bs=1G count={fill_size}'.format( out_file=ou...
Fills the primary scratch disk with a zeros file.
FillDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _ApplySysctlPersistent(self, sysctl_params): """Apply "key=value" pairs to /etc/sysctl.conf and load via sysctl -p. These values should remain persistent across future reboots. Args: sysctl_params: dict - the keys and values to write """ if not sysctl_params: return for key, v...
Apply "key=value" pairs to /etc/sysctl.conf and load via sysctl -p. These values should remain persistent across future reboots. Args: sysctl_params: dict - the keys and values to write
_ApplySysctlPersistent
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def ApplySysctlPersistent(self, sysctl_params, should_reboot=False): """Apply "key=value" pairs to /etc/sysctl.conf and load via sysctl -p. These values should remain persistent across future reboots. Args: sysctl_params: dict - the keys and values to write should_reboot: bool - whether to reb...
Apply "key=value" pairs to /etc/sysctl.conf and load via sysctl -p. These values should remain persistent across future reboots. Args: sysctl_params: dict - the keys and values to write should_reboot: bool - whether to reboot after applying sysctl changes
ApplySysctlPersistent
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def DoSysctls(self): """Apply --sysctl to the VM. The Sysctl pairs are written persistently so that if a reboot occurs, the flags are not lost. """ sysctl_params = {} for pair in FLAGS.sysctl: key, value = pair.split('=') sysctl_params[key] = value self._ApplySysctlPersistent(sy...
Apply --sysctl to the VM. The Sysctl pairs are written persistently so that if a reboot occurs, the flags are not lost.
DoSysctls
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def DoConfigureTCPWindow(self): """Change TCP window parameters in sysctl.""" possible_tcp_flags = [ FLAGS.tcp_max_receive_buffer, FLAGS.tcp_max_send_buffer, _TCP_MAX_NOTSENT_BYTES.value, FLAGS.rmem_max, FLAGS.wmem_max, ] # Return if none of these flags are set ...
Change TCP window parameters in sysctl.
DoConfigureTCPWindow
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _RebootIfNecessary(self): """Will reboot the VM if self._needs_reboot has been set.""" if self._needs_reboot: self.Reboot() self._needs_reboot = False
Will reboot the VM if self._needs_reboot has been set.
_RebootIfNecessary
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def TcpCongestionControl(self): """Return the congestion control used for tcp.""" try: resp, _ = self.RemoteCommand( 'cat /proc/sys/net/ipv4/tcp_congestion_control' ) return resp.rstrip('\n') except errors.VirtualMachine.RemoteCommandError: return 'unknown'
Return the congestion control used for tcp.
TcpCongestionControl
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetCPUVersion(self): """Get the CPU version of the VM. Refer to flag definition '--required_cpu_version' in virtual_machine.py for more details. Returns: guest_arch: str. """ proccpu_results = self.CheckProcCpu(check_cache=False).GetValues() if 'vendor_id' in proccpu_results: ...
Get the CPU version of the VM. Refer to flag definition '--required_cpu_version' in virtual_machine.py for more details. Returns: guest_arch: str.
GetCPUVersion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def CheckLsCpu(self): """Returns a LsCpuResults from the host VM.""" if not self._lscpu_cache: lscpu, _ = self.RemoteCommand('lscpu') self._lscpu_cache = LsCpuResults(lscpu) return self._lscpu_cache
Returns a LsCpuResults from the host VM.
CheckLsCpu
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def CheckProcCpu(self, check_cache=True): """Returns a ProcCpuResults from the host VM.""" if not self._proccpu_cache or not check_cache: proccpu, _ = self.RemoteCommand('cat /proc/cpuinfo') self._proccpu_cache = ProcCpuResults(proccpu) return self._proccpu_cache
Returns a ProcCpuResults from the host VM.
CheckProcCpu
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetOsInfo(self) -> str: """Returns information regarding OS type and version.""" stdout, _ = self.RemoteCommand('grep PRETTY_NAME /etc/os-release') return regex_util.ExtractGroup(OS_PRETTY_NAME_REGEXP, stdout)
Returns information regarding OS type and version.
GetOsInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def cpu_arch(self) -> str: """Returns the CPU architecture of the VM.""" if not self._cpu_arch: self._cpu_arch = self.RemoteCommand('uname -m')[0].strip() return self._cpu_arch
Returns the CPU architecture of the VM.
cpu_arch
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def WaitForBootCompletion(self): """Waits until the VM has booted.""" # Test for listening on the port first, because this will happen strictly # first. if ( FLAGS.cluster_boot_test_port_listening and self.port_listening_time is None ): self.TestConnectRemoteAccessPort() ...
Waits until the VM has booted.
WaitForBootCompletion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _WaitForSSH(self, ip_address: Union[str, None] = None): """Waits until the VM is ready.""" # Always wait for remote host command to succeed, because it is necessary to # run benchmarks resp, _ = self.RemoteHostCommand( 'hostname', retries=1, ip_address=ip_address ) if self.hostname i...
Waits until the VM is ready.
_WaitForSSH
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RecordAdditionalMetadata(self): """After the VM has been prepared, store metadata about the VM.""" super().RecordAdditionalMetadata() if not self.bootable_time: logging.warning( 'RecordAdditionalMetadata: skipping additional metadata' ' capture due to an unreachable VM.' ...
After the VM has been prepared, store metadata about the VM.
RecordAdditionalMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _get_network_device_mtus(self) -> Dict[str, str]: """Returns network device names and their MTUs.""" if not self._network_device_mtus: stdout, _ = self.RemoteCommand('PATH="${PATH}":/usr/sbin ip link show up') self._network_device_mtus = {} for line in stdout.splitlines(): m = self...
Returns network device names and their MTUs.
_get_network_device_mtus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def VMLastBootTime(self): """Returns the time the VM was last rebooted as reported by the VM. See https://unix.stackexchange.com/questions/165002/how-to-reliably-get-timestamp-at-which-the-system-booted. """ stdout, _ = self.RemoteHostCommand('stat -c %z /proc/', retries=1) if stdout.startswith...
Returns the time the VM was last rebooted as reported by the VM. See https://unix.stackexchange.com/questions/165002/how-to-reliably-get-timestamp-at-which-the-system-booted.
VMLastBootTime
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def PackageCleanup(self): """Cleans up all installed packages. Deletes the temp directory, restores packages, and uninstalls all PerfKit packages. """ for package_name in self._installed_packages: self.Uninstall(package_name) self.RestorePackages() self.RemoteCommand('sudo rm -rf %s' ...
Cleans up all installed packages. Deletes the temp directory, restores packages, and uninstalls all PerfKit packages.
PackageCleanup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def IsMounted(self, mount_point: str, dev_path: str): """Returns whether the given mount point is mounted.""" # GCP disk uses a symlink for the device path, so we need to translate it # to the actual device path. For other cloud providers, the device path # should already be the actual device path and r...
Returns whether the given mount point is mounted.
IsMounted
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def FormatDisk(self, device_path, disk_type=None): """Formats a disk attached to the VM.""" # Some images may automount one local disk, but we don't # want to fail if this wasn't the case. if disk.NFS == disk_type: return if disk.SMB == disk_type: return umount_cmd = '[[ -d /mnt ]] &...
Formats a disk attached to the VM.
FormatDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def MountDisk( self, device_path, mount_path, disk_type=None, mount_options=disk.DEFAULT_MOUNT_OPTIONS, fstab_options=disk.DEFAULT_FSTAB_OPTIONS, ): """Mounts a formatted disk in the VM.""" mount_options = '-o %s' % mount_options if mount_options else '' if disk.NFS == ...
Mounts a formatted disk in the VM.
MountDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def LogVmDebugInfo(self): """Logs the output of calling dmesg on the VM.""" if FLAGS.log_dmesg: self.RemoteCommand('hostname && sudo dmesg')
Logs the output of calling dmesg on the VM.
LogVmDebugInfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteHostCopy(self, file_path, remote_path='', copy_to=True): """Copies a file to or from the VM. Args: file_path: Local path to file. remote_path: Optional path of where to copy file on remote host. copy_to: True to copy to vm, False to copy from vm. Raises: RemoteCommandErro...
Copies a file to or from the VM. Args: file_path: Local path to file. remote_path: Optional path of where to copy file on remote host. copy_to: True to copy to vm, False to copy from vm. Raises: RemoteCommandError: If there was a problem copying the file.
RemoteHostCopy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteCommand(self, *args, **kwargs) -> Tuple[str, str]: """Runs a command on the VM. Args: *args: Arguments passed directly to RemoteCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteCommandWithReturnCode. Returns: A tuple of stdout, stderr from run...
Runs a command on the VM. Args: *args: Arguments passed directly to RemoteCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteCommandWithReturnCode. Returns: A tuple of stdout, stderr from running the command. Raises: RemoteCommandError: If there wa...
RemoteCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteCommandWithReturnCode( self, *args, **kwargs ) -> Tuple[str, str, int]: """Runs a command on the VM. Args: *args: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteHostCommandWithReturnCode. Returns: ...
Runs a command on the VM. Args: *args: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteHostCommandWithReturnCode. Returns: A tuple of stdout, stderr, return_code from running the command. Raises: RemoteComm...
RemoteCommandWithReturnCode
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteHostCommandWithReturnCode( self, command: str, retries: int | None = None, ignore_failure: bool = False, login_shell: bool = False, disable_tty_lock: bool = False, timeout: float | None = None, ip_address: str | None = None, should_pre_log: bool = True, ...
Runs a command on the VM. This is guaranteed to run on the host VM, whereas RemoteCommand might run within i.e. a container in the host VM. Args: command: A valid bash command. retries: The maximum number of times RemoteCommand should retry SSHing when it receives a 255 return code. If...
RemoteHostCommandWithReturnCode
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def RemoteHostCommand(self, *args, **kwargs) -> Tuple[str, str]: """Runs a command on the VM. This is guaranteed to run on the host VM, whereas RemoteCommand might run within i.e. a container in the host VM. Args: *args: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwarg...
Runs a command on the VM. This is guaranteed to run on the host VM, whereas RemoteCommand might run within i.e. a container in the host VM. Args: *args: Arguments passed directly to RemoteHostCommandWithReturnCode. **kwargs: Keyword arguments passed directly to RemoteHostCommandWithRet...
RemoteHostCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _Reboot(self): """OS-specific implementation of reboot command.""" self._CheckRebootability() self.RemoteCommand('sudo reboot', ignore_failure=True)
OS-specific implementation of reboot command.
_Reboot
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _AfterReboot(self): """Performs any OS-specific setup on the VM following reboot. This will be called after every call to Reboot(). """ # redetect os metadata as it might have changed self._os_info = None self._kernel_release = None self._kernel_command_line = None self._lscpu_cache...
Performs any OS-specific setup on the VM following reboot. This will be called after every call to Reboot().
_AfterReboot
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def MoveHostFile(self, target, source_path, remote_path=''): """Copies a file from one VM to a target VM. Args: target: The target BaseVirtualMachine object. source_path: The location of the file on the REMOTE machine. remote_path: The destination of the file on the TARGET machine, default is...
Copies a file from one VM to a target VM. Args: target: The target BaseVirtualMachine object. source_path: The location of the file on the REMOTE machine. remote_path: The destination of the file on the TARGET machine, default is the home directory.
MoveHostFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AuthenticateVm(self): """Authenticate a remote machine to access all peers.""" if not self.has_private_key: if not self.is_static: self.RemoteHostCopy(vm_util.GetPrivateKeyPath(), REMOTE_KEY_PATH) elif self.ssh_private_key and FLAGS.copy_ssh_private_keys_into_static_vms: logging....
Authenticate a remote machine to access all peers.
AuthenticateVm
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def TestAuthentication(self, peer): """Tests whether the VM can access its peer. Raises: AuthError: If the VM cannot access its peer. """ if not self.TryRemoteCommand('ssh %s hostname' % peer.internal_ip): raise errors.VirtualMachine.AuthError( 'Authentication check failed. If you...
Tests whether the VM can access its peer. Raises: AuthError: If the VM cannot access its peer.
TestAuthentication
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def CheckJavaVersion(self): """Check the version of java on remote machine. Returns: The version of Java installed on remote machine. """ version, _ = self.RemoteCommand( "java -version 2>&1 >/dev/null | grep version | awk '{print $3}'" ) return version[:-1]
Check the version of java on remote machine. Returns: The version of Java installed on remote machine.
CheckJavaVersion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetDeviceSizeFromPath(self, path): """Gets the size of the a drive that contains the path specified. Args: path: The function will return the amount of space on the file system that contains this file name. Returns: The size in 1K blocks of the file system containing the file. ...
Gets the size of the a drive that contains the path specified. Args: path: The function will return the amount of space on the file system that contains this file name. Returns: The size in 1K blocks of the file system containing the file.
GetDeviceSizeFromPath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _RemoteFileExists(self, file_path: str) -> bool: """Returns true if the file exists on the VM.""" stdout, _ = self.RemoteCommand( f'ls {file_path} >> /dev/null 2>&1 || echo file_not_exist' ) return not stdout
Returns true if the file exists on the VM.
_RemoteFileExists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetCpusAllowedSet(self) -> set[int]: r"""Returns the list of CPUs allowed for the current process. Processes the output of the following files in order: 1. /sys/fs/cgroup/cpuset.cpus.effective 2. /proc/self/status 3. /proc/cpuinfo Below are the example of their returns: $ cat XX/cpuset...
Returns the list of CPUs allowed for the current process. Processes the output of the following files in order: 1. /sys/fs/cgroup/cpuset.cpus.effective 2. /proc/self/status 3. /proc/cpuinfo Below are the example of their returns: $ cat XX/cpuset.cpus.effective : 0-23 $ cat /proc/...
GetCpusAllowedSet
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _GetNumCpus(self): """Returns the number of logical CPUs on the VM. If the flag `use_numcpu_multi_files` is true, call GetCpusAllowedSet function to help calculate the number of CPUs. Otherwise, extracts the value from `/proc/cpuinfo` file. This method does not cache results (unlike "num_cpus")...
Returns the number of logical CPUs on the VM. If the flag `use_numcpu_multi_files` is true, call GetCpusAllowedSet function to help calculate the number of CPUs. Otherwise, extracts the value from `/proc/cpuinfo` file. This method does not cache results (unlike "num_cpus").
_GetNumCpus
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _GetTotalFreeMemoryKb(self): """Calculate amount of free memory in KB of the given vm. Free memory is calculated as sum of free, cached, and buffers as output from /proc/meminfo. Returns: free memory on the vm in KB """ stdout, _ = self.RemoteCommand(""" awk ' BEGIN ...
Calculate amount of free memory in KB of the given vm. Free memory is calculated as sum of free, cached, and buffers as output from /proc/meminfo. Returns: free memory on the vm in KB
_GetTotalFreeMemoryKb
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def SetupLocalDisks(self): """Performs Linux specific setup of local disks.""" local_disks = [] for d in self.scratch_disks: if d.disk_type == disk.LOCAL and d.IsNvme(): if isinstance(d, disk.StripedDisk): local_disks += d.disks else: local_disks.append(d) if _E...
Performs Linux specific setup of local disks.
SetupLocalDisks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def hasStripedDiskDevice(self, dev_name: str) -> bool: """Checks if the striped disk device exists or not. Args: dev_name: The name of the device. Returns: True if the striped disk device exists. """ # Suppress the error as it's not a blocker to the test if the command fails. # The...
Checks if the striped disk device exists or not. Args: dev_name: The name of the device. Returns: True if the striped disk device exists.
hasStripedDiskDevice
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def StripeDisks(self, devices, striped_device): """Raids disks together using mdadm. Args: devices: A list of device paths that should be striped together. striped_device: The path to the device that will be created. """ self.Install('mdadm') stripe_cmd = ( 'yes | sudo mdadm --c...
Raids disks together using mdadm. Args: devices: A list of device paths that should be striped together. striped_device: The path to the device that will be created.
StripeDisks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def IsDiskFormatted(self, dev_name, num_partitions): """Checks if the disk is formatted. Args: dev_name: The name of the device. num_partitions: The number of new partitions to create. Returns: True if the disk is already formatted with given number of partitions. """ # Check how...
Checks if the disk is formatted. Args: dev_name: The name of the device. num_partitions: The number of new partitions to create. Returns: True if the disk is already formatted with given number of partitions.
IsDiskFormatted
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def PartitionDisk(self, dev_name, dev_path, num_partitions, partition_size): """Partitions the disk into smaller pieces. Args: dev_name: The name of the device. dev_path: The device path that should be partitioned. num_partitions: The number of new partitions to create. partition_size: ...
Partitions the disk into smaller pieces. Args: dev_name: The name of the device. dev_path: The device path that should be partitioned. num_partitions: The number of new partitions to create. partition_size: The size of each partition. The last partition will use the rest of the devi...
PartitionDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def BurnCpu(self, burn_cpu_threads=None, burn_cpu_seconds=None): """Burns vm cpu for some amount of time and dirty cache. Args: burn_cpu_threads: Number of threads to burn cpu. burn_cpu_seconds: Amount of time in seconds to burn cpu. """ burn_cpu_threads = burn_cpu_threads or FLAGS.burn_cpu...
Burns vm cpu for some amount of time and dirty cache. Args: burn_cpu_threads: Number of threads to burn cpu. burn_cpu_seconds: Amount of time in seconds to burn cpu.
BurnCpu
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def SetReadAhead(self, num_sectors, devices): """Set read-ahead value for block devices. Args: num_sectors: int. Number of sectors of read ahead. devices: list of strings. A list of block devices. """ self.RemoteCommand( 'sudo blockdev --setra {0} {1}; sudo blockdev --setfra {0} {1}...
Set read-ahead value for block devices. Args: num_sectors: int. Number of sectors of read ahead. devices: list of strings. A list of block devices.
SetReadAhead
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def GetSha256sum(self, path, filename): """Gets the sha256sum hash for a filename in a path on the VM. Args: path: string; Path on the VM. filename: string; Name of the file in the path. Returns: string; The sha256sum hash. """ stdout, _ = self.RemoteCommand( 'sha256sum %...
Gets the sha256sum hash for a filename in a path on the VM. Args: path: string; Path on the VM. filename: string; Name of the file in the path. Returns: string; The sha256sum hash.
GetSha256sum
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def AppendKernelCommandLine(self, command_line, reboot=True): """Appends the provided command-line to the VM and reboots by default. This method should be overwritten by the desired Linux flavor to be useful. Most (all?) Linux flavors modify the kernel command line by updating the GRUB configuration fi...
Appends the provided command-line to the VM and reboots by default. This method should be overwritten by the desired Linux flavor to be useful. Most (all?) Linux flavors modify the kernel command line by updating the GRUB configuration files and rebooting. Args: command_line: The string to appen...
AppendKernelCommandLine
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def _DoAppendKernelCommandLine(self): """If the flag is set, attempts to append the provided kernel command line. In addition, to consolidate reboots during VM prepare, this method sets the needs reboot bit instead of immediately rebooting. """ if FLAGS.disable_smt and self.CheckLsCpu().threads_per...
If the flag is set, attempts to append the provided kernel command line. In addition, to consolidate reboots during VM prepare, this method sets the needs reboot bit instead of immediately rebooting.
_DoAppendKernelCommandLine
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0
def ModifyKernelModules(self): """Add or remove kernel modules based on flags.""" for module in _KERNEL_MODULES_TO_ADD.value: self.RemoteCommand(f'sudo modprobe {module}') for module in _KERNEL_MODULES_TO_REMOVE.value: self.RemoteCommand(f'sudo modprobe -r {module}')
Add or remove kernel modules based on flags.
ModifyKernelModules
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/linux_virtual_machine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/linux_virtual_machine.py
Apache-2.0