diff --git a/nwb_linkml/src/nwb_linkml/adapters/dataset.py b/nwb_linkml/src/nwb_linkml/adapters/dataset.py index d990eac..02b1cc6 100644 --- a/nwb_linkml/src/nwb_linkml/adapters/dataset.py +++ b/nwb_linkml/src/nwb_linkml/adapters/dataset.py @@ -164,7 +164,7 @@ class MapArrayLikeAttributes(DatasetMap): if all([cls.dims, cls.shape]) and \ cls.neurodata_type_inc != 'VectorData' and \ has_attrs(cls) and \ - (dtype is 'AnyType' or dtype in flat_to_linkml): + (dtype == 'AnyType' or dtype in flat_to_linkml): return True else: diff --git a/nwb_linkml/src/nwb_linkml/providers/schema.py b/nwb_linkml/src/nwb_linkml/providers/schema.py index 8ce85d7..2af3119 100644 --- a/nwb_linkml/src/nwb_linkml/providers/schema.py +++ b/nwb_linkml/src/nwb_linkml/providers/schema.py @@ -82,6 +82,11 @@ class Provider(ABC): Attributes: config (:class:`.Config`): Configuration for the directories used by this provider, unless overridden by ``path`` + allow_repo (bool): Allow the pathfinder to return the installed repository/package, + useful to enforce building into temporary directories, decoupling finding a path + during loading vs. building. Building into the repo is still possible if both + namespace and version are provided (ie. the path is fully qualified) and + :attr:`.config`'s path is the repository path. cache_dir (:class:`pathlib.Path`): The main cache directory under which the other providers will store the things they provide """ @@ -90,6 +95,7 @@ class Provider(ABC): def __init__(self, path: Optional[Path] = None, + allow_repo: bool = True, verbose: bool = True): if path is not None: config = Config(cache_dir=path) @@ -97,6 +103,7 @@ class Provider(ABC): config = Config() self.config = config self.cache_dir = config.cache_dir + self.allow_repo = allow_repo self.verbose = verbose @property @@ -124,7 +131,7 @@ class Provider(ABC): self, namespace: str, version: Optional[str] = None, - allow_repo: bool = True + allow_repo: Optional[bool] = None ) -> Path: """ Get the location for a given namespace of this type. @@ -141,12 +148,11 @@ class Provider(ABC): recent *version*, but the most recently *generated* version because it's assumed that's the one you want if you're just gesturally reaching for one. - allow_repo (bool): Allow the pathfinder to return the installed repository/package, - useful to enforce building into temporary directories, decoupling finding a path - during loading vs. building. Building into the repo is still possible if both - namespace and version are provided (ie. the path is fully qualified) and - :attr:`.config`'s path is the repository path. + allow_repo (bool): Optional - override instance-level ``allow_repo`` attr """ + if allow_repo is None: + allow_repo = self.allow_repo + namespace_module = module_case(namespace) namespace_path = self.path / namespace_module if not namespace_path.exists() and namespace in ('core', 'hdmf-common') and allow_repo: diff --git a/nwb_linkml/tests/test_providers/test_provider_schema.py b/nwb_linkml/tests/test_providers/test_provider_schema.py index 2d8ae5c..336eb1f 100644 --- a/nwb_linkml/tests/test_providers/test_provider_schema.py +++ b/nwb_linkml/tests/test_providers/test_provider_schema.py @@ -38,10 +38,11 @@ CORE_MODULES = ( ) def test_linkml_provider(tmp_output_dir, repo_version, schema_version, schema_dir): - provider = LinkMLProvider(path=tmp_output_dir) + provider = LinkMLProvider(path=tmp_output_dir, allow_repo=False) # clear any prior output shutil.rmtree(provider.path, ignore_errors=True) assert not provider.path.exists() + assert not provider.namespace_path('core', repo_version).exists() # end to end, check that we can get the 'core' repo at the latest version # in the gitrepo