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

remove warning, change to log.info #46

Merged
merged 3 commits into from
Oct 18, 2023
Merged
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
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