11from abc import ABC , abstractmethod
22from typing import TextIO , Union , Optional , Callable , Dict , Type , Any , List
33from logging import getLogger
4- from functools import lru_cache
54
65from pydantic import BaseModel
76from hbreader import FileInfo , hbread
@@ -150,15 +149,10 @@ def _read_source(self,
150149 base_dir : Optional [str ] = None ,
151150 metadata : Optional [FileInfo ] = None ,
152151 accept_header : Optional [str ] = "text/plain, application/yaml;q=0.9" ) -> Union [dict , str ]:
153-
154- # avoid instantiating unhashable FileInfo type by getting default base_path, if any
155- if base_dir is None :
156- if metadata is not None :
157- base_dir = str (metadata .base_path ) if metadata .base_path is not None else None
158- else :
159- base_dir = str (FileInfo ().base_path ) if FileInfo ().base_path is not None else None
160- elif base_dir is not None :
161- base_dir = str (base_dir )
152+ if metadata is None :
153+ metadata = FileInfo ()
154+ if base_dir and not metadata .base_path :
155+ metadata .base_path = base_dir
162156
163157 if not isinstance (source , dict ):
164158 # Try to get local version of schema, if one is known to exist
@@ -170,15 +164,8 @@ def _read_source(self,
170164 logger = getLogger ('linkml_runtime.loaders.Loader' )
171165 logger .debug (f"Error converting stringlike source to local linkml file: { source } , got: { e } " )
172166
173- if not isinstance (metadata , FileInfo ):
174- data = self ._hashable_read (source , base_dir , accept_header )
175- else :
176- data = hbread (source , metadata , base_dir , accept_header )
167+ data = hbread (source , metadata , base_dir , accept_header )
177168 else :
178169 data = source
179170
180- return data
181-
182- @lru_cache (maxsize = CACHE_SIZE )
183- def _hashable_read (self , source : Union [dict , TextIO ], base_dir : Optional [str ] = None , accept_header : Optional [str ] = None ):
184- return hbread (source , None , base_dir , accept_header )
171+ return data
0 commit comments