Skip to content

Importing class Model from google.cloud.aiplatform.models is slow #1994

Open

Description

@shahar1

Environment details

  • OS type and version:
  • Python version: 3.8
  • pip version: 20.1.1
  • google-cloud-aiplatform version: google-cloud-aiplatform>=1.7.1,<2.0.0

Steps to reproduce

  1. Create a Python file in an environment where google-cloud-aiplatform is installed
  2. Type: from google.cloud.aiplatform.models import Model
  3. Run it with time python

Code example

from google.cloud.aiplatform.models import Model

Stack trace

real    0m0.836s
user    0m1.085s
sys     0m1.045s

Compare it with an import of an entire package such as pandas (import pandas as pd):

real    0m0.271s
user    0m0.541s
sys     0m0.930s

I originally opened this issue in Apache Airflow repository, and I was referred to here. The time of import makes parsing of Airflow DAGs that utilize Vertex AI operators significantly slower.

Activity

  1. added
    api: vertex-ai
    on Feb 24, 2023
  2. potiuk commented on Feb 24, 2023

    @potiuk

    Indeed. It's super slow.

  3. dvmorris commented on Sep 27, 2023

    @dvmorris

    Any updates on this? I'm experiencing something similar.

  4. ethanjyx commented on Oct 26, 2024

    @ethanjyx
    $ time python -c “from vertexai.generative_models import GenerativeModel, Part, GenerationResponse”
    
    real    0m3.919s
    user    0m3.535s
    sys     0m0.685s
    

    it takes 3 seonds to import, which is insane

  5. potiuk commented on Oct 26, 2024

    @potiuk

    it takes 3 seonds to import, which is insane

    Indeed. Why don't you raise an issue ti google library @ethanjyx ? - it sounds strange to have an issue in airflow about slow import of some libarary. It should be created there. Can you open an issue - or check if there is one there. Until then I will convert it into a discussion - as there is nothing in Airflow we can do about it.

  6. potiuk commented on Oct 26, 2024

    @potiuk

    Ah... It's already in googleapis 🤯 .... Yes. Let me add to it, it is insane.

  7. pjsg commented on May 15, 2025

    @pjsg

    Is there any progress on this?

    This is on MacOS

    $ time python -c "import vertexai"
    
    real	0m4.156s
    user	0m2.810s
    sys	0m0.846s
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: vertex-ai

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions