@@ -121,6 +121,7 @@ def _create_input_data_config( |
121 | 121 | test_fraction_split: float = 0.1, |
122 | 122 | predefined_split_column_name: Optional[str] = None, |
123 | 123 | gcs_destination_uri_prefix: Optional[str] = None, |
| 124 | + bigquery_destination: Optional[str] = None |
124 | 125 | ) -> Optional[gca_training_pipeline.InputDataConfig]: |
125 | 126 | """Constructs a input data config to pass to the training pipeline. |
126 | 127 |
|
@@ -159,6 +160,8 @@ def _create_input_data_config( |
159 | 160 | - AIP_TRAINING_DATA_URI = "gcs_destination/training-*" |
160 | 161 | - AIP_VALIDATION_DATA_URI = "gcs_destination/validation-*" |
161 | 162 | - AIP_TEST_DATA_URI = "gcs_destination/test-*". |
| 163 | + bigquery_destination (str): |
| 164 | + TODO(asobran) |
162 | 165 | """ |
163 | 166 |
|
164 | 167 | input_data_config = None |
@@ -192,12 +195,18 @@ def _create_input_data_config( |
192 | 195 | output_uri_prefix=gcs_destination_uri_prefix |
193 | 196 | ) |
194 | 197 |
|
| 198 | + bigquery_destination_proto=None |
| 199 | + if bigquery_destination: |
| 200 | + bigquery_destination_proto = gca_io.BigQueryDestination( |
| 201 | + output_uri=bigquery_destination) |
| 202 | + |
195 | 203 | # create input data config |
196 | 204 | input_data_config = gca_training_pipeline.InputDataConfig( |
197 | 205 | fraction_split=fraction_split, |
198 | 206 | predefined_split=predefined_split, |
199 | 207 | dataset_id=dataset.name, |
200 | 208 | gcs_destination=gcs_destination, |
| 209 | + bigquery_destination=bigquery_destination_proto |
201 | 210 | ) |
202 | 211 |
|
203 | 212 | return input_data_config |
@@ -213,6 +222,7 @@ def _run_job( |
213 | 222 | predefined_split_column_name: Optional[str] = None, |
214 | 223 | model: Optional[gca_model.Model] = None, |
215 | 224 | gcs_destination_uri_prefix: Optional[str] = None, |
| 225 | + bigquery_destination: Optional[str] = None |
216 | 226 | ) -> Optional[models.Model]: |
217 | 227 | """Runs the training job. |
218 | 228 |
|
@@ -294,6 +304,8 @@ def _run_job( |
294 | 304 | - AIP_TRAINING_DATA_URI = "gcs_destination/training-*" |
295 | 305 | - AIP_VALIDATION_DATA_URI = "gcs_destination/validation-*" |
296 | 306 | - AIP_TEST_DATA_URI = "gcs_destination/test-*". |
| 307 | + bigquery_destination (str): |
| 308 | + TODO(asobran) |
297 | 309 | """ |
298 | 310 |
|
299 | 311 | input_data_config = self._create_input_data_config( |
@@ -303,6 +315,7 @@ def _run_job( |
303 | 315 | test_fraction_split=test_fraction_split, |
304 | 316 | predefined_split_column_name=predefined_split_column_name, |
305 | 317 | gcs_destination_uri_prefix=gcs_destination_uri_prefix, |
| 318 | + bigquery_destination=bigquery_destination |
306 | 319 | ) |
307 | 320 |
|
308 | 321 | # create training pipeline |
@@ -1157,6 +1170,7 @@ def run( |
1157 | 1170 | dataset: Optional[datasets.Dataset] = None, |
1158 | 1171 | model_display_name: Optional[str] = None, |
1159 | 1172 | base_output_dir: Optional[str] = None, |
| 1173 | + bigquery_destination: Optional[str] = None, |
1160 | 1174 | args: Optional[List[Union[str, float, int]]] = None, |
1161 | 1175 | replica_count: int = 0, |
1162 | 1176 | machine_type: str = "n1-standard-4", |
@@ -1186,7 +1200,7 @@ def run( |
1186 | 1200 | Args: |
1187 | 1201 | dataset (aiplatform.Dataset): |
1188 | 1202 | AI Platform to fit this training against. Custom training script should |
1189 | | - retrieve datasets through passed in environement variables uris: |
| 1203 | + retrieve datasets through passed in environment variables uris: |
1190 | 1204 |
|
1191 | 1205 | os.environ["AIP_TRAINING_DATA_URI"] |
1192 | 1206 | os.environ["AIP_VALIDATION_DATA_URI"] |
@@ -1202,6 +1216,8 @@ def run( |
1202 | 1216 | base_output_dir (str): |
1203 | 1217 | GCS output directory of job. If not provided a |
1204 | 1218 | timestamped directory in the staging directory will be used. |
| 1219 | + bigquery_destination (str): |
| 1220 | + TODO(asobran) |
1205 | 1221 | args (List[Unions[str, int, float]]): |
1206 | 1222 | Command line arguments to be passed to the Python script. |
1207 | 1223 | replica_count (int): |
@@ -1291,6 +1307,7 @@ def run( |
1291 | 1307 | managed_model=managed_model, |
1292 | 1308 | args=args, |
1293 | 1309 | base_output_dir=base_output_dir, |
| 1310 | + bigquery_destination=bigquery_destination, |
1294 | 1311 | training_fraction_split=training_fraction_split, |
1295 | 1312 | validation_fraction_split=validation_fraction_split, |
1296 | 1313 | test_fraction_split=test_fraction_split, |
@@ -1307,6 +1324,7 @@ def _run( |
1307 | 1324 | managed_model: Optional[gca_model.Model] = None, |
1308 | 1325 | args: Optional[List[Union[str, float, int]]] = None, |
1309 | 1326 | base_output_dir: Optional[str] = None, |
| 1327 | + bigquery_destination: Optional[str] = None, |
1310 | 1328 | training_fraction_split: float = 0.8, |
1311 | 1329 | validation_fraction_split: float = 0.1, |
1312 | 1330 | test_fraction_split: float = 0.1, |
@@ -1328,6 +1346,8 @@ def _run( |
1328 | 1346 | base_output_dir (str): |
1329 | 1347 | GCS output directory of job. If not provided a |
1330 | 1348 | timestamped directory in the staging directory will be used. |
| 1349 | + bigquery_destination (str): |
| 1350 | + TODO(asobran) |
1331 | 1351 | training_fraction_split (float): |
1332 | 1352 | The fraction of the input data that is to be |
1333 | 1353 | used to train the Model. |
@@ -1394,6 +1414,7 @@ def _run( |
1394 | 1414 | predefined_split_column_name=predefined_split_column_name, |
1395 | 1415 | model=managed_model, |
1396 | 1416 | gcs_destination_uri_prefix=base_output_dir, |
| 1417 | + bigquery_destination=bigquery_destination |
1397 | 1418 | ) |
1398 | 1419 |
|
1399 | 1420 | return model |
|