Skip to content

Commit

Permalink
fix: package name and initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin.kozlov committed Jul 8, 2024
1 parent 7bf30ee commit 34d6a19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion {{ cookiecutter.__repo_name }}/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_model_metadata_values(self):
"{{ cookiecutter.__app_name }}".lower().replace("-", "_"),
)
self.assertEqual(
self.meta["author"].lower(), "{{ cookiecutter.author_name }}".lower()
self.meta["author"], "{{ cookiecutter.author_name }}".replace(", ", ",").split(",")
)
self.assertEqual(
self.meta["license"].lower(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def predict(**kwargs):

BASE_DIR = Path(__file__).resolve().parents[1]

# DO NOT REMOVE - All modules should have a get_metadata() function
# with appropriate keys.

@_catch_error
def get_metadata():
"""Returns a dictionary containing metadata information about the module.
DO NOT REMOVE - All modules should have a get_metadata() function
Raises:
HTTPException: Unexpected errors aim to return 50X
Expand All @@ -51,6 +51,7 @@ def get_metadata():
try: # Call your AI model metadata() method
logger.info("Collecting metadata from: %s", config.API_NAME)
metadata = {
"name": config.API_METADATA.get("name"),
"author": config.API_METADATA.get("authors"),
"author-email": config.API_METADATA.get("author-emails"),
"description": config.API_METADATA.get("summary"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
By convention, the CONSTANTS defined in this module are in UPPER_CASE.
"""

import logging
import os
from importlib import metadata
Expand All @@ -19,12 +20,12 @@
API_METADATA["Author-emails"] = dict(_EMAILS)

# Fix metadata for authors from pyproject parsing
_AUTHORS = API_METADATA.get("Author", "").split(", ")
_AUTHORS = API_METADATA.get("Author", "").replace(", ", ",").split(",")
_AUTHORS = [] if _AUTHORS == [""] else _AUTHORS
_AUTHORS += API_METADATA["Author-emails"].keys()
API_METADATA["Authors"] = sorted(_AUTHORS)

# logging level across API modules can be setup via API_LOG_LEVEL,
# options: DEBUG, INFO(default), WARNING, ERROR, CRITICAL
ENV_LOG_LEVEL = os.getenv("API_LOG_LEVEL", default="INFO")
LOG_LEVEL = getattr(logging, ENV_LOG_LEVEL.upper())
LOG_LEVEL = getattr(logging, ENV_LOG_LEVEL.upper())

0 comments on commit 34d6a19

Please sign in to comment.