From 59e1c36dc14a9e50ab358733542b0643ca31b90f Mon Sep 17 00:00:00 2001 From: Amos Jun-yeung Ng Date: Mon, 3 Jul 2023 23:48:19 +0700 Subject: [PATCH] Lazily load yaml to avoid libyaml dependency --- ice/metrics/gold_standards.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ice/metrics/gold_standards.py b/ice/metrics/gold_standards.py index 145856c4..7c0e43d6 100644 --- a/ice/metrics/gold_standards.py +++ b/ice/metrics/gold_standards.py @@ -16,8 +16,6 @@ from pydantic import BaseModel from pydantic.generics import GenericModel from structlog.stdlib import get_logger -from yaml import CLoader as Loader -from yaml import load from ice.paper import Paper from ice.settings import settings @@ -60,6 +58,9 @@ class Config: def _parse_answer( _answer: str, model: Type[ParsedGoldStandardType] ) -> ParsedGoldStandardType: + from yaml import CLoader as Loader + from yaml import load + data = load(_answer, Loader=Loader) return model.parse_obj(data)