Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge mds module and component #6378

Merged
merged 11 commits into from
Sep 28, 2021
Merged
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
2 changes: 1 addition & 1 deletion experiment/popularity_community/crawl_torrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
SelectRequest, \
SelectResponsePayload
from tribler_core.modules.remote_query_community.settings import RemoteQueryCommunitySettings
from tribler_core.modules.metadata_store.serialization import REGULAR_TORRENT
from tribler_core.components.metadata_store.db.serialization import REGULAR_TORRENT
from tribler_core.utilities.tiny_tribler_service import TinyTriblerService
from tribler_core.utilities.unicode import hexlify

Expand Down
4 changes: 2 additions & 2 deletions experiment/popularity_community/initial_filling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.metadata_store import MetadataStoreComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.popularity import PopularityComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.components.socks_configurator import SocksServersComponent
from tribler_core.components.torrent_checker import TorrentCheckerComponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.modules.metadata_store.community.sync_strategy import RemovePeers
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers
from tribler_core.modules.popularity.community import PopularityCommunity
from tribler_core.utilities.tiny_tribler_service import TinyTriblerService

Expand Down
4 changes: 2 additions & 2 deletions src/seedbox/disseminator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import sentry_sdk

from tribler_core.modules.libtorrent.torrentdef import TorrentDef
from tribler_core.modules.metadata_store.community.gigachannel_community import GigaChannelCommunity
from tribler_core.modules.metadata_store.orm_bindings.channel_node import NEW
from tribler_core.components.gigachannel.community import GigaChannelCommunity
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler_core.utilities.tiny_tribler_service import TinyTriblerService

# fmt: off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

from tribler_common.simpledefs import CHANNELS_VIEW_UUID, NTFY

from tribler_core.modules.metadata_store.community.discovery_booster import DiscoveryBooster
from tribler_core.modules.metadata_store.payload_checker import ObjState
from tribler_core.modules.metadata_store.serialization import CHANNEL_TORRENT
from tribler_core.modules.metadata_store.utils import NoChannelSourcesException
from tribler_core.components.gigachannel.community.discovery_booster import DiscoveryBooster
from tribler_core.components.gigachannel.community.payload_checker import ObjState
from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT
from tribler_core.components.metadata_store.utils import NoChannelSourcesException
from tribler_core.modules.remote_query_community.community import RemoteQueryCommunity
from tribler_core.utilities.unicode import hexlify

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pony.orm import db_session

