From e6a98107aee79bdb629967c1f649a3e01e454bce Mon Sep 17 00:00:00 2001 From: adrian-wojcik Date: Fri, 15 Mar 2024 09:04:48 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Change=20logic=20of=20chec?= =?UTF-8?q?king=20credentials=5Fkeys=20dictionary=20from=20task=20to=20the?= =?UTF-8?q?=20source=20level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- viadot/sources/sap_rfc.py | 20 ++++++++++++++++++++ viadot/tasks/sap_rfc.py | 10 ---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/viadot/sources/sap_rfc.py b/viadot/sources/sap_rfc.py index 365fa72f6..261a673bb 100644 --- a/viadot/sources/sap_rfc.py +++ b/viadot/sources/sap_rfc.py @@ -266,6 +266,16 @@ def __init__( self.sap_credentials_key = sap_credentials_key self.env = env + if isinstance(sap_credentials, dict): + credentials_keys = list(sap_credentials.keys()) + required_credentials_params = ["sysnr", "user", "passwd", "ashost"] + for key in required_credentials_params: + if key not in credentials_keys: + self.logger.warning( + f"Required key '{key}' not found in your 'sap_credentials' dictionary!" + ) + sap_credentials = None + if sap_credentials is None: logger.warning( f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in sap_credentials parameter." @@ -718,6 +728,16 @@ def __init__( self.sap_credentials_key = sap_credentials_key self.env = env + if isinstance(sap_credentials, dict): + credentials_keys = list(sap_credentials.keys()) + required_credentials_params = ["sysnr", "user", "passwd", "ashost"] + for key in required_credentials_params: + if key not in credentials_keys: + self.logger.warning( + f"Required key '{key}' not found in your 'sap_credentials' dictionary!" + ) + sap_credentials = None + if sap_credentials is None: logger.warning( f"Your credentials will use {env} environment from local config. If you would like to use different one - please specified it in sap_credentials parameter." diff --git a/viadot/tasks/sap_rfc.py b/viadot/tasks/sap_rfc.py index b2ef7552b..469b0b1df 100644 --- a/viadot/tasks/sap_rfc.py +++ b/viadot/tasks/sap_rfc.py @@ -133,16 +133,6 @@ def run( pd.DataFrame: DataFrame with SAP data. """ - if isinstance(sap_credentials, dict): - credentials_keys = list(sap_credentials.keys()) - required_credentials_params = ["sysnr", "user", "passwd", "ashost"] - for key in required_credentials_params: - if key not in credentials_keys: - self.logger.warning( - f"Required key '{key}' not found in your 'sap_credentials' dictionary!" - ) - sap_credentials = None - if sap_credentials is None: credentials_str = AzureKeyVaultSecret( secret=sap_credentials_key,