Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: jsonasobj2 vendoring #361

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha i am assuming this is a "temporary fix until we update PythonGen" thing right? we should remember to write that down somewhere or else merge this at the same time as we make that small change in pythongen upstream? wdyt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it's "temporary".
I'll add a comment that it should be deleted after PythonGen is updated.
Worst case, the command has no effect if we forget to remove it immediately.


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 $< > [email protected] && mv [email protected] $@
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotta love turning issue discussion into ambient docs fixes, thanks for this :)


### 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