Skip to content

Commit 86c4f48

Browse files
committed
Use dataproc console url instead of gcs for log uri
Signed-off-by: Khor Shu Heng <khor.heng@gojek.com>
1 parent f4f345e commit 86c4f48

1 file changed

Lines changed: 39 additions & 10 deletions

File tree

sdk/python/feast/pyspark/launchers/gcloud/dataproc.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626

2727
class DataprocJobMixin:
2828
def __init__(
29-
self, job: Job, refresh_fn: Callable[[], Job], cancel_fn: Callable[[], None]
29+
self,
30+
job: Job,
31+
refresh_fn: Callable[[], Job],
32+
cancel_fn: Callable[[], None],
33+
project: str,
34+
region: str,
3035
):
3136
"""
3237
Implementation of common methods for different types of SparkJob running on Dataproc cluster.
@@ -39,6 +44,8 @@ def __init__(
3944
self._job = job
4045
self._refresh_fn = refresh_fn
4146
self._cancel_fn = cancel_fn
47+
self._project = project
48+
self._region = region
4249

4350
def get_id(self) -> str:
4451
"""
@@ -134,7 +141,10 @@ def get_start_time(self):
134141
return self._job.status.state_start_time
135142

136143
def get_log_uri(self) -> Optional[str]:
137-
return self._job.driver_output_resource_uri
144+
return (
145+
f"https://console.cloud.google.com/dataproc/jobs/{self.get_id()}"
146+
f"?region={self._region}&project={self._project}"
147+
)
138148

139149

140150
class DataprocRetrievalJob(DataprocJobMixin, RetrievalJob):
@@ -147,6 +157,8 @@ def __init__(
147157
job: Job,
148158
refresh_fn: Callable[[], Job],
149159
cancel_fn: Callable[[], None],
160+
project: str,
161+
region: str,
150162
output_file_uri: str,
151163
):
152164
"""
@@ -155,7 +167,7 @@ def __init__(
155167
Args:
156168
output_file_uri (str): Uri to the historical feature retrieval job output file.
157169
"""
158-
super().__init__(job, refresh_fn, cancel_fn)
170+
super().__init__(job, refresh_fn, cancel_fn, project, region)
159171
self._output_file_uri = output_file_uri
160172

161173
def get_output_file_uri(self, timeout_sec=None, block=True):
@@ -187,9 +199,11 @@ def __init__(
187199
job: Job,
188200
refresh_fn: Callable[[], Job],
189201
cancel_fn: Callable[[], None],
202+
project: str,
203+
region: str,
190204
job_hash: str,
191205
) -> None:
192-
super().__init__(job, refresh_fn, cancel_fn)
206+
super().__init__(job, refresh_fn, cancel_fn, project, region)
193207
self._job_hash = job_hash
194208

195209
def get_hash(self) -> str:
@@ -379,21 +393,30 @@ def historical_feature_retrieval(
379393
job_params, {"dev.feast.outputuri": job_params.get_destination_path()}
380394
)
381395
return DataprocRetrievalJob(
382-
job, refresh_fn, cancel_fn, job_params.get_destination_path()
396+
job,
397+
refresh_fn,
398+
cancel_fn,
399+
job_params.get_destination_path(),
400+
self.project_id,
401+
self.region,
383402
)
384403

385404
def offline_to_online_ingestion(
386405
self, ingestion_job_params: BatchIngestionJobParameters
387406
) -> BatchIngestionJob:
388407
job, refresh_fn, cancel_fn = self.dataproc_submit(ingestion_job_params, {})
389-
return DataprocBatchIngestionJob(job, refresh_fn, cancel_fn)
408+
return DataprocBatchIngestionJob(
409+
job, refresh_fn, cancel_fn, self.project_id, self.region
410+
)
390411

391412
def start_stream_to_online_ingestion(
392413
self, ingestion_job_params: StreamIngestionJobParameters
393414
) -> StreamIngestionJob:
394415
job, refresh_fn, cancel_fn = self.dataproc_submit(ingestion_job_params, {})
395416
job_hash = ingestion_job_params.get_job_hash()
396-
return DataprocStreamingIngestionJob(job, refresh_fn, cancel_fn, job_hash)
417+
return DataprocStreamingIngestionJob(
418+
job, refresh_fn, cancel_fn, self.project_id, self.region, job_hash
419+
)
397420

398421
def get_job_by_id(self, job_id: str) -> SparkJob:
399422
job = self.job_client.get_job(
@@ -414,14 +437,20 @@ def _dataproc_job_to_spark_job(self, job: Job) -> SparkJob:
414437

415438
if job_type == SparkJobType.HISTORICAL_RETRIEVAL.name.lower():
416439
output_path = job.pyspark_job.properties.get("dev.feast.outputuri", "")
417-
return DataprocRetrievalJob(job, refresh_fn, cancel_fn, output_path)
440+
return DataprocRetrievalJob(
441+
job, refresh_fn, cancel_fn, self.project_id, self.region, output_path
442+
)
418443

419444
if job_type == SparkJobType.BATCH_INGESTION.name.lower():
420-
return DataprocBatchIngestionJob(job, refresh_fn, cancel_fn)
445+
return DataprocBatchIngestionJob(
446+
job, refresh_fn, cancel_fn, self.project_id, self.region
447+
)
421448

422449
if job_type == SparkJobType.STREAM_INGESTION.name.lower():
423450
job_hash = job.labels[self.JOB_HASH_LABEL_KEY]
424-
return DataprocStreamingIngestionJob(job, refresh_fn, cancel_fn, job_hash)
451+
return DataprocStreamingIngestionJob(
452+
job, refresh_fn, cancel_fn, self.project_id, self.region, job_hash
453+
)
425454

426455
raise ValueError(f"Unrecognized job type: {job_type}")
427456

0 commit comments

Comments
 (0)