From 9c04ce35df5afc49c709283f458c6216eeb75674 Mon Sep 17 00:00:00 2001 From: Paul Felt Date: Tue, 26 Oct 2021 13:08:55 -0600 Subject: [PATCH] if ACD_KEY is empty, use a NoAuthAuthenticator (supports running against development ACD deployments without IAM keys) Signed-off-by: Paul Felt --- services/nlp-insights/text_analytics/acd/acd_service.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/nlp-insights/text_analytics/acd/acd_service.py b/services/nlp-insights/text_analytics/acd/acd_service.py index 68b136ed..1bd1133d 100644 --- a/services/nlp-insights/text_analytics/acd/acd_service.py +++ b/services/nlp-insights/text_analytics/acd/acd_service.py @@ -9,6 +9,7 @@ from fhir.resources.quantity import Quantity from fhir.resources.timing import Timing from ibm_cloud_sdk_core.authenticators.iam_authenticator import IAMAuthenticator +from ibm_cloud_sdk_core.authenticators.no_auth_authenticator import NoAuthAuthenticator from ibm_whcs_sdk import annotator_for_clinical_data as acd from text_analytics.abstract_nlp_service import NLPService @@ -44,8 +45,12 @@ def __init__(self, json_string): self.version = config_dict.get('version') def process(self, text): + if self.acd_key is None or len(self.acd_key) == 0: + authenticator = NoAuthAuthenticator() + else: + authenticator = IAMAuthenticator(apikey=self.acd_key) service = acd.AnnotatorForClinicalDataV1( - authenticator=IAMAuthenticator(apikey=self.acd_key), + authenticator=authenticator, version=self.version ) service.set_service_url(self.acd_url)