Skip to content

Commit

Permalink
chore(ruff): configure ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Nov 29, 2023
1 parent 79ed930 commit 6d772c9
Show file tree
Hide file tree
Showing 18 changed files with 2,347 additions and 1,303 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install setuptools wheel ruff
- name: Run ruff
run: ruff check nucypher_ops

- name: Build dist
run: |
python setup.py sdist bdist_wheel
run: python setup.py sdist bdist_wheel
4 changes: 2 additions & 2 deletions nucypher_ops/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__url__ = "https://github.com/nucypher/nucypher-ops"

__summary__ = 'Install and management tools for a proxy re-encryption network to empower privacy in decentralized systems.'
__summary__ = "Install and management tools for a proxy re-encryption network to empower privacy in decentralized systems."

__version__ = "0.11.2"

Expand All @@ -12,4 +12,4 @@

__license__ = "GNU Affero General Public License, Version 3"

__copyright__ = 'Copyright (C) 2022 NuCypher'
__copyright__ = "Copyright (C) 2022 NuCypher"
1 change: 0 additions & 1 deletion nucypher_ops/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .ops.fleet_ops import CloudDeployers
82 changes: 61 additions & 21 deletions nucypher_ops/cli/ethereum.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,78 @@
from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK
from nucypher_ops.ops.fleet_ops import CloudDeployers
import os

import click

from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK
from nucypher_ops.ops.fleet_ops import CloudDeployers

emitter = click


@click.group('ethereum')
@click.group("ethereum")
def cli():
"""deploy and update geth nodes"""


@cli.command('deploy')
@click.option('--image', help="The geth image to deploy", default='ethereum/client-go:stable')
@click.option('--namespace', help="Namespace for these operations. Used to address hosts and data locally and name hosts on cloud platforms.", type=click.STRING, default=DEFAULT_NAMESPACE)
@click.option('--network', help="The Nucypher network name these hosts will run on.", type=click.STRING, default=DEFAULT_NETWORK)
@click.option('--include-host', 'include_hosts', help="specify hosts to update", multiple=True, type=click.STRING)
@click.option('--env', '-e', 'envvars', help="additional environment variables (ENVVAR=VALUE)", multiple=True, type=click.STRING, default=[])
@click.option('--cli', '-c', 'cliargs', help="additional cli arguments for geth", multiple=True, type=click.STRING, default=[])
@cli.command("deploy")
@click.option(
"--image", help="The geth image to deploy", default="ethereum/client-go:stable"
)
@click.option(
"--namespace",
help="Namespace for these operations. Used to address hosts and data locally and name hosts on cloud platforms.",
type=click.STRING,
default=DEFAULT_NAMESPACE,
)
@click.option(
"--network",
help="The Nucypher network name these hosts will run on.",
type=click.STRING,
default=DEFAULT_NETWORK,
)
@click.option(
"--include-host",
"include_hosts",
help="specify hosts to update",
multiple=True,
type=click.STRING,
)
@click.option(
"--env",
"-e",
"envvars",
help="additional environment variables (ENVVAR=VALUE)",
multiple=True,
type=click.STRING,
default=[],
)
@click.option(
"--cli",
"-c",
"cliargs",
help="additional cli arguments for geth",
multiple=True,
type=click.STRING,
default=[],
)
def deploy(image, namespace, network, include_hosts, envvars, cliargs):
"""Deploys NuCypher on managed hosts."""

deployer = CloudDeployers.get_deployer('ethereum')(emitter,
docker_image=image,
namespace=namespace,
network=network,
envvars=envvars,
cliargs=cliargs,
resource_name='ethereum'
)
deployer = CloudDeployers.get_deployer("ethereum")(
emitter,
docker_image=image,
namespace=namespace,
network=network,
envvars=envvars,
cliargs=cliargs,
resource_name="ethereum",
)

hostnames = deployer.config['instances'].keys()
hostnames = deployer.config["instances"].keys()
if include_hosts:
hostnames = include_hosts
for name, hostdata in [(n, d) for n, d in deployer.config['instances'].items() if n in hostnames]:
for name, hostdata in [
(n, d) for n, d in deployer.config["instances"].items() if n in hostnames
]:
emitter.echo(f'\t{name}: {hostdata["publicaddress"]}', color="yellow")
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
os.environ["ANSIBLE_HOST_KEY_CHECKING"] = "False"
deployer.deploy(hostnames)
5 changes: 2 additions & 3 deletions nucypher_ops/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import click

from nucypher_ops.cli.nodes import cli as nodes
from nucypher_ops.cli.ursula import cli as ursula
from nucypher_ops.cli.ethereum import cli as ethereum
from nucypher_ops.cli.namespaces import cli as namespaces
from nucypher_ops.cli.nodes import cli as nodes
from nucypher_ops.cli.porter import cli as porter
from nucypher_ops.cli.tbtcv2 import cli as tbtcv2
from nucypher_ops.cli.ursula import cli as ursula


@click.group()
Expand All @@ -19,4 +19,3 @@ def index():
index.add_command(namespaces)
index.add_command(porter)
index.add_command(tbtcv2)

33 changes: 22 additions & 11 deletions nucypher_ops/cli/namespaces.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK, NETWORKS
from nucypher_ops.ops.fleet_ops import CloudDeployers
import os
import click

from nucypher_ops.constants import NETWORKS
from nucypher_ops.ops.fleet_ops import CloudDeployers

emitter = click


@click.group('namespaces')
@click.group("namespaces")
def cli():
"""Organize the machinery"""

@cli.command('list')
@click.option('--all', help="list all namespaces under all networks", default=False, is_flag=True)
@click.option('--network', help="The network whose namespaces you want to see.", type=click.Choice(NETWORKS.keys()), default='mainnet')

@cli.command("list")
@click.option(
"--all", help="list all namespaces under all networks", default=False, is_flag=True
)
@click.option(
"--network",
help="The network whose namespaces you want to see.",
type=click.Choice(NETWORKS.keys()),
default="mainnet",
)
def list_namespaces(network, all):
"""lists namespaces"""
if all:
networks = NETWORKS.keys()
else:
networks = [network]
deployers = [
CloudDeployers.get_deployer('generic')(emitter, network=network, pre_config={"namespace": None})
for network in networks]
CloudDeployers.get_deployer("generic")(
emitter, network=network, pre_config={"namespace": None}
)
for network in networks
]
for deployer in deployers:
namespaces = deployer.get_namespace_names()
if namespaces:
emitter.echo(deployer.network)
for ns in namespaces:
emitter.echo(f'\t{ns}')

emitter.echo(f"\t{ns}")
Loading

0 comments on commit 6d772c9

Please sign in to comment.