Code Monkey home page Code Monkey logo

examples-first-cookiecutter's People

Contributors

cmungall avatar hrshdhgd avatar noelmcloughlin avatar pkalita-lbl avatar sierra-moxon avatar sujaypatil96 avatar tkphd avatar turbomam avatar

examples-first-cookiecutter's Issues

add .idea/ to .gitignore

PyCharm puts its configuration in .idea/

this is might be separate from adding it to the repo created by the cookiecutter

existing and proposed test steps

make test from ./Makefile currently does the following, at a high level:

  • make test-schema
    • make gen-project
  • make test-python
    • python -m unittest discover
      • applies tests/test_valid_collections.py to selected files in src/data/examples/valid
  • make test-examples
    • runs linkml-run-examples
    • input: src/data/examples
    • output: examples/output

make check-jsonschema-example from ./project.Makefile provides a minimal example of checking one hard-coded data file with check-jsonschema

Change that to iterate over all valid and invalid files. Wrap with ! (not -!) for the invalid files.

Clarify that check-jsonschema exhaustively reports schema violations but is not part of the LinkML ecosystem. Its functionality will probably be replaced by a (potentially even more useful) LinkML tool at some point.

Improve the ability of tests/test_valid_collections.py to autodetect the tree root class

I really mean detecting the tree root class at runtime, not at the time of repo creation

git diff tests/test_valid_collections.py 
diff --git a/tests/test_valid_collections.py b/tests/test_valid_collections.py
index 6f2a618..d929828 100644
--- a/tests/test_valid_collections.py
+++ b/tests/test_valid_collections.py
@@ -4,14 +4,14 @@ import glob
 import unittest
 
 from linkml_runtime.loaders import yaml_loader
-from identifiers_sandbox.datamodel.identifiers_sandbox import ThingCollection
+from identifiers_sandbox.datamodel.identifiers_sandbox import NamedThingCollection
 
 ROOT = os.path.join(os.path.dirname(__file__), '..')
 DATA_DIR = os.path.join(ROOT, "src", "data", "examples", "valid")
 
 EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR, '*.yaml'))
 
-MAIN_SCHEMA_CLASS_NAME = ThingCollection.class_name
+MAIN_SCHEMA_CLASS_NAME = NamedThingCollection.class_name
 
 ACCEPTABLE_PREFIX = DATA_DIR + "/" + MAIN_SCHEMA_CLASS_NAME
 
@@ -23,7 +23,7 @@ class TestData(unittest.TestCase):
         """Date test."""
         for path in EXAMPLE_FILES:
             if path.startswith(ACCEPTABLE_PREFIX):
-                obj = yaml_loader.load(path, target_class=ThingCollection)
+                obj = yaml_loader.load(path, target_class=NamedThingCollection)
                 assert obj
             else:
                 print()

invalid and valid examples dirs not copied

make setup

cp src/data/examples/* examples
cp: -r not specified; omitting directory 'src/data/examples/invalid'
cp: -r not specified; omitting directory 'src/data/examples/valid'
make: *** [Makefile:100: gen-examples] Error 1

last line is really
make: *** [Makefile:100: gen-examples] Error 1

dupe ids example is passing

After generation of the repo, in src/data/examples/invalid/PersonCollection-dupe-ids.yaml

with

entries:
  - id: example:Person001
    name: foo bar
  - id: example:Person001
    name: foo bar

make test

ValueError: Counter example src/data/examples/invalid/PersonCollection-dupe-ids.yaml succeeded validation
make: *** [Makefile:138: examples/output] Error 1

Some LinkML tools can't handle collections with elements that have only one slot populated

One part of make test:

poetry run python -m unittest discover

Can't instantiate the following:

entries:
  - id: example:Thing001
  - id: example:Thing002

/Users/MAM/Documents/gitrepos/linkml-projects/identifiers-sandbox/tests/../src/data/examples/valid/NamedThingCollection-single-slot.yaml
E
======================================================================
ERROR: test_data (tests.test_valid_collections.TestData)
Date test.


Traceback (most recent call last):
File "/Users/MAM/Documents/gitrepos/linkml-projects/identifiers-sandbox/tests/test_valid_collections.py", line 27, in test_data
obj = yaml_loader.load(path, target_class=NamedThingCollection)
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/loaders/loader_root.py", line 85, in load
results = self.load_any(*args, **kwargs)
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/loaders/yaml_loader.py", line 32, in load_any
return self.load_source(source, loader, target_class, accept_header="text/yaml, application/yaml;q=0.9",
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/loaders/loader_root.py", line 66, in load_source
return target_class(**data_as_dict)
File "", line 4, in init
File "/Users/MAM/Documents/gitrepos/linkml-projects/identifiers-sandbox/src/identifiers_sandbox/datamodel/identifiers_sandbox.py", line 96, in post_init
self._normalize_inlined_as_list(slot_name="entries", slot_type=NamedThing, key_name="id", keyed=True)
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/utils/yamlutils.py", line 97, in _normalize_inlined_as_list
self._normalize_inlined(slot_name, slot_type, key_name, keyed, True)
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/utils/yamlutils.py", line 173, in _normalize_inlined
order_up(list_entry[lek], slot_type(list_entry))
File "", line 6, in init
File "/Users/MAM/Documents/gitrepos/linkml-projects/identifiers-sandbox/src/identifiers_sandbox/datamodel/identifiers_sandbox.py", line 70, in post_init
self.id = NamedThingId(self.id)
File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/identifiers-sandbox-c7uJR0Fx-py3.10/lib/python3.10/site-packages/linkml_runtime/utils/metamodelcore.py", line 100, in init
raise ValueError(f"{v} is not a valid URI or CURIE")
ValueError: JsonObj(id='example:Thing001') is not a valid URI or CURIE

Add directories and .gitkeeps for examples/output target

examples/output: src/{{cookiecutter.__project_slug}}/schema/{{cookiecutter.__project_slug}}.yaml
	mkdir -p $@
	$(RUN) linkml-run-examples \
		--output-formats json \
		--output-formats yaml \
		--counter-example-input-directory src/data/examples/invalid \
		--input-directory src/data/examples/valid \
		--output-directory $@ \
		--schema $< > $@/README.md

document how to create local DataHarmonizer

  • install npm
  • make create-data-harmonizer
    • ? What would you like your new project to be called?
      • dataharmonizer
    • Which [classes] should be used as DataHarmonizer templates?
      • only include Person for now
      • we should add more collections to illustrate DH functionality
        • switching template
        • template parameter on URLs
        • multiview

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.