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 GetMemoryStorePassword(self) -> str: """Returns the access password of the managed memory store, if any.""" if not self._password: self._password = self._GetDatabase()['security']['password'] logging.info('Database password: %s', self._password) return self._password
Returns the access password of the managed memory store, if any.
GetMemoryStorePassword
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_redis_enterprise.py
Apache-2.0
def _ValidateSpec(self): """Validates PostgreSQL spec for CPU and memory. Raises: data.ResourceNotFound: On missing memory or cpus in postgres benchmark config. """ if not hasattr(self.spec.db_spec, 'cpus') or not self.spec.db_spec.cpus: raise data.ResourceNotFound( 'Must ...
Validates PostgreSQL spec for CPU and memory. Raises: data.ResourceNotFound: On missing memory or cpus in postgres benchmark config.
_ValidateSpec
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_relational_db.py
Apache-2.0
def _ValidateMachineType(self, memory, cpus): """Validates the custom machine type configuration. Memory and CPU must be within the parameters described here: https://cloud.google.com/sql/docs/postgres/instance-settings Args: memory: (int) in MiB cpus: (int) Raises: ValueError o...
Validates the custom machine type configuration. Memory and CPU must be within the parameters described here: https://cloud.google.com/sql/docs/postgres/instance-settings Args: memory: (int) in MiB cpus: (int) Raises: ValueError on invalid configuration.
_ValidateMachineType
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_relational_db.py
Apache-2.0
def _IsReady(self, timeout=IS_READY_TIMEOUT): """Return true if the underlying resource is ready. Supplying this method is optional. Use it when a resource can exist without being ready. If the subclass does not implement it then it just returns true. Args: timeout: how long to wait when c...
Return true if the underlying resource is ready. Supplying this method is optional. Use it when a resource can exist without being ready. If the subclass does not implement it then it just returns true. Args: timeout: how long to wait when checking if the DB is ready. Returns: True ...
_IsReady
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_relational_db.py
Apache-2.0
def _ParseEndpoint(self, describe_instance_json): """Returns the IP of the resource given the metadata as JSON. Args: describe_instance_json: JSON output. Returns: public IP address (string) """ if describe_instance_json is None: return '' try: selflink = describe_insta...
Returns the IP of the resource given the metadata as JSON. Args: describe_instance_json: JSON output. Returns: public IP address (string)
_ParseEndpoint
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_relational_db.py
Apache-2.0
def _GetEngineVersionString(engine, version): """Returns CloudSQL-specific version string for givin database engine. Args: engine: database engine version: engine version Returns: (string): CloudSQL-specific name for requested engine and version. Raises: NotImplementedError on...
Returns CloudSQL-specific version string for givin database engine. Args: engine: database engine version: engine version Returns: (string): CloudSQL-specific name for requested engine and version. Raises: NotImplementedError on invalid engine / version combination.
_GetEngineVersionString
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_relational_db.py
Apache-2.0
def _Create(self) -> None: """Creates the instance, the database, and update the schema.""" cmd = util.GcloudCommand( self, 'spanner', 'instances', 'create', self.instance_id ) cmd.flags['description'] = self._description cmd.flags['config'] = self._config if self.spec.db_tier: cm...
Creates the instance, the database, and update the schema.
_Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def CreateTables(self, ddl: str) -> None: """Creates the tables specified by the DDL. If the table already exists, this is a no-op. Args: ddl: The DDL statement used to create the table schema. Raises: errors.Benchmarks.RunError if updating the DDL fails. """ cmd = util.GcloudComm...
Creates the tables specified by the DDL. If the table already exists, this is a no-op. Args: ddl: The DDL statement used to create the table schema. Raises: errors.Benchmarks.RunError if updating the DDL fails.
CreateTables
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def _Exists(self, instance_only: bool = False) -> bool: """Returns true if the instance and the database exists.""" _, retcode = self._DescribeInstance(raise_on_failure=False) if retcode != 0: logging.info('Could not find GCP Spanner instance %s.', self.instance_id) return False if instance...
Returns true if the instance and the database exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def GetApiEndPoint(self) -> str: """Returns the API endpoint override for Cloud Spanner.""" if self._api_endpoint: return self._api_endpoint cmd = util.GcloudCommand( self, 'config', 'get-value', 'api_endpoint_overrides/spanner' ) stdout, _, retcode = cmd.Issue(raise_on_failure=False)...
Returns the API endpoint override for Cloud Spanner.
GetApiEndPoint
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def _WaitUntilInstanceReady(self) -> None: """Waits until the instance is ready.""" # TODO(user): Refactor Spanner instance to use this method in Create while True: instance, _ = self._DescribeInstance() if json.loads(instance)['state'] == 'READY': break
Waits until the instance is ready.
_WaitUntilInstanceReady
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def _SetNodes(self, nodes: int) -> None: """Sets the number of nodes on the Spanner instance.""" # Not yet supported for user managed instances since instance attributes # are not discovered. if self.user_managed: return # Cannot set nodes with autoscaler. if self._autoscaler: retur...
Sets the number of nodes on the Spanner instance.
_SetNodes
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def _DescribeInstance(self, raise_on_failure=True) -> tuple[str, int]: """Returns `spanner instances describe` output for this instance.""" cmd = util.GcloudCommand( self, 'spanner', 'instances', 'describe', self.instance_id ) stdout, _, retcode = cmd.Issue(raise_on_failure=raise_on_failure) ...
Returns `spanner instances describe` output for this instance.
_DescribeInstance
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def GetResourceMetadata(self) -> Dict[Any, Any]: """Returns useful metadata about the instance.""" metadata = { 'gcp_spanner_name': self.instance_id, 'gcp_spanner_database': self.database, 'gcp_spanner_database_dialect': self.dialect, 'gcp_spanner_config': self._config, '...
Returns useful metadata about the instance.
GetResourceMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def GetAverageCpuUsage( self, duration_minutes: int, end_time: datetime.datetime ) -> float: """Gets the average high priority CPU usage through the time duration. Note that there is a delay for the API to get data, so this returns the average CPU usage in the period ending at `end_time` with missi...
Gets the average high priority CPU usage through the time duration. Note that there is a delay for the API to get data, so this returns the average CPU usage in the period ending at `end_time` with missing data in the last CPU_API_DELAY_SECONDS. Args: duration_minutes: The time duration for whic...
GetAverageCpuUsage
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_spanner.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_spanner.py
Apache-2.0
def _Exists(self): """Returns true if the cloud TPU exists.""" _, retcode = self._GetTpuDescription() return retcode == 0
Returns true if the cloud TPU exists.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_tpu.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_tpu.py
Apache-2.0
def GetMasterGrpcAddress(self): """Gets the grpc address of the 0th NetworkEndpoint.""" master_network_endpoint = self._GetTpuDescription()[0]['networkEndpoints'][ 0 ] return 'grpc://{ip_address}:{port}'.format( ip_address=master_network_endpoint['ipAddress'], port=master_networ...
Gets the grpc address of the 0th NetworkEndpoint.
GetMasterGrpcAddress
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_tpu.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_tpu.py
Apache-2.0
def GetNumShards(self): """Gets the number of TPU shards.""" num_tpus = len(self._GetTpuDescription()[0]['networkEndpoints']) return num_tpus * FLAGS.tpu_cores_per_donut
Gets the number of TPU shards.
GetNumShards
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_tpu.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_tpu.py
Apache-2.0
def GetResourceMetadata(self): """Returns the metadata associated with the resource. All keys will be prefaced with tpu before being published (done in publisher.py). Returns: metadata: dict of GCP cloud TPU metadata. """ metadata = super().GetResourceMetadata() metadata.update({'pro...
Returns the metadata associated with the resource. All keys will be prefaced with tpu before being published (done in publisher.py). Returns: metadata: dict of GCP cloud TPU metadata.
GetResourceMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcp_tpu.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcp_tpu.py
Apache-2.0
def MakeBucket(self, bucket_name, raise_on_failure=True, tag_bucket=True): """Creates a GCS bucket. Args: bucket_name: The name of the bucket to create, without gs:// prefix. raise_on_failure: If False, exceptions are swallowed. tag_bucket: If True, tag the bucket with default tags. """ ...
Creates a GCS bucket. Args: bucket_name: The name of the bucket to create, without gs:// prefix. raise_on_failure: If False, exceptions are swallowed. tag_bucket: If True, tag the bucket with default tags.
MakeBucket
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def Copy(self, src_url, dst_url, recursive=False, timeout=None): """See base class. Args: src_url: The source url to copy from. Both url parameters need a schema prefix, e.g. gs://, local, or other. dst_url: The destination url to copy to. recursive: If True, copy the directory recurs...
See base class. Args: src_url: The source url to copy from. Both url parameters need a schema prefix, e.g. gs://, local, or other. dst_url: The destination url to copy to. recursive: If True, copy the directory recursively. timeout: The timeout for the copy command.
Copy
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def CopyToBucket(self, src_path, bucket_name, object_path): """See base class. Args: src_path: The source path to copy from. Needs a schema prefix, e.g. gs://, local, or other. bucket_name: GCS bucket, without gs://. object_path: Path within the bucket to the object. """ dst_u...
See base class. Args: src_path: The source path to copy from. Needs a schema prefix, e.g. gs://, local, or other. bucket_name: GCS bucket, without gs://. object_path: Path within the bucket to the object.
CopyToBucket
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def MakeRemoteCliDownloadUrl(self, bucket_name, object_path): """See base class. Args: bucket_name: GCS bucket, without gs://. object_path: Path within the bucket to the object. Returns: The full gs:// URL. """ path = posixpath.join(bucket_name, object_path) return 'gs://' + ...
See base class. Args: bucket_name: GCS bucket, without gs://. object_path: Path within the bucket to the object. Returns: The full gs:// URL.
MakeRemoteCliDownloadUrl
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def ListTopLevelSubfolders(self, bucket_name): """Lists the top level folders (not files) in a bucket_name. Each folder is returned as its full uri, eg. "gs://pkbtpch1/customer/", so just the folder name is extracted. When there's more than one, splitting on the newline returns a final blank row, so bl...
Lists the top level folders (not files) in a bucket_name. Each folder is returned as its full uri, eg. "gs://pkbtpch1/customer/", so just the folder name is extracted. When there's more than one, splitting on the newline returns a final blank row, so blank values are skipped. Args: bucket_name: ...
ListTopLevelSubfolders
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def AclBucket(self, entity: str, roles: TList[str], bucket_name: str): """Updates access control lists. Args: entity: the user or group to grant permission. roles: the IAM roles to be granted. bucket_name: the name of the bucket to change """ vm_util.IssueCommand([ 'gsutil', ...
Updates access control lists. Args: entity: the user or group to grant permission. roles: the IAM roles to be granted. bucket_name: the name of the bucket to change
AclBucket
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def AcquireWritePermissionsWindows(cls, vm): """Prepare boto file on a remote Windows instance. If the boto file specifies a service key file, copy that service key file to the VM and modify the .boto file on the VM to point to the copied file. Args: vm: gce virtual machine object. """ i...
Prepare boto file on a remote Windows instance. If the boto file specifies a service key file, copy that service key file to the VM and modify the .boto file on the VM to point to the copied file. Args: vm: gce virtual machine object.
AcquireWritePermissionsWindows
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def AcquireWritePermissionsLinux(cls, vm): """Prepare boto file on a remote Linux instance. If the boto file specifies a service key file, copy that service key file to the VM and modify the .boto file on the VM to point to the copied file. Args: vm: gce virtual machine object. """ if GC...
Prepare boto file on a remote Linux instance. If the boto file specifies a service key file, copy that service key file to the VM and modify the .boto file on the VM to point to the copied file. Args: vm: gce virtual machine object.
AcquireWritePermissionsLinux
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def _PrepareGcsServiceKey( cls, vm, boto_src, service_key_src, service_key_des ): """Copy GS service key file to remote VM and update key path in boto file. Args: vm: gce virtual machine object. boto_src: string, the boto file path in local machine. service_key_src: string, the gs ser...
Copy GS service key file to remote VM and update key path in boto file. Args: vm: gce virtual machine object. boto_src: string, the boto file path in local machine. service_key_src: string, the gs service key file in local machine. service_key_des: string, the gs service key file in remote ...
_PrepareGcsServiceKey
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/gcs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/gcs.py
Apache-2.0
def GetMonitoringLink(self): """Returns link to internal Cloud Run Jobsmonitoring page.""" utc_end = int(time.time()) + _TWO_HOURS - 5 * 60 return ( 'https://monitoring.corp.google.com/dashboard/run/jobs%2Finstances?' f'scope=cloud_project_number%3D{self.project_number}&' f'duratio...
Returns link to internal Cloud Run Jobsmonitoring page.
GetMonitoringLink
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_cloud_run_jobs.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_cloud_run_jobs.py
Apache-2.0
def _RunClusterCreateCommand(self, cmd: util.GcloudCommand): """Adds flags to the cluster create command and runs it.""" # All combinations of cluster-version and release-channel are supported. # Specifying one uses default for the other. Specifying both can be needed # as some versions are only support...
Adds flags to the cluster create command and runs it.
_RunClusterCreateCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def _IssueResourceCreationCommand(self, cmd: util.GcloudCommand): """Issues a command to gcloud to create resources.""" # This command needs a long timeout due to the many minutes it # can take to provision a large GPU-accelerated GKE cluster. _, stderr, retcode = cmd.Issue(timeout=ONE_HOUR, raise_on_f...
Issues a command to gcloud to create resources.
_IssueResourceCreationCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def _Exists(self): """Returns True if the cluster exits.""" cmd = self._GcloudCommand('container', 'clusters', 'describe', self.name) _, _, retcode = cmd.Issue(raise_on_failure=False) return retcode == 0
Returns True if the cluster exits.
_Exists
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def GetDefaultStorageClass(self) -> str: """Gets the default storage class for the provider.""" # https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/gce-pd-csi-driver # PD-SSD return 'premium-rwo'
Gets the default storage class for the provider.
GetDefaultStorageClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def GetNodePoolNames(self) -> list[str]: """Get node pool names for the cluster.""" # Command `gcloud container node-pools list` does not work for Autopilot # clusters - node pools are hidden and command results in 4xx. cmd = self._GcloudCommand('container', 'clusters', 'describe', self.name) cmd.fl...
Get node pool names for the cluster.
GetNodePoolNames
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def _CreateNodePools(self): """Creates additional nodepools for the cluster, if applicable.""" for name, nodepool in self.nodepools.items(): cmd = self._GcloudCommand( 'container', 'node-pools', 'create', name, '--cluster', self.name ) self._AddNodeParamsToCmd( nodepool, ...
Creates additional nodepools for the cluster, if applicable.
_CreateNodePools
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def _AddNodeParamsToCmd( self, nodepool_config: container_service.BaseNodePoolConfig, cmd: util.GcloudCommand, ): """Modifies cmd to include node specific command arguments.""" # Apply labels to all nodepools. cmd.flags['labels'] = util.MakeFormattedDefaultTags() # Allow a long timeo...
Modifies cmd to include node specific command arguments.
_AddNodeParamsToCmd
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def LabelDisks(self): """Sets common labels on PVCs. GKE does this in the background every hour. Do it immediately in case the cluster is deleted within that hour. https://cloud.google.com/kubernetes-engine/docs/how-to/creating-managing-labels#label_propagation """ pvcs = self._GetPvcs() fo...
Sets common labels on PVCs. GKE does this in the background every hour. Do it immediately in case the cluster is deleted within that hour. https://cloud.google.com/kubernetes-engine/docs/how-to/creating-managing-labels#label_propagation
LabelDisks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def ResizeNodePool( self, new_size: int, node_pool: str = container_service.DEFAULT_NODEPOOL ): """Changes the number of nodes in the node pool.""" cmd = self._GcloudCommand('container', 'clusters', 'resize', self.name) cmd.flags['num-nodes'] = new_size # updates default node pool by default ...
Changes the number of nodes in the node pool.
ResizeNodePool
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def GetNodeSelectors(self) -> list[str]: """Node selectors for instance capabilites in AutoPilot clusters.""" selectors = [] # https://cloud.google.com/kubernetes-engine/docs/how-to/autopilot-gpus#request-gpus if virtual_machine.GPU_TYPE.value: gpu_count = virtual_machine.GPU_COUNT.value or 1 ...
Node selectors for instance capabilites in AutoPilot clusters.
GetNodeSelectors
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/google_kubernetes_engine.py
Apache-2.0
def GetProjectNumber(project_id: str | None = None) -> str: """Get the number of the default project.""" # All GCP projects have both a project number & a project id. The project id # is the human-readable name of the project. if not project_id: project_id = GetDefaultProject() cmd = [ FLAGS.gcloud_...
Get the number of the default project.
GetProjectNumber
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetZonesInRegion(region) -> Set[str]: """Gets a list of zones for the given region.""" cmd = GcloudCommand(None, 'compute', 'zones', 'list') cmd.flags.update({ 'filter': f"region='{region}'", 'format': 'value(name)', }) stdout, _, _ = cmd.Issue() return set(stdout.splitlines())
Gets a list of zones for the given region.
GetZonesInRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetZonesFromMachineType(machine_type: str) -> Set[str]: """Gets a list of zones for the given machine type.""" cmd = GcloudCommand(None, 'compute', 'machine-types', 'list') cmd.flags.update({ 'filter': f"name='{machine_type}'", 'format': 'value(zone)', }) stdout, _, _ = cmd.Issue() zones_wit...
Gets a list of zones for the given machine type.
GetZonesFromMachineType
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetMultiRegionFromRegion(region: str): """Gets the closest multi-region location to the region.""" if ( region.startswith('us') or region.startswith('northamerica') or region.startswith('southamerica') ): return 'us' elif region.startswith('europe'): return 'eu' elif region.start...
Gets the closest multi-region location to the region.
GetMultiRegionFromRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def IssueCommandFunction(cmd: 'GcloudCommand', **kwargs): """Use vm_util to issue the given command. Args: cmd: the gcloud command to run **kwargs: additional arguments for the gcloud command Returns: stdout, stderr, retcode tuple from running the command """ kwargs['stack_level'] = kwargs.get('...
Use vm_util to issue the given command. Args: cmd: the gcloud command to run **kwargs: additional arguments for the gcloud command Returns: stdout, stderr, retcode tuple from running the command
IssueCommandFunction
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def IssueRetryableCommandFunction(cmd: 'GcloudCommand', **kwargs): """Use vm_util to issue the given retryable command. Args: cmd: the gcloud command to run **kwargs: additional arguments for the gcloud command Returns: stdout, stderr, tuple from running the command """ kwargs['stack_level'] = k...
Use vm_util to issue the given retryable command. Args: cmd: the gcloud command to run **kwargs: additional arguments for the gcloud command Returns: stdout, stderr, tuple from running the command
IssueRetryableCommandFunction
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def SetIssueCommandFunction(func): """Set the issue command function to be the given function. Args: func: the function to run when issuing a GcloudCommand. """ global _issue_command_function _issue_command_function = func
Set the issue command function to be the given function. Args: func: the function to run when issuing a GcloudCommand.
SetIssueCommandFunction
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def SetIssueRetryableCommandFunction(func): """Set the issue retryable command function to be the given function. Args: func: the function to run when issuing a GcloudCommand. """ global _issue_retryable_command_function _issue_retryable_command_function = func
Set the issue retryable command function to be the given function. Args: func: the function to run when issuing a GcloudCommand.
SetIssueRetryableCommandFunction
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def __init__(self, common_resource: resource.BaseResource | None, *args): """Initializes a GcloudCommand with the provided args and common flags. Args: common_resource: A GCE resource of type BaseResource. *args: sequence of strings. Non-flag args to pass to gcloud, typically specifying an ...
Initializes a GcloudCommand with the provided args and common flags. Args: common_resource: A GCE resource of type BaseResource. *args: sequence of strings. Non-flag args to pass to gcloud, typically specifying an operation to perform (e.g. ['compute', 'images', 'list'] to list availabl...
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetCommand(self): """Generates the gcloud command. Returns: list of strings. When joined by spaces, forms the gcloud shell command. Raises: ValueError: if passed a None value """ cmd = [FLAGS.gcloud_path] cmd.extend(self.args) for flag_name, values in sorted(self.flags.item...
Generates the gcloud command. Returns: list of strings. When joined by spaces, forms the gcloud shell command. Raises: ValueError: if passed a None value
GetCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def IssueRetryable(self, **kwargs): """Tries running the gcloud command until it succeeds or times out. Args: **kwargs: Keyword arguments to forward to vm_util.IssueRetryableCommand when issuing the gcloud command. Returns: (stdout, stderr) pair of strings from running the gcloud comma...
Tries running the gcloud command until it succeeds or times out. Args: **kwargs: Keyword arguments to forward to vm_util.IssueRetryableCommand when issuing the gcloud command. Returns: (stdout, stderr) pair of strings from running the gcloud command.
IssueRetryable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def _AddCommonFlags(self, common_resource: resource.BaseResource | None): """Adds common flags to the command. Adds common gcloud flags derived from the PKB flags and provided resource. Args: common_resource: A GCE resource of type BaseResource. """ self.flags['format'] = 'json' self.fla...
Adds common flags to the command. Adds common gcloud flags derived from the PKB flags and provided resource. Args: common_resource: A GCE resource of type BaseResource.
_AddCommonFlags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def CheckGcloudResponseKnownFailures(stderr: str, retcode: int): """Checks gcloud responses for quota exceeded errors. Args: stderr: The stderr from a gcloud command. retcode: The return code from a gcloud command. """ if retcode: if _QUOTA_EXCEEDED_REGEX.search(stderr): message = virtual...
Checks gcloud responses for quota exceeded errors. Args: stderr: The stderr from a gcloud command. retcode: The return code from a gcloud command.
CheckGcloudResponseKnownFailures
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def AuthenticateServiceAccount( vm: virtual_machine.BaseVirtualMachine, vm_gcloud_path: str = 'gcloud', benchmark: Any = None, ): """Authorize gcloud to access Google Cloud Platform with a service account. If you want gcloud (and other tools in the Cloud SDK) to use service account credentials to mak...
Authorize gcloud to access Google Cloud Platform with a service account. If you want gcloud (and other tools in the Cloud SDK) to use service account credentials to make requests, use this method to authenticate. Account name is provided by FLAGS.gcp_service_account Credentials are fetched from a file whose lo...
AuthenticateServiceAccount
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def InstallGcloudComponents( vm: virtual_machine.BaseVirtualMachine, vm_gcloud_path: str = 'gcloud', component: str = 'alpha', ): """Install gcloud components on the target vm. Args: vm: vm on which the gcloud's alpha components need to be installed. vm_gcloud_path: Optional path to the gcloud ...
Install gcloud components on the target vm. Args: vm: vm on which the gcloud's alpha components need to be installed. vm_gcloud_path: Optional path to the gcloud binary on the vm. component: Gcloud component to install.
InstallGcloudComponents
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def SplitTags(tags: str): """Formats a string of joined tags into a dictionary. Args: tags: A string containing tags formatted as key1=value1,key2=value2,... Returns: An OrderedDict mapping tag keys to values in the order the tags were given. """ return collections.OrderedDict( tag_pair.split(...
Formats a string of joined tags into a dictionary. Args: tags: A string containing tags formatted as key1=value1,key2=value2,... Returns: An OrderedDict mapping tag keys to values in the order the tags were given.
SplitTags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetDefaultTags(timeout_minutes: int | None = None): """Get the default tags in a dictionary. Args: timeout_minutes: Timeout used for setting the timeout_utc tag. Returns: A dict of tags, contributed from the benchmark spec. """ benchmark_spec = context.GetThreadBenchmarkSpec() if not benchmark...
Get the default tags in a dictionary. Args: timeout_minutes: Timeout used for setting the timeout_utc tag. Returns: A dict of tags, contributed from the benchmark spec.
GetDefaultTags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def GetAccessToken(application_default: bool = True) -> str: """Gets the access token for the default project. Args: application_default: whether to use application-default in gcloud args. Returns: Text string of the access token. """ cmd = [FLAGS.gcloud_path, 'auth'] if application_default: c...
Gets the access token for the default project. Args: application_default: whether to use application-default in gcloud args. Returns: Text string of the access token.
GetAccessToken
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def SetupPrivateServicesAccess(network: str, project: str) -> None: """Setup private services access for the network. Private services access is used by several GCP services and enables VMs to connect to service producers using internal IP addressses. See https://cloud.google.com/vpc/docs/configure-private-ser...
Setup private services access for the network. Private services access is used by several GCP services and enables VMs to connect to service producers using internal IP addressses. See https://cloud.google.com/vpc/docs/configure-private-services-access for more info. Args: network: The network (VPC) nam...
SetupPrivateServicesAccess
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/util.py
Apache-2.0
def _InitializeNewModel(self) -> 'BaseVertexAiModel': """Returns a new instance of the same class.""" return self.__class__( vm=self.vm, model_spec=self.model_spec, name=self.name + '2', # Reuse the same bucket for the next model. bucket_uri=self.bucket_uri, ) # pyty...
Returns a new instance of the same class.
_InitializeNewModel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def ListExistingEndpoints(self, region: str | None = None) -> list[str]: """Returns a list of existing model endpoint ids in the same region.""" if region is None: region = self.region # Expected output example: # ENDPOINT_ID DISPLAY_NAME # 12345 some_endpoint_name ...
Returns a list of existing model endpoint ids in the same region.
ListExistingEndpoints
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetSamples(self) -> list[sample.Sample]: """Gets samples relating to the provisioning of the resource.""" samples = super().GetSamples() metadata = self.GetResourceMetadata() if self.model_upload_time: samples.append( sample.Sample( 'Model Upload Time', se...
Gets samples relating to the provisioning of the resource.
GetSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _UploadModel(self) -> None: """Uploads the model to the model registry.""" raise NotImplementedError( '_UploadModel is not implemented for this model type.' )
Uploads the model to the model registry.
_UploadModel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _DeployModel(self) -> None: """Deploys the model to the endpoint.""" raise NotImplementedError( '_DeployModel is not implemented for this model type.' )
Deploys the model to the endpoint.
_DeployModel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _CreateDependencies(self): """Creates the endpoint & copies the model to a bucket.""" super()._CreateDependencies() if self.gcs_client: gcs_bucket_copy_start_time = time.time() self.gcs_client.MakeBucket( self.bucket_uri ) # pytype: disable=attribute-error self.gcs_cli...
Creates the endpoint & copies the model to a bucket.
_CreateDependencies
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _PreDelete(self) -> None: """Deletes dependencies before deleting the underlying resource.""" # Normally _DeleteDependencies is called by parent after _Delete, but we # need to call it before. self._DeleteDependencies()
Deletes dependencies before deleting the underlying resource.
_PreDelete
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetPromptCommand( self, prompt: str, max_tokens: int, temperature: float, **kwargs: Any ) -> str: """Returns the command to send a prompt to the model.""" instances = self.model_spec.ConvertToInstances( prompt, max_tokens, temperature, **kwargs ) instances_dict = {'instances': instan...
Returns the command to send a prompt to the model.
GetPromptCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _GetPromptCommand(self, json_file_name: str): """Returns the prompting command once json file is written.""" return ( 'gcloud ai endpoints predict' f' {self.endpoint.endpoint_name} --json-request={json_file_name}' )
Returns the prompting command once json file is written.
_GetPromptCommand
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _UploadModel(self) -> None: """Uploads the model via gcloud command.""" upload_cmd = ( f'gcloud ai models upload --display-name={self.name}' f' --project={self.project} --region={self.region}' f' --artifact-uri={self.model_bucket_path}' ) if util.GetDefaultTags(): uploa...
Uploads the model via gcloud command.
_UploadModel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _DeployModel(self): """Deploys the model to the endpoint via gcloud command.""" accelerator_type = self.model_spec.accelerator_type.lower() accelerator_type = accelerator_type.replace('_', '-') _, err, code = self.vm.RunCommand( f'gcloud ai endpoints deploy-model {self.endpoint.endpoint_name...
Deploys the model to the endpoint via gcloud command.
_DeployModel
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def __getstate__(self): """Override pickling as the AI platform objects are not picklable.""" to_pickle_dict = { 'name': self.name, 'model_name': self.model_name, 'model_bucket_path': self.model_bucket_path, 'region': self.region, 'project': self.project, 'service...
Override pickling as the AI platform objects are not picklable.
__getstate__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def short_endpoint_name(self) -> str | None: """Returns the short name of the endpoint. Returns: The short name. ie 1234 rather than projects/123/locations/us-east1/endpoints/1234. """ if self.endpoint_name is None: return None return self.endpoint_name.split('/')[-1]
Returns the short name of the endpoint. Returns: The short name. ie 1234 rather than projects/123/locations/us-east1/endpoints/1234.
short_endpoint_name
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def UpdateLabels(self) -> None: """Updates the labels of the endpoint.""" self.vm.RunCommand( f'gcloud ai endpoints update {self.endpoint_name} ' f' --project={self.project} --region={self.region}' f' --update-labels={util.MakeFormattedDefaultTags()}', )
Updates the labels of the endpoint.
UpdateLabels
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def _FindRegexInOutput( output: str, regex: str, exception_type: type[errors.Error] | None = None, group_index: int = 1, ) -> str | None: """Returns the 1st match of the regex in the output. Args: output: The output to search. regex: The regex to search for. exception_type: The exceptio...
Returns the 1st match of the regex in the output. Args: output: The output to search. regex: The regex to search for. exception_type: The exception type to raise if no match is found. group_index: If there are multiple groups in the regex, which one to return.
_FindRegexInOutput
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetModelUploadCliArgs(self, **input_args) -> str: """Returns the kwargs needed to upload the model.""" env_vars = self.GetEnvironmentVariables(**input_args) env_vars_str = ','.join(f'{key}={value}' for key, value in env_vars.items()) ports_str = ','.join(str(port) for port in self.serving_container_...
Returns the kwargs needed to upload the model.
GetModelUploadCliArgs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetModelDeployKwargs(self) -> dict[str, Any]: """Returns the kwargs needed to deploy the model.""" return { 'machine_type': self.machine_type, 'accelerator_type': self.accelerator_type, 'accelerator_count': self.accelerator_count, }
Returns the kwargs needed to deploy the model.
GetModelDeployKwargs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetEnvironmentVariables(self, **kwargs) -> dict[str, str]: """Returns container's environment variables needed by Llama2.""" return { 'MODEL_ID': kwargs['model_bucket_path'], 'DEPLOY_SOURCE': 'pkb', }
Returns container's environment variables needed by Llama2.
GetEnvironmentVariables
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def ConvertToInstances( self, prompt: str, max_tokens: int, temperature: float, **kwargs: Any ) -> list[dict[str, Any]]: """Converts input to the form expected by the model.""" instances = { 'prompt': prompt, 'max_tokens': max_tokens, 'temperature': temperature, } for par...
Converts input to the form expected by the model.
ConvertToInstances
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def GetModelGardenName(self) -> str: """Returns the name of the model in Model Garden.""" suffix = self.model_size if self.model_size == 'scout-17b': suffix += '-16e' else: suffix += '-128e' return f'meta/llama4@llama-4-{suffix}'
Returns the name of the model in Model Garden.
GetModelGardenName
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/gcp/vertex_ai.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/gcp/vertex_ai.py
Apache-2.0
def Attach(self, vm): """Attaches the disk to a VM. Args: vm: instance of the vm to which the disk will be attached. """ if self.vol_id is None: raise errors.Error(f'Cannot attach remote volume {self.name}') if vm.vmid is None: raise errors.Error( f'Cannot attach remote ...
Attaches the disk to a VM. Args: vm: instance of the vm to which the disk will be attached.
Attach
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
Apache-2.0
def _WaitForVolumeAttachment(self, vm): """Waits and checks until the volume status is attached.""" if self.vol_id is None: return volcmd = ibm.IbmAPICommand(self) volcmd.flags.update( {'instanceid': self.attached_vm.vmid, 'volume': self.vol_id} ) logging.info( 'Checking vo...
Waits and checks until the volume status is attached.
_WaitForVolumeAttachment
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
Apache-2.0
def _GetDeviceFromVDisk(self, vm): """Gets device path for the volume.""" cmd = 'fdisk -l' endtime = time.time() + _MAX_FIND_DEVICE_SECONDS self.device_path = None while time.time() < endtime: stdout, _ = self.attached_vm.RemoteCommand(cmd) # parse for lines that contain disk size in byt...
Gets device path for the volume.
_GetDeviceFromVDisk
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_disk.py
Apache-2.0
def Request( self, method, path, data=None, headers=None, timeout=None, session=None ): """Constructs base rest api calls to run against IBM Cloud regional api server. Args: method: one of GET, POST, PUT, PATCH or DELETE. path: rest api uri. data: body data. headers: header data...
Constructs base rest api calls to run against IBM Cloud regional api server. Args: method: one of GET, POST, PUT, PATCH or DELETE. path: rest api uri. data: body data. headers: header data if any. timeout: timeout for the request session: session object if available. Return...
Request
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def __getattr__(self, name): """Handles non standard action method names with underscores.""" if '_' not in name: raise AttributeError(name) action, path = name.split('_', 1) if path in SPEC_PATHS: paths = path else: paths = path.split('_') if action in ['create', 'show', 'de...
Handles non standard action method names with underscores.
__getattr__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create( self, name, imageid, profile, vpcid, zone=None, key=None, # pytype: disable=signature-mismatch # overriding-parameter-count-checks subnet=None, networks=None, resource_group=None, iops=None, capacity=None, user_data=None, ...
Construct and send a vm create request. Args: name: name of the vm. imageid: image id to use. profile: machine_type. vpcid: vpc id. zone: zone name. key: regional ssh key id. subnet: subnet id. networks: optional. additional subnet ids. resource_group:...
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def CreateVolume(self, instance, name, volume, delete) -> Dict[str, Any]: """Send a volume create request on a vm.""" inst_uri = self.GetUri(instance) + '/volume_attachments' return self._g.Request( 'POST', '%s' % inst_uri, { 'delete_volume_on_instance_delete': delete, ...
Send a volume create request on a vm.
CreateVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ListVolumes(self, instance) -> Dict[str, Any]: """Send a volume list request on a vm.""" inst_uri = self.GetUri(instance) + '/volume_attachments' return self._g.Request('GET', inst_uri)
Send a volume list request on a vm.
ListVolumes
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ShowVolume(self, instance, volume_attachment) -> Dict[str, Any]: """Send a volume get request on a vm.""" inst_uri = ( self.GetUri(instance) + '/volume_attachments/' + volume_attachment ) return self._g.Request('GET', inst_uri)
Send a volume get request on a vm.
ShowVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def DeleteVolume(self, instance, volume_attachment): """Send a volume delete request on a vm.""" inst_uri = ( self.GetUri(instance) + '/volume_attachments/' + volume_attachment ) return self._g.Request('DELETE', inst_uri)
Send a volume delete request on a vm.
DeleteVolume
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, zone, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a vm create request. Args: zone: zone name. **kwargs: name - volume name. profile - volume profile. capacity - boot volume size. iops - iops o...
Construct and send a vm create request. Args: zone: zone name. **kwargs: name - volume name. profile - volume profile. capacity - boot volume size. iops - iops on the volume. resource_group - optional. encryption_key - key to encrypt, optional. Returns: created volume.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def CreatePrefix(self, vpc, zone, cidr, name=None) -> Dict[str, Any]: """Send a vpc address prefix create request.""" req_data = {'zone': {'name': zone}, 'cidr': cidr} if name: req_data['name'] = name vpc_uri = self.GetUri(vpc) + '/address_prefixes' return self._g.Request('POST', '%s' % vpc_ur...
Send a vpc address prefix create request.
CreatePrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def DeletePrefix(self, vpc, prefix): """Send a vpc address prefix delete request.""" return self._g.Request( 'DELETE', 'vpcs/%s/address_prefixes/%s' % (vpc, prefix) )
Send a vpc address prefix delete request.
DeletePrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def PatchPrefix( self, vpc, prefix, default=False, name=None ) -> Dict[str, Any]: """Send a vpc address prefix patch request.""" req_data = {'is_default': default} if name: req_data['name'] = name return self._g.Request( 'PATCH', 'vpcs/%s/address_prefixes/%s' % (vpc, prefix), req_d...
Send a vpc address prefix patch request.
PatchPrefix
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def CreateRoutingTable( self, vpc, name, routes=None, session=None ) -> Dict[str, Any]: """Send a vpc routing table create request.""" req_data = {'name': name} if routes: req_data['routes'] = routes vpc_uri = self.GetUri(vpc) + '/routing_tables' return self._g.Request('POST', '%s' % v...
Send a vpc routing table create request.
CreateRoutingTable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ShowRoutingTable(self, vpc, routing, session=None) -> Dict[str, Any]: """Send a vpc routing table get request.""" return self._g.Request( 'GET', 'vpcs/%s/routing_tables/%s' % (vpc, routing), session=session )
Send a vpc routing table get request.
ShowRoutingTable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def PatchRoutingTable( self, vpc, routing, ingress, flag, session=None ) -> Dict[str, Any]: """Send a vpc routing table patch request.""" vpc_uri = self.GetUri(vpc) + '/routing_tables/' + routing return self._g.Request('PATCH', vpc_uri, {ingress: flag}, session=session)
Send a vpc routing table patch request.
PatchRoutingTable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def DeleteRoutingTable(self, vpc, routing, session=None): """Send a vpc routing table delete request.""" vpc_uri = self.GetUri(vpc) + '/routing_tables/' + routing return self._g.Request('DELETE', '%s' % vpc_uri, session=session)
Send a vpc routing table delete request.
DeleteRoutingTable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ListRoutingTable(self, vpc, session=None) -> Dict[str, Any]: """Send a vpc routing table list request.""" return self._g.Request( 'GET', 'vpcs/%s/routing_tables?limit=100' % vpc, session=session )
Send a vpc routing table list request.
ListRoutingTable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def Create(self, resource_group, vpcid, **kwargs) -> Dict[str, Any]: # pytype: disable=signature-mismatch # overriding-parameter-count-checks """Construct and send a security group create request. Args: resource_group: optional. vpcid: vpc id. **kwargs: name - name of the vm. Return...
Construct and send a security group create request. Args: resource_group: optional. vpcid: vpc id. **kwargs: name - name of the vm. Returns: returns created security groups.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ShowRule(self, sg, ruleid) -> Dict[str, Any]: """Send a security group rule get request.""" sg_uri = self.GetUris(sg) + '/rules/' + ruleid return self._g.Request('GET', sg_uri)
Send a security group rule get request.
ShowRule
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0
def ListRules(self, sg) -> Dict[str, Any]: """Send a security group rule list request.""" sg_uri = self.GetUris(sg) + '/rules' return self._g.Request('GET', sg_uri)
Send a security group rule list request.
ListRules
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/providers/ibmcloud/ibmcloud_manager.py
Apache-2.0