From 040ecb9787d40ad542c4a771a815939c7d39a3bc Mon Sep 17 00:00:00 2001 From: haianhng31 Date: Wed, 11 Dec 2024 21:02:49 +0000 Subject: [PATCH 1/5] Remove IContentTypeConfigStore from HMA --- .../src/OpenMediaMatch/storage/interface.py | 11 +---------- .../src/OpenMediaMatch/storage/mocked.py | 5 +++-- .../src/OpenMediaMatch/storage/postgres/impl.py | 5 +++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py index 75fb9420f..b0ebec911 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py @@ -22,6 +22,7 @@ import flask +from threatexchange.cli.storage.interfaces import IContentTypeConfigStore from threatexchange.utils import dataclass_json from threatexchange.content_type.content_base import ContentType from threatexchange.signal_type.signal_base import SignalType @@ -50,16 +51,6 @@ class ContentTypeConfig: content_type: t.Type[ContentType] -class IContentTypeConfigStore(metaclass=abc.ABCMeta): - """Interface for accessing ContentType configuration""" - - @abc.abstractmethod - def get_content_type_configs(self) -> t.Mapping[str, ContentTypeConfig]: - """ - Return all installed content types. - """ - - @dataclass class SignalTypeConfig: """ diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py index 476c3f6d0..655f4f2ad 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py @@ -20,6 +20,7 @@ TUpdateRecordKey, ) +from threatexchange.cli.storage import interfaces from OpenMediaMatch.storage import interface from OpenMediaMatch.storage.interface import SignalTypeConfig @@ -40,9 +41,9 @@ def __init__(self) -> None: def is_ready(self) -> bool: return True - def get_content_type_configs(self) -> t.Mapping[str, interface.ContentTypeConfig]: + def get_content_type_configs(self) -> t.Mapping[str, interfaces.ContentTypeConfig]: return { - c.get_name(): interface.ContentTypeConfig(True, c) + c.get_name(): interfaces.ContentTypeConfig(True, c) for c in (PhotoContent, VideoContent) } diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py index 8a9a1c092..ab5ddc7c8 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py @@ -36,6 +36,7 @@ TUpdateRecordKey, ) +from threatexchange.cli.storage import interfaces from OpenMediaMatch.storage import interface from OpenMediaMatch.storage.postgres import database, flask_utils @@ -88,9 +89,9 @@ def __init__( exchange_types ), "All exchange types must have unique names" - def get_content_type_configs(self) -> t.Mapping[str, interface.ContentTypeConfig]: + def get_content_type_configs(self) -> t.Mapping[str, interfaces.ContentTypeConfig]: return { - name: interface.ContentTypeConfig(True, ct) + name: interfaces.ContentTypeConfig(True, ct) for name, ct in self.content_types.items() } From 8c5ff52bf3459d29c3390da982e41c7f7481c026 Mon Sep 17 00:00:00 2001 From: haianhng31 Date: Wed, 11 Dec 2024 21:37:12 +0000 Subject: [PATCH 2/5] remove import interfaces from pytx in hma --- hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py | 5 ++--- .../src/OpenMediaMatch/storage/postgres/impl.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py index 655f4f2ad..476c3f6d0 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/mocked.py @@ -20,7 +20,6 @@ TUpdateRecordKey, ) -from threatexchange.cli.storage import interfaces from OpenMediaMatch.storage import interface from OpenMediaMatch.storage.interface import SignalTypeConfig @@ -41,9 +40,9 @@ def __init__(self) -> None: def is_ready(self) -> bool: return True - def get_content_type_configs(self) -> t.Mapping[str, interfaces.ContentTypeConfig]: + def get_content_type_configs(self) -> t.Mapping[str, interface.ContentTypeConfig]: return { - c.get_name(): interfaces.ContentTypeConfig(True, c) + c.get_name(): interface.ContentTypeConfig(True, c) for c in (PhotoContent, VideoContent) } diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py index ab5ddc7c8..8a9a1c092 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/postgres/impl.py @@ -36,7 +36,6 @@ TUpdateRecordKey, ) -from threatexchange.cli.storage import interfaces from OpenMediaMatch.storage import interface from OpenMediaMatch.storage.postgres import database, flask_utils @@ -89,9 +88,9 @@ def __init__( exchange_types ), "All exchange types must have unique names" - def get_content_type_configs(self) -> t.Mapping[str, interfaces.ContentTypeConfig]: + def get_content_type_configs(self) -> t.Mapping[str, interface.ContentTypeConfig]: return { - name: interfaces.ContentTypeConfig(True, ct) + name: interface.ContentTypeConfig(True, ct) for name, ct in self.content_types.items() } From 2a1d21b1f6ee79ed298d0c45f9a3706eb085d268 Mon Sep 17 00:00:00 2001 From: haianhng31 Date: Fri, 13 Dec 2024 18:55:04 +0000 Subject: [PATCH 3/5] add __init__.py to interfaces directory --- python-threatexchange/threatexchange/cli/storage/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 python-threatexchange/threatexchange/cli/storage/__init__.py diff --git a/python-threatexchange/threatexchange/cli/storage/__init__.py b/python-threatexchange/threatexchange/cli/storage/__init__.py new file mode 100644 index 000000000..71ca4b12c --- /dev/null +++ b/python-threatexchange/threatexchange/cli/storage/__init__.py @@ -0,0 +1 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. From 73243f8d71b8d1072f6e14739c94a0d700866370 Mon Sep 17 00:00:00 2001 From: haianhng31 Date: Fri, 13 Dec 2024 19:25:06 +0000 Subject: [PATCH 4/5] pytx move storage outside of cli --- hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py b/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py index b0ebec911..0a88c4ed4 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/storage/interface.py @@ -22,7 +22,7 @@ import flask -from threatexchange.cli.storage.interfaces import IContentTypeConfigStore +from threatexchange.storage.interfaces import IContentTypeConfigStore from threatexchange.utils import dataclass_json from threatexchange.content_type.content_base import ContentType from threatexchange.signal_type.signal_base import SignalType From e44ffa03c28a9257bf688be8d0d6f88a03f1944b Mon Sep 17 00:00:00 2001 From: haianhng31 Date: Fri, 13 Dec 2024 19:31:59 +0000 Subject: [PATCH 5/5] pytx move storage outside of cli --- .../threatexchange/{cli => }/storage/__init__.py | 0 .../threatexchange/{cli => }/storage/interfaces.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename python-threatexchange/threatexchange/{cli => }/storage/__init__.py (100%) rename python-threatexchange/threatexchange/{cli => }/storage/interfaces.py (100%) diff --git a/python-threatexchange/threatexchange/cli/storage/__init__.py b/python-threatexchange/threatexchange/storage/__init__.py similarity index 100% rename from python-threatexchange/threatexchange/cli/storage/__init__.py rename to python-threatexchange/threatexchange/storage/__init__.py diff --git a/python-threatexchange/threatexchange/cli/storage/interfaces.py b/python-threatexchange/threatexchange/storage/interfaces.py similarity index 100% rename from python-threatexchange/threatexchange/cli/storage/interfaces.py rename to python-threatexchange/threatexchange/storage/interfaces.py