Merge pull request #39 from pmdaly/scripts-clean

Scripts clean
This commit is contained in:
Robert Miller 2021-07-29 09:47:04 -04:00 committed by GitHub
commit 654b416336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 42 deletions

View File

@ -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/'
```

View File

@ -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 = '''

View File

@ -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,
]
)

View File

@ -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:

25
scripts/poetry/inspect.py Normal file
View File

@ -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,
]
)