From d2185ee1c3bb15822f2a2283efe231faf7053d8e Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Thu, 12 Oct 2023 00:02:52 -0700 Subject: [PATCH] for pydantic provider test by escaping additional bad chars in numpy field name --- nwb_linkml/src/nwb_linkml/generators/pydantic.py | 12 ++++++++++-- .../tests/test_providers/test_provider_schema.py | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/nwb_linkml/src/nwb_linkml/generators/pydantic.py b/nwb_linkml/src/nwb_linkml/generators/pydantic.py index 025f445..def7eed 100644 --- a/nwb_linkml/src/nwb_linkml/generators/pydantic.py +++ b/nwb_linkml/src/nwb_linkml/generators/pydantic.py @@ -24,6 +24,7 @@ The `serialize` method """ import pdb +import re from dataclasses import dataclass, field from pathlib import Path from typing import List, Dict, Set, Tuple, Optional, TypedDict, Type @@ -407,8 +408,15 @@ class NWBPydanticGenerator(PydanticGenerator): shape_part = str(attr.maximum_cardinality) else: shape_part = "*" - # do this cheaply instead of using regex because i want to see if this works at all first... - name_part = attr.name.replace(',', '_').replace(' ', '_').replace('__', '_').replace('|','_') + + # do this with the most heinous chain of string replacements rather than regex + # because i am still figuring out what needs to be subbed lol + name_part = attr.name.replace(',', '_' + ).replace(' ', '_' + ).replace('__', '_' + ).replace('|','_' + ).replace('-','_' + ).replace('+','plus') dim_pieces.append(' '.join([shape_part, name_part])) diff --git a/nwb_linkml/tests/test_providers/test_provider_schema.py b/nwb_linkml/tests/test_providers/test_provider_schema.py index 9218772..d59c3dd 100644 --- a/nwb_linkml/tests/test_providers/test_provider_schema.py +++ b/nwb_linkml/tests/test_providers/test_provider_schema.py @@ -17,6 +17,8 @@ import nwb_linkml from nwb_linkml.maps.naming import version_module_case from nwb_linkml.providers.git import DEFAULT_REPOS from nwb_linkml.adapters import NamespacesAdapter +from nwb_linkml.types.ndarray import NDArray +from nptyping import Shape, UByte CORE_MODULES = ( @@ -71,7 +73,6 @@ def test_linkml_build_from_yaml(tmp_output_dir): res = provider.build_from_yaml(ns_file) -@pytest.mark.skip() @pytest.mark.depends(on=['test_linkml_provider']) @pytest.mark.parametrize( ['class_name', 'test_fields'], @@ -82,7 +83,7 @@ def test_linkml_build_from_yaml(tmp_output_dir): 'comments': Optional[str], 'data': 'TimeSeriesData', 'timestamps': 'Optional', # __name__ just gets the first part of Optional[TimeSeriesTimestamps] - 'control': Optional[List[int]], + 'control': Optional[NDArray[Shape['* num_times'], UByte]], }) ] )