Execute a DQM job synchronously. Manages status transitions.
(self, job_id: str, monitoring_service)
| 101 | self._offline_store.save_monitoring_metrics(self._config, "job", [job]) |
| 102 | |
| 103 | def execute_job(self, job_id: str, monitoring_service) -> Dict[str, Any]: |
| 104 | """Execute a DQM job synchronously. Manages status transitions.""" |
| 105 | job = self.get_job(job_id) |
| 106 | if job is None: |
| 107 | raise ValueError(f"Failed to find DQM job '{job_id}'") |
| 108 | |
| 109 | self.update_status(job_id, JOB_STATUS_RUNNING) |
| 110 | |
| 111 | try: |
| 112 | params = job.get("parameters") or {} |
| 113 | job_type = job["job_type"] |
| 114 | project = job["project_id"] |
| 115 | |
| 116 | if job_type == "auto_compute": |
| 117 | result = monitoring_service.auto_compute( |
| 118 | project=project, |
| 119 | feature_view_name=job.get("feature_view_name"), |
| 120 | ) |
| 121 | elif job_type == "baseline": |
| 122 | result = monitoring_service.compute_baseline( |
| 123 | project=project, |
| 124 | feature_view_name=job.get("feature_view_name"), |
| 125 | feature_names=params.get("feature_names"), |
| 126 | ) |
| 127 | elif job_type == "compute": |
| 128 | result = monitoring_service.compute_metrics( |
| 129 | project=project, |
| 130 | feature_view_name=job.get("feature_view_name"), |
| 131 | feature_names=params.get("feature_names"), |
| 132 | start_date=date.fromisoformat(params["start_date"]) |
| 133 | if params.get("start_date") |
| 134 | else None, |
| 135 | end_date=date.fromisoformat(params["end_date"]) |
| 136 | if params.get("end_date") |
| 137 | else None, |
| 138 | granularity=params.get("granularity", "daily"), |
| 139 | set_baseline=params.get("set_baseline", False), |
| 140 | ) |
| 141 | else: |
| 142 | raise ValueError(f"Unknown job type '{job_type}'") |
| 143 | |
| 144 | self.update_status(job_id, JOB_STATUS_COMPLETED, result_summary=result) |
| 145 | return result |
| 146 | |
| 147 | except Exception as e: |
| 148 | self.update_status(job_id, JOB_STATUS_FAILED, error_message=str(e)) |
| 149 | raise |
no test coverage detected