def test_success(self, mock_hook):
        task = MLEngineDeleteVersionOperator(
            task_id="task-id",
            project_id=TEST_PROJECT_ID,
            model_name=TEST_MODEL_NAME,
            version_name=TEST_VERSION_NAME,
            gcp_conn_id=TEST_GCP_CONN_ID,
            delegate_to=TEST_DELEGATE_TO,
        )

        task.execute(None)

        mock_hook.assert_called_once_with(delegate_to=TEST_DELEGATE_TO,
                                          gcp_conn_id=TEST_GCP_CONN_ID)
        mock_hook.return_value.delete_version.assert_called_once_with(
            project_id=TEST_PROJECT_ID,
            model_name=TEST_MODEL_NAME,
            version_name=TEST_VERSION_NAME)
 def test_missing_model_name(self):
     with self.assertRaises(AirflowException):
         MLEngineDeleteVersionOperator(
             task_id="task-id",
             project_id=TEST_PROJECT_ID,
             model_name=None,
             version_name=TEST_VERSION_NAME,
             gcp_conn_id=TEST_GCP_CONN_ID,
             delegate_to=TEST_DELEGATE_TO,
         )
Beispiel #3
0
        task_id="list-version-result",
    )

    prediction = MLEngineBatchPredictionOperator(
        task_id="prediction",
        project_id="polidea-airflow",
        job_id="prediciton-{{ ts_nodash }}-{{ params.model_name }}",
        region="us-central1",
        model_name=MODEL_NAME,
        data_format="TEXT",
        input_paths=[PREDICTION_INPUT],
        output_path=PREDICTION_OUTPUT,
    )

    delete_version = MLEngineDeleteVersionOperator(task_id="delete-version",
                                                   project_id=PROJECT_ID,
                                                   model_name=MODEL_NAME,
                                                   version_name="v1")

    delete_model = MLEngineDeleteModelOperator(task_id="delete-model",
                                               project_id=PROJECT_ID,
                                               model_name=MODEL_NAME,
                                               delete_contents=True)

    training >> create_version
    training >> create_version_2
    create_model >> get_model >> get_model_result
    create_model >> create_version >> create_version_2 >> set_defaults_version >> list_version
    create_version >> prediction
    create_version_2 >> prediction
    prediction >> delete_version
    list_version >> list_version_result