mirror of
https://github.com/p2p-ld/nwb-linkml.git
synced 2024-11-10 00:34:29 +00:00
trying to debug on CI by abusing warnings lol
This commit is contained in:
parent
52754112aa
commit
3a426454c6
4 changed files with 45 additions and 3 deletions
|
@ -12,6 +12,9 @@ packages = [
|
||||||
{include = "nwb_linkml", from="src"},
|
{include = "nwb_linkml", from="src"},
|
||||||
#{include = "nwb_schema_language", from="../nwb_schema_language/src"}
|
#{include = "nwb_schema_language", from="../nwb_schema_language/src"}
|
||||||
]
|
]
|
||||||
|
include = [
|
||||||
|
'src/nwb_linkml/schema/**/*'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
from nwb_linkml.monkeypatch import apply_patches
|
from nwb_linkml.monkeypatch import apply_patches
|
||||||
apply_patches()
|
apply_patches()
|
||||||
|
|
||||||
|
from nwb_linkml.config import Config
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
Manage the operation of nwb_linkml from environmental variables
|
Manage the operation of nwb_linkml from environmental variables
|
||||||
"""
|
"""
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from typing import Any
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pydantic import Field, DirectoryPath, computed_field, field_validator, FieldValidationInfo
|
from pydantic import Field, DirectoryPath, computed_field, field_validator, model_validator, FieldValidationInfo
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
class Config(BaseSettings):
|
class Config(BaseSettings):
|
||||||
|
@ -48,6 +49,15 @@ class Config(BaseSettings):
|
||||||
assert v.exists()
|
assert v.exists()
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@model_validator(mode='after')
|
||||||
|
def folder_exists(self) -> 'Config':
|
||||||
|
for field, path in self.model_dump().items():
|
||||||
|
if isinstance(path, Path):
|
||||||
|
path.mkdir(exist_ok=True, parents=True)
|
||||||
|
assert path.exists()
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.cache_dir.mkdir(exist_ok=True)
|
self.cache_dir.mkdir(exist_ok=True)
|
||||||
self.linkml_dir.mkdir(exist_ok=True)
|
self.linkml_dir.mkdir(exist_ok=True)
|
||||||
|
|
|
@ -4,6 +4,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import yaml
|
||||||
|
from pprint import pformat
|
||||||
|
|
||||||
from typing import Optional, Union, List
|
from typing import Optional, Union, List
|
||||||
from ..fixtures import tmp_output_dir
|
from ..fixtures import tmp_output_dir
|
||||||
|
@ -13,6 +15,7 @@ import pytest
|
||||||
from nwb_linkml.providers.schema import LinkMLProvider, PydanticProvider
|
from nwb_linkml.providers.schema import LinkMLProvider, PydanticProvider
|
||||||
import nwb_linkml
|
import nwb_linkml
|
||||||
from nwb_linkml.maps.naming import version_module_case
|
from nwb_linkml.maps.naming import version_module_case
|
||||||
|
from nwb_linkml.providers.git import DEFAULT_REPOS
|
||||||
|
|
||||||
|
|
||||||
CORE_MODULES = (
|
CORE_MODULES = (
|
||||||
|
@ -40,9 +43,9 @@ def test_linkml_provider(tmp_output_dir, repo_version, schema_version, schema_di
|
||||||
|
|
||||||
provider = LinkMLProvider(path=tmp_output_dir, allow_repo=False)
|
provider = LinkMLProvider(path=tmp_output_dir, allow_repo=False)
|
||||||
# clear any prior output
|
# clear any prior output
|
||||||
shutil.rmtree(provider.path, ignore_errors=True)
|
shutil.rmtree(provider.path)
|
||||||
assert not provider.path.exists()
|
assert not provider.path.exists()
|
||||||
assert not provider.namespace_path('core', repo_version).exists()
|
assert not (provider.namespace_path('core', repo_version) / 'namespace.yaml').exists()
|
||||||
|
|
||||||
# end to end, check that we can get the 'core' repo at the latest version
|
# end to end, check that we can get the 'core' repo at the latest version
|
||||||
# in the gitrepo
|
# in the gitrepo
|
||||||
|
@ -52,6 +55,30 @@ def test_linkml_provider(tmp_output_dir, repo_version, schema_version, schema_di
|
||||||
assert all([mod in core.schema.imports for mod in CORE_MODULES])
|
assert all([mod in core.schema.imports for mod in CORE_MODULES])
|
||||||
assert schema_dir in [path.name for path in (provider.path / 'core').iterdir()]
|
assert schema_dir in [path.name for path in (provider.path / 'core').iterdir()]
|
||||||
|
|
||||||
|
def test_linkml_build_from_yaml(tmp_output_dir):
|
||||||
|
core = DEFAULT_REPOS['core']
|
||||||
|
git_dir = nwb_linkml.Config().git_dir / 'core'
|
||||||
|
if git_dir.exists():
|
||||||
|
shutil.rmtree(str(git_dir))
|
||||||
|
ns_file = core.provide_from_git('2.6.0')
|
||||||
|
assert git_dir.exists()
|
||||||
|
assert ns_file.exists()
|
||||||
|
|
||||||
|
# for the sake of debugging CI...
|
||||||
|
with open(ns_file) as nfile:
|
||||||
|
ns_yaml = yaml.safe_load(nfile)
|
||||||
|
warnings.warn(pformat(ns_yaml))
|
||||||
|
files = [str(f) for f in list(ns_file.parent.glob('*.yaml'))]
|
||||||
|
warnings.warn('\n'.join(files))
|
||||||
|
|
||||||
|
provider = LinkMLProvider(path=tmp_output_dir, allow_repo=False)
|
||||||
|
|
||||||
|
res = provider.build_from_yaml(ns_file)
|
||||||
|
warnings.warn(pformat(res))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip()
|
@pytest.mark.skip()
|
||||||
@pytest.mark.depends(on=['test_linkml_provider'])
|
@pytest.mark.depends(on=['test_linkml_provider'])
|
||||||
|
|
Loading…
Reference in a new issue