Skip to content

Commit

Permalink
feat: vendor jsonasobj2
Browse files Browse the repository at this point in the history
  • Loading branch information
ticapix committed Jan 13, 2025
1 parent ad74966 commit c3c0d1b
Show file tree
Hide file tree
Showing 42 changed files with 418 additions and 39 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ MODEL_DIR = ../linkml-model/linkml_model/

update_model:
cp -pr $(MODEL_DIR)/* linkml_runtime/linkml_model
sed -i 's/from jsonasobj2/from linkml_runtime.utils.jsonasobj2/g' linkml_runtime/linkml_model/*.py

test:
poetry run pytest
Expand All @@ -16,3 +17,4 @@ test:
# temporary measure until linkml-model is synced
linkml_runtime/processing/validation_datamodel.py: linkml_runtime/processing/validation_datamodel.yaml
gen-python $< > $@.tmp && mv $@.tmp $@
sed -i 's/from jsonasobj2/from linkml_runtime.utils.jsonasobj2/g' linkml_runtime/processing/validation_datamodel.py
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ It also includes the [SchemaView](https://linkml.io/linkml/developers/manipulati
## Notebooks

See the [notebooks](https://github.com/linkml/linkml-runtime/tree/main/notebooks) folder for examples

## Development

### Measure tests code coverage

```shell
poetry add pytest-coverage
poetry run coverage run -m pytest # run the existing tests, measuring coverage
poetry run coverage html # to generate an HTML, browsable report
```
2 changes: 1 addition & 1 deletion linkml_runtime/dumpers/json_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from linkml_runtime.utils.context_utils import CONTEXTS_PARAM_TYPE
from linkml_runtime.utils.formatutils import remove_empty_items
from linkml_runtime.utils.yamlutils import YAMLRoot, as_json_object
from jsonasobj2 import JsonObj
from linkml_runtime.utils.jsonasobj2 import JsonObj


class JSONDumper(Dumper):
Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/linkml_model/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dataclasses
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass

Expand Down
4 changes: 2 additions & 2 deletions linkml_runtime/loaders/loader_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pydantic import BaseModel
from hbreader import FileInfo, hbread
from jsonasobj2 import as_dict, JsonObj
from linkml_runtime.utils.jsonasobj2 import as_dict, JsonObj

from linkml_runtime.utils.yamlutils import YAMLRoot
from linkml_runtime import URI_TO_LOCAL
Expand Down Expand Up @@ -168,4 +168,4 @@ def _read_source(self,
else:
data = source

return data
return data
2 changes: 1 addition & 1 deletion linkml_runtime/processing/validation_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dataclasses
import sys
import re
from jsonasobj2 import JsonObj, as_dict
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict
from typing import Optional, List, Union, Dict, ClassVar, Any
from dataclasses import dataclass
from linkml_runtime.linkml_model.meta import (
Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/utils/context_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional, Union, List, Any, Dict, Callable

import yaml
from jsonasobj2 import JsonObj, loads
from linkml_runtime.utils.jsonasobj2 import JsonObj, loads

CONTEXT_TYPE = Union[str, dict, JsonObj]
CONTEXTS_PARAM_TYPE = Optional[Union[CONTEXT_TYPE, List[CONTEXT_TYPE]]]
Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/utils/formatutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from numbers import Number
from typing import List, Any, Union

from jsonasobj2 import JsonObj, as_dict, is_list, is_dict, items, as_json_obj
from linkml_runtime.utils.jsonasobj2 import JsonObj, as_dict, is_list, is_dict, items, as_json_obj

ws_pattern = re.compile(r'\s+')
us_pattern = re.compile(r'_+')
Expand Down
2 changes: 1 addition & 1 deletion linkml_runtime/utils/inference_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import field, dataclass
from enum import Enum
from typing import Union, Optional, Any, Dict, Callable
from jsonasobj2 import JsonObj, items
from linkml_runtime.utils.jsonasobj2 import JsonObj, items

from linkml_runtime import SchemaView
from linkml_runtime.linkml_model import SlotDefinitionName, PermissibleValue, ClassDefinitionName
Expand Down
6 changes: 6 additions & 0 deletions linkml_runtime/utils/jsonasobj2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ._jsonobj import JsonObj, as_dict, as_json, as_json_obj, get, items, loads, load, setdefault, \
keys, items, values, JsonTypes, JsonObjTypes, is_dict, is_list
from .extendednamespace import ExtendedNamespace

__all__ = ['JsonObj', 'ExtendedNamespace', 'is_dict', 'is_list', 'as_dict', 'as_json', 'as_json_obj', 'get', 'items',
'load', 'loads', 'setdefault', 'keys', 'values', 'JsonTypes', 'JsonObjTypes']
Loading

0 comments on commit c3c0d1b

Please sign in to comment.