Skip to content

Commit d33ad0f

Browse files
authored
Merge pull request #29 from philschmid/fix-input-fn
added fix
2 parents 2b50a4c + 96bf9a2 commit d33ad0f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sagemaker_huggingface_inference_toolkit/handler_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ def preprocess(self, input_data, content_type):
126126
"""
127127
# raises en error when using zero-shot-classification or table-question-answering, not possible due to nested properties
128128
if (
129-
os.environ["HF_TASK"] == "zero-shot-classification" or os.environ["HF_TASK"] == "table-question-answering"
129+
os.environ.get("HF_TASK", None) == "zero-shot-classification"
130+
or os.environ.get("HF_TASK", None) == "table-question-answering"
130131
) and content_type == content_types.CSV:
131132
raise PredictionException(
132-
f"content type {content_type} not support with {os.environ['HF_TASK']}, use different content_type",
133+
f"content type {content_type} not support with {os.environ.get('HF_TASK', 'unknown task')}, use different content_type",
133134
400,
134135
)
135136

0 commit comments

Comments
 (0)