Skip to content

Commit 8ea56e8

Browse files
authored
Operator in Jobs should auto-detect RP (#558)
2 parents 654e8f2 + 6291748 commit 8ea56e8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ads/common/auth.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,13 @@ def create_signer(self) -> Dict:
687687
logger.info(f"Using 'resource_principal' authentication.")
688688
return signer_dict
689689

690+
@staticmethod
691+
def supported():
692+
return any(
693+
os.environ.get(var)
694+
for var in ['JOB_RUN_OCID', 'NB_SESSION_OCID', 'DATAFLOW_RUN_ID', 'PIPELINE_RUN_OCID']
695+
)
696+
690697

691698
class InstancePrincipal(AuthSignerGenerator):
692699
"""

ads/opctl/config/merger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import yaml
1313

14-
from ads.common.auth import AuthType
14+
from ads.common.auth import AuthType, ResourcePrincipal
1515
from ads.opctl import logger
1616
from ads.opctl.config.base import ConfigProcessor
1717
from ads.opctl.config.utils import read_from_ini, _DefaultNoneDict
@@ -115,7 +115,7 @@ def _fill_config_with_defaults(self, ads_config_path: str) -> None:
115115
)
116116
# set default auth
117117
if not self.config["execution"].get("auth", None):
118-
if is_in_notebook_session():
118+
if ResourcePrincipal.supported():
119119
self.config["execution"]["auth"] = (
120120
exec_config.get("auth") or AuthType.RESOURCE_PRINCIPAL
121121
)

0 commit comments

Comments
 (0)