From 7f26c600dc790ac6923a458f5e64c015c1856df4 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Wed, 28 Jul 2021 21:03:33 -0700 Subject: [PATCH] moved all scripts to ./scripts and added some arg shorthands --- README.md | 10 ++++---- pyproject.toml | 24 +++++++++---------- scripts/inspect.py | 21 ---------------- inspect_block.py => scripts/inspect_block.py | 0 scripts/{ => poetry}/dev_tools.py | 0 scripts/{ => poetry}/docker.py | 8 +++---- scripts/poetry/inspect.py | 25 ++++++++++++++++++++ 7 files changed, 46 insertions(+), 42 deletions(-) delete mode 100644 scripts/inspect.py rename inspect_block.py => scripts/inspect_block.py (100%) rename scripts/{ => poetry}/dev_tools.py (100%) rename scripts/{ => poetry}/docker.py (82%) create mode 100644 scripts/poetry/inspect.py diff --git a/README.md b/README.md index f8c7ec6..fcd3c35 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Install dependencies through poetry poetry install ``` -Start the services (optionally as background processes) +Start the services (optionally as daemon ``` -poetry run start [-b] +poetry run start [-d] ``` Apply the latest migrations against the local DB: @@ -30,7 +30,7 @@ poetry run exec alembic upgrade head Run inspect on a block ``` -poetry run inspect --block-number 11931270 --rpc 'http://111.11.11.111:8545/' +poetry run inspect -b/--block-number 11931270 -r/--rpc 'http://111.11.11.111:8545/' ``` To stop the services (if running in the background, otherwise just ctrl+c) @@ -67,12 +67,12 @@ poetry run mypy # type checking poetry run black # style guide poetry run pre-commit run --all-files # runs Black, PyLint and MyPy # docker management -poetry run start [-b] # starts all services, optionally in the background +poetry run start [-d] # starts all services, optionally as a daemon poetry run stop # shutsdown all services or just ctrl + c if foreground poetry run build # rebuilds containers poetry run attach # enters the mev-inspect container in interactive mode # launches inspection script -poetry run inspect --block-number 11931270 --rpc 'http://111.11.11.111:8545/' +poetry run inspect -b/--block-number 11931270 -r/--rpc 'http://111.11.11.111:8545/' ``` diff --git a/pyproject.toml b/pyproject.toml index 76a07dd..47e514f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,18 +29,18 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] -lint = 'scripts.dev_tools:lint' -test = 'scripts.dev_tools:test' -isort = 'scripts.dev_tools:isort' -mypy = 'scripts.dev_tools:mypy' -black = 'scripts.dev_tools:black' -pre_commit = 'scripts.dev_tools:pre_commit' -start = 'scripts.docker:start' -stop = 'scripts.docker:stop' -build = 'scripts.docker:build' -attach = 'scripts.docker:attach' -exec = 'scripts.docker:exec' -inspect = 'scripts.inspect:inspect' +lint = 'scripts.poetry.dev_tools:lint' +test = 'scripts.poetry.dev_tools:test' +isort = 'scripts.poetry.dev_tools:isort' +mypy = 'scripts.poetry.dev_tools:mypy' +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' [tool.black] exclude = ''' diff --git a/scripts/inspect.py b/scripts/inspect.py deleted file mode 100644 index fc36014..0000000 --- a/scripts/inspect.py +++ /dev/null @@ -1,21 +0,0 @@ -from subprocess import check_call - -import click - - -@click.command() -@click.option("--block-number", type=int, help="the block number you are targetting") -@click.option("--rpc", help="rpc endpoint, this needs to have parity style traces") -def inspect(block_number: int, rpc: str): - check_call( - [ - "docker", - "compose", - "exec", - "mev-inspect", - "python", - "inspect_block.py", - str(block_number), - rpc, - ] - ) diff --git a/inspect_block.py b/scripts/inspect_block.py similarity index 100% rename from inspect_block.py rename to scripts/inspect_block.py diff --git a/scripts/dev_tools.py b/scripts/poetry/dev_tools.py similarity index 100% rename from scripts/dev_tools.py rename to scripts/poetry/dev_tools.py diff --git a/scripts/docker.py b/scripts/poetry/docker.py similarity index 82% rename from scripts/docker.py rename to scripts/poetry/docker.py index e034c33..fc8ba02 100644 --- a/scripts/docker.py +++ b/scripts/poetry/docker.py @@ -5,10 +5,10 @@ import click @click.command() -@click.option("-b", required=False, is_flag=True) -def start(b: str): - """if d is present background compose""" - if b: +@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: diff --git a/scripts/poetry/inspect.py b/scripts/poetry/inspect.py new file mode 100644 index 0000000..1128925 --- /dev/null +++ b/scripts/poetry/inspect.py @@ -0,0 +1,25 @@ +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" +) +def inspect(block_number: str, rpc: str): + check_call( + [ + "docker", + "compose", + "exec", + "mev-inspect", + "python", + "./scripts/inspect_block.py", + block_number, + rpc, + ] + )