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

Eliminate unnecessary URL options from the command line. #530

Merged
merged 1 commit into from
Dec 6, 2024
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
4 changes: 1 addition & 3 deletions docs/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ Common command line arguments:
| F | Long | What it does |
| lag | Flag | |
+=====+==========+=====================================================+
| -u | –url | The url of the serviceX ingress |
+-----+----------+-----------------------------------------------------+
| -b | –backend | Named backend from the .servicex file endpoints |
| | | list |
+-----+----------+-----------------------------------------------------+

If neither url nor backend are specified then the client will attempt to
If no backend is specified then the client will attempt to
use the ``default_endpoint`` value to determine who to talk to.

codegens
Expand Down
1 change: 0 additions & 1 deletion servicex/app/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import typer


url_cli_option = typer.Option(None, "-u", "--url", help="URL of ServiceX server")
backend_cli_option = typer.Option(None, "-b", "--backend",
help="Name of backend server from .servicex file")
config_file_option = typer.Option(None, "-c", "--config",
Expand Down
8 changes: 3 additions & 5 deletions servicex/app/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import rich
import typer

from servicex.app.cli_options import url_cli_option, backend_cli_option, config_file_option
from servicex.app.cli_options import backend_cli_option, config_file_option
from servicex.servicex_client import ServiceXClient
from typing import Optional

Expand All @@ -38,25 +38,23 @@

@codegen_app.command(no_args_is_help=False)
def flush(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
config_path: Optional[str] = config_file_option):
"""
Flush the available code generators from the cache
"""
sx = ServiceXClient(url=url, backend=backend, config_path=config_path)
sx = ServiceXClient(backend=backend, config_path=config_path)
cache = sx.query_cache
cache.delete_codegen_by_backend(backend)
rich.print("Deleted cached code generators.")


@codegen_app.command(no_args_is_help=False)
def list(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
config_path: Optional[str] = config_file_option):
"""
List the available code generators
"""
sx = ServiceXClient(url=url, backend=backend, config_path=config_path)
sx = ServiceXClient(backend=backend, config_path=config_path)
rich.print_json(data=sx.get_code_generators())
11 changes: 4 additions & 7 deletions servicex/app/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import rich

from servicex.app.cli_options import url_cli_option, backend_cli_option
from servicex.app.cli_options import backend_cli_option

import typer

Expand All @@ -42,7 +42,6 @@

@datasets_app.command(no_args_is_help=True)
def list(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
did_finder: Optional[str] = typer.Option(
None,
Expand All @@ -58,7 +57,7 @@
"""
List the datasets.
"""
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 60 in servicex/app/datasets.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/datasets.py#L60

Added line #L60 was not covered by tests
table = Table(title="ServiceX Datasets")
table.add_column("ID")
table.add_column("Name")
Expand Down Expand Up @@ -90,11 +89,10 @@

@datasets_app.command(no_args_is_help=True)
def get(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
dataset_id: int = typer.Argument(..., help="The ID of the dataset to get")
):
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 95 in servicex/app/datasets.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/datasets.py#L95

Added line #L95 was not covered by tests
table = Table(title=f"Dataset ID {dataset_id}")
table.add_column("Paths")
dataset = asyncio.run(sx.get_dataset(dataset_id))
Expand All @@ -114,11 +112,10 @@

@datasets_app.command(no_args_is_help=True)
def delete(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
dataset_id: int = typer.Argument(..., help="The ID of the dataset to delete")
):
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 118 in servicex/app/datasets.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/datasets.py#L118

Added line #L118 was not covered by tests
result = asyncio.run(sx.delete_dataset(dataset_id))
if result:
typer.echo(f"Dataset {dataset_id} deleted")
Expand Down
14 changes: 5 additions & 9 deletions servicex/app/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from rich.progress import Progress
from rich.table import Table

from servicex.app.cli_options import url_cli_option, backend_cli_option
from servicex.app.cli_options import backend_cli_option
from servicex.minio_adapter import MinioAdapter
from servicex.models import Status, ResultFile
from servicex.servicex_client import ServiceXClient
Expand All @@ -55,7 +55,6 @@

@transforms_app.command(no_args_is_help=True)
def list(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
complete: Optional[bool] = typer.Option(
None, "--complete", help="Only show successfully completed transforms"
Expand All @@ -64,7 +63,7 @@
"""
List the transforms that have been run.
"""
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 66 in servicex/app/transforms.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/transforms.py#L66

Added line #L66 was not covered by tests
table = Table(title="ServiceX Transforms")
table.add_column("Transform ID")
table.add_column("Title")
Expand All @@ -82,7 +81,6 @@

@transforms_app.command(no_args_is_help=True)
def files(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
transform_id: str = typer.Option(None, "-t", "--transform-id", help="Transform ID"),
):
Expand All @@ -94,7 +92,7 @@
minio = MinioAdapter.for_transform(transform)
return await minio.list_bucket()

sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 95 in servicex/app/transforms.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/transforms.py#L95

Added line #L95 was not covered by tests
result_files = asyncio.run(list_files(sx, transform_id))
table = rich.table.Table(title=f"Files from {transform_id}")
table.add_column("filename")
Expand All @@ -107,7 +105,6 @@

@transforms_app.command(no_args_is_help=True)
def download(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
transform_id: str = typer.Option(None, "-t", "--transform-id", help="Transform ID"),
local_dir: str = typer.Option(".", "-d", help="Local dir to download to"),
Expand Down Expand Up @@ -136,7 +133,7 @@

with Progress() as progress:
download_progress = progress.add_task("Downloading", start=False, total=None)
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)

Check warning on line 136 in servicex/app/transforms.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/transforms.py#L136

Added line #L136 was not covered by tests
result_files = asyncio.run(download_files(sx, transform_id, local_dir))

for path in result_files:
Expand Down Expand Up @@ -200,7 +197,6 @@

@transforms_app.command(no_args_is_help=True)
def logs(
url: Optional[str] = url_cli_option,
backend: Optional[str] = backend_cli_option,
transform_id: str = typer.Option(None, "-t", "--transform-id", help="Transform ID"),
log_level: Optional[LogLevel] = typer.Option("ERROR", "-l", "--log-level",
Expand All @@ -213,7 +209,7 @@
"""
Open the URL to the Kibana dashboard of the logs of a tranformer
"""
sx = ServiceXClient(backend=backend, url=url)
sx = ServiceXClient(backend=backend)

Check warning on line 212 in servicex/app/transforms.py

View check run for this annotation

Codecov / codecov/patch

servicex/app/transforms.py#L212

Added line #L212 was not covered by tests
transforms = sx.get_transform_status(transform_id)
if transforms and transforms.request_id == transform_id:
kibana_link = create_kibana_link_parameters(transforms.log_url,
Expand Down
Loading