Skip to content

Create URIs (w3id.org PURLs) for Enums in same style as for classes & slots #393

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

Open
wants to merge 2 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
15 changes: 5 additions & 10 deletions .github/workflows/test-upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
set +e
set +o pipefail

UPSTREAM_BRANCH=$( \
echo "$PR_BODY" | \
head -2 | \
Expand All @@ -52,12 +52,12 @@ jobs:
)
echo "Got upstream branch:"
echo $UPSTREAM_BRANCH

if [[ -z "$UPSTREAM_BRANCH" ]]; then
echo "Using main as default"
UPSTREAM_BRANCH="main"
fi

UPSTREAM_REPO=$( \
echo "$PR_BODY" | \
head -2 | \
Expand All @@ -67,7 +67,7 @@ jobs:
)
echo "Got upstream repo:"
echo $UPSTREAM_REPO

if [[ -z "$UPSTREAM_REPO" ]]; then
echo "Using linkml/linkml as default"
UPSTREAM_REPO="linkml/linkml"
Expand Down Expand Up @@ -128,11 +128,6 @@ jobs:
path: linkml/.venv
key: venv-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

# make extra sure we're removing any old version of linkml-runtime that exists
- name: uninstall potentially cached linkml-runtime
working-directory: linkml
run: poetry run pip uninstall -y linkml-runtime

# we are not using linkml-runtime's lockfile, but simulating what will happen
# when we merge this and update linkml's lockfile
- name: add linkml-runtime to lockfile
Expand All @@ -145,7 +140,7 @@ jobs:
# the cache will still speedup the rest of the installation
- name: install linkml
working-directory: linkml
run: poetry install --no-interaction -E tests
run: poetry sync --no-interaction --all-extras

- name: print linkml-runtime version
working-directory: linkml
Expand Down
3 changes: 3 additions & 0 deletions linkml_runtime/utils/schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,9 @@ def get_uri(
elif isinstance(e, SlotDefinition):
uri = e.slot_uri
e_name = underscore(e.name)
elif isinstance(e, EnumDefinition):
uri = e.enum_uri
e_name = e.name
elif isinstance(e, TypeDefinition):
uri = e.uri
e_name = underscore(e.name)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_utils/test_schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from linkml_runtime.linkml_model.meta import (
ClassDefinition,
ClassDefinitionName,
EnumDefinition,
Example,
Prefix,
SchemaDefinition,
Expand Down Expand Up @@ -517,6 +518,9 @@ def test_imports(schema_view_with_imports: SchemaView) -> None:
assert view.get_uri("TestClass", use_element_type=True) == "core:class/TestClass"
assert view.get_uri("name", use_element_type=True) == "core:slot/name"

assert view.get_uri("OrganismType") == "ks:OrganismType"
assert view.get_uri("OrganismType", use_element_type=True) == "ks:enum/OrganismType"

assert view.get_uri("string") == "xsd:string"

# dynamic enums
Expand Down Expand Up @@ -988,6 +992,8 @@ def test_uris_without_default_prefix() -> None:
view = SchemaView(schema_definition)
view.add_class(ClassDefinition(name="TestClass", from_schema="https://example.org/another#"))
view.add_slot(SlotDefinition(name="test_slot", from_schema="https://example.org/another#"))
view.add_enum(EnumDefinition(name="tEsT_enum", from_schema="https://example.org/another#"))

assert view.get_uri("TestClass", imports=True) == "https://example.org/test#TestClass"
assert view.get_uri("test_slot", imports=True) == "https://example.org/test#test_slot"
assert view.get_uri("tEsT_enum", imports=True) == "https://example.org/test#tEsT_enum"
Loading