Skip to content

Commit

Permalink
feat: enabling AutoML Forecasting training response to include BigQue…
Browse files Browse the repository at this point in the history
…ry location of exported evaluated examples (#657)

* Added BigQuery location of exported evaluated examples from AutoML Forecasting Training Job in training output

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Testing BQ uri output feature for AutoML Forecasting

* Adding changes from dev to master branch

* Removed extra try/except block 

Removed the unnecessary try/except block from the evaluated bigquery uri property method in Automl Forecasting

* Fix lint errors

* Address comments

* Add metadata existence check

Co-authored-by: Mansi Achuthan <mansiachuthan@google.com>
Co-authored-by: Vinny Senthil <vinnysenthil@gmail.com>
Co-authored-by: Hardik Vala <hardikv@google.com>
Co-authored-by: sasha-gitg <44654632+sasha-gitg@users.noreply.github.com>
Co-authored-by: thehardikv <78449654+thehardikv@users.noreply.github.com>
  • Loading branch information
6 people committed Oct 14, 2021
1 parent 293809e commit c1c2326
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 26 additions & 1 deletion google/cloud/aiplatform/training_jobs.py
Expand Up @@ -4418,7 +4418,7 @@ def _run(
encryption_spec=self._model_encryption_spec,
)

return self._run_job(
new_model = self._run_job(
training_task_definition=training_task_definition,
training_task_inputs=training_task_inputs_dict,
dataset=dataset,
Expand All @@ -4430,6 +4430,14 @@ def _run(
model=model,
)

if export_evaluated_data_items:
_LOGGER.info(
"Exported examples available at:\n%s"
% self.evaluated_data_items_bigquery_uri
)

return new_model

@property
def _model_upload_fail_string(self) -> str:
"""Helper property for model upload failure."""
Expand All @@ -4438,6 +4446,23 @@ def _model_upload_fail_string(self) -> str:
"Model."
)

@property
def evaluated_data_items_bigquery_uri(self) -> Optional[str]:
"""BigQuery location of exported evaluated examples from the Training Job
Returns:
str: BigQuery uri for the exported evaluated examples if the export
feature is enabled for training.
None: If the export feature was not enabled for training.
"""

self._assert_gca_resource_is_available()

metadata = self._gca_resource.training_task_metadata
if metadata and "evaluatedDataItemsBigqueryUri" in metadata:
return metadata["evaluatedDataItemsBigqueryUri"]

return None

def _add_additional_experiments(self, additional_experiments: List[str]):
"""Add experiment flags to the training job.
Args:
Expand Down
Expand Up @@ -151,6 +151,9 @@ def mock_pipeline_service_get():
name=_TEST_PIPELINE_RESOURCE_NAME,
state=gca_pipeline_state.PipelineState.PIPELINE_STATE_SUCCEEDED,
model_to_upload=gca_model.Model(name=_TEST_MODEL_NAME),
training_task_metadata={
"evaluatedDataItemsBigqueryUri": _TEST_TRAINING_EXPORT_EVALUATED_DATA_ITEMS_BIGQUERY_DESTINATION_URI
},
)
yield mock_get_training_pipeline

Expand Down

0 comments on commit c1c2326

Please sign in to comment.