Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ruff): configure ruff #33

Merged
merged 4 commits into from
Nov 30, 2023
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
28 changes: 24 additions & 4 deletions .github/workflows/python.yml
derekpierre marked this conversation as resolved.
Show resolved Hide resolved
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)
Comment on lines +14 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piotr-roslaniec did this get merged with conflicts?

- 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

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