Skip to content

Commit

Permalink
chore: lint and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabpain authored and ankitrgadiya committed Oct 18, 2024
1 parent e5ac892 commit adce386
Show file tree
Hide file tree
Showing 179 changed files with 5,379 additions and 3,677 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ New dependencies can be installed directly using `uv`. This modifies the

``` bash
uv add <package-name>
```

### Linting and formatting
You can check and fix the code style by running the following commands.
```bash
uvx ruff check --fix
uvx ruff format
```
47 changes: 23 additions & 24 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,40 @@
import os
import sys

project = u'CLI'
copyright = u'2024, Rapyuta Robotics'
author = u'Rapyuta Robotics'
project = "CLI"
copyright = "2024, Rapyuta Robotics"
author = "Rapyuta Robotics"

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))

extensions = ['sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.autosummary',
'sphinx.ext.ifconfig',
'sphinx_click']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.autosummary",
"sphinx.ext.ifconfig",
"sphinx_click",
]

templates_path = ['_templates']
templates_path = ["_templates"]
autosummary_generate = True # Turn on sphinx.ext.autosummary
source_suffix = '.rst'
master_doc = 'index'
language = 'en'
source_suffix = ".rst"
master_doc = "index"
language = "en"
exclude_patterns = []
todo_include_todos = False

html_theme = 'furo'
html_favicon = 'favicon.ico'
html_static_path = ['_static']
html_theme = "furo"
html_favicon = "favicon.ico"
html_static_path = ["_static"]
html_theme_options = {
"light_logo": "logo-light-mode.svg",
"dark_logo": "logo-dark-mode.svg",
}
html_css_files = ['css/rio-sphinx.css']
html_js_files = ['js/rio-sphinx.js']
htmlhelp_basename = 'RIOdoc'
man_pages = [
(master_doc, 'cli', u'Rapyuta IO CLI',
[author], 1)
]
html_css_files = ["css/rio-sphinx.css"]
html_js_files = ["js/rio-sphinx.js"]
htmlhelp_basename = "RIOdoc"
man_pages = [(master_doc, "cli", "Rapyuta IO CLI", [author], 1)]
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
"python": ("https://docs.python.org/3/", None),
}
add_module_names = False
3 changes: 2 additions & 1 deletion docs/source/rapyuta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""

import os

__version__ = '0.2.5b1'
__version__ = "0.2.5b1"
__version_full__ = __version__


Expand Down
3 changes: 2 additions & 1 deletion riocli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# on windows.
from sys import platform

if platform.lower() == 'win32':
if platform.lower() == "win32":
import signal

signal.SIGKILL = signal.SIGTERM
234 changes: 159 additions & 75 deletions riocli/apply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,91 @@
import click
from click_help_colors import HelpColorsCommand

from riocli.apply.explain import explain, list_examples
from riocli.apply.parse import Applier
from riocli.apply.template import template
from riocli.apply.util import process_files_values_secrets
from riocli.constants import Colors
from riocli.utils import print_centered_text


@click.command(
'apply',
"apply",
cls=HelpColorsCommand,
help_headers_color=Colors.YELLOW,
help_options_color=Colors.GREEN,
)
@click.option('--dryrun', '-d', is_flag=True, default=False,
help='Dry run the yaml files without applying any change')
@click.option('--show-graph', '-g', is_flag=True, default=False,
help='Opens a mermaid.live dependency graph')
@click.option('--values', '-v', multiple=True, default=(),
help="Path to values yaml file. Key/values "
"specified in the values file can be "
"used as variables in template YAMLs")
@click.option('--secrets', '-s', multiple=True, default=(),
help="Secret files are sops encoded value files. "
"rio-cli expects sops to be authorized for "
"decoding files on this computer")
@click.option('--workers', '-w',
help="Number of parallel workers while running apply "
"command. defaults to 6.", type=int)
@click.option('-f', '--force', '--silent', 'silent', is_flag=True,
type=click.BOOL, default=False,
help="Skip confirmation")
@click.option('--retry-count', '-rc', type=int, default=50,
help="Number of retries before a resource creation times out status, defaults to 50")
@click.option('--retry-interval', '-ri', type=int, default=6,
help="Interval between retries defaults to 6")
@click.argument('files', nargs=-1)
@click.option(
"--dryrun",
"-d",
is_flag=True,
default=False,
help="Dry run the yaml files without applying any change",
)
@click.option(
"--show-graph",
"-g",
is_flag=True,
default=False,
help="Opens a mermaid.live dependency graph",
)
@click.option(
"--values",
"-v",
multiple=True,
default=(),
help="Path to values yaml file. Key/values "
"specified in the values file can be "
"used as variables in template YAMLs",
)
@click.option(
"--secrets",
"-s",
multiple=True,
default=(),
help="Secret files are sops encoded value files. "
"rio-cli expects sops to be authorized for "
"decoding files on this computer",
)
@click.option(
"--workers",
"-w",
help="Number of parallel workers while running apply " "command. defaults to 6.",
type=int,
)
@click.option(
"-f",
"--force",
"--silent",
"silent",
is_flag=True,
type=click.BOOL,
default=False,
help="Skip confirmation",
)
@click.option(
"--retry-count",
"-rc",
type=int,
default=50,
help="Number of retries before a resource creation times out status, defaults to 50",
)
@click.option(
"--retry-interval",
"-ri",
type=int,
default=6,
help="Interval between retries defaults to 6",
)
@click.argument("files", nargs=-1)
def apply(
values: Iterable[str],
secrets: Iterable[str],
files: Iterable[str],
retry_count: int = 50,
retry_interval: int = 6,
dryrun: bool = False,
workers: int = 6,
silent: bool = False,
show_graph: bool = False,
values: Iterable[str],
secrets: Iterable[str],
files: Iterable[str],
retry_count: int = 50,
retry_interval: int = 6,
dryrun: bool = False,
workers: int = 6,
silent: bool = False,
show_graph: bool = False,
) -> None:
"""Apply resource manifests.
Expand Down Expand Up @@ -110,22 +148,22 @@ def apply(
$ rio apply -v values1.yaml -v values2.yaml templates/**
"""
glob_files, abs_values, abs_secrets = process_files_values_secrets(
files, values, secrets)
files, values, secrets
)

