From 4d56bb45e5f21ca8d79e727022dee24951388d4b Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Mon, 3 Feb 2025 18:48:29 -0300 Subject: [PATCH] Drop old ipfs node docker managment --- skynet/ipfs/docker.py | 69 ------------------------------------------- tests/conftest.py | 4 +-- 2 files changed, 1 insertion(+), 72 deletions(-) delete mode 100755 skynet/ipfs/docker.py diff --git a/skynet/ipfs/docker.py b/skynet/ipfs/docker.py deleted file mode 100755 index c2da5fb..0000000 --- a/skynet/ipfs/docker.py +++ /dev/null @@ -1,69 +0,0 @@ -import sys -import logging - -from pathlib import Path -from contextlib import contextmanager as cm - -import docker - -from docker.types import Mount - - -@cm -def open_ipfs_node( - name: str = 'skynet-ipfs', - teardown: bool = False, - peers: list[str] = [] -): - dclient = docker.from_env() - - container = None - try: - container = dclient.containers.get(name) - - except docker.errors.NotFound: - data_dir = Path().resolve() / 'ipfs-docker-data' - data_dir.mkdir(parents=True, exist_ok=True) - - data_target = '/data/ipfs' - - container = dclient.containers.run( - 'ipfs/go-ipfs:latest', - name='skynet-ipfs', - ports={ - '8080/tcp': 8080, - '4001/tcp': 4001, - '5001/tcp': ('127.0.0.1', 5001) - }, - mounts=[ - Mount(data_target, str(data_dir), 'bind') - ], - detach=True, - remove=True - ) - - uid, gid = 1000, 1000 - - if sys.platform != 'win32': - ec, out = container.exec_run(['chown', f'{uid}:{gid}', '-R', data_target]) - logging.info(out) - assert ec == 0 - - for log in container.logs(stream=True): - log = log.decode().rstrip() - logging.info(log) - if 'Daemon is ready' in log: - break - - for peer in peers: - ec, out = container.exec_run( - ['ipfs', 'swarm', 'connect', peer]) - if ec != 0: - logging.error(out) - - # TODO, why not deliver some kinda API here for controlling the - # ipfs node? - yield - - if teardown and container: - container.stop() diff --git a/tests/conftest.py b/tests/conftest.py index f990935..56c0780 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,14 +2,12 @@ import pytest from skynet.config import * from skynet.ipfs import AsyncIPFSHTTP -from skynet.ipfs.docker import open_ipfs_node from skynet.nodeos import open_nodeos @pytest.fixture(scope='session') def ipfs_client(): - with open_ipfs_node(teardown=True): - yield AsyncIPFSHTTP('http://127.0.0.1:5001') + yield AsyncIPFSHTTP('http://127.0.0.1:5001') @pytest.fixture(scope='session') def postgres_db():