@@ -1054,6 +1054,70 @@ def assess_tuning_resources(
10541054 response ["tuningResourceUsageAssessmentResult" ],
10551055 )
10561056
1057+ def assess_batch_prediction_resources (
1058+ self ,
1059+ * ,
1060+ dataset_name : str ,
1061+ model_name : str ,
1062+ template_config : Optional [types .GeminiTemplateConfigOrDict ] = None ,
1063+ config : Optional [types .AssessDatasetConfigOrDict ] = None ,
1064+ ) -> types .BatchPredictionResourceUsageAssessmentResult :
1065+ """Assess the batch prediction resources required for a given model.
1066+
1067+ Args:
1068+ dataset_name:
1069+ Required. The name of the dataset to assess the batch prediction
1070+ resources.
1071+ model_name:
1072+ Required. The name of the model to assess the batch prediction
1073+ resources.
1074+ template_config:
1075+ Optional. The template config used to assemble the dataset
1076+ before assessing the batch prediction resources. If not provided,
1077+ the template config attached to the dataset will be used. Required
1078+ if no template config is attached to the dataset.
1079+ template_config:
1080+ Optional. The template config used to assemble the dataset
1081+ before assessing the batch prediction resources. If not provided, the
1082+ template config attached to the dataset will be used. Required
1083+ if no template config is attached to the dataset.
1084+ config:
1085+ Optional. A configuration for assessing the batch prediction
1086+ resources. If not provided, the default configuration will be
1087+ used.
1088+
1089+ Returns:
1090+ A types.BatchPredictionResourceUsageAssessmentResult object
1091+ representing the batch prediction resource usage assessment result.
1092+ It contains the following keys:
1093+ - token_count: The number of tokens in the dataset.
1094+ - audio_token_count: The number of audio tokens in the dataset.
1095+
1096+ """
1097+ if isinstance (config , dict ):
1098+ config = types .AssessDatasetConfig (** config )
1099+ elif not config :
1100+ config = types .AssessDatasetConfig ()
1101+
1102+ operation = self ._assess_multimodal_dataset (
1103+ name = dataset_name ,
1104+ batch_prediction_resource_usage_assessment_config = types .BatchPredictionResourceUsageAssessmentConfig (
1105+ model_name = model_name ,
1106+ ),
1107+ gemini_request_read_config = types .GeminiRequestReadConfig (
1108+ template_config = template_config ,
1109+ ),
1110+ config = config ,
1111+ )
1112+ response = self ._wait_for_operation (
1113+ operation = operation ,
1114+ timeout_seconds = config .timeout ,
1115+ )
1116+ result = response ["batchPredictionResourceUsageAssessmentResult" ]
1117+ return _datasets_utils .create_from_response (
1118+ types .BatchPredictionResourceUsageAssessmentResult , result
1119+ )
1120+
10571121
10581122class AsyncDatasets (_api_module .BaseModule ):
10591123
@@ -1875,3 +1939,67 @@ async def assess_tuning_resources(
18751939 types .TuningResourceUsageAssessmentResult ,
18761940 response ["tuningResourceUsageAssessmentResult" ],
18771941 )
1942+
1943+ async def assess_batch_prediction_resources (
1944+ self ,
1945+ * ,
1946+ dataset_name : str ,
1947+ model_name : str ,
1948+ template_config : Optional [types .GeminiTemplateConfigOrDict ] = None ,
1949+ config : Optional [types .AssessDatasetConfigOrDict ] = None ,
1950+ ) -> types .BatchPredictionResourceUsageAssessmentResult :
1951+ """Assess the batch prediction resources required for a given model.
1952+
1953+ Args:
1954+ dataset_name:
1955+ Required. The name of the dataset to assess the batch prediction
1956+ resources.
1957+ model_name:
1958+ Required. The name of the model to assess the batch prediction
1959+ resources.
1960+ template_config:
1961+ Optional. The template config used to assemble the dataset
1962+ before assessing the batch prediction resources. If not provided,
1963+ the template config attached to the dataset will be used. Required
1964+ if no template config is attached to the dataset.
1965+ template_config:
1966+ Optional. The template config used to assemble the dataset
1967+ before assessing the batch prediction resources. If not provided, the
1968+ template config attached to the dataset will be used. Required
1969+ if no template config is attached to the dataset.
1970+ config:
1971+ Optional. A configuration for assessing the batch prediction
1972+ resources. If not provided, the default configuration will be
1973+ used.
1974+
1975+ Returns:
1976+ A types.BatchPredictionResourceUsageAssessmentResult object
1977+ representing the batch prediction resource usage assessment result.
1978+ It contains the following keys:
1979+ - token_count: The number of tokens in the dataset.
1980+ - audio_token_count: The number of audio tokens in the dataset.
1981+
1982+ """
1983+ if isinstance (config , dict ):
1984+ config = types .AssessDatasetConfig (** config )
1985+ elif not config :
1986+ config = types .AssessDatasetConfig ()
1987+
1988+ operation = await self ._assess_multimodal_dataset (
1989+ name = dataset_name ,
1990+ batch_prediction_resource_usage_assessment_config = types .BatchPredictionResourceUsageAssessmentConfig (
1991+ model_name = model_name ,
1992+ ),
1993+ gemini_request_read_config = types .GeminiRequestReadConfig (
1994+ template_config = template_config ,
1995+ ),
1996+ config = config ,
1997+ )
1998+ response = await self ._wait_for_operation (
1999+ operation = operation ,
2000+ timeout_seconds = config .timeout ,
2001+ )
2002+ result = response ["batchPredictionResourceUsageAssessmentResult" ]
2003+ return _datasets_utils .create_from_response (
2004+ types .BatchPredictionResourceUsageAssessmentResult , result
2005+ )
0 commit comments