Skip to content

Commit 7e9b454

Browse files
authored
Fixed default pipeline run log when service log is not enabled (#907)
2 parents 32d031e + 9169b21 commit 7e9b454

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

ads/pipeline/ads_pipeline_run.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
4+
# Copyright (c) 2022, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66
import copy
77
import logging
@@ -689,6 +689,16 @@ def _build_filter_expression(self, steps: List = [], log_type: str = None) -> st
689689
sources = []
690690
subjects = []
691691
skipped_step_list = []
692+
693+
is_service_logging_enabled = False
694+
try:
695+
if self.service_logging:
696+
is_service_logging_enabled = True
697+
except LogNotConfiguredError:
698+
logger.warning(
699+
"Service log is not configured for pipeline. Streaming custom log."
700+
)
701+
692702
for step_run in self.step_runs:
693703
if not steps or (step_run.step_name in steps):
694704
step_name = step_run.step_name
@@ -703,7 +713,8 @@ def _build_filter_expression(self, steps: List = [], log_type: str = None) -> st
703713
subjects.append(f"subject = '{step_name}'")
704714
else:
705715
sources.append(f"source = '*{job_run_id}'")
706-
subjects.append(f"subject = '{step_name}'")
716+
if is_service_logging_enabled:
717+
subjects.append(f"subject = '{step_name}'")
707718
else:
708719
subjects.append(f"subject = '{step_name}'")
709720

tests/unitary/default_setup/pipeline/test_pipeline_run.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright (c) 2023 Oracle and/or its affiliates.
3+
# Copyright (c) 2024 Oracle and/or its affiliates.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
55

66
from datetime import datetime
@@ -391,6 +391,8 @@ def test_stream_log(self, mock_stream, mock_sync):
391391
**PIPELINE_RUN_LOG_DETAILS
392392
)
393393
pipeline_run.time_accepted = datetime.now()
394+
service_logging = OCILog()
395+
pipeline_run._set_service_logging_resource(service_logging)
394396
pipeline_run._PipelineRun__stream_log(
395397
ConsolidatedLog(OCILog()),
396398
[custom_script_step.step_name, ml_job_step.step_name],
@@ -749,6 +751,9 @@ def test_build_filter_expression(self):
749751
ml_job_step_without_job_run_id,
750752
]
751753

754+
service_logging = OCILog()
755+
pipeline_run._set_service_logging_resource(service_logging)
756+
752757
consolidated_log_expression = pipeline_run._build_filter_expression()
753758

754759
assert (

0 commit comments

Comments
 (0)