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

fix: more logging config fixes #351

Merged
merged 1 commit into from
Jul 8, 2024
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
16 changes: 0 additions & 16 deletions src/gene/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
"""The VICC library for normalizing genes."""
import logging
from os import environ
from pathlib import Path

from .version import __version__ # noqa: F401

APP_ROOT = Path(__file__).resolve().parent

logging.basicConfig(
filename="gene.log", format="[%(asctime)s] - %(name)s - %(levelname)s : %(message)s"
)
logger = logging.getLogger("gene")
logger.setLevel(logging.DEBUG)
logger.handlers = []

logging.getLogger("boto3").setLevel(logging.INFO)
logging.getLogger("botocore").setLevel(logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
logging.getLogger("python_jsonschema_objects").setLevel(logging.INFO)
logging.getLogger("biocommons.seqrepo.seqaliasdb.seqaliasdb").setLevel(logging.INFO)
logging.getLogger("biocommons.seqrepo.fastadir.fastadir").setLevel(logging.INFO)


SEQREPO_ROOT_DIR = Path(
environ.get("SEQREPO_ROOT_DIR", "/usr/local/share/seqrepo/latest")
)
Expand Down
18 changes: 11 additions & 7 deletions src/gene/query.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Provides methods for handling queries."""
import logging
import re
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar

from ga4gh.core import core_models, ga4gh_identify
from ga4gh.vrs import models

from gene import ITEM_TYPES, NAMESPACE_LOOKUP, PREFIX_LOOKUP, logger
from gene import ITEM_TYPES, NAMESPACE_LOOKUP, PREFIX_LOOKUP
from gene.database import AbstractDatabase, DatabaseReadException
from gene.schemas import (
BaseGene,
Expand All @@ -28,6 +29,9 @@
)
from gene.version import __version__


_logger = logging.getLogger(__name__)

NormService = TypeVar("NormService", bound=BaseNormalizationService)


Expand Down Expand Up @@ -72,7 +76,7 @@ def _emit_warnings(query_str: str) -> List:
"non_breaking_space_characters": "Query contains non-breaking space characters"
}
]
logger.warning(
_logger.warning(
f"Query ({query_str}) contains non-breaking space characters."
)
return warnings
Expand Down Expand Up @@ -188,14 +192,14 @@ def _fetch_record(
try:
match = self.db.get_record_by_id(concept_id, case_sensitive=False)
except DatabaseReadException as e:
logger.error(
_logger.error(
f"Encountered DatabaseReadException looking up {concept_id}: {e}"
)
else:
if match:
self._add_record(response, match, match_type)
else:
logger.error(
_logger.error(
f"Unable to find expected record for {concept_id} matching as {match_type}"
) # noqa: E501

Expand Down Expand Up @@ -263,7 +267,7 @@ def _get_search_response(self, query: str, sources: Set[str]) -> Dict:
matched_concept_ids.append(ref)

except DatabaseReadException as e:
logger.error(
_logger.error(
f"Encountered DatabaseReadException looking up {item_type}"
f" {term}: {e}"
)
Expand Down Expand Up @@ -535,7 +539,7 @@ def _handle_failed_merge_ref(record: Dict, response: Dict, query: str) -> Dict:
:param query: original query value
:return: response with no match
"""
logger.error(
_logger.error(
f"Merge ref lookup failed for ref {record['merge_ref']} "
f"in record {record['concept_id']} from query {query}"
)
Expand Down Expand Up @@ -600,7 +604,7 @@ def _resolve_merge(
merge = self.db.get_record_by_id(merge_ref, False, True)
if merge is None:
query = response.query
logger.error(
_logger.error(
f"Merge ref lookup failed for ref {record['merge_ref']} "
f"in record {record['concept_id']} from query `{query}`"
)
Expand Down
Loading