Skip to content

Commit

Permalink
chore: addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Sep 18, 2024
1 parent 06daa73 commit 7410b9b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ repos:
types: [python]
args: [--no-cache]
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "0"
exclude: ^src/.*core/_vendor/
- id: ruff
name: ruff
description: "Run 'ruff' for extremely fast Python linting"
Expand All @@ -19,16 +18,14 @@ repos:
"types": [python]
args: [--fix, --no-cache]
require_serial: false
additional_dependencies: []
minimum_pre_commit_version: "0"
files: "^(src|tests)/"
exclude: ^src/.*core/_vendor/
- id: mypy
name: mypy
description: "`mypy` will check Python types for correctness"
entry: poetry run mypy
language: system
types_or: [python, pyi]
require_serial: true
additional_dependencies: []
minimum_pre_commit_version: "2.9.2"
files: "^(src|tests)/"
exclude: ^src/.*core/_vendor/
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ exclude = [
"node_modules",
"venv",
"docs/sphinx",
"src/algokit/core/_vendor/*",
"src/**/core/_vendor",
]
# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
Expand All @@ -163,7 +163,7 @@ markers = [
addopts = "-m 'not pyinstaller_binary_tests'" # by default, exclude pyinstaller_binary_tests
[tool.mypy]
files = ["src", "tests"]
exclude = ["dist", "src/algokit/core/_vendor/*"]
exclude = ["dist", "*/_vendor/*"]
python_version = "3.10"
warn_unused_ignores = true
warn_redundant_casts = true
Expand Down
10 changes: 6 additions & 4 deletions src/algokit/cli/localnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from algokit.cli.explore import explore_command
from algokit.cli.goal import goal_command
from algokit.core import proc
from algokit.core.conf import get_app_config_dir
from algokit.core.config_commands.container_engine import get_container_engine, save_container_engine
from algokit.core.sandbox import (
COMPOSE_VERSION_COMMAND,
Expand Down Expand Up @@ -126,7 +127,7 @@ def config_command(*, engine: str | None, force: bool) -> None:
default=None,
help="Specify a name for a custom LocalNet instance. "
"AlgoKit will not manage the configuration of named LocalNet instances, "
"allowing developers to configure it in any way they need.",
f"allowing developers to configure it in any way they need. Defaults to '{SANDBOX_BASE_NAME}'.",
)
@click.option(
"--config-dir",
Expand All @@ -135,7 +136,7 @@ def config_command(*, engine: str | None, force: bool) -> None:
type=click.Path(exists=True, readable=True, file_okay=False, resolve_path=True, path_type=Path),
default=lambda: os.environ.get("ALGOKIT_LOCALNET_CONFIG_DIR", None),
required=False,
help="Specify the custom localnet configuration directory.",
help=f"Specify the custom localnet configuration directory. Defaults to '{get_app_config_dir()}'.",
)
@click.option(
"--dev/--no-dev",
Expand Down Expand Up @@ -180,11 +181,12 @@ def start_localnet(*, name: str | None, config_path: Path | None, algod_dev_mode
if sandbox.is_algod_dev_mode() != algod_dev_mode:
sandbox.set_algod_dev_mode(dev_mode=algod_dev_mode)
if click.confirm(
f"Would you like to recreate 'algod' container to apply 'DevMode' flag set to '{algod_dev_mode}'? "
f"Would you like to restart 'LocalNet' to apply 'DevMode' flag set to '{algod_dev_mode}'? "
"Otherwise, the next `algokit localnet reset` will restart with the new flag",
default=True,
):
sandbox.recreate_container("algod")
sandbox.down()
sandbox.up()
else:
sandbox.up()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
File ref: https://github.com/auth0/auth0-python/blob/master/auth0/authentication/token_verifier.py
"""


from __future__ import annotations

import json
Expand Down
27 changes: 11 additions & 16 deletions src/algokit/core/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,20 @@ def compose_file_status(self) -> ComposeFileStatus:
return ComposeFileStatus.OUT_OF_DATE
return ComposeFileStatus.MISSING
else:
algod_network_json_content = json.loads(
algod_network_template_content.replace("NUM_ROUNDS", '"NUM_ROUNDS"')
)
latest_algod_network_json_content = json.loads(
self._latest_algod_network_template.replace("NUM_ROUNDS", '"NUM_ROUNDS"')
)

del algod_network_json_content["Genesis"]["DevMode"]
del latest_algod_network_json_content["Genesis"]["DevMode"]

if (
compose_content == self._latest_yaml
and config_content == self._latest_config_json
and algod_network_template_content == self._latest_algod_network_template
and algod_network_json_content == latest_algod_network_json_content
and proxy_config_content == self._latest_proxy_config
):
return ComposeFileStatus.UP_TO_DATE
Expand Down Expand Up @@ -195,21 +205,6 @@ def up(self) -> None:
else:
logger.warning("AlgoKit LocalNet failed to return a successful health check")

def recreate_container(self, container_name: str) -> None:
logger.info("Recreating the algod container to apply configuration changes...")
self._run_compose_command(
f"stop {container_name}",
bad_return_code_error_message=f"Failed to remove {container_name} container.",
)
self._run_compose_command(
f"rm -f -v {container_name}",
bad_return_code_error_message=f"Failed to remove {container_name} container.",
)
self._run_compose_command(
f"up -d {container_name}",
bad_return_code_error_message=f"Failed to recreate {container_name} container.",
)

def stop(self) -> None:
logger.info("Stopping AlgoKit LocalNet now...")
self._run_compose_command("stop", bad_return_code_error_message="Failed to stop LocalNet")
Expand Down

0 comments on commit 7410b9b

Please sign in to comment.