Skip to content

Commit

Permalink
Merge pull request #515 from kozlovsky/fix/tribler_new_directory_stru…
Browse files Browse the repository at this point in the history
…cture

Update Gumby to work with new Tribler directory structure
  • Loading branch information
kozlovsky authored Mar 17, 2022
2 parents b9d9d9e + 9239340 commit c9d29d1
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random

from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.bandwidth_accounting.community.bandwidth_accounting_community import \
from tribler.core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler.core.components.bandwidth_accounting.community.bandwidth_accounting_community import \
BandwidthAccountingCommunity

from gumby.experiment import experiment_callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from pony.orm import db_session

from tribler_core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler_core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData
from tribler.core.components.bandwidth_accounting.db.database import BandwidthDatabase
from tribler.core.components.bandwidth_accounting.db.transaction import BandwidthTransactionData

from gumby.statsparser import StatisticsParser

Expand Down
2 changes: 1 addition & 1 deletion experiments/dht/dht_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ipv8.dht import DHTError
from ipv8.dht.discovery import DHTDiscoveryCommunity

from tribler_core.components.ipv8.ipv8_component import Ipv8Component
from tribler.core.components.ipv8.ipv8_component import Ipv8Component

from gumby.experiment import experiment_callback
from gumby.modules.tribler_module import TriblerBasedModule
Expand Down
10 changes: 5 additions & 5 deletions experiments/gigachannel/gigachannel_module.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pony.orm import db_session

from tribler_core.components.gigachannel.community.gigachannel_community import GigaChannelCommunity
from tribler_core.components.gigachannel.gigachannel_component import GigaChannelComponent
from tribler_core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.utilities.simpledefs import DLSTATUS_SEEDING
from tribler.core.components.gigachannel.community.gigachannel_community import GigaChannelCommunity
from tribler.core.components.gigachannel.gigachannel_component import GigaChannelComponent
from tribler.core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler.core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler.core.utilities.simpledefs import DLSTATUS_SEEDING

from gumby.experiment import experiment_callback
from gumby.modules.tribler_module import TriblerBasedModule
Expand Down
8 changes: 4 additions & 4 deletions experiments/popularity/popularity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from pony.orm import count, db_session, desc

from tribler_core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler_core.components.popularity.community.popularity_community import PopularityCommunity
from tribler_core.components.popularity.popularity_component import PopularityComponent
from tribler.core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler.core.components.metadata_store.db.orm_bindings.channel_node import NEW
from tribler.core.components.popularity.community.popularity_community import PopularityCommunity
from tribler.core.components.popularity.popularity_component import PopularityComponent

from gumby.experiment import experiment_callback
from gumby.modules.tribler_module import TriblerBasedModule
Expand Down
6 changes: 3 additions & 3 deletions experiments/tribler_idle_run/tribler_idle_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import sys
from pathlib import Path

from tribler_core.components.base import Session
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.start_core import components_gen
from tribler.core.components.base import Session
from tribler.core.config.tribler_config import TriblerConfig
from tribler.core.start_core import components_gen

BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
DEFAULT_EXECUTION_TIME = 60 * 10 # Run for 10 minutes by default
Expand Down
6 changes: 3 additions & 3 deletions experiments/trustchain/post_process_trustchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import os
import sys

from gumby.statsparser import StatisticsParser
from anydex.trustchain.database import TrustChainDB

from tribler_core.utilities.unicode import hexlify
from tribler.core.utilities.unicode import hexlify

from anydex.trustchain.database import TrustChainDB
from gumby.statsparser import StatisticsParser


class TrustchainStatisticsParser(StatisticsParser):
Expand Down
2 changes: 1 addition & 1 deletion experiments/tunnels/hidden_tunnel_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tribler_core.utilities.unicode import hexlify
from tribler.core.utilities.unicode import hexlify

from experiments.tunnels.tunnel_module import TunnelModule

