@@ -924,23 +924,46 @@ def _wait_for_operation(
924924 def create_from_bigquery (
925925 self ,
926926 * ,
927- multimodal_dataset : types .MultimodalDatasetOrDict ,
927+ bigquery_uri : Optional [str ] = None ,
928+ multimodal_dataset : Optional [types .MultimodalDatasetOrDict ] = None ,
928929 config : Optional [types .CreateMultimodalDatasetConfigOrDict ] = None ,
929930 ) -> types .MultimodalDataset :
930931 """Creates a multimodal dataset from a BigQuery table.
931932
932933 Args:
934+ bigquery_uri:
935+ Optional. The BigQuery URI of the table to create the dataset from.
936+ e.g. "bq://project.dataset.table". If both `bigquery_uri` and
937+ `multimodal_dataset` are provided, and `multimodal_dataset` also
938+ contains a BigQuery URI, the `bigquery_uri` parameter takes precedence.
933939 multimodal_dataset:
934- Required. A representation of a multimodal dataset.
940+ Optional. A representation of a multimodal dataset. If `bigquery_uri`
941+ is set, `multimodal_dataset` can still be used to set other metadata
942+ fields. If both `bigquery_uri` and `multimodal_dataset` are provided,
943+ and `multimodal_dataset` also contains a BigQuery URI, the
944+ `bigquery_uri` parameter takes precedence.
935945 config:
936946 Optional. A configuration for creating the multimodal dataset. If not
937947 provided, the default configuration will be used.
938948
939949 Returns:
940950 A types.MultimodalDataset object representing a multimodal dataset.
941951 """
942- if isinstance (multimodal_dataset , dict ):
952+ if not bigquery_uri and not multimodal_dataset :
953+ raise ValueError (
954+ "At least one of `bigquery_uri` or `multimodal_dataset` must be"
955+ " provided."
956+ )
957+
958+ if multimodal_dataset is None :
959+ multimodal_dataset = types .MultimodalDataset ()
960+ elif isinstance (multimodal_dataset , dict ):
943961 multimodal_dataset = types .MultimodalDataset (** multimodal_dataset )
962+
963+ if bigquery_uri :
964+ multimodal_dataset = multimodal_dataset .model_copy (deep = True )
965+ multimodal_dataset .set_bigquery_uri (bigquery_uri )
966+
944967 _datasets_utils .validate_multimodal_dataset_bigquery_uri (multimodal_dataset )
945968
946969 if isinstance (config , dict ):
@@ -2187,23 +2210,46 @@ async def _wait_for_operation(
21872210 async def create_from_bigquery (
21882211 self ,
21892212 * ,
2190- multimodal_dataset : types .MultimodalDatasetOrDict ,
2213+ bigquery_uri : Optional [str ] = None ,
2214+ multimodal_dataset : Optional [types .MultimodalDatasetOrDict ] = None ,
21912215 config : Optional [types .CreateMultimodalDatasetConfigOrDict ] = None ,
21922216 ) -> types .MultimodalDataset :
21932217 """Creates a multimodal dataset from a BigQuery table.
21942218
21952219 Args:
2220+ bigquery_uri:
2221+ Optional. The BigQuery URI of the table to create the dataset from.
2222+ e.g. "bq://project.dataset.table". If both `bigquery_uri` and
2223+ `multimodal_dataset` are provided, and `multimodal_dataset` also
2224+ contains a BigQuery URI, the `bigquery_uri` parameter takes precedence.
21962225 multimodal_dataset:
2197- Required. A representation of a multimodal dataset.
2226+ Optional. A representation of a multimodal dataset. If `bigquery_uri`
2227+ is set, `multimodal_dataset` can still be used to set other metadata
2228+ fields. If both `bigquery_uri` and `multimodal_dataset` are provided,
2229+ and `multimodal_dataset` also contains a BigQuery URI, the
2230+ `bigquery_uri` parameter takes precedence.
21982231 config:
21992232 Optional. A configuration for creating the multimodal dataset. If not
22002233 provided, the default configuration will be used.
22012234
22022235 Returns:
22032236 A types.MultimodalDataset object representing a multimodal dataset.
22042237 """
2205- if isinstance (multimodal_dataset , dict ):
2238+ if not bigquery_uri and not multimodal_dataset :
2239+ raise ValueError (
2240+ "At least one of `bigquery_uri` or `multimodal_dataset` must be"
2241+ " provided."
2242+ )
2243+
2244+ if multimodal_dataset is None :
2245+ multimodal_dataset = types .MultimodalDataset ()
2246+ elif isinstance (multimodal_dataset , dict ):
22062247 multimodal_dataset = types .MultimodalDataset (** multimodal_dataset )
2248+
2249+ if bigquery_uri :
2250+ multimodal_dataset = multimodal_dataset .model_copy (deep = True )
2251+ multimodal_dataset .set_bigquery_uri (bigquery_uri )
2252+
22072253 _datasets_utils .validate_multimodal_dataset_bigquery_uri (multimodal_dataset )
22082254
22092255 if isinstance (config , dict ):
0 commit comments