mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-28 02:17:53 +00:00
refactor(ingest): cli deletion function (#3694)
This commit is contained in:
parent
3cc4e76748
commit
15ed3aecf0
@ -54,6 +54,7 @@ class DeletionResult:
|
||||
self.sample_records.extend(another_result.sample_records)
|
||||
|
||||
|
||||
@telemetry.with_telemetry
|
||||
def delete_for_registry(
|
||||
registry_id: str,
|
||||
soft: bool,
|
||||
@ -123,7 +124,7 @@ def delete(
|
||||
session, host = cli_utils.get_session_and_host()
|
||||
entity_type = guess_entity_type(urn=urn)
|
||||
logger.info(f"DataHub configured with {host}")
|
||||
deletion_result: DeletionResult = delete_one_urn(
|
||||
deletion_result: DeletionResult = delete_one_urn_cmd(
|
||||
urn,
|
||||
soft=soft,
|
||||
dry_run=dry_run,
|
||||
@ -209,7 +210,7 @@ def delete_with_filters(
|
||||
)
|
||||
|
||||
for urn in progressbar.progressbar(urns, redirect_stdout=True):
|
||||
one_result = delete_one_urn(
|
||||
one_result = _delete_one_urn(
|
||||
urn,
|
||||
soft=soft,
|
||||
dry_run=dry_run,
|
||||
@ -222,8 +223,7 @@ def delete_with_filters(
|
||||
return batch_deletion_result
|
||||
|
||||
|
||||
@telemetry.with_telemetry
|
||||
def delete_one_urn(
|
||||
def _delete_one_urn(
|
||||
urn: str,
|
||||
soft: bool = False,
|
||||
dry_run: bool = False,
|
||||
@ -271,3 +271,28 @@ def delete_one_urn(
|
||||
|
||||
deletion_result.end()
|
||||
return deletion_result
|
||||
|
||||
|
||||
@telemetry.with_telemetry
|
||||
def delete_one_urn_cmd(
|
||||
urn: str,
|
||||
soft: bool = False,
|
||||
dry_run: bool = False,
|
||||
entity_type: str = "dataset",
|
||||
cached_session_host: Optional[Tuple[sessions.Session, str]] = None,
|
||||
cached_emitter: Optional[rest_emitter.DatahubRestEmitter] = None,
|
||||
) -> DeletionResult:
|
||||
"""
|
||||
Wrapper around delete_one_urn because it is also called in a loop via delete_with_filters.
|
||||
|
||||
This is a separate function that is called only when a single URN is deleted via the CLI.
|
||||
"""
|
||||
|
||||
return _delete_one_urn(
|
||||
urn,
|
||||
soft,
|
||||
dry_run,
|
||||
entity_type,
|
||||
cached_session_host,
|
||||
cached_emitter,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user