Expand Down
14 changes: 7 additions & 7 deletions experiments/tunnels/tunnel_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from ipv8.messaging.anonymization.community import TunnelSettings
from ipv8.messaging.anonymization.tunnel import PEER_FLAG_EXIT_BT, PEER_FLAG_RELAY

from tribler_core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler_core.components.payout.payout_component import PayoutComponent
from tribler_core.components.tunnel.community.tunnel_community import TriblerTunnelCommunity
from tribler_core.components.tunnel.settings import TunnelCommunitySettings
from tribler_core.components.tunnel.tunnel_component import TunnelsComponent
from tribler_core.utilities.simpledefs import DOWNLOAD, UPLOAD, dlstatus_strings
from tribler_core.utilities.unicode import hexlify
from tribler.core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler.core.components.payout.payout_component import PayoutComponent
from tribler.core.components.tunnel.community.tunnel_community import TriblerTunnelCommunity
from tribler.core.components.tunnel.settings import TunnelCommunitySettings
from tribler.core.components.tunnel.tunnel_component import TunnelsComponent
from tribler.core.utilities.simpledefs import DOWNLOAD, UPLOAD, dlstatus_strings
from tribler.core.utilities.unicode import hexlify

from gumby.experiment import experiment_callback
from gumby.modules.tribler_module import TriblerBasedModule
Expand Down
9 changes: 4 additions & 5 deletions gumby/launch_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ def setup_environment_other():
if "TRIBLER_DIR" not in environ:
environ["TRIBLER_DIR"] = path.abspath(path.join(environ["PROJECT_DIR"], "tribler"))

# Add the Tribler source directories to the Python path so we can import from them
for subdir_name in ['tribler-core']:
subdir_path = path.join(environ["TRIBLER_DIR"], 'src', subdir_name)
if subdir_path not in python_path:
python_path.append(subdir_path)
# Add the Tribler source directory to the Python path so we can import from them
src_dir = path.join(environ["TRIBLER_DIR"], 'src')
if src_dir not in python_path:
python_path.append(src_dir)

if "ANYDEX_DIR" in environ:
python_path.append(environ["ANYDEX_DIR"])
Expand Down
12 changes: 6 additions & 6 deletions gumby/modules/tribler_community_launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@

# Communities
def tribler_tunnel_community():
from tribler_core.components.tunnel.community.tunnel_community import TriblerTunnelCommunity
from tribler.core.components.tunnel.community.tunnel_community import TriblerTunnelCommunity
return TriblerTunnelCommunity


def bandwidth_accounting_community():
from tribler_core.components.bandwidth_accounting.community.bandwidth_accounting_community import \
from tribler.core.components.bandwidth_accounting.community.bandwidth_accounting_community import \
BandwidthAccountingCommunity
return BandwidthAccountingCommunity


def popularity_community():
from tribler_core.components.popularity.community.popularity_community import PopularityCommunity
from tribler.core.components.popularity.community.popularity_community import PopularityCommunity
return PopularityCommunity


def giga_channel_community():
from tribler_core.components.gigachannel.community.gigachannel_community import GigaChannelCommunity
from tribler.core.components.gigachannel.community.gigachannel_community import GigaChannelCommunity
return GigaChannelCommunity


# Strategies
def golden_ratio_strategy():
from tribler_core.components.tunnel.community.discovery import GoldenRatioStrategy
from tribler.core.components.tunnel.community.discovery import GoldenRatioStrategy
return GoldenRatioStrategy


def remove_peers():
from tribler_core.components.gigachannel.community.sync_strategy import RemovePeers
from tribler.core.components.gigachannel.community.sync_strategy import RemovePeers
return RemovePeers


Expand Down
48 changes: 24 additions & 24 deletions gumby/modules/tribler_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@

from pony.orm import db_session, desc

