Skip to content

Commit

Permalink
Merge pull request #33 from piotr-roslaniec/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Nov 30, 2023
2 parents 7ef3f0d + ed3eb89 commit 326e291
Show file tree
Hide file tree
Showing 17 changed files with 2,366 additions and 1,304 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,43 @@ name: Python package CI
on: [ push, pull_request ]

jobs:
test:

build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.9", "3.12" ]

steps:
- uses: actions/checkout@v4
<<<<<<< HEAD
=======

>>>>>>> cced0c2 (Update .github/workflows/python.yml)
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build dist
run: |
python setup.py sdist bdist_wheel
run: python setup.py sdist bdist_wheel

lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install ruff
run: pip install ruff

- name: Run ruff
run: ruff check --output-format=github nucypher_ops
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__ = "Node management tools for nodes on the Threshold Network to empower privacy in decentralized systems."

__version__ = "0.12.0"

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

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

__copyright__ = 'Copyright (C) 2022 NuCypher'
__copyright__ = "Copyright (C) 2023 NuCypher"
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)
8 changes: 4 additions & 4 deletions nucypher_ops/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from importlib.metadata import version

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 importlib.metadata import version
from nucypher_ops.cli.ursula import cli as ursula

package_version = version('nucypher_ops')

Expand Down
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 326e291

Please sign in to comment.