Skip to content

Commit 0af797c

Browse files
committed
added supported static method in ResourcePrincipal
1 parent cf159e6 commit 0af797c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ads/common/auth.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,10 @@ 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(os.environ.get(var) for var in ['JOB_RUN_OCID', 'NB_SESSION_OCID', 'DATAFLOW_RUN_ID'])
693+
690694

691695
class InstancePrincipal(AuthSignerGenerator):
692696
"""

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() or is_in_jobrun():
118+
if ResourcePrincipal.supported():
119119
self.config["execution"]["auth"] = (
120120
exec_config.get("auth") or AuthType.RESOURCE_PRINCIPAL
121121
)

0 commit comments

Comments
 (0)