Remove docker compose and old poetry scripts

This commit is contained in:
Luke Van Seters 2021-09-20 13:04:37 -04:00
parent 036228036d
commit 4d5c8977c1
6 changed files with 13 additions and 166 deletions

View File

@ -1,3 +1,5 @@
import os
import click
from web3 import Web3
@ -6,6 +8,9 @@ from mev_inspect.inspect_block import inspect_block
from mev_inspect.provider import get_base_provider
RPC_URL_ENV = "RPC_URL"
@click.group()
def cli():
pass
@ -13,7 +18,7 @@ def cli():
@cli.command()
@click.argument("block_number", type=int)
@click.argument("rpc")
@click.option("--rpc", default=lambda: os.environ.get(RPC_URL_ENV, ""))
@click.option("--cache/--no-cache", default=True)
def inspect_block_command(block_number: int, rpc: str, cache: bool):
db_session = get_session()
@ -29,7 +34,7 @@ def inspect_block_command(block_number: int, rpc: str, cache: bool):
@cli.command()
@click.argument("after_block", type=int)
@click.argument("before_block", type=int)
@click.argument("rpc")
@click.option("--rpc", default=lambda: os.environ.get(RPC_URL_ENV, ""))
@click.option("--cache/--no-cache", default=True)
def inspect_many_blocks_command(
after_block: int, before_block: int, rpc: str, cache: bool
@ -61,5 +66,9 @@ def inspect_many_blocks_command(
)
def get_rpc_url() -> str:
return os.environ["RPC_URL"]
if __name__ == "__main__":
cli()

View File

@ -1,24 +0,0 @@
services:
mev-inspect:
build: .
depends_on:
- db
env_file:
- .env
volumes:
- .:/app
tty: true
db:
image: postgres:12
volumes:
- mev-inspect-db-data:/var/lib/postgresql/data/pgdata
env_file:
- .env
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
mev-inspect-db-data:

View File

@ -29,20 +29,8 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
lint = 'scripts.poetry.dev_tools:lint'
test = 'scripts.poetry.dev_tools:test'
isort = 'scripts.poetry.dev_tools:isort'
black = 'scripts.poetry.dev_tools:black'
pre_commit = 'scripts.poetry.dev_tools:pre_commit'
start = 'scripts.poetry.docker:start'
stop = 'scripts.poetry.docker:stop'
build = 'scripts.poetry.docker:build'
attach = 'scripts.poetry.docker:attach'
exec = 'scripts.poetry.docker:exec'
inspect = 'scripts.poetry.inspect:inspect'
inspect-many = 'scripts.poetry.inspect:inspect_many'
inspect-block = 'scripts.inspect_commands:inspect_block_command'
inspect-many-blocks = 'scripts.inspect_commands:inspect_many_blocks_command'
inspect-block = 'cli:inspect_block_command'
inspect-many-blocks = 'cli:inspect_many_blocks_command'
[tool.black]
exclude = '''

View File

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

View File

@ -1,33 +0,0 @@
from subprocess import check_call
from typing import List
import click
@click.command()
@click.option("-d", required=False, is_flag=True)
def start(d: str):
"""if d is present, run docker compose as daemon"""
if d:
check_call(["docker-compose", "up", "-d"])
click.echo("docker running in the background...")
else:
check_call(["docker-compose", "up"])
def stop():
check_call(["docker-compose", "down"])
def build():
check_call(["docker-compose", "build"])
def attach():
check_call(["docker", "exec", "-it", "mev-inspect-py_mev-inspect_1", "bash"])
@click.command()
@click.argument("args", nargs=-1)
def exec(args: List[str]):
check_call(["docker-compose", "exec", "mev-inspect", *args])

View File

@ -1,59 +0,0 @@
from subprocess import check_call
import click
@click.command()
@click.option(
"-b", "--block-number", type=str, help="the block number you are targetting"
)
@click.option(
"-r", "--rpc", help="rpc endpoint, this needs to have parity style traces"
)
@click.option(
"--cache/--no-cache",
help="whether to read / write to the cache",
default=True,
)
def inspect(block_number: str, rpc: str, cache: bool):
check_call(
[
"docker",
"compose",
"exec",
"mev-inspect",
"python",
"./scripts/inspect_block.py",
"inspect-block",
block_number,
rpc,
"--cache" if cache else "--no-cache",
]
)
@click.command()
@click.argument("after_block", type=str)
@click.argument("before_block", type=str)
@click.argument("rpc")
@click.option(
"--cache/--no-cache",
help="whether to read / write to the cache",
default=True,
)
def inspect_many(after_block: str, before_block: str, rpc: str, cache: bool):
check_call(
[
"docker",
"compose",
"exec",
"mev-inspect",
"python",
"./scripts/inspect_block.py",
"inspect-many-blocks",
after_block,
before_block,
rpc,
"--cache" if cache else "--no-cache",
]
)