Skip to content

Commit

Permalink
fix: lint issues!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Jul 2, 2024
1 parent 83a1670 commit 6c1fa07
Show file tree
Hide file tree
Showing 33 changed files with 87 additions and 109 deletions.
2 changes: 1 addition & 1 deletion tc_analyzer_lib/DB_operations/mongo_neo4j_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from tc_analyzer_lib.DB_operations.mongodb_interaction import MongoDBOps
from tc_analyzer_lib.DB_operations.network_graph import NetworkGraph
from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query
from tc_analyzer_lib.schemas import GraphSchema
from tc_neo4j_lib.neo4j_ops import Neo4jOps, Query


class MongoNeo4jDB:
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/DB_operations/mongodb_interaction.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from tc_analyzer_lib.DB_operations.mongodb_access import DB_access
from pymongo.read_concern import ReadConcern
from pymongo.write_concern import WriteConcern
from tc_analyzer_lib.DB_operations.mongodb_access import DB_access


class MongoDBOps:
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/DB_operations/network_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import datetime

import networkx
from tc_neo4j_lib import Query
from tc_analyzer_lib.schemas import GraphSchema
from tc_neo4j_lib import Query


class NetworkGraph:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import copy
from typing import Any
from datetime import datetime
from typing import Any

from numpy import diag_indices_from, ndarray

from tc_analyzer_lib.utils.mongo import MongoSingleton

