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

Review help/usage for cli commands #802

Merged
merged 8 commits into from
Jan 15, 2025
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
16 changes: 12 additions & 4 deletions src/datachain/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
if args.command in ("internal-run-udf", "internal-run-udf-worker"):
return handle_udf(args.command)

if args.command is None:
datachain_parser.print_help(sys.stderr)
return 1

Check warning on line 44 in src/datachain/cli/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/cli/__init__.py#L43-L44

Added lines #L43 - L44 were not covered by tests

logger.addHandler(logging.StreamHandler())
logging_level = get_logging_level(args)
logger.setLevel(logging_level)
Expand Down Expand Up @@ -120,12 +124,17 @@
recursive=bool(args.recursive),
no_glob=args.no_glob,
no_cp=args.no_cp,
edatachain=args.edatachain,
edatachain_file=args.edatachain_file,
)


def handle_dataset_command(args, catalog):
if args.datasets_cmd is None:
print(

Check warning on line 132 in src/datachain/cli/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/cli/__init__.py#L132

Added line #L132 was not covered by tests
f"Use 'datachain {args.command} --help' to see available options",
file=sys.stderr,
)
return 1

Check warning on line 136 in src/datachain/cli/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/cli/__init__.py#L136

Added line #L136 was not covered by tests

dataset_commands = {
"pull": lambda: catalog.pull_dataset(
args.dataset,
Expand All @@ -134,8 +143,6 @@
local_ds_version=args.local_version,
cp=args.cp,
force=bool(args.force),
edatachain=args.edatachain,
edatachain_file=args.edatachain_file,
),
"edit": lambda: edit_dataset(
catalog,
Expand Down Expand Up @@ -187,6 +194,7 @@
handler = dataset_commands.get(args.datasets_cmd)
if handler:
return handler()

raise Exception(f"Unexpected command {args.datasets_cmd}")


Expand Down
5 changes: 2 additions & 3 deletions src/datachain/cli/commands/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datachain.cli.utils import determine_flavors
from datachain.config import Config
from datachain.error import DatasetNotFoundError
from datachain.studio import list_datasets as list_datasets_studio


def list_datasets(
Expand All @@ -20,14 +21,12 @@ def list_datasets(
all: bool = True,
team: Optional[str] = None,
):
from datachain.studio import list_datasets

token = Config().read().get("studio", {}).get("token")
all, local, studio = determine_flavors(studio, local, all, token)

local_datasets = set(list_datasets_local(catalog)) if all or local else set()
studio_datasets = (
set(list_datasets(team=team)) if (all or studio) and token else set()
set(list_datasets_studio(team=team)) if (all or studio) and token else set()
)

rows = [
Expand Down
Loading
Loading