Skip to content

Commit

Permalink
fix(cli/delete): prevent duplicates in delete message (datahub-projec…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Jan 13, 2025
1 parent 9897804 commit 8d48622
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions metadata-ingestion/src/datahub/cli/delete_cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import random
from concurrent.futures import ThreadPoolExecutor, as_completed
from dataclasses import dataclass
from datetime import datetime
from random import choices
from typing import Dict, List, Optional

import click
Expand Down Expand Up @@ -457,11 +457,11 @@ def by_filter(
click.echo("Found urns of multiple entity types")
for entity_type, entity_urns in urns_by_type.items():
click.echo(
f"- {len(entity_urns)} {entity_type} urn(s). Sample: {choices(entity_urns, k=min(5, len(entity_urns)))}"
f"- {len(entity_urns)} {entity_type} urn(s). Sample: {random.sample(entity_urns, k=min(5, len(entity_urns)))}"
)
else:
click.echo(
f"Found {len(urns)} {entity_type} urn(s). Sample: {choices(urns, k=min(5, len(urns)))}"
f"Found {len(urns)} {entity_type} urn(s). Sample: {random.sample(urns, k=min(5, len(urns)))}"
)

if not force and not dry_run:
Expand Down
4 changes: 2 additions & 2 deletions metadata-ingestion/src/datahub/cli/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def dataplatform2instance_func(

if not force and not dry_run:
# get a confirmation from the operator before proceeding if this is not a dry run
sampled_urns_to_migrate = random.choices(
sampled_urns_to_migrate = random.sample(
urns_to_migrate, k=min(10, len(urns_to_migrate))
)
sampled_new_urns: List[str] = [
Expand All @@ -193,7 +193,7 @@ def dataplatform2instance_func(
if key
]
click.echo(
f"Will migrate {len(urns_to_migrate)} urns such as {random.choices(urns_to_migrate, k=min(10, len(urns_to_migrate)))}"
f"Will migrate {len(urns_to_migrate)} urns such as {random.sample(urns_to_migrate, k=min(10, len(urns_to_migrate)))}"
)
click.echo(f"New urns will look like {sampled_new_urns}")
click.confirm("Ok to proceed?", abort=True)
Expand Down

0 comments on commit 8d48622

Please sign in to comment.