Skip to content

Commit

Permalink
fix: fix circular import breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Nov 7, 2024
1 parent 6284515 commit 861d210
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 10 additions & 2 deletions ckanext/event_audit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import click

from ckanext.event_audit import types
from ckanext.event_audit.repositories.cloudwatch import CloudWatchRepository
from ckanext.event_audit import types, utils


__all__ = [
"event_audit",
Expand Down Expand Up @@ -39,6 +39,8 @@ def cw_write_event(
payload: str | None = None,
):
"""Write an event to CloudWatch Logs."""
from ckanext.event_audit.repositories import CloudWatchRepository

repo = CloudWatchRepository()

event_data = {
Expand All @@ -65,6 +67,8 @@ def cw_write_event(
@click.argument("event_id")
def cw_get_event(event_id: str):
"""Get an event from CloudWatch Logs."""
from ckanext.event_audit.repositories import CloudWatchRepository

repo = CloudWatchRepository()

event = repo.get_event(event_id)
Expand Down Expand Up @@ -99,6 +103,8 @@ def cw_filter_events(
time_to: str | None = None,
):
"""Filter events from CloudWatch logs based on the given filters."""
from ckanext.event_audit.repositories import CloudWatchRepository

repo = CloudWatchRepository()

filter_data: dict[str, Any] = {
Expand All @@ -123,6 +129,8 @@ def cw_filter_events(
@click.argument("log_group", required=False)
def cw_remove_log_group(log_group: str | None = None):
"""Remove the specified log group or the default log group if not specified."""
from ckanext.event_audit.repositories import CloudWatchRepository

repo = CloudWatchRepository()

try:
Expand Down
5 changes: 2 additions & 3 deletions ckanext/event_audit/listeners/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import ckan.plugins as p
from ckan.model.base import Session

from ckanext.event_audit import config, const, types
from ckanext.event_audit import config, const, types, utils
from ckanext.event_audit.interfaces import IEventAudit
from ckanext.event_audit.model import EventModel
from ckanext.event_audit.utils import get_active_repo

CACHE_ATTR = "_audit_cache"

Expand Down Expand Up @@ -55,7 +54,7 @@ def after_commit(session: SQLAlchemySession):
if not hasattr(session, CACHE_ATTR):
return

repo = get_active_repo()
repo = utils.get_active_repo()
thread_mode_enabled = config.is_threaded_mode_enabled()

for action, instances in session._audit_cache.items(): # type: ignore
Expand Down
1 change: 0 additions & 1 deletion ckanext/event_audit/repositories/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from datetime import datetime
from typing import Any, Iterable

from ckanext.event_audit import plugin, types
Expand Down
2 changes: 1 addition & 1 deletion ckanext/event_audit/repositories/cloudwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


from ckanext.event_audit import config, types
from ckanext.event_audit.repositories import AbstractRepository, RemoveAll
from ckanext.event_audit.repositories.base import AbstractRepository, RemoveAll


class CloudWatchEvent(TypedDict):
Expand Down

0 comments on commit 861d210

Please sign in to comment.