statmike / vertex-ai-mlops

Google Cloud Platform Vertex AI end-to-end workflows for machine learning operations
Apache License 2.0
450 stars 202 forks source link

02c: failure of import aiplatform from google_cloud_pipeline_components #51

Closed JonB451 closed 6 months ago

JonB451 commented 10 months ago

The following fails in current version:

from google_cloud_pipeline_components import aiplatform as gcc_aip

JonB451 commented 10 months ago

A workaround may be:

from google.cloud import aiplatform as gcc_aip

though this leads, later in the notebook, to:

AttributeError: module 'google.cloud.aiplatform' has no attribute 'TabularDatasetCreateOp'

khadijakhaldi commented 10 months ago

@JonB451 did you solve this ?

statmike commented 10 months ago

Hello @khadijakhaldi and @JonB451 I just noticed this issue as closed. I took a look and the SDK for kfp and google_cloud_pipeline_components have shift a little since this notebook was create. I just pushed an update version of the notebook that should resolve this problem. I tested it through running the pipeline and it worked. Thank You! @statmike

JonB451 commented 10 months ago

Thanks @statmike . I've had to move onto something else for now, but will let you know when i get back to this. It's still high enough up my priorities that i hope that should be possible in the coming weeks so i will feedback if it worked here too. Thanks again, loads. You are a brilliant teacher, and generours, in material and in spirit it seems!

JonB451 commented 10 months ago

@khadijakhaldi No, i didn't.

JonB451 commented 10 months ago

@statmike Unfortunately, after pulling these changes, the imports do not work in my env.

Despite replicating your procedures as closely as possible there was at least one difference, in the creation of the notebook instance and its env version, if i remember correctly. I don't think the 'TensorFlow Enterprise 2.3' env was available (Support End Date: 16.08.23) so i used 'TensorFlow Enterprise 2.6' which is python3.9 (rather 3.7), as you can see below in excerpts from the error.


ImportError Traceback (most recent call last)

Cell In[4], line 8 _----> 8 from google_cloud_pipeline_components.v1.automl.training_job import AutoMLTabularTrainingJobRunOp_

File /opt/conda/lib/python3.9/site-packages/google_cloud_pipeline_components/v1/automl/trainingjob/init.py:16 ---> 16 from google_cloud_pipeline_components.v1.automl.training_job.automl_forecasting_training_job.component import automl_forecasting_training_job as AutoMLForecastingTrainingJobRunOp_

File /opt/conda/lib/python3.9/site-packages/google_cloud_pipeline_components/v1/automl/training_job/automl_forecasting_trainingjob/component.py:22 ---> 22 from kfp.dsl import Input_

ImportError: cannot import name 'Input' from 'kfp.dsl' (/opt/conda/lib/python3.9/site-packages/kfp/dsl/init.py)

statmike commented 10 months ago

Hello @JonB451 ,

Any notebook environment should work for this. The main thing is the package installs with:

!pip install kfp google-cloud-pipeline-components google-cloud-aiplatform -q -U

To test this out I started a new environment, did these pip installs and tried importing and checking versions:

from google.cloud import aiplatform

import kfp
from kfp.v2 import compiler
#import kfp.v2.dsl as dsl
import google_cloud_pipeline_components as gcc_aip
from google_cloud_pipeline_components.v1.dataset import TabularDatasetCreateOp
from google_cloud_pipeline_components.v1.automl.training_job import AutoMLTabularTrainingJobRunOp
from google_cloud_pipeline_components.v1.endpoint import EndpointCreateOp, ModelDeployOp

Maybe try fresh pip installs with the -U option?

JonB451 commented 8 months ago

Hello @statmike.

Sorry i didn't respond sooner but i haven't been able to continue with this course before my GCP trial runs out.

Although i cannot remember clearly now, i wanted to thank you for your reply and to respond. My memory is that you were right, and this was resolved as you suggested with fresh installs.

All the best. Sad not to be continuing your great course!