cleaning up poetry scripts

This commit is contained in:
Patrick Daly 2021-07-24 16:04:34 -07:00
parent c592a49c35
commit f55b94192f
2 changed files with 56 additions and 21 deletions

View File

@ -1,29 +1,38 @@
from subprocess import check_call
import click
from subprocess import check_call, run
def lint():
check_call(['pylint', '.'])
check_call(["pylint", "."])
def test():
check_call(['pytest', '--cov=mev_inspect', 'tests'])
check_call(["pytest", "--cov=mev_inspect", "tests"])
@click.command()
@click.option('-c', required=False, is_flag=True)
@click.option("-c", required=False, is_flag=True)
def isort(c: str):
'''if c is present run isort in diff mode'''
"""if c is present run isort in diff mode"""
if c:
check_call(['isort', '.'])
check_call(["isort", "."])
else:
check_call(['isort', '--diff', '.'])
check_call(["isort", "--diff", "."])
def mypy():
check_call(['mypy', '.'])
check_call(["mypy", "."])
@click.command()
@click.option('-c', required=False, is_flag=True)
@click.option("-c", required=False, is_flag=True)
def black(c: str):
'''if c is present run black in diff mode'''
"""if c is present run black in diff mode"""
if c:
check_call(['black', '.'])
check_call(["black", "."])
else:
check_call(['black', '--diff', '--color', '.'])
check_call(["black", "--diff", "--color", "."])
def pre_commit():
check_call(["pre-commit", "run", "--all-files"])

View File

@ -1,19 +1,45 @@
from subprocess import check_call
import click
from subprocess import check_call, run
from typing import List
@click.command()
@click.option('-b', required=False, is_flag=True)
@click.option("-b", required=False, is_flag=True)
def start(b: str):
'''if d is present background compose'''
"""if d is present background compose"""
if b:
check_call(['docker', 'compose', 'up', '-d'])
click.echo('docker running in the background...')
check_call(["docker", "compose", "up", "-d"])
click.echo("docker running in the background...")
else:
check_call(['docker', 'compose', 'up'])
check_call(["docker", "compose", "up"])
def stop():
check_call(['docker', 'compose', 'down'])
check_call(["docker", "compose", "down"])
def build():
check_call(['docker', 'compose', 'build'])
check_call(["docker", "compose", "build"])
def attach():
check_call(["docker", "exec", "-it", "mev-inspect-py_mev-inspect_1", "bash"])
@click.command()
@click.option("-script", help="inspect script", default="./examples/uniswap_inspect.py")
@click.option("-block_num", help="block number to inspect", default=11931271)
@click.option("-rpc", help="rpc address", default="http://111.11.11.111:8545")
def inspect(script: str, block_num: int, rpc: str):
"""Runs mev-inspect scripts through docker services"""
check_call(
[
"docker",
"compose",
"exec",
"mev-inspect",
"python",
script,
f"-block_number {block_num}",
f"-rpc {rpc}",
]
)