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

Improve wordings and dots in overall the code #426

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion tdp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
logger.addHandler(ch)

# 'application' code
logger.debug("Logger initialized")
logger.debug("Logger initialized.")
2 changes: 1 addition & 1 deletion tdp/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
default=".env",
envvar="TDP_ENV",
type=Path,
help="Path to environment configuration file",
help="Path to environment configuration file.",
)
def tdp(env):
load_dotenv(env)
Expand Down
22 changes: 11 additions & 11 deletions tdp/cli/commands/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@
from tdp.core.models import DeploymentLog, OperationLog


@click.command(short_help="Browse deployment logs")
@click.command(short_help="Browse deployment logs.")
@click.argument("deployment_id", required=False)
@click.argument("operation", required=False)
@click.option(
"-p",
"--plan",
is_flag=True,
help="Print the planned deployment, if exist.",
help="Print the planned deployment, if exists.",
)
@click.option(
"--limit",
envvar="TDP_LIMIT",
type=int,
default=15,
help="Limit number of deployments returned",
help="Limit number of deployments returned.",
)
@click.option(
"--offset",
envvar="TDP_OFFSET",
type=int,
default=0,
help="At which offset should the database query should start",
help="At which offset should the database query should start.",
)
@database_dsn
def browse(
Expand All @@ -55,8 +55,8 @@ def browse(
if deployment_plan:
_print_deployment(deployment_plan)
else:
click.echo("No planned deployment found")
click.echo("Create a deployment plan using the `tdp plan` command")
click.echo("No planned deployment found.")
click.echo("Create a deployment plan using the `tdp plan` command.")
return

# Print a specific operation
Expand All @@ -77,11 +77,11 @@ def _print_deployments(deployments: Iterable[DeploymentLog]) -> None:
"""Print a list of deployments in a human readable format.

Args:
deployments: List of deployments to print
deployments: List of deployments to print.
"""
if not deployments:
click.echo("No deployment found")
click.echo("Create a deployment plan using the `tdp plan` command")
click.echo("No deployment found.")
click.echo("Create a deployment plan using the `tdp plan` command.")

print_table(
[d.to_dict(filter_out=["options"]) for d in deployments],
Expand All @@ -92,7 +92,7 @@ def _print_deployment(deployment: DeploymentLog) -> None:
"""Print a deployment in a human readable format.

Args:
deployment: Deployment to print
deployment: Deployment to print.
"""
if not deployment:
click.echo("Deployment does not exist.")
Expand All @@ -105,7 +105,7 @@ def _print_operation(operation: OperationLog) -> None:
"""Print an operation in a human readable format.

Args:
operation: Operation to print
operation: Operation to print.
"""
# Print general operation infos
click.secho("Operation details", bold=True)
Expand Down
16 changes: 8 additions & 8 deletions tdp/cli/commands/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@
"-t",
"--transitive-reduction",
is_flag=True,
help="Apply a transitive reduction on the DAG",
help="Apply a transitive reduction on the DAG.",
)
@click.option(
"-g",
"--glob",
"pattern_format",
flag_value="glob",
help="Each node argument will be process as glob pattern",
help="Each node argument will be processed as a glob pattern.",
)
@click.option(
"-r",
"--regex",
"pattern_format",
flag_value="regex",
help="Each node argument will be process as regex pattern",
help="Each node argument will be process as a regex pattern.",
)
@click.option(
"-ct",
"--color-to",
help="List of node to color to, separated with a comma (,)",
help="List of nodes to color to, separated by commas (,).",
)
@click.option(
"-cf",
"--color-from",
help="Nodes that will be colored after applying get_operations_to_nodes, separed with a comma (,)",
help="List of nodes to color from after applying `--color-to`, separed by commas (,).",
type=str,
)
@click.option(
"-c",
"--cluster",
is_flag=True,
help="Group node into cluster inside each service",
help="Group nodes into cluster inside each service.",
)
@collections
def dag(
Expand All @@ -79,7 +79,7 @@ def dag(
else:
raise ValueError("pattern_format invalid")
if not nodes_expanded:
raise ValueError(f"No nodes found with {nodes}")
raise ValueError(f"No nodes found with {nodes}.")
nodes = nodes_expanded

# Nx ancestors only returns the ancestor, and node the selected node
Expand Down Expand Up @@ -113,7 +113,7 @@ def import_show():
if importlib.util.find_spec(package) is None:
raise click.ClickException(
"You need to install the 'visualization' extras to be able to use the "
+ "dag command. Run 'poetry install --extras visualization'."
+ "`tdp dag` command. Run 'poetry install --extras visualization'."
)

from tdp.core.dag_dot import show
Expand Down
22 changes: 11 additions & 11 deletions tdp/cli/commands/default_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tdp.core.variables import ClusterVariables, Variables, merge_hash


@click.command(short_help="Difference between tdp_vars and defaults")
@click.command(short_help="Difference between tdp_vars and defaults.")
@click.argument("service", required=False)
@collections
@vars
Expand All @@ -27,11 +27,11 @@ def default_diff(service, collections, vars):


def service_diff(collections, service):
"""computes the difference between the default variables from a service, and the variables from your service variables inside your tdp_vars
"""Computes the difference between the default variables from a service, and the variables from your service variables inside your tdp_vars.

Args:
collections (Collections): Collections object
service (ServiceManager): service to compare's manager
collections (Collections): Collections object.
service (ServiceManager): Service to compare's manager.
"""
# key: filename with extension, value: PosixPath(filepath)
default_service_vars_paths = OrderedDict()
Expand Down Expand Up @@ -101,15 +101,15 @@ def service_diff(collections, service):
def compute_and_print_difference(
service_name, filename, left_content, right_content, left_path, right_path
):
"""computes differences between 2 files, and outputs them.
"""Computes differences between 2 files, and outputs them.

Args:
service_name (str): name of the service
filename (str): name of the file to display
left_content (Iterator[str]): content to compare from
right_content (Iterator[str]): content to compare to
left_path (str): filename to compare from, to use as contextual information
right_path (str): filename to compare to, to use as contextual information
service_name (str): Name of the service.
filename (str): Name of the file to display.
left_content (Iterator[str]): Content to compare from.
right_content (Iterator[str]): Content to compare to.
left_path (str): Filename to compare from, to use as contextual information.
right_path (str): Filename to compare to, to use as contextual information.
"""
differences = difflib.context_diff(
left_content,
Expand Down
2 changes: 1 addition & 1 deletion tdp/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tdp.core.variables import ClusterVariables


@click.command(short_help="Init database / services in tdp vars")
@click.command(short_help="Init database / services in tdp vars.")
@click.option(
"--overrides",
envvar="TDP_OVERRIDES",
Expand Down
2 changes: 1 addition & 1 deletion tdp/cli/commands/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tdp.core.dag import Dag


@click.command(short_help="List nodes from operations DAG")
@click.command(short_help="List nodes from operations DAG.")
@collections
def nodes(collections):
dag = Dag(collections)
Expand Down
4 changes: 2 additions & 2 deletions tdp/cli/commands/plan/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def dag(
raise click.BadParameter(f"{set_difference} are not valid nodes.")

if sources:
click.echo(f"Creating a deployment plan from: {sources}")
click.echo(f"Creating a deployment plan from: {sources}.")
elif targets:
click.echo(f"Creating a deployment plan to: {targets}")
click.echo(f"Creating a deployment plan to: {targets}.")
else:
click.echo("Creating a deployment plan for the whole DAG.")
deployment_log = DeploymentLog.from_dag(
Expand Down
10 changes: 5 additions & 5 deletions tdp/cli/commands/playbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@

# TODO: Transform this to a script as it is not really a command (see #346).
@click.command(
short_help="Generate meta playbooks in order to use a TDP like collection without tdp-lib"
short_help="Generate meta playbooks in order to use a TDP like collection without tdp-lib."
)
@click.argument("services", required=False, nargs=-1)
@click.option(
"--output-dir",
type=Path,
help="Output dir where playbooks will be written",
help="Output directory where playbooks will be written.",
required=False,
default=".",
)
@click.option(
"--for-collection",
type=str,
help="Only write operation from this collection",
help="Only write operations from this collection.",
required=False,
multiple=True,
)
Expand All @@ -48,7 +48,7 @@ def playbooks(services, output_dir, for_collection, collections):
dag_service_operations.setdefault(operation.service_name, []).append(operation)

if not nx.is_directed_acyclic_graph(dag_services):
raise RuntimeError("dag_services is not a DAG")
raise RuntimeError("dag_services is not a DAG.")

def custom_key(node):
operation_priority = SERVICE_PRIORITY.get(node, DEFAULT_SERVICE_PRIORITY)
Expand All @@ -62,7 +62,7 @@ def custom_key(node):
for service in services:
if service not in dag_services.nodes:
raise ValueError(
f"Service '{service}' is not in the DAG, services available: {dag_services.nodes}"
f"Service '{service}' is not in a DAG, services available: {dag_services.nodes}."
)
# Reorder services specified with services DAG topological_sort order
services = [
Expand Down
4 changes: 2 additions & 2 deletions tdp/cli/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from tdp.core.variables import ClusterVariables


@click.command(short_help="Validate tdp vars against the loaded collections schemas")
@click.command(short_help="Validate tdp vars against the loaded collections schemas.")
@collections
@vars
def validate(collections, vars):
ClusterVariables.get_cluster_variables(collections, vars, validate=True)
click.echo("TDP Vars are valid")
click.echo("TDP Vars are valid.")
8 changes: 4 additions & 4 deletions tdp/cli/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def get_deployments(session: Session, limit: int, offset: int) -> list[Deploymen


def get_deployment(session: Session, deployment_id: int) -> DeploymentLog:
"""Get a deployment by id.
"""Get a deployment by ID.

Args:
session: The database session.
deployment_id: The deployment id.
deployment_id: The deployment ID.

Returns:
The deployment.
Expand All @@ -140,7 +140,7 @@ def get_deployment(session: Session, deployment_id: int) -> DeploymentLog:
try:
return session.query(DeploymentLog).filter_by(id=deployment_id).one()
except NoResultFound as e:
raise Exception(f"Deployment id {deployment_id} does not exist.") from e
raise Exception(f"Deployment with ID {deployment_id} does not exist.") from e


def get_last_deployment(session: Session) -> DeploymentLog:
Expand Down Expand Up @@ -185,7 +185,7 @@ def get_operation_log(

Args:
session: The database session.
deployment_id: The deployment id.
deployment_id: The deployment ID.
operation_name: The operation name.

Returns:
Expand Down
Loading