Skip to content
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
17 changes: 15 additions & 2 deletions tools/content_manager/content_manager/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@
import logging
import os
import pathlib
import sys
from typing import Literal

import click
from content_manager.common import datetime_converter

# Add the directory containing this file to sys.path to fix imports when
# running via Blaze
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
if parent_dir not in sys.path:
sys.path.insert(0, parent_dir)

from content_manager.common import datetime_converter # pylint: disable=g-import-not-at-top
from content_manager.common.custom_exceptions import RuleVerificationError
from content_manager.data_tables import DataTables
from content_manager.reference_lists import ReferenceLists
Expand All @@ -41,7 +50,11 @@

LOGGER = logging.getLogger()

ROOT_DIR = pathlib.Path(__file__).parent.parent
ROOT_DIR = pathlib.Path(
os.environ.get(
"CONTENT_MANAGER_ROOT", str(pathlib.Path(__file__).parent.parent)
)
)
RULES_DIR = ROOT_DIR / "rules"
RULE_CONFIG_FILE = ROOT_DIR / "rule_config.yaml"
REF_LISTS_DIR = ROOT_DIR / "reference_lists"
Expand Down
11 changes: 7 additions & 4 deletions tools/content_manager/content_manager/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import hashlib
import json
import logging
import os
import pathlib
import re
from typing import Any, List, Mapping, Sequence, Tuple

from content_manager.common.custom_exceptions import DuplicateRuleIdError
from content_manager.common.custom_exceptions import DuplicateRuleNameError
from content_manager.common.custom_exceptions import RuleConfigError
from content_manager.common.custom_exceptions import RuleError
from google.auth.transport import requests
Expand All @@ -43,7 +43,9 @@

LOGGER = logging.getLogger()

ROOT_DIR = pathlib.Path(__file__).parent.parent
ROOT_DIR = pathlib.Path(
os.environ.get("CONTENT_MANAGER_ROOT", pathlib.Path(__file__).parent.parent)
)
RULES_DIR = ROOT_DIR / "rules"
RULE_CONFIG_FILE = ROOT_DIR / "rule_config.yaml"

Expand Down Expand Up @@ -451,8 +453,9 @@ def check_for_duplicate_rule_names(cls, rules: List[Rule]):
if duplicate_rule_names:
for rule_name, count in duplicate_rule_names:
LOGGER.info("%s rules found with the same name %s", count, rule_name)
raise DuplicateRuleNameError(
f"Duplicate rule names found {duplicate_rule_names}."
LOGGER.warning(
"Duplicate rule names found %s. Overwriting will occur.",
duplicate_rule_names,
)

@classmethod
Expand Down