mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
weird python relative import error from not having version naming
This commit is contained in:
parent
94c204e8ea
commit
1f61dca46f
1 changed files with 8 additions and 4 deletions
|
@ -183,10 +183,10 @@ class Provider(ABC):
|
||||||
module_path = Path(importlib.util.find_spec('nwb_linkml').origin).parent
|
module_path = Path(importlib.util.find_spec('nwb_linkml').origin).parent
|
||||||
builtin_namespaces = []
|
builtin_namespaces = []
|
||||||
if self.PROVIDES == 'linkml':
|
if self.PROVIDES == 'linkml':
|
||||||
namespace_path = module_path / 'schema'
|
namespace_path = module_path / 'schema' / 'linkml'
|
||||||
builtin_namespaces = list(namespace_path.iterdir())
|
builtin_namespaces = list(namespace_path.iterdir())
|
||||||
elif self.PROVIDES == 'pydantic':
|
elif self.PROVIDES == 'pydantic':
|
||||||
namespace_path = module_path / 'models'
|
namespace_path = module_path / 'models' / 'pydantic'
|
||||||
builtin_namespaces = list(namespace_path.iterdir())
|
builtin_namespaces = list(namespace_path.iterdir())
|
||||||
|
|
||||||
for ns_dir in builtin_namespaces + list(self.path.iterdir()):
|
for ns_dir in builtin_namespaces + list(self.path.iterdir()):
|
||||||
|
@ -557,8 +557,8 @@ class PydanticProvider(Provider):
|
||||||
return serialized
|
return serialized
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def module_name(self, namespace:str, version:Optional[str]=None) -> str:
|
def module_name(self, namespace:str, version: Optional[str]=None) -> str:
|
||||||
name_pieces = ['nwb_linkml', 'models', namespace]
|
name_pieces = ['nwb_linkml', 'models', 'pydantic', namespace]
|
||||||
if version is not None:
|
if version is not None:
|
||||||
name_pieces.append(version_module_case(version))
|
name_pieces.append(version_module_case(version))
|
||||||
module_name = '.'.join(name_pieces)
|
module_name = '.'.join(name_pieces)
|
||||||
|
@ -582,6 +582,10 @@ class PydanticProvider(Provider):
|
||||||
Returns:
|
Returns:
|
||||||
:class:`types.ModuleType`
|
:class:`types.ModuleType`
|
||||||
"""
|
"""
|
||||||
|
# get latest version if None
|
||||||
|
if version is None:
|
||||||
|
version = self.versions[namespace][-1]
|
||||||
|
|
||||||
path = self.namespace_path(namespace, version) / 'namespace.py'
|
path = self.namespace_path(namespace, version) / 'namespace.py'
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
raise ImportError(f'Module has not been built yet {path}')
|
raise ImportError(f'Module has not been built yet {path}')
|
||||||
|
|
Loading…
Reference in a new issue