Skip to content

Commit

Permalink
g-code-testing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
amit lissack committed Oct 23, 2021
1 parent 6ae4a1e commit e5ffa15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions g-code-testing/g_code_parsing/g_code_engine.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import os
import sys
import threading
import asyncio
import time
from multiprocessing import Process
from typing import Generator, Callable
from collections import namedtuple

from opentrons.hardware_control.emulation.magdeck import MagDeckEmulator
from opentrons.hardware_control.emulation.parser import Parser
from opentrons.hardware_control.emulation.run_emulator import \
run_emulator_client
from opentrons.hardware_control.emulation.settings import Settings
from opentrons.hardware_control.emulation.tempdeck import TempDeckEmulator
from opentrons.hardware_control.emulation.thermocycler import \
ThermocyclerEmulator
from opentrons.hardware_control.emulation.types import ModuleType
from opentrons.protocols.parse import parse
from opentrons.protocols.execution import execute
Expand Down Expand Up @@ -69,7 +60,9 @@ def _get_loop() -> asyncio.AbstractEventLoop:
@staticmethod
def _set_env_vars(settings: Settings) -> None:
"""Set URLs of where to find modules and config for smoothie"""
os.environ["OT_MAGNETIC_EMULATOR_URI"] = GCodeEngine.URI_TEMPLATE % settings.magdeck_proxy.driver_port
os.environ["OT_MAGNETIC_EMULATOR_URI"] = (
GCodeEngine.URI_TEMPLATE % settings.magdeck_proxy.driver_port
)
os.environ["OT_THERMOCYCLER_EMULATOR_URI"] = (
GCodeEngine.URI_TEMPLATE % settings.thermocycler_proxy.driver_port
)
Expand All @@ -83,14 +76,18 @@ def _start_emulation_app(emulator_settings: Settings) -> Process:
modules = [ModuleType.Magnetic, ModuleType.Temperature, ModuleType.Thermocycler]

def runit():
asyncio.run(run_app.run(emulator_settings, modules=[m.value for m in modules]))
asyncio.run(
run_app.run(emulator_settings, modules=[m.value for m in modules])
)

proc = Process(target=runit)
proc.daemon = True
proc.start()

async def _wait_ready() -> None:
c = await module_server.ModuleServerClient.connect(host="localhost", port=emulator_settings.module_server.port)
c = await module_server.ModuleServerClient.connect(
host="localhost", port=emulator_settings.module_server.port
)
await module_server.wait_emulators(client=c, modules=modules, timeout=5)
c.close()

Expand Down Expand Up @@ -152,7 +149,9 @@ def run_http(self, executable: Callable):
"""
app_process = self._start_emulation_app(emulator_settings=self._config)
with GCodeWatcher(emulator_settings=self._config) as watcher:
asyncio.run(executable(hardware=self._emulate_hardware(settings=self._config)))
asyncio.run(
executable(hardware=self._emulate_hardware(settings=self._config))
)
yield GCodeProgram.from_g_code_watcher(watcher)
app_process.terminate()
app_process.join()
2 changes: 1 addition & 1 deletion g-code-testing/tests/g_code_parsing/test_g_code_program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator, Iterator
from typing import Iterator

import pytest
from opentrons.hardware_control.emulation.settings import Settings
Expand Down

0 comments on commit e5ffa15

Please sign in to comment.