def test_list_ingest_jobs(self, mock_jobcontroller_client, mocker): mocker.patch.object( mock_jobcontroller_client, "_jobcontroller_service_stub", return_value=Core.JobControllerServiceStub(grpc.insecure_channel("")), ) feature_set_ref = FeatureSetRef(project="test", name="driver",) mocker.patch.object( mock_jobcontroller_client._jobcontroller_service_stub, "ListIngestionJobs", return_value=ListIngestionJobsResponse( jobs=[ IngestJobProto( id="kafka-to-redis", external_id="job-2222", status=IngestionJobStatus.RUNNING, feature_set_references=[feature_set_ref.to_proto()], source=Source( type=SourceType.KAFKA, kafka_source_config=KafkaSourceConfig( bootstrap_servers="localhost:9092", topic="topic" ), ), stores=[Store(name="redis")], ) ] ), ) # list ingestion jobs by target feature set reference ingest_jobs = mock_jobcontroller_client.list_ingest_jobs( feature_set_ref=feature_set_ref ) assert len(ingest_jobs) >= 1 ingest_job = ingest_jobs[0] assert ( ingest_job.status == IngestionJobStatus.RUNNING and ingest_job.id == "kafka-to-redis" and ingest_job.external_id == "job-2222" and ingest_job.feature_sets[0].name == "driver" and ingest_job.source.source_type == "Kafka" )
def list_ingest_jobs( self, job_id: str = None, feature_set_ref: FeatureSetRef = None, store_name: str = None, ): """ List the ingestion jobs currently registered in Feast, with optional filters. Provides detailed metadata about each ingestion job. Args: job_id: Select specific ingestion job with the given job_id feature_set_ref: Filter ingestion jobs by target feature set (via reference) store_name: Filter ingestion jobs by target feast store's name Returns: List of IngestJobs matching the given filters """ # construct list request feature_set_ref_proto = None if feature_set_ref: feature_set_ref_proto = feature_set_ref.to_proto() list_filter = ListIngestionJobsRequest.Filter( id=job_id, feature_set_reference=feature_set_ref_proto, store_name=store_name, ) request = ListIngestionJobsRequest(filter=list_filter) # make list request & unpack response response = self._core_service.ListIngestionJobs( request, metadata=self._get_grpc_metadata(), ) # type: ignore ingest_jobs = [ IngestJob(proto, self._core_service, auth_metadata_plugin=self._auth_metadata) for proto in response.jobs # type: ignore ] return ingest_jobs