if len(glob_files) == 0:
click.secho('No files specified', fg=Colors.RED)
click.secho("No files specified", fg=Colors.RED)
raise SystemExit(1)

print_centered_text('Files Processed')
print_centered_text("Files Processed")
for file in glob_files:
click.secho(file, fg=Colors.YELLOW)

applier = Applier(glob_files, abs_values, abs_secrets)
applier.parse_dependencies()

if show_graph and dryrun:
click.secho('You cannot dry run and launch the graph together.',
fg='yellow')
click.secho("You cannot dry run and launch the graph together.", fg="yellow")
return

if show_graph:
Expand All @@ -135,44 +173,84 @@ def apply(
if not silent and not dryrun:
click.confirm("\nDo you want to proceed?", default=True, abort=True)

print_centered_text('Applying Manifests')
applier.apply(dryrun=dryrun, workers=workers, retry_count=retry_count, retry_interval=retry_interval)
print_centered_text("Applying Manifests")
applier.apply(
dryrun=dryrun,
workers=workers,
retry_count=retry_count,
retry_interval=retry_interval,
)


@click.command(
'delete',
"delete",
cls=HelpColorsCommand,
help_headers_color=Colors.YELLOW,
help_options_color=Colors.GREEN,
)
@click.option('--dryrun', '-d', is_flag=True, default=False,
help='Dry run the yaml files without applying any change')
@click.option('--values', '-v', multiple=True, default=(),
help="Path to values yaml file. key/values specified in the"
" values file can be used as variables in template YAMLs")
@click.option('--secrets', '-s', multiple=True, default=(),
help="Secret files are sops encoded value files. riocli expects "
"sops to be authorized for decoding files on this computer")
@click.option('-f', '--force', '--silent', 'silent', is_flag=True,
type=click.BOOL, default=False,
help="Skip confirmation")
@click.option('--workers', '-w',
help="Number of parallel workers while running apply "
"command. defaults to 6.", type=int)
@click.option('--retry-count', '-rc', type=int, default=50,
help="Number of retries before a resource creation times out status, defaults to 50")
@click.option('--retry-interval', '-ri', type=int, default=6,
help="Interval between retries defaults to 6")
@click.argument('files', nargs=-1)
@click.option(
"--dryrun",
"-d",
is_flag=True,
default=False,
help="Dry run the yaml files without applying any change",
)
@click.option(
"--values",
"-v",
multiple=True,
default=(),
help="Path to values yaml file. key/values specified in the"
" values file can be used as variables in template YAMLs",
)
@click.option(
"--secrets",
"-s",
multiple=True,
default=(),
help="Secret files are sops encoded value files. riocli expects "
"sops to be authorized for decoding files on this computer",
)
@click.option(
"-f",
"--force",
"--silent",
"silent",
is_flag=True,
type=click.BOOL,
default=False,
help="Skip confirmation",
)
@click.option(
"--workers",
"-w",
help="Number of parallel workers while running apply " "command. defaults to 6.",
type=int,
)
@click.option(
"--retry-count",
"-rc",
type=int,
default=50,
help="Number of retries before a resource creation times out status, defaults to 50",
)
@click.option(
"--retry-interval",
"-ri",
type=int,
default=6,
help="Interval between retries defaults to 6",
)
@click.argument("files", nargs=-1)
def delete(
values: str,
secrets: str,
files: Iterable[str],
retry_count: int = 50,
retry_interval: int = 6,
dryrun: bool = False,
workers: int = 6,
silent: bool = False
values: str,
secrets: str,
files: Iterable[str],
retry_count: int = 50,
retry_interval: int = 6,
dryrun: bool = False,
workers: int = 6,
silent: bool = False,
) -> None:
"""Removes resources via manifests
Expand Down Expand Up @@ -215,13 +293,14 @@ def delete(
$ rio delete -v values1.yaml -v values2.yaml templates/**
"""
glob_files, abs_values, abs_secrets = process_files_values_secrets(
files, values, secrets)
files, values, secrets
)

if len(glob_files) == 0:
click.secho('no files specified', fg=Colors.RED)
click.secho("no files specified", fg=Colors.RED)
raise SystemExit(1)

print_centered_text('Files Processed')
print_centered_text("Files Processed")
for file in glob_files:
click.secho(file, fg=Colors.YELLOW)

Expand All @@ -231,5 +310,10 @@ def delete(
if not silent and not dryrun:
click.confirm("\nDo you want to proceed?", default=True, abort=True)

print_centered_text('Deleting Resources')
applier.delete(dryrun=dryrun, workers=workers, retry_count=retry_count, retry_interval=retry_interval)
print_centered_text("Deleting Resources")
applier.delete(
dryrun=dryrun,
workers=workers,
retry_count=retry_count,
retry_interval=retry_interval,
)
Loading

0 comments on commit adce386

Please sign in to comment.