Skip to content

Commit

Permalink
Merge pull request #46 from linkml/remove_noisy_warning
Browse files Browse the repository at this point in the history
remove warning, change to log.info
  • Loading branch information
sierra-moxon authored Oct 18, 2023
2 parents 932cbda + 5830072 commit fc03487
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ test:
etl:
$(RUN) slurp-prefixmaps -d $(DATA)

lint-fix:
$(RUN) tox -e lint-fix
$(RUN) tox -e flake8


format: lint-fix
13 changes: 10 additions & 3 deletions src/prefixmaps/datamodel/context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Classes for managing individual Contexts."""

import logging
import re
import warnings
from collections import defaultdict
from dataclasses import dataclass, field
from enum import Enum
Expand All @@ -25,6 +25,9 @@
PREFIX_RE = re.compile(r"^[\w\.]+$")
NAMESPACE_RE = re.compile(r"http[s]?://[\w\.\-\/]+[#/_:]$")

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class StatusType(Enum):
"""
Expand Down Expand Up @@ -304,8 +307,12 @@ def as_extended_prefix_map(self) -> List[curies.Record]:
expansion.status == StatusType.namespace_alias
and expansion.namespace not in reverse_prefix_map
):
warnings.warn(
f"Namespace {expansion.namespace} has no canonical prefix", stacklevel=2
# this is too noisy, we need a logger here instead
# warnings.warn(
# f"namespace alias {expansion.namespace} => {expansion.prefix} is not a canonical namespace"
# )
logger.info(
f"namespace alias {expansion.namespace} => {expansion.prefix} is not a canonical namespace"
)

return [
Expand Down
2 changes: 1 addition & 1 deletion src/prefixmaps/ingest/ingest_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parse_go_xrefs(input: Union[str, TextIO]) -> Context:
for p in prefixes:
if "rdf_uri_prefix" in p:
ns = p["rdf_uri_prefix"]
if not ns[-1] in ["/", "#", "_"]:
if ns[-1] not in ["/", "#", "_"]:
ns += "/"
context.add_prefix(p["database"], ns)
return context
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ commands =
isort .
description = Run linters.

[testenv:lint-fix]
deps =
black
ruff
skip_install = true
commands =
black src/ tests/
ruff --fix src/ tests/
description = Run linters.

[testenv:flake8]
skip_install = true
deps =
Expand Down

0 comments on commit fc03487

Please sign in to comment.