Skip to content

Commit

Permalink
Merge pull request #5 from linkml/rename
Browse files Browse the repository at this point in the history
Rename
  • Loading branch information
cmungall authored Jan 8, 2022
2 parents 0f64767 + 9e960a5 commit 52d4d05
Show file tree
Hide file tree
Showing 37 changed files with 117 additions and 70 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# linkml-runtime-api
# linkml-dataops

An extension to linkml-runtime to provide an API over runtime data objects.

Documentation will later be added in the main [linkml](https://linkml.io/linkml/) repo

This provides data models for CRUD (Create, Read, Update, Delete) objects, i.e.

* Representations of *queries* over objects that instantiate linkml classes
Expand All @@ -18,11 +16,11 @@ Current engines implemented here:

Other engines may be implemented elsewhere - e.g. linkml-solr

See [tests/](https://github.com/linkml/linkml-runtime-api/tree/main/tests) for examples
See [tests/](https://github.com/linkml/linkml-dataops/tree/main/tests) for examples

## Changes Datamodel

See linkml_runtime_api.changes
See linkml_dataops.changes

Change classes include:

Expand Down Expand Up @@ -67,7 +65,7 @@ In future there will be other datastores

## Query Datamodel

See linkml_runtime_api.query
See linkml_dataops.query

The main query class is `FetchQuery`

Expand Down
2 changes: 2 additions & 0 deletions linkml_dataops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from linkml_dataops.query import *
from linkml_dataops.changer import *
File renamed without changes.
2 changes: 2 additions & 0 deletions linkml_dataops/changer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from linkml_dataops.changer.object_changer import ObjectChanger
from linkml_dataops.changer.jsonpatch_changer import JsonPatchChanger
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from linkml_runtime.utils.formatutils import underscore

from linkml_runtime_api.apiroot import ApiRoot, PATH_EXPRESSION
from linkml_runtime_api.changer.changes_model import Change, AddObject, RemoveObject
from linkml_dataops.apiroot import ApiRoot, PATH_EXPRESSION
from linkml_dataops.changer.changes_model import Change, AddObject, RemoveObject
from linkml_runtime.utils.yamlutils import YAMLRoot

@dataclass
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from linkml_runtime.utils.schemaview import SchemaView
from ruamel.yaml import YAML

from linkml_runtime_api.changer.changer import Changer, ChangeResult
from linkml_runtime_api.changer.changes_model import Change, AddObject, RemoveObject, Append, Rename
from linkml_dataops.changer.changer import Changer, ChangeResult
from linkml_dataops.changer.changes_model import Change, AddObject, RemoveObject, Append, Rename
from linkml_runtime.utils.formatutils import underscore, is_empty
from linkml_runtime.utils.yamlutils import YAMLRoot, as_json_object
from linkml_runtime_api.diffs.yaml_patch import YAMLPatch
from linkml_dataops.diffs.yaml_patch import YAMLPatch

OPDICT = Dict[str, Any]
OPS = List[OPDICT]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import copy, deepcopy

from linkml_runtime_api.changer.changer import Changer, ChangeResult
from linkml_runtime_api.changer.changes_model import Change, AddObject, RemoveObject, Append, Rename
from linkml_dataops.changer.changer import Changer, ChangeResult
from linkml_dataops.changer.changes_model import Change, AddObject, RemoveObject, Append, Rename
from linkml_runtime.utils.formatutils import underscore
from linkml_runtime.utils.yamlutils import YAMLRoot

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from linkml_runtime.dumpers import json_dumper

from linkml_runtime_api.apiroot import ApiRoot
from linkml_dataops.apiroot import ApiRoot
from linkml_runtime.utils.yamlutils import YAMLRoot

def _as_dict(obj: YAMLRoot) -> dict:
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions linkml_dataops/generators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from linkml_dataops.generators.apigenerator import ApiGenerator
from linkml_dataops.generators.pyapigenerator import PythonApiGenerator
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from linkml_runtime.utils.formatutils import camelcase, underscore
from linkml_runtime.utils.schemaview import SchemaView

from linkml_runtime_api.apiroot import ApiRoot
from linkml_dataops.apiroot import ApiRoot

@dataclass
class ApiGenerator(ApiRoot):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
from linkml_runtime.utils.formatutils import camelcase, underscore
from linkml_runtime.utils.schemaview import SchemaView

from linkml_runtime_api.apiroot import ApiRoot
from linkml_dataops.apiroot import ApiRoot

# TODO
jinja2_template = """
import logging
from dataclasses import dataclass
from linkml_runtime_api.query.queryengine import QueryEngine
from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
from linkml_dataops.query.queryengine import QueryEngine
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
FetchById
from linkml_runtime_api.query.queryengine import MatchExpression
from linkml_dataops.query.queryengine import MatchExpression
from {{ datamodel_package_full}} import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
from linkml_runtime.utils.formatutils import camelcase, underscore
from linkml_runtime.utils.schemaview import SchemaView

from linkml_runtime_api.apiroot import ApiRoot
from linkml_dataops.apiroot import ApiRoot

jinja2_template = """
import logging
from dataclasses import dataclass
from linkml_runtime_api.query.queryengine import QueryEngine
from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
from linkml_dataops.query.queryengine import QueryEngine
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
FetchById
from linkml_runtime_api.query.queryengine import MatchExpression
from linkml_dataops.query.queryengine import MatchExpression
from {{ datamodel_package_full}} import *
Expand Down
1 change: 1 addition & 0 deletions linkml_dataops/query/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from linkml_dataops.query.object_queryengine import ObjectQueryEngine
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

from linkml_runtime.utils.formatutils import camelcase, underscore

from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
FetchById
from linkml_runtime.utils.yamlutils import YAMLRoot

from linkml_runtime_api.query.queryengine import QueryEngine, create_match_constraint
from linkml_dataops.query.queryengine import QueryEngine, create_match_constraint


def like(x: Any, y: Any) -> bool:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from linkml_runtime.utils.formatutils import camelcase, underscore

from linkml_runtime_api.apiroot import ApiRoot, Database
from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
from linkml_dataops.apiroot import ApiRoot, Database
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
FetchById
from linkml_runtime.utils.yamlutils import YAMLRoot

Expand Down
2 changes: 0 additions & 2 deletions linkml_runtime_api/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions linkml_runtime_api/changer/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions linkml_runtime_api/generators/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion linkml_runtime_api/query/__init__.py

This file was deleted.

24 changes: 12 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[metadata]
name = linkml_runtime_api
url = https://github.com/biolink/linkml-runtime-api
author = Harold Solbrig
author-email = [email protected]
summary = LinkML Runtime Environment API
description = Runtime Environment API for the Linked Open Data Modeling Language
home-page = http://linkml.github.io/linkml-runtime-api
name = linkml_dataops
url = https://github.com/biolink/linkml-dataops
author = Chris Mungall
author-email = [email protected]
summary = LinkML Data Operations API
description = Data Operations API for the Linked Open Data Modeling Language
home-page = http://github.com/linkml/linkml-dataops
license = CC0 1.0 Universal
python-requires = >=3.7
classifiers =
Expand All @@ -30,11 +30,11 @@ keywords =

[files]
packages =
linkml_runtime_api
linkml_dataops

[entry_points]
console_scripts =
gen-api-datamodel = linkml_runtime_api.generators.apigenerator:cli
gen-crud-datamodel = linkml_runtime_api.generators.apigenerator:cli
gen-python-api = linkml_runtime_api.generators.pyapigenerator:cli
linkml-apply = linkml_runtime_api.changer.jsonpatch_changer:cli
gen-api-datamodel = linkml_dataops.generators.apigenerator:cli
gen-crud-datamodel = linkml_dataops.generators.apigenerator:cli
gen-python-api = linkml_dataops.generators.pyapigenerator:cli
linkml-apply = linkml_dataops.changer.jsonpatch_changer:cli
4 changes: 2 additions & 2 deletions tests/model/kitchen_sink_api_bespoke.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from dataclasses import dataclass
from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, \
FetchById
from linkml_runtime_api.query.queryengine import MatchExpression, QueryEngine
from linkml_dataops.query.queryengine import MatchExpression, QueryEngine

from tests.model.kitchen_sink import *

Expand Down
6 changes: 3 additions & 3 deletions tests/output/kitchen_sink_api_generated_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import logging
from dataclasses import dataclass
from linkml_runtime_api.query.queryengine import QueryEngine
from linkml_runtime_api.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, FetchById
from linkml_runtime_api.query.queryengine import MatchExpression
from linkml_dataops.query.queryengine import QueryEngine
from linkml_dataops.query.query_model import FetchQuery, Constraint, MatchConstraint, OrConstraint, AbstractQuery, FetchById
from linkml_dataops.query.queryengine import MatchExpression

from tests.model.kitchen_sink import *

Expand Down
4 changes: 2 additions & 2 deletions tests/test_apigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import unittest

from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime_api.generators.apigenerator import ApiGenerator
from linkml_runtime_api.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_dataops.generators.apigenerator import ApiGenerator
from linkml_dataops.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.schemaview import SchemaView
from tests.model.kitchen_sink import Person, Dataset, FamilialRelationship
Expand Down
4 changes: 2 additions & 2 deletions tests/test_changer_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import unittest

from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime_api.changer.object_changer import ObjectChanger
from linkml_runtime_api.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_dataops.changer.object_changer import ObjectChanger
from linkml_dataops.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.schemaview import SchemaView
from tests.model.kitchen_sink import Person, Dataset, FamilialRelationship
Expand Down
6 changes: 3 additions & 3 deletions tests/test_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import unittest
import logging

from linkml_runtime_api.changer.object_changer import ObjectChanger
from linkml_runtime_api.changer.changes_model import Rename
from linkml_runtime_api.diffs.differ import DiffEngine
from linkml_dataops.changer.object_changer import ObjectChanger
from linkml_dataops.changer.changes_model import Rename
from linkml_dataops.diffs.differ import DiffEngine
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.schemaview import SchemaView
from tests.model.kitchen_sink import Dataset
Expand Down
4 changes: 2 additions & 2 deletions tests/test_jsonpatch_changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from linkml_runtime.utils.schemaview import SchemaView
from linkml_runtime.utils.yamlutils import YAMLRoot

from linkml_runtime_api.changer.jsonpatch_changer import JsonPatchChanger
from linkml_runtime_api.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_dataops.changer.jsonpatch_changer import JsonPatchChanger
from linkml_dataops.changer.changes_model import AddObject, RemoveObject, Append, Rename

from tests.model.kitchen_sink import Person, Dataset, FamilialRelationship
from tests import MODEL_DIR, INPUT_DIR, OUTPUT_DIR
Expand Down
4 changes: 2 additions & 2 deletions tests/test_object_changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import unittest

from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime_api.changer.object_changer import ObjectChanger
from linkml_runtime_api.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_dataops.changer.object_changer import ObjectChanger
from linkml_dataops.changer.changes_model import AddObject, RemoveObject, Append, Rename
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.schemaview import SchemaView
from tests.model.kitchen_sink import Person, Dataset, FamilialRelationship
Expand Down
6 changes: 3 additions & 3 deletions tests/test_objectqueryengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import List

from linkml_runtime.loaders import yaml_loader
from linkml_runtime_api.query.object_queryengine import ObjectQueryEngine
from linkml_runtime_api.query.queryengine import Database, MatchExpression
from linkml_runtime_api.query.query_model import FetchQuery, MatchConstraint, OrConstraint, FetchById
from linkml_dataops.query.object_queryengine import ObjectQueryEngine
from linkml_dataops.query.queryengine import Database, MatchExpression
from linkml_dataops.query.query_model import FetchQuery, MatchConstraint, OrConstraint, FetchById
from linkml_runtime.utils.schemaview import SchemaView
from tests.model.kitchen_sink import Person, Dataset
from tests.model.kitchen_sink_api import PersonQuery, PersonFetchById
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pythonapigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.utils.compile_python import compile_python

from linkml_runtime_api import ObjectQueryEngine
from linkml_runtime_api.generators import PythonApiGenerator
from linkml_dataops import ObjectQueryEngine
from linkml_dataops.generators import PythonApiGenerator
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.schemaview import SchemaView

from linkml_runtime_api.query.queryengine import Database, MatchExpression
from linkml_dataops.query.queryengine import Database, MatchExpression
from tests.model.kitchen_sink import Person, Dataset, FamilialRelationship
from tests import MODEL_DIR, INPUT_DIR, OUTPUT_DIR

Expand Down
4 changes: 2 additions & 2 deletions tests/test_schema_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from linkml_runtime.linkml_model import SchemaDefinition, ClassDefinition, SlotDefinition
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime_api.changer.object_changer import ObjectChanger
from linkml_runtime_api.changer.changes_model import AddObject, RemoveObject, Append
from linkml_dataops.changer.object_changer import ObjectChanger
from linkml_dataops.changer.changes_model import AddObject, RemoveObject, Append

class ObjectPatcherTestCase(unittest.TestCase):

Expand Down
49 changes: 49 additions & 0 deletions tests/test_yaml_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import sys
import unittest
import logging
from ruamel.yaml import YAML

from jsonpatch import JsonPatch

from linkml_dataops.diffs.yaml_patch import YAMLPatch

inp = """\
# example
name:
# details
family: Smith # very common
given: Alice # one of the siblings
"""

yaml_patch = YAMLPatch()

class YamlPatchTestCase(unittest.TestCase):
"""
Tests yaml patching
"""

def test_patch(self):
"""
test patch works, preserving comments
"""
patch = JsonPatch([
{'op': 'add', 'path': '/foo', 'value': {'bar': 'baz'}},
{'op': 'remove', 'path': '/name/family'}
])
nu = yaml_patch.patchs(inp, patch)
assert '# example' in nu
assert '# details' in nu
assert '# one of the siblings' in nu
yaml=YAML()
obj = yaml.load(nu)
self.assertEqual(obj, {"name": {"given": "Alice"},
"foo": {"bar": "baz"}})






if __name__ == '__main__':
unittest.main()

0 comments on commit 52d4d05

Please sign in to comment.