Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ warnet.egg-info
dist/
build/
**/kubeconfigs/
src/warnet/_version.py
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "warnet"
version = "1.1.11"
dynamic = ["version"]
description = "Monitor and analyze the emergent behaviours of bitcoin networks"
readme = "README.md"
requires-python = ">=3.9"
Expand Down Expand Up @@ -34,7 +34,7 @@ warcli = "warnet.main:cli"

[project.urls]
Homepage = "https://warnet.dev"
GitHub = "https://github.com/bitcoindevproject/warnet"
GitHub = "https://github.com/bitcoin-dev-project/warnet"
Pypi = "https://pypi.org/project/warnet/"

[project.optional-dependencies]
Expand All @@ -56,3 +56,8 @@ include = ["warnet*", "test_framework*", "resources*"]

[tool.setuptools.package-data]
"resources" = ["**/*"]

[tool.setuptools_scm]
write_to = "src/warnet/_version.py"
version_scheme = "no-guess-dev"
local_scheme = "node-and-date"
30 changes: 24 additions & 6 deletions src/warnet/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,33 @@ def stop_scenario(scenario_name):
)


def stop_all_scenarios(scenarios):
"""Stop all active scenarios in parallel using multiprocessing"""
def _stop_single(scenario: str) -> str:
"""
Stop a single scenario

Args:
scenario: Name of the scenario to stop

Returns:
str: Message indicating the scenario has been stopped
"""
stop_scenario(scenario)
return f"Stopped scenario: {scenario}"


def stop_single(scenario):
stop_scenario(scenario)
return f"Stopped scenario: {scenario}"
def stop_all_scenarios(scenarios) -> None:
"""
Stop all active scenarios in parallel using multiprocessing

Args:
scenarios: List of scenario names to stop

Returns:
None
"""

with console.status("[bold yellow]Stopping all scenarios...[/bold yellow]"), Pool() as pool:
results = pool.map(stop_single, scenarios)
results = pool.map(_stop_single, scenarios)

for result in results:
console.print(f"[bold green]{result}[/bold green]")
Expand Down
45 changes: 44 additions & 1 deletion src/warnet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,49 @@ def cli():
pass


@click.command()
def version() -> None:
"""Display the installed version of warnet"""
try:
from warnet._version import __version__

# For PyPI releases, this will be the exact tag (e.g. "1.1.11")
# For dev installs, it will be something like "1.1.11.post1.dev17+g27af3a7.d20250309"
# Which is <tag>.post<postN>.dev<devN>+g<git commit hash>.d<YYYYMMDD>
# <postN> is the number of local commits since the checkout commit
# <devN> is the number of commits since the last tag
raw_version = __version__

# Format the version string to our desired format
if "+" in raw_version:
version_part, git_date_part = raw_version.split("+", 1)

# Get just the git commit hash
commit_hash = (
git_date_part[1:].split(".", 1)[0]
if git_date_part.startswith("g")
else git_date_part.split(".", 1)[0]
)

# Remove .dev component (from "no-guess-dev" scheme)
clean_version = version_part
if ".dev" in clean_version:
clean_version = clean_version.split(".dev")[0]

# Apply dirty status (from "no-guess-dev" scheme)
if ".post" in clean_version:
base = clean_version.split(".post")[0]
version_str = f"{base}-{commit_hash}-dirty"
else:
version_str = f"{clean_version}-{commit_hash}"
else:
version_str = raw_version

click.echo(f"warnet version {version_str}")
except ImportError:
click.echo("warnet version unknown")


cli.add_command(admin)
cli.add_command(auth)
cli.add_command(bitcoin)
Expand All @@ -37,7 +80,7 @@ def cli():
cli.add_command(status)
cli.add_command(stop)
cli.add_command(create)

cli.add_command(version)

if __name__ == "__main__":
cli()
6 changes: 6 additions & 0 deletions src/warnet/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ def new_internal(directory: Path, from_init=False):
if proj_answers["custom_network"]:
click.secho("\nGenerating custom network...", fg="yellow", bold=True)
custom_network_path = inquirer_create_network(directory)
else:
click.echo(
f"No custom network specified, see example network files in {project_path}/networks/"
)
click.echo("Deploy any of these networks by running:")
click.echo(f" warnet deploy {project_path}/networks/<example-network-name>")

if custom_network_path:
click.echo(
Expand Down
Loading