from tribler_core.modules.category_filter.l2_filter import is_forbidden
from tribler_core.modules.metadata_store.serialization import (
from tribler_core.components.metadata_store.category_filter.l2_filter import is_forbidden
from tribler_core.components.metadata_store.db.serialization import (
CHANNEL_DESCRIPTION,
CHANNEL_THUMBNAIL,
CHANNEL_TORRENT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from tribler_core.modules.metadata_store.community.discovery_booster import DiscoveryBooster
from tribler_core.components.gigachannel.community.discovery_booster import DiscoveryBooster

TEST_BOOSTER_TIMEOUT_IN_SEC = 10
TEST_BOOSTER_TAKE_STEP_INTERVAL_IN_SEC = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import pytest

from tribler_core.modules.metadata_store.community.gigachannel_community import (
from tribler_core.components.gigachannel.community.gigachannel_community import (
ChannelsPeersMapping,
GigaChannelCommunity,
NoChannelSourcesException,
)
from tribler_core.modules.metadata_store.settings import ChantSettings
from tribler_core.modules.metadata_store.store import MetadataStore
from tribler_core.modules.metadata_store.utils import RequestTimeoutException
from tribler_core.components.gigachannel.community.settings import ChantSettings
from tribler_core.components.metadata_store.db.store import MetadataStore
from tribler_core.components.metadata_store.utils import RequestTimeoutException
from tribler_core.modules.remote_query_community.settings import RemoteQueryCommunitySettings
from tribler_core.notifier import Notifier
from tribler_core.utilities.path_util import Path
Expand Down Expand Up @@ -55,7 +55,7 @@ def create_node(self, *args, **kwargs):
kwargs['metadata_store'] = metadata_store
kwargs['settings'] = ChantSettings()
kwargs['rqc_settings'] = RemoteQueryCommunitySettings()
with mock.patch('tribler_core.modules.metadata_store.community.gigachannel_community.DiscoveryBooster'):
with mock.patch('tribler_core.components.gigachannel.community.gigachannel_community.DiscoveryBooster'):
node = super().create_node(*args, **kwargs)
self.count += 1
return node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ipv8.peerdiscovery.network import Network
from ipv8.test.base import TestBase

from tribler_core.modules.metadata_store.community.sync_strategy import RemovePeers
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers


class MockCommunity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
from ipv8_service import IPv8
from tribler_core.components.base import Component
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.metadata_store import MetadataStoreComponent
from tribler_core.components.gigachannel.community.gigachannel_community import GigaChannelCommunity, \
GigaChannelTestnetCommunity
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.reporter import ReporterComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.modules.metadata_store.community.gigachannel_community import (
GigaChannelCommunity,
GigaChannelTestnetCommunity,
)
from tribler_core.modules.metadata_store.community.sync_strategy import RemovePeers
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers
from tribler_core.restapi.rest_manager import RESTManager

INFINITE = -1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest.mock import patch

from tribler_core.components.base import Session
from tribler_core.components.gigachannel.gigachannel_component import GigaChannelComponent
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.restapi.rest_manager import RESTManager


# pylint: disable=protected-access


async def test_giga_channel_component(tribler_config):
components = [MetadataStoreComponent(), RESTComponent(), MasterKeyComponent(), Ipv8Component(),
GigaChannelComponent()]
session = Session(tribler_config, components)
with session:
comp = GigaChannelComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.community
assert comp._rest_manager
assert comp._ipv8

await session.shutdown()
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from tribler_core.modules.libtorrent.download_config import DownloadConfig
from tribler_core.modules.libtorrent.download_manager import DownloadManager
from tribler_core.modules.libtorrent.torrentdef import TorrentDef
from tribler_core.modules.metadata_store.orm_bindings.channel_node import COMMITTED
from tribler_core.modules.metadata_store.serialization import CHANNEL_TORRENT
from tribler_core.modules.metadata_store.store import MetadataStore
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import COMMITTED
from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT
from tribler_core.components.metadata_store.db.store import MetadataStore
from tribler_core.notifier import Notifier
from tribler_core.utilities.unicode import hexlify

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from tribler_core.components.base import Component
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.metadata_store import MetadataStoreComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.reporter import ReporterComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.modules.metadata_store.manager.gigachannel_manager import GigaChannelManager
from tribler_core.components.gigachannel_manager.gigachannel_manager import GigaChannelManager
from tribler_core.restapi.rest_manager import RESTManager


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from tribler_common.simpledefs import DLSTATUS_SEEDING

from tribler_core.modules.libtorrent.torrentdef import TorrentDef
from tribler_core.modules.metadata_store.manager.gigachannel_manager import GigaChannelManager
from tribler_core.modules.metadata_store.orm_bindings.channel_node import NEW
from tribler_core.components.gigachannel_manager.gigachannel_manager import GigaChannelManager
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler_core.tests.tools.base_test import MockObject
from tribler_core.tests.tools.common import TORRENT_UBUNTU_FILE
from tribler_core.utilities.random_utils import random_infohash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from unittest.mock import patch

from tribler_core.components.base import Session
from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.components.socks_configurator import SocksServersComponent
from tribler_core.restapi.rest_manager import RESTManager


# pylint: disable=protected-access

async def test_gigachannel_manager_component(tribler_config):
components = [SocksServersComponent(), MasterKeyComponent(), RESTComponent(), MetadataStoreComponent(),
LibtorrentComponent(), GigachannelManagerComponent()]
session = Session(tribler_config, components)
with session:
comp = GigachannelManagerComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.gigachannel_manager
assert comp._rest_manager

await session.shutdown()
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import re
from functools import cmp_to_key

from tribler_core.modules.category_filter.family_filter import default_xxx_filter
from tribler_core.modules.category_filter.init_category import getCategoryInfo
from tribler_core.components.metadata_store.category_filter.family_filter import default_xxx_filter
from tribler_core.components.metadata_store.category_filter.init_category import getCategoryInfo
from tribler_core.utilities.install_dir import get_lib_path
from tribler_core.utilities.unicode import recursive_unicode

CATEGORY_CONFIG_FILE = get_lib_path() / 'modules/category_filter/category.conf'
CATEGORY_CONFIG_FILE = get_lib_path() / 'components/metadata_store/category_filter/category.conf'


def cmp_rank(a, b):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

WORDS_REGEXP = re.compile('[a-zA-Z0-9]+')

termfilename = get_lib_path() / 'modules' / 'category_filter' / 'filter_terms.filter'
termfilename = get_lib_path() / 'components' / 'metadata_store' /'category_filter' / 'filter_terms.filter'


def initTerms(filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# !ACHTUNG! We must first read the line into a file, then release the lock, and only then pass it to regex compiler.
# Otherwise, there is an annoying race condition that reads in an empty file!
with open(get_lib_path() / 'modules' / 'category_filter' / 'level2.regex', encoding="utf-8") as f:
with open(get_lib_path() / 'components' / 'metadata_store' / 'category_filter' / 'level2.regex', encoding="utf-8") as f:
regex = f.read().strip()
stoplist_expression = re.compile(regex, re.IGNORECASE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tribler_core.modules.category_filter.category import cmp_rank, default_category_filter
from tribler_core.modules.category_filter.family_filter import default_xxx_filter
from tribler_core.components.metadata_store.category_filter.category import cmp_rank, default_category_filter
from tribler_core.components.metadata_store.category_filter.family_filter import default_xxx_filter


default_xxx_filter.xxx_terms.add("term1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from tribler_core.modules.category_filter.family_filter import XXXFilter
from tribler_core.modules.category_filter.l2_filter import is_forbidden
from tribler_core.components.metadata_store.category_filter.family_filter import XXXFilter
from tribler_core.components.metadata_store.category_filter.l2_filter import is_forbidden


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tribler_core.modules.category_filter.category import CATEGORY_CONFIG_FILE
from tribler_core.modules.category_filter.init_category import INIT_FUNC_DICT, getCategoryInfo
from tribler_core.components.metadata_store.category_filter.category import CATEGORY_CONFIG_FILE
from tribler_core.components.metadata_store.category_filter.init_category import INIT_FUNC_DICT, getCategoryInfo


def test_split_list():
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pony.orm import Optional

from tribler_core.modules.metadata_store.serialization import BINARY_NODE, BinaryNodePayload
from tribler_core.components.metadata_store.db.serialization import BINARY_NODE, BinaryNodePayload


def define_binding(db, db_version: int):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tribler_core.modules.metadata_store.serialization import CHANNEL_DESCRIPTION
from tribler_core.components.metadata_store.db.serialization import CHANNEL_DESCRIPTION


def define_binding(db):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from tribler_common.simpledefs import CHANNEL_STATE

from tribler_core.modules.metadata_store.discrete_clock import clock
from tribler_core.modules.metadata_store.orm_bindings.channel_node import (
from tribler_core.components.metadata_store.db.orm_bindings.discrete_clock import clock
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import (
CHANNEL_DESCRIPTION_FLAG,
CHANNEL_THUMBNAIL_FLAG,
COMMITTED,
Expand All @@ -20,7 +20,7 @@
TODELETE,
UPDATED,
)
from tribler_core.modules.metadata_store.serialization import (
from tribler_core.components.metadata_store.db.serialization import (
CHANNEL_TORRENT,
ChannelMetadataPayload,
HealthItemsPayload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pony.orm.core import DEFAULT, db_session

from tribler_core.exceptions import InvalidChannelNodeException, InvalidSignatureException
from tribler_core.modules.metadata_store.discrete_clock import clock
from tribler_core.modules.metadata_store.serialization import (
from tribler_core.components.metadata_store.db.orm_bindings.discrete_clock import clock
from tribler_core.components.metadata_store.db.serialization import (
CHANNEL_NODE,
ChannelNodePayload,
DELETED,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tribler_core.modules.metadata_store.serialization import CHANNEL_THUMBNAIL
from tribler_core.components.metadata_store.db.serialization import CHANNEL_THUMBNAIL


def define_binding(db):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
from pony.orm import db_session, select

from tribler_common.simpledefs import CHANNEL_STATE

from tribler_core.exceptions import DuplicateTorrentFileError
from tribler_core.modules.libtorrent.torrentdef import TorrentDef
from tribler_core.modules.metadata_store.discrete_clock import clock
from tribler_core.modules.metadata_store.orm_bindings.channel_metadata import chunks
from tribler_core.modules.metadata_store.orm_bindings.channel_node import (
from tribler_core.components.metadata_store.db.orm_bindings.channel_metadata import chunks
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import (
CHANNEL_DESCRIPTION_FLAG,
CHANNEL_THUMBNAIL_FLAG,
COMMITTED,
Expand All @@ -19,10 +15,15 @@
TODELETE,
UPDATED,
)
from tribler_core.modules.metadata_store.orm_bindings.torrent_metadata import tdef_to_metadata_dict
from tribler_core.modules.metadata_store.serialization import CHANNEL_TORRENT, COLLECTION_NODE, CollectionNodePayload
from tribler_core.components.metadata_store.db.orm_bindings.discrete_clock import clock
from tribler_core.components.metadata_store.db.orm_bindings.torrent_metadata import tdef_to_metadata_dict
from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT, COLLECTION_NODE, \
CollectionNodePayload
from tribler_core.exceptions import DuplicateTorrentFileError
from tribler_core.modules.libtorrent.torrentdef import TorrentDef
from tribler_core.utilities.random_utils import random_infohash


# pylint: disable=too-many-statements


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# not go backwards between Tribler restarts.
from datetime import datetime

from tribler_core.modules.metadata_store.serialization import time2int
from tribler_core.components.metadata_store.db.serialization import time2int


class DiscreteClock:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pony.orm import Optional

from tribler_core.modules.metadata_store.serialization import JSON_NODE, JsonNodePayload
from tribler_core.components.metadata_store.db.serialization import JSON_NODE, JsonNodePayload


def define_binding(db, db_version: int):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pony import orm

from tribler_core.modules.metadata_store.serialization import METADATA_NODE, MetadataNodePayload
from tribler_core.components.metadata_store.db.serialization import METADATA_NODE, MetadataNodePayload


def define_binding(db):
Expand Down
Loading