{"record":{"id":"a12c14dfe0043f52","repo":"apache/beam","slug":"vertex-ai-model-monitoring-v2-dependencies-are-not-installed","errorCode":null,"errorMessage":"Vertex AI Model Monitoring v2 dependencies are not installed.","messagePattern":"Vertex AI Model Monitoring v2 dependencies are not installed\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/vertex_ai_model_monitoring_v2.py","lineNumber":89,"sourceCode":"    self.location = location\n    self.display_name = display_name\n    self.model_name = model_name\n    self.model_version_id = model_version_id\n    self.model_monitoring_schema = model_monitoring_schema\n    self.training_dataset = training_dataset\n    self.tabular_objective_spec = tabular_objective_spec\n    self.model_monitor_id = model_monitor_id\n    self.explanation_spec = explanation_spec\n    self.output_spec = output_spec\n    self.notification_spec = notification_spec\n    self.credentials = credentials\n    self.manager = None\n    self.kwargs = kwargs\n\n  def create_model_monitor(self):\n    \"\"\"Creates a ModelMonitor with a deterministic ID or retrieves existing one.\"\"\"\n    if ml_monitoring is None:\n      raise ImportError(\n          'Vertex AI Model Monitoring v2 dependencies are not installed.')\n\n    try:\n      return ml_monitoring.model_monitors.ModelMonitor.create(\n          model_name=self.model_name,\n          model_version_id=self.model_version_id,\n          training_dataset=self.training_dataset,\n          display_name=self.display_name,\n          model_monitoring_schema=self.model_monitoring_schema,\n          tabular_objective_spec=self.tabular_objective_spec,\n          output_spec=self.output_spec,\n          notification_spec=self.notification_spec,\n          explanation_spec=self.explanation_spec,\n          project=self.project_id,\n          location=self.location,\n          credentials=self.credentials,\n          model_monitor_id=self.model_monitor_id,\n          **self.kwargs,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/vertex_ai_model_monitoring_v2.py#L71-L107","documentation":"VertexModelMonitoringV2.create_model_monitor requires google-cloud-aiplatform's model monitoring (v2) module. If the ml_monitoring import is None (dependencies absent), it raises ImportError stating the Vertex AI Model Monitoring v2 dependencies are not installed.","triggerScenarios":"Calling create_model_monitor() (directly or via the setup method of the DoFn) in an environment where the aiplatform SDK lacks model monitoring support or the google-cloud-aiplatform extra is not installed.","commonSituations":"Running on Beam workers with the default apache_beam image that lacks the aiplatform extra; forgetting to include google-cloud-aiplatform in requirements.txt of the pipeline.","solutions":["Install the dependency: pip install apache-beam[gcp] or pip install google-cloud-aiplatform>=1.x with model monitoring support","Add google-cloud-aiplatform to pipeline_options requirements_file so workers install it","Upgrade google-cloud-aiplatform to a version that includes the model_monitoring v2 module"],"exampleFix":"# before\npython -m apache_beam.runners.worker... # missing aiplatform\n# after\npip install 'apache-beam[gcp]' 'google-cloud-aiplatform[model-monitoring]'","handlingStrategy":"validation","validationCode":"try:\n    from google.cloud.aiplatform import model_monitoring as ml_monitoring\nexcept ImportError:\n    raise RuntimeError('Install google-cloud-aiplatform with model monitoring support')","typeGuard":null,"tryCatchPattern":"try:\n    monitor.create_model_monitor()\nexcept ImportError:\n    logger.error('Vertex AI Model Monitoring v2 deps missing; add google-cloud-aiplatform to requirements')\n    raise","preventionTips":["Include apache-beam[gcp] and google-cloud-aiplatform in the job's requirements file","Pin a google-cloud-aiplatform version that ships model_monitoring v2","Smoke-test imports in the worker image before deploying"],"tags":["apache-beam","vertex-ai","dependency","import-error"],"backgroundTag":"missing-optional-dependency","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}