from .utils.compute_interaction_mtx_utils import (
generate_interaction_matrix,
prepare_per_account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(
self.projection_utils = ProjectionUtils(self.platform_id, self.graph_schema)

def compute_stats(self, from_start: bool) -> None:

# possible dates to do the computations
possible_dates = self.projection_utils.get_dates()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from datetime import datetime, timedelta
from typing import Any

from dateutil import parser
from tc_analyzer_lib.DB_operations.mongodb_access import DB_access
from numpy import array
from tc_analyzer_lib.DB_operations.mongodb_access import DB_access


class MemberActivityPastUtils:
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/algorithms/utils/member_activity_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import numpy as np
import pymongo
from networkx import DiGraph
from tc_analyzer_lib.algorithms.compute_interaction_matrix_discord import (
compute_interaction_matrix_discord,
)
from tc_analyzer_lib.DB_operations.mongodb_access import DB_access
from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase
from networkx import DiGraph
from tc_core_analyzer_lib.assess_engagement import EngagementAssessment


Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/automation/automation_workflow.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
from typing import Any

from pybars import Compiler
from tc_analyzer_lib.automation.utils.automation_base import AutomationBase
from tc_analyzer_lib.automation.utils.model import AutomationDB
from pybars import Compiler
from tc_messageBroker.rabbit_mq.event import Event
from tc_messageBroker.rabbit_mq.queue import Queue

Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/metrics/utils/platform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bson import ObjectId
from datetime import datetime

from bson import ObjectId
from tc_analyzer_lib.utils.mongo import MongoSingleton


Expand Down
3 changes: 1 addition & 2 deletions tc_analyzer_lib/models/GuildsRnDaoModel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from tc_analyzer_lib.models.BaseModel import BaseModel
from pymongo.database import Database
from tc_analyzer_lib.models.BaseModel import BaseModel


class GuildsRnDaoModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/models/HeatMapModel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
from datetime import datetime

from tc_analyzer_lib.models.BaseModel import BaseModel
from pymongo import DESCENDING
from pymongo.database import Database
from tc_analyzer_lib.models.BaseModel import BaseModel


class HeatMapModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/models/RawInfoModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from datetime import datetime, timedelta
from typing import Any

from tc_analyzer_lib.models.BaseModel import BaseModel
from pymongo import ASCENDING
from pymongo.database import Database
from tc_analyzer_lib.models.BaseModel import BaseModel


class RawInfoModel(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions tc_analyzer_lib/publish_on_success.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging

from tc_analyzer_lib.automation.automation_workflow import AutomationWorkflow
from tc_messageBroker.rabbit_mq.event import Event
from tc_messageBroker.rabbit_mq.queue import Queue
from tc_analyzer_lib.utils.get_guild_utils import (
get_platform_guild_id,
get_platform_name,
get_platform_community_owner,
)
from tc_analyzer_lib.utils.rabbitmq import RabbitMQAccess
from tc_messageBroker.rabbit_mq.event import Event
from tc_messageBroker.rabbit_mq.queue import Queue


def publish_on_success(platform_id: str, recompute: bool) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa
from .activity_type import ActivityDirection, ActivityType
from .graph import GraphSchema
from .hourly_analytics import HourlyAnalytics
from .raw_analytics import RawAnalytics
from .raw_analytics_item import RawAnalyticsItem
from .graph import GraphSchema
3 changes: 1 addition & 2 deletions tc_analyzer_lib/tc_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from datetime import datetime

from tc_analyzer_lib.metrics.analyzer_memberactivities import MemberActivities
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.metrics.neo4j_analytics import Neo4JAnalytics
Expand All @@ -9,7 +9,6 @@
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig
from tc_analyzer_lib.schemas.platform_configs.config_base import PlatformConfigBase
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig


class TCAnalyzer(AnalyzerDBManager):
Expand Down
2 changes: 1 addition & 1 deletion tc_analyzer_lib/utils/rabbitmq.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials
from tc_messageBroker import RabbitMQ
from tc_messageBroker.rabbit_mq.queue import Queue
from tc_analyzer_lib.utils.credentials import get_rabbit_mq_credentials


class RabbitMQAccess:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_analyzer_platform_fetch_period.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from bson import ObjectId
from datetime import datetime
from unittest import TestCase

from tc_analyzer_lib.utils.mongo import MongoSingleton
from bson import ObjectId
from tc_analyzer_lib.metrics.utils import Platform
from tc_analyzer_lib.utils.mongo import MongoSingleton


class TestPlatformUtilsFetchPeriod(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_analyzer_platform_fetch_resources.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from bson import ObjectId
from datetime import datetime
from unittest import TestCase

from tc_analyzer_lib.utils.mongo import MongoSingleton
from bson import ObjectId
from tc_analyzer_lib.metrics.utils import Platform
from tc_analyzer_lib.utils.mongo import MongoSingleton


class TestPlatformUtilsFetchResources(TestCase):
Expand Down
21 changes: 1 addition & 20 deletions tests/integration/test_analyzer_utils_platform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bson import ObjectId
from unittest import TestCase

from bson import ObjectId
from tc_analyzer_lib.metrics.utils import Platform
from tc_analyzer_lib.utils.mongo import MongoSingleton

Expand Down Expand Up @@ -150,25 +150,6 @@ def test_get_community_id_single_platform_available(self):

self.assertEqual(expected_community_id, community_id)

def test_get_community_id_single_platform_available(self):
platform_id = "60d5ec44f9a3c2b6d7e2d11a"
expected_community_id = "77d5ec44f6a3c2b6d7e2d11a"

self.client["Core"]["platforms"].insert_one(
{
"_id": ObjectId(platform_id),
"name": "discord",
"community": ObjectId(expected_community_id),
"metadata": {
"isInProgress": True,
},
}
)
platform_obj = Platform(platform_id)
community_id = platform_obj.get_community_id()

self.assertEqual(expected_community_id, community_id)

def test_get_community_id_irrelevant_platform_available(self):
platform_id = "60d5ec44f9a3c2b6d7e2d11a"
platform_id2 = "60d5ec44f9a3c2b6d7e2d11b"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_analyzer_utils_platform_parameters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from bson import ObjectId
from unittest import TestCase
from datetime import datetime, timedelta
from unittest import TestCase

from bson import ObjectId
from tc_analyzer_lib.metrics.utils import Platform
from tc_analyzer_lib.utils.mongo import MongoSingleton

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_assess_engagement_mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from unittest import TestCase

from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig

from .utils.analyzer_setup import launch_db_access
from .utils.setup_platform import setup_platform
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig


class TestAssessEngagementMentions(TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_assess_engagement_reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from unittest import TestCase

from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig

from .utils.analyzer_setup import launch_db_access
from .utils.setup_platform import setup_platform
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig


class TestAssessEngagementReactions(TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_assess_engagement_replies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from unittest import TestCase

from tc_analyzer_lib.algorithms.utils.member_activity_utils import assess_engagement
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.metrics.utils.analyzer_db_manager import AnalyzerDBManager
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig

from .utils.analyzer_setup import launch_db_access
from .utils.setup_platform import setup_platform
from tc_analyzer_lib.metrics.heatmaps import Heatmaps
from tc_analyzer_lib.schemas import GraphSchema
from tc_analyzer_lib.schemas.platform_configs import DiscordAnalyzerConfig


class TestAssessEngagementReplies(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_automation_db_load_from_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import unittest
from datetime import datetime, timedelta

from tc_analyzer_lib.automation.utils.model import AutomationDB
from dotenv import load_dotenv
from tc_analyzer_lib.automation.utils.model import AutomationDB
from tc_analyzer_lib.utils.mongo import MongoSingleton


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_automation_db_save_to_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import unittest
from datetime import datetime, timezone

from dotenv import load_dotenv
from tc_analyzer_lib.automation.utils.interfaces import Automation
from tc_analyzer_lib.automation.utils.model import AutomationDB
from dotenv import load_dotenv
from tc_analyzer_lib.utils.mongo import MongoSingleton


Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_get_guild_owner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from bson import ObjectId
from unittest import TestCase
from datetime import datetime, timedelta
from unittest import TestCase

from tc_analyzer_lib.utils.mongo import MongoSingleton
from bson import ObjectId
from tc_analyzer_lib.utils.get_guild_utils import get_platform_community_owner
from tc_analyzer_lib.utils.mongo import MongoSingleton


class TestGetGuildOwner(TestCase):
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/test_get_past_7_days_heatmaps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from datetime import datetime, timedelta

import numpy as np
from tc_analyzer_lib.algorithms.utils.member_activity_utils import (
get_users_past_window,
)
from tc_analyzer_lib.algorithms.utils.member_activity_utils import get_users_past_window

from .utils.analyzer_setup import launch_db_access

Expand Down
39 changes: 21 additions & 18 deletions tests/integration/test_network_graph_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

@pytest.mark.skip("To be updated to platform centric!")
def test_network_graph_create():
"""
testing the mock graph generation
"""
from .utils.mock_graph import generate_mock_graph, store_mock_data_in_neo4j

community_id = "4321"
Expand Down Expand Up @@ -160,21 +163,21 @@ def test_network_graph_create():

# DATABASE SAVING

store_mock_data_in_neo4j(
graph_dict=graph_dict, guildId=guildId, community_id=community_id
)

results = neo4j_ops.gds.run_cypher(
f"""
MATCH (a:{user_label}) -[:{is_member}] -> (g:{platform_label} {{guildId: '{platform_id}'}})
MATCH (a)-[r{interacted_with}]-> (b:{user_label})
RETURN
a.id as fromUserId,
r.weight as weight,
r.date as date,
b.id as toUserId
"""
)
print(desired_outputs)
print(results)
assert desired_outputs in results.values
# store_mock_data_in_neo4j(
# graph_dict=graph_dict, guildId=guildId, community_id=community_id
# )

# results = neo4j_ops.gds.run_cypher(
# f"""
# MATCH (a:{user_label}) -[:{is_member}] -> (g:{platform_label} {{guildId: '{platform_id}'}})
# MATCH (a)-[r{interacted_with}]-> (b:{user_label})
# RETURN
# a.id as fromUserId,
# r.weight as weight,
# r.date as date,
# b.id as toUserId
# """
# )
# print(desired_outputs)
# print(results)
# assert desired_outputs in results.values
Loading

0 comments on commit 6c1fa07

Please sign in to comment.