Skip to content

Commit

Permalink
Merge pull request #530 from ssl-hep/remote_url_option
Browse files Browse the repository at this point in the history
Eliminate unnecessary URL options from the command line.
  • Loading branch information
kyungeonchoi authored Dec 6, 2024
2 parents b969ab3 + 142cc50 commit be8f31f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
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 @@ def list(
"""
List the datasets.
"""
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)
table = Table(title="ServiceX Datasets")
table.add_column("ID")
table.add_column("Name")
Expand Down Expand Up @@ -90,11 +89,10 @@ def list(

@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)
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 @@ def get(

@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)
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 @@ def transforms():

@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 @@ def list(
"""
List the transforms that have been run.
"""
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)
table = Table(title="ServiceX Transforms")
table.add_column("Transform ID")
table.add_column("Title")
Expand All @@ -82,7 +81,6 @@ def list(

@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 @@ async def list_files(sx: ServiceXClient, transform_id: str) -> List[ResultFile]:
minio = MinioAdapter.for_transform(transform)
return await minio.list_bucket()

sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)
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 @@ async def list_files(sx: ServiceXClient, transform_id: str) -> List[ResultFile]:

@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 @@ async def download_with_progress(filename) -> Path:

with Progress() as progress:
download_progress = progress.add_task("Downloading", start=False, total=None)
sx = ServiceXClient(url=url, backend=backend)
sx = ServiceXClient(backend=backend)
result_files = asyncio.run(download_files(sx, transform_id, local_dir))

for path in result_files:
Expand Down Expand Up @@ -200,7 +197,6 @@ def create_kibana_link_parameters(log_url, transform_id=None, log_level=None, ti

@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 @@ def logs(
"""
Open the URL to the Kibana dashboard of the logs of a tranformer
"""
sx = ServiceXClient(backend=backend, url=url)
sx = ServiceXClient(backend=backend)
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

0 comments on commit be8f31f

Please sign in to comment.