1
1
from abc import ABC , abstractmethod
2
2
from typing import TextIO , Union , Optional , Callable , Dict , Type , Any , List
3
3
from logging import getLogger
4
- from functools import lru_cache
5
4
6
5
from pydantic import BaseModel
7
6
from hbreader import FileInfo , hbread
@@ -150,15 +149,10 @@ def _read_source(self,
150
149
base_dir : Optional [str ] = None ,
151
150
metadata : Optional [FileInfo ] = None ,
152
151
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
162
156
163
157
if not isinstance (source , dict ):
164
158
# Try to get local version of schema, if one is known to exist
@@ -170,15 +164,8 @@ def _read_source(self,
170
164
logger = getLogger ('linkml_runtime.loaders.Loader' )
171
165
logger .debug (f"Error converting stringlike source to local linkml file: { source } , got: { e } " )
172
166
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 )
177
168
else :
178
169
data = source
179
170
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