Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information...
David Minarsch
David Minarsch committed Aug 4, 2019
1 parent 136d1b0 commit c1735c2775edee625bf4302c410a1f8aaada9b2f
Showing with 10 additions and 3 deletions.
  1. +1 −0 scripts/generate_private_key.py
  2. +8 −1 scripts/launch_alt.py
  3. +0 −1 tac/platform/simulation.py
  4. +1 −1 tox.ini
@@ -21,6 +21,7 @@

"""
Generate a private key to be used for the Trading Agent Competition.
It prints the key in PEM format to the specified file.
"""

@@ -20,8 +20,10 @@


class VisdomServer:
"""Class to manage the visdom server."""

def __enter__(self):
"""Define what the context manager should do at the beginning of the block."""
if platform.system() == 'Darwin':
# This is required due to a bug in mac os Mojave
print("Setting environment var...")
@@ -30,20 +32,24 @@ def __enter__(self):
self.proc = subprocess.Popen(["python3", "-m", "visdom.server"], env=os.environ, cwd=ROOT_DIR)

def __exit__(self, exc_type, exc_val, exc_tb):
"""Define what the context manager should do after the block has been executed."""
print("Terminating Visdom server...")
self.proc.terminate()


class OEFNode:
"""Class to manage the OEF node."""

def _stop_oef_search_images(self):
"""Stop any running OEF nodes."""
client = docker.from_env()
for container in client.containers.list():
if any(re.match("fetchai/oef-search", tag) for tag in container.image.tags):
print("Stopping existing OEF Node...")
container.stop()

def _wait_for_oef(self):
"""Wait for the OEF to come live."""
print("Waiting for the OEF to be operative...")
wait_for_oef = subprocess.Popen([
os.path.join("sandbox", "wait-for-oef.sh"),
@@ -55,6 +61,7 @@ def _wait_for_oef(self):
wait_for_oef.wait(30)

def __enter__(self):
"""Define what the context manager should do at the beginning of the block."""
self._stop_oef_search_images()
script_path = os.path.join("oef_search_pluto_scripts", "launch.py")
configuration_file_path = os.path.join("oef_search_pluto_scripts", "launch_config_latest.json")
@@ -66,6 +73,7 @@ def __enter__(self):
print("ID: ", self.id)

def __exit__(self, exc_type, exc_val, exc_tb):
"""Define what the context manager should do after the block has been executed."""
print("Stopping OEF Node...")
p = subprocess.Popen(["docker", "stop", self.id], env=os.environ)
p.wait()
@@ -83,4 +91,3 @@ def _get_image_id(self):

with VisdomServer(), OEFNode():
tac.platform.simulation.run(simulation_params)

@@ -39,7 +39,6 @@
import multiprocessing
import pprint
import random
import signal
import time
from typing import Optional, List

@@ -19,4 +19,4 @@ basepython = python3.7
deps = flake8
flake8-docstrings
pydocstyle==3.0.0
commands = flake8 tac simulation sandbox templates tests --exclude=tac/gui/static,tac/gui/templates,.md,tac/tac_pb2.py,tac/gui/.visdom_env,tac/__init__.py --ignore=E501,E701
commands = flake8 tac simulation sandbox scripts templates tests --exclude=tac/gui/static,tac/gui/templates,.md,tac/tac_pb2.py,tac/gui/.visdom_env,tac/__init__.py --ignore=E501,E701

0 comments on commit c1735c2

Please sign in to comment.
You can’t perform that action at this time.