from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Session
from tribler_core.components.gigachannel.gigachannel_component import GigaChannelComponent
from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent
from tribler_core.components.ipv8.ipv8_component import Ipv8Component
from tribler_core.components.key.key_component import KeyComponent
from tribler_core.components.libtorrent.download_manager.download_config import DownloadConfig
from tribler_core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler_core.components.libtorrent.torrentdef import TorrentDef
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.payout.payout_component import PayoutComponent
from tribler_core.components.popularity.popularity_component import PopularityComponent
from tribler_core.components.resource_monitor.resource_monitor_component import ResourceMonitorComponent
from tribler_core.components.restapi.restapi_component import RESTComponent
from tribler_core.components.socks_servers.socks_servers_component import SocksServersComponent
from tribler_core.components.tag.tag_component import TagComponent
from tribler_core.components.torrent_checker.torrent_checker_component import TorrentCheckerComponent
from tribler_core.components.tunnel.tunnel_component import TunnelsComponent
from tribler_core.components.watch_folder.watch_folder_component import WatchFolderComponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.config.tribler_config_section import TriblerConfigSection
from tribler_core.utilities.simpledefs import dlstatus_strings
from tribler_core.utilities.unicode import hexlify
from tribler.core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler.core.components.base import Session
from tribler.core.components.gigachannel.gigachannel_component import GigaChannelComponent
from tribler.core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent
from tribler.core.components.ipv8.ipv8_component import Ipv8Component
from tribler.core.components.key.key_component import KeyComponent
from tribler.core.components.libtorrent.download_manager.download_config import DownloadConfig
from tribler.core.components.libtorrent.libtorrent_component import LibtorrentComponent
from tribler.core.components.libtorrent.torrentdef import TorrentDef
from tribler.core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler.core.components.payout.payout_component import PayoutComponent
from tribler.core.components.popularity.popularity_component import PopularityComponent
from tribler.core.components.resource_monitor.resource_monitor_component import ResourceMonitorComponent
from tribler.core.components.restapi.restapi_component import RESTComponent
from tribler.core.components.socks_servers.socks_servers_component import SocksServersComponent
from tribler.core.components.tag.tag_component import TagComponent
from tribler.core.components.torrent_checker.torrent_checker_component import TorrentCheckerComponent
from tribler.core.components.tunnel.tunnel_component import TunnelsComponent
from tribler.core.components.watch_folder.watch_folder_component import WatchFolderComponent
from tribler.core.config.tribler_config import TriblerConfig
from tribler.core.config.tribler_config_section import TriblerConfigSection
from tribler.core.utilities.simpledefs import dlstatus_strings
from tribler.core.utilities.unicode import hexlify

from gumby.experiment import experiment_callback
from gumby.modules.base_ipv8_module import IPv8Provider
Expand Down Expand Up @@ -117,7 +117,7 @@ def generate_isolated_community_id(self, overlay):

def components_gen(self, config: GumbyTriblerConfig): # pylint: disable=too-many-branches
"""
Copy-pasted and modified version of tribler_core.start_core.components_gen
Copy-pasted and modified version of tribler.core.start_core.components_gen
"""
# Removed part of components_gen are commented out and not removed to make the difference clearer

Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def run_experiment(conf_path):
args = parser.parse_args()

if not os.path.exists(args.confpath):
print("Error: The specified configuration file doesn't exist.")
print(f"Error: The specified configuration file doesn't exist: {args.confpath}")
sys.exit(1)

sys.path.append(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_in_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def expand_var(var):
extend_var(environ, "PYTHONPATH", path.join(project_dir, "gumby"))

# Add tribler dir to PYTHONPATH
extend_var(environ, "PYTHONPATH", path.join(project_dir, "tribler", "src", "tribler-core"))
extend_var(environ, "PYTHONPATH", path.join(project_dir, "tribler", "src"))

# Add gumby scripts dir to PATH
extend_var(environ, "PATH", scripts_dir)
Expand Down

0 comments on commit c9d29d1

Please sign in to comment.