From 71af44c3c5e0e81322f2c7f47873e2bce3d1c75b Mon Sep 17 00:00:00 2001 From: "yexuan.li" Date: Thu, 9 Sep 2021 22:14:30 +0800 Subject: [PATCH] style(cli): unify the variable name of tbrn string and TBRN instance --- tensorbay/cli/branch.py | 20 +++++++-------- tensorbay/cli/commit.py | 19 +++++++------- tensorbay/cli/cp.py | 14 ++++++----- tensorbay/cli/dataset.py | 10 ++++---- tensorbay/cli/draft.py | 54 +++++++++++++++++++++------------------- tensorbay/cli/log.py | 12 +++++---- tensorbay/cli/ls.py | 32 ++++++++++++------------ tensorbay/cli/rm.py | 20 +++++++-------- tensorbay/cli/tag.py | 20 +++++++-------- tensorbay/cli/tbrn.py | 16 ++++++------ tensorbay/cli/utility.py | 30 +++++++++++++--------- 11 files changed, 130 insertions(+), 117 deletions(-) diff --git a/tensorbay/cli/branch.py b/tensorbay/cli/branch.py index b603b64d3..621044dff 100644 --- a/tensorbay/cli/branch.py +++ b/tensorbay/cli/branch.py @@ -16,15 +16,15 @@ def _implement_branch( obj: ContextInfo, tbrn: str, name: str, verbose: bool, is_delete: bool ) -> None: - info = TBRN(tbrn=tbrn) - if info.type != TBRNType.DATASET: - error(f'To operate a branch, "{info}" must be a dataset') + tbrn_info = TBRN(tbrn=tbrn) + if tbrn_info.type != TBRNType.DATASET: + error(f'To operate a branch, "{tbrn_info}" must be a dataset') gas = get_gas(*obj) - dataset_client = get_dataset_client(gas, info) + dataset_client = get_dataset_client(gas, tbrn_info) if is_delete: - _delete_branch(dataset_client, info) + _delete_branch(dataset_client, tbrn_info) return if name: @@ -53,9 +53,9 @@ def _list_branches(dataset_client: DatasetClientType, verbose: bool) -> None: click.echo(f"{branch.name:{name_length}} {shorten(branch.commit_id)} {branch.title}") -def _delete_branch(dataset_client: DatasetClientType, info: TBRN) -> None: - if not info.revision: - error(f'To delete a branch, "{info}" must have a branch name') +def _delete_branch(dataset_client: DatasetClientType, tbrn_info: TBRN) -> None: + if not tbrn_info.revision: + error(f'To delete a branch, "{tbrn_info.get_tbrn()}" must have a branch name') - dataset_client._delete_branch(info.revision) # pylint: disable=protected-access - click.echo(f'Successfully deleted branch "{info.get_colored_tbrn()}"') + dataset_client._delete_branch(tbrn_info.revision) # pylint: disable=protected-access + click.echo(f'Successfully deleted branch "{tbrn_info.get_colored_tbrn()}"') diff --git a/tensorbay/cli/commit.py b/tensorbay/cli/commit.py index b001e02da..aa6bba76c 100644 --- a/tensorbay/cli/commit.py +++ b/tensorbay/cli/commit.py @@ -31,15 +31,15 @@ @exception_handler def _implement_commit(obj: ContextInfo, tbrn: str, message: Tuple[str, ...]) -> None: gas = get_gas(*obj) - info = TBRN(tbrn=tbrn) - dataset_client = get_dataset_client(gas, info) + tbrn_info = TBRN(tbrn=tbrn) + dataset_client = get_dataset_client(gas, tbrn_info) - if info.type != TBRNType.DATASET: - error(f'To operate a commit, "{info}" must be a dataset') - if not info.is_draft: - error(f'To commit, "{info}" must be in draft status, like "{info}#1"') + if tbrn_info.type != TBRNType.DATASET: + error(f'To operate a commit, "{tbrn}" must be a dataset') + if not tbrn_info.is_draft: + error(f'To commit, "{tbrn}" must be in draft status, like "{tbrn}#1"') - dataset_client.checkout(draft_number=info.draft_number) + dataset_client.checkout(draft_number=tbrn_info.draft_number) draft = dataset_client.get_draft() hint_message = format_hint(draft.title, draft.description, _COMMIT_HINT) title, description = edit_message(message, hint_message, obj.config_parser) @@ -47,7 +47,8 @@ def _implement_commit(obj: ContextInfo, tbrn: str, message: Tuple[str, ...]) -> error("Aborting commit due to empty commit message") dataset_client.commit(title, description) - commit_tbrn = TBRN(info.dataset_name, revision=dataset_client.status.commit_id) + commit_tbrn = TBRN(tbrn_info.dataset_name, revision=dataset_client.status.commit_id) click.echo( - "Committed successfully: " f"{info.get_colored_tbrn()} -> {commit_tbrn.get_colored_tbrn()}" + "Committed successfully: " + f"{tbrn_info.get_colored_tbrn()} -> {commit_tbrn.get_colored_tbrn()}" ) diff --git a/tensorbay/cli/cp.py b/tensorbay/cli/cp.py index 0ae11ac10..f6d0d4247 100644 --- a/tensorbay/cli/cp.py +++ b/tensorbay/cli/cp.py @@ -24,14 +24,14 @@ def _implement_cp( # pylint: disable=too-many-arguments skip_uploaded_files: bool, ) -> None: gas = get_gas(*obj) - info = TBRN(tbrn=tbrn) + tbrn_info = TBRN(tbrn=tbrn) - dataset_client = get_dataset_client(gas, info, is_fusion=False) + dataset_client = get_dataset_client(gas, tbrn_info, is_fusion=False) - if info.type not in (TBRNType.SEGMENT, TBRNType.NORMAL_FILE): + if tbrn_info.type not in (TBRNType.SEGMENT, TBRNType.NORMAL_FILE): error(f'"{tbrn}" is not a segment or file type') - target_remote_path = info.remote_path if info.type == TBRNType.NORMAL_FILE else "" + target_remote_path = tbrn_info.remote_path if tbrn_info.type == TBRNType.NORMAL_FILE else "" local_abspaths = [os.path.abspath(local_path) for local_path in local_paths] if ( @@ -40,10 +40,12 @@ def _implement_cp( # pylint: disable=too-many-arguments and target_remote_path and not target_remote_path.endswith("/") ): - segment_client = dataset_client.get_or_create_segment(info.segment_name) + segment_client = dataset_client.get_or_create_segment(tbrn_info.segment_name) segment_client.upload_file(local_abspaths[0], target_remote_path) else: - segment = _get_segment(info.segment_name, local_abspaths, target_remote_path, is_recursive) + segment = _get_segment( + tbrn_info.segment_name, local_abspaths, target_remote_path, is_recursive + ) dataset_client.upload_segment(segment, jobs=jobs, skip_uploaded_files=skip_uploaded_files) diff --git a/tensorbay/cli/dataset.py b/tensorbay/cli/dataset.py index a853bd848..307b44f26 100644 --- a/tensorbay/cli/dataset.py +++ b/tensorbay/cli/dataset.py @@ -20,10 +20,10 @@ def _implement_dataset(obj: ContextInfo, tbrn: str, is_delete: bool, yes: bool) for dataset_name in gas.list_dataset_names(): click.echo(TBRN(dataset_name).get_tbrn()) - info = TBRN(tbrn=tbrn) - if info.type != TBRNType.DATASET: + tbrn_info = TBRN(tbrn=tbrn) + if tbrn_info.type != TBRNType.DATASET: error(f'"{tbrn}" is not a dataset') - colored_tbrn = info.get_colored_tbrn() + colored_tbrn = tbrn_info.get_colored_tbrn() if is_delete: if not yes: @@ -32,9 +32,9 @@ def _implement_dataset(obj: ContextInfo, tbrn: str, is_delete: bool, yes: bool) abort=True, ) - gas.delete_dataset(info.dataset_name) + gas.delete_dataset(tbrn_info.dataset_name) click.echo(f'Successfully deleted dataset "{colored_tbrn}"') return - gas.create_dataset(info.dataset_name) + gas.create_dataset(tbrn_info.dataset_name) click.echo(f'Successfully created dataset "{colored_tbrn}"') diff --git a/tensorbay/cli/draft.py b/tensorbay/cli/draft.py index e191dbbe2..474c46f1c 100644 --- a/tensorbay/cli/draft.py +++ b/tensorbay/cli/draft.py @@ -47,30 +47,30 @@ def _implement_draft( # pylint: disable=too-many-arguments message: Tuple[str, ...], ) -> None: gas = get_gas(*obj) - info = TBRN(tbrn=tbrn) - dataset_client = get_dataset_client(gas, info) + tbrn_info = TBRN(tbrn=tbrn) + dataset_client = get_dataset_client(gas, tbrn_info) - if info.type != TBRNType.DATASET: - error(f'To operate a draft, "{info}" must be a dataset') + if tbrn_info.type != TBRNType.DATASET: + error(f'To operate a draft, "{tbrn}" must be a dataset') if is_list: - _list_drafts(dataset_client, info) + _list_drafts(dataset_client, tbrn_info) elif edit: - _edit_draft(dataset_client, info, message, obj.config_parser) + _edit_draft(dataset_client, tbrn_info, message, obj.config_parser) elif close: - _close_draft(dataset_client, info) + _close_draft(dataset_client, tbrn_info) else: - _create_draft(dataset_client, info, message, obj.config_parser) + _create_draft(dataset_client, tbrn_info, message, obj.config_parser) def _create_draft( dataset_client: DatasetClientType, - info: TBRN, + tbrn_info: TBRN, message: Tuple[str, ...], config_parser: ConfigParser, ) -> None: - if info.is_draft: - error(f'Create a draft in draft status "{info}" is not permitted') + if tbrn_info.is_draft: + error(f'Create a draft in draft status "{tbrn_info.get_tbrn()}" is not permitted') title, description = edit_message(message, _DRAFT_HINT, config_parser) if not title: @@ -78,22 +78,24 @@ def _create_draft( dataset_client.create_draft(title=title, description=description) status = dataset_client.status - draft_tbrn = TBRN(info.dataset_name, draft_number=status.draft_number).get_colored_tbrn() + draft_tbrn = TBRN(tbrn_info.dataset_name, draft_number=status.draft_number).get_colored_tbrn() click.echo(f'Successfully created draft "{draft_tbrn}"') _echo_draft(dataset_client, title, description, status.branch_name) -def _list_drafts(dataset_client: DatasetClientType, info: TBRN) -> None: - if info.revision: - error(f'list drafts based on given revision "{info}" is not supported') +def _list_drafts(dataset_client: DatasetClientType, tbrn_info: TBRN) -> None: + if tbrn_info.revision: + error(f'list drafts based on given revision "{tbrn_info.get_tbrn()}" is not supported') - if info.is_draft: - draft = dataset_client.get_draft(info.draft_number) - click.echo(f"Draft: {info.get_tbrn()}") + if tbrn_info.is_draft: + draft = dataset_client.get_draft(tbrn_info.draft_number) + click.echo(f"Draft: {tbrn_info.get_tbrn()}") _echo_draft(dataset_client, draft.title, draft.description, draft.branch_name) else: for draft in dataset_client.list_drafts(): - click.echo(f"Draft: {TBRN(info.dataset_name, draft_number=draft.number).get_tbrn()}") + click.echo( + f"Draft: {TBRN(tbrn_info.dataset_name, draft_number=draft.number).get_tbrn()}" + ) _echo_draft(dataset_client, draft.title, draft.description, draft.branch_name) @@ -129,11 +131,11 @@ def _echo_draft( def _edit_draft( dataset_client: DatasetClientType, - info: TBRN, + tbrn_info: TBRN, message: Tuple[str, ...], config_parser: ConfigParser, ) -> None: - if not info.is_draft: + if not tbrn_info.is_draft: error("Draft number is required when editing draft") draft = dataset_client.get_draft() @@ -143,13 +145,13 @@ def _edit_draft( error("Aborting updating draft due to empty draft message") dataset_client.update_draft(title=title, description=description) - click.echo(f'Successfully updated draft "{info.get_colored_tbrn()}"') + click.echo(f'Successfully updated draft "{tbrn_info.get_colored_tbrn()}"') _echo_draft(dataset_client, title, description, dataset_client.status.branch_name) -def _close_draft(dataset_client: DatasetClientType, info: TBRN) -> None: - if not info.draft_number: +def _close_draft(dataset_client: DatasetClientType, tbrn_info: TBRN) -> None: + if not tbrn_info.draft_number: error("Draft number is required when editing draft") - dataset_client._close_draft(info.draft_number) # pylint: disable=protected-access - click.echo(f'Successfully closed draft "{info.get_colored_tbrn()}"') + dataset_client._close_draft(tbrn_info.draft_number) # pylint: disable=protected-access + click.echo(f'Successfully closed draft "{tbrn_info.get_colored_tbrn()}"') diff --git a/tensorbay/cli/log.py b/tensorbay/cli/log.py index 4e52f1a81..4c9d6c494 100644 --- a/tensorbay/cli/log.py +++ b/tensorbay/cli/log.py @@ -59,12 +59,12 @@ def _implement_log( # pylint: disable=too-many-arguments graph: bool, ) -> None: gas = get_gas(*obj) - info = TBRN(tbrn=tbrn) - if info.type != TBRNType.DATASET: - error(f'To log commits, "{info}" must be a dataset') + tbrn_info = TBRN(tbrn=tbrn) + if tbrn_info.type != TBRNType.DATASET: + error(f'To log commits, "{tbrn}" must be a dataset') dataset_client = gas._get_dataset_with_any_type( # pylint: disable=protected-access - info.dataset_name + tbrn_info.dataset_name ) commit_id_to_branches: DefaultDict[str, List[str]] = defaultdict(list) for branch in dataset_client.list_branches(): @@ -72,7 +72,9 @@ def _implement_log( # pylint: disable=too-many-arguments if is_all: revisions: List[Optional[str]] = [branch.name for branch in dataset_client.list_branches()] else: - revisions = [info.revision] if info.revision else [dataset_client.status.branch_name] + revisions = ( + [tbrn_info.revision] if tbrn_info.revision else [dataset_client.status.branch_name] + ) Printer: Union[Type[_GraphPrinter], Type[_CommitPrinter]] = ( _GraphPrinter if graph else _CommitPrinter diff --git a/tensorbay/cli/ls.py b/tensorbay/cli/ls.py index ac27415bf..71e31a14b 100644 --- a/tensorbay/cli/ls.py +++ b/tensorbay/cli/ls.py @@ -50,8 +50,8 @@ def _validate_dataset_client(dataset_client: DatasetClientType) -> None: error(f'"{dataset_client.name}" has no commit history.') -def _ls_dataset(gas: GAS, info: TBRN, list_all_files: bool, show_total_num: bool) -> None: - dataset_client = get_dataset_client(gas, info) +def _ls_dataset(gas: GAS, tbrn_info: TBRN, list_all_files: bool, show_total_num: bool) -> None: + dataset_client = get_dataset_client(gas, tbrn_info) _validate_dataset_client(dataset_client) segment_names = dataset_client.list_segment_names() @@ -59,7 +59,7 @@ def _ls_dataset(gas: GAS, info: TBRN, list_all_files: bool, show_total_num: bool if show_total_num: click.echo(f"total {len(segment_names)}") for segment_name in segment_names: - click.echo(TBRN(info.dataset_name, segment_name).get_tbrn()) + click.echo(TBRN(tbrn_info.dataset_name, segment_name).get_tbrn()) return if isinstance(dataset_client, FusionDatasetClient): @@ -74,9 +74,9 @@ def _ls_dataset(gas: GAS, info: TBRN, list_all_files: bool, show_total_num: bool for segment_name, segment_path in zip(segment_names, segment_paths): _echo_data( - info.dataset_name, - info.draft_number, - info.revision, + tbrn_info.dataset_name, + tbrn_info.draft_number, + tbrn_info.revision, segment_name, segment_path, ) @@ -84,30 +84,30 @@ def _ls_dataset(gas: GAS, info: TBRN, list_all_files: bool, show_total_num: bool def _ls_segment( gas: GAS, - info: TBRN, + tbrn_info: TBRN, list_all_files: bool, # pylint: disable=unused-argument show_total_num: bool, ) -> None: - dataset_client = get_dataset_client(gas, info) + dataset_client = get_dataset_client(gas, tbrn_info) _validate_dataset_client(dataset_client) if isinstance(dataset_client, FusionDatasetClient): error("List fusion segment is not supported yet") - segment_path = dataset_client.get_segment(info.segment_name).list_data_paths() + segment_path = dataset_client.get_segment(tbrn_info.segment_name).list_data_paths() if show_total_num: click.echo(f"total {len(segment_path)}") _echo_data( - info.dataset_name, - info.draft_number, - info.revision, - info.segment_name, + tbrn_info.dataset_name, + tbrn_info.draft_number, + tbrn_info.revision, + tbrn_info.segment_name, segment_path, ) def _ls_normal_file( gas: GAS, # pylint: disable=unused-argument - info: TBRN, # pylint: disable=unused-argument + tbrn_info: TBRN, # pylint: disable=unused-argument list_all_files: bool, # pylint: disable=unused-argument show_total_num: bool, # pylint: disable=unused-argument ) -> None: @@ -132,5 +132,5 @@ def _implement_ls(obj: ContextInfo, tbrn: str, list_all_files: bool, show_total_ click.echo(TBRN(dataset_name).get_tbrn()) return - info = TBRN(tbrn=tbrn) - _LS_FUNCS[info.type](gas, info, list_all_files, show_total_num) + tbrn_info = TBRN(tbrn=tbrn) + _LS_FUNCS[tbrn_info.type](gas, tbrn_info, list_all_files, show_total_num) diff --git a/tensorbay/cli/rm.py b/tensorbay/cli/rm.py index bf43177a0..a42996572 100644 --- a/tensorbay/cli/rm.py +++ b/tensorbay/cli/rm.py @@ -14,22 +14,22 @@ @exception_handler def _implement_rm(obj: ContextInfo, tbrn: str, is_recursive: bool) -> None: gas = get_gas(*obj) - info = TBRN(tbrn=tbrn) - dataset_client = get_dataset_client(gas, info, is_fusion=False) + tbrn_info = TBRN(tbrn=tbrn) + dataset_client = get_dataset_client(gas, tbrn_info, is_fusion=False) - if info.type not in (TBRNType.SEGMENT, TBRNType.NORMAL_FILE): + if tbrn_info.type not in (TBRNType.SEGMENT, TBRNType.NORMAL_FILE): error(f'"{tbrn}" is an invalid path to remove') - if not info.is_draft: - error(f'To remove the data, "{info}" must be in draft status, like "{info}#1"') + if not tbrn_info.is_draft: + error(f'To remove the data, "{tbrn}" must be in draft status, like "{tbrn}#1"') - if info.type == TBRNType.SEGMENT: + if tbrn_info.type == TBRNType.SEGMENT: if not is_recursive: error("Please use -r option to remove the whole segment") - dataset_client.delete_segment(info.segment_name) + dataset_client.delete_segment(tbrn_info.segment_name) else: - segment = dataset_client.get_segment(info.segment_name) - segment.delete_data(info.remote_path) + segment = dataset_client.get_segment(tbrn_info.segment_name) + segment.delete_data(tbrn_info.remote_path) - click.echo(f'Successfully deleted "{info.get_colored_tbrn()}"') + click.echo(f'Successfully deleted "{tbrn_info.get_colored_tbrn()}"') diff --git a/tensorbay/cli/tag.py b/tensorbay/cli/tag.py index 50f09b313..b18a5936b 100644 --- a/tensorbay/cli/tag.py +++ b/tensorbay/cli/tag.py @@ -14,28 +14,28 @@ @exception_handler def _implement_tag(obj: ContextInfo, tbrn: str, name: str, is_delete: bool) -> None: - info = TBRN(tbrn=tbrn) + tbrn_info = TBRN(tbrn=tbrn) - if info.type != TBRNType.DATASET: - error(f'To operate a tag, "{info}" must be a dataset') + if tbrn_info.type != TBRNType.DATASET: + error(f'To operate a tag, "{tbrn}" must be a dataset') gas = get_gas(*obj) - dataset_client = get_dataset_client(gas, info) + dataset_client = get_dataset_client(gas, tbrn_info) if is_delete: - _delete_tag(dataset_client, info) + _delete_tag(dataset_client, tbrn_info) elif name: _create_tag(dataset_client, name) else: _list_tags(dataset_client) -def _delete_tag(dataset_client: DatasetClientType, info: TBRN) -> None: - if not info.revision: - error(f'To delete a tag, "{info}" must have a tag name') +def _delete_tag(dataset_client: DatasetClientType, tbrn_info: TBRN) -> None: + if not tbrn_info.revision: + error(f'To delete a tag, "{tbrn_info.get_tbrn()}" must have a tag name') - dataset_client.delete_tag(info.revision) - tag_tbrn = TBRN(dataset_client.name, revision=info.revision).get_colored_tbrn() + dataset_client.delete_tag(tbrn_info.revision) + tag_tbrn = TBRN(dataset_client.name, revision=tbrn_info.revision).get_colored_tbrn() click.echo(f'Successfully deleted tag "{tag_tbrn}"') diff --git a/tensorbay/cli/tbrn.py b/tensorbay/cli/tbrn.py index 7b35b7106..dec34faec 100644 --- a/tensorbay/cli/tbrn.py +++ b/tensorbay/cli/tbrn.py @@ -120,23 +120,23 @@ class TBRN: Use as a generator: - >>> info = TBRN("VOC2010", "train", remote_path="2012_004330.jpg") - >>> info.type + >>> tbrn_info = TBRN("VOC2010", "train", remote_path="2012_004330.jpg") + >>> tbrn_info.type - >>> info.get_tbrn() + >>> tbrn_info.get_tbrn() 'tb:VOC2010:train://2012_004330.jpg' - >>> print(info) + >>> print(tbrn_info) 'tb:VOC2010:train://2012_004330.jpg' Use as a parser: >>> tbrn = "tb:VOC2010:train://2012_004330.jpg" - >>> info = TBRN(tbrn=tbrn) - >>> info.dataset + >>> tbrn_info = TBRN(tbrn=tbrn) + >>> tbrn_info.dataset 'VOC2010' - >>> info.segment_name + >>> tbrn_info.segment_name 'train' - >>> info.remote_path + >>> tbrn_info.remote_path '2012_004330.jpg' Arguments: diff --git a/tensorbay/cli/utility.py b/tensorbay/cli/utility.py index 29bedce23..5c8a9fc9b 100644 --- a/tensorbay/cli/utility.py +++ b/tensorbay/cli/utility.py @@ -118,31 +118,37 @@ def get_gas(access_key: str, url: str, profile_name: str, config_parser: ConfigP @overload -def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Literal[None] = None) -> DatasetClientType: +def get_dataset_client( + gas: GAS, tbrn_info: TBRN, is_fusion: Literal[None] = None +) -> DatasetClientType: ... @overload -def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Literal[False]) -> DatasetClient: +def get_dataset_client(gas: GAS, tbrn_info: TBRN, is_fusion: Literal[False]) -> DatasetClient: ... @overload -def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Literal[True]) -> FusionDatasetClient: +def get_dataset_client(gas: GAS, tbrn_info: TBRN, is_fusion: Literal[True]) -> FusionDatasetClient: ... @overload -def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Optional[bool] = None) -> DatasetClientType: +def get_dataset_client( + gas: GAS, tbrn_info: TBRN, is_fusion: Optional[bool] = None +) -> DatasetClientType: ... -def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Optional[bool] = None) -> DatasetClientType: +def get_dataset_client( + gas: GAS, tbrn_info: TBRN, is_fusion: Optional[bool] = None +) -> DatasetClientType: """Get the dataset client with any type and its version info. Arguments: gas: The gas client. - info: The tbrn of the resource. + tbrn_info: The tbrn of the resource. is_fusion: Whether the dataset is a fusion dataset, True for fusion dataset. Returns: @@ -150,14 +156,14 @@ def get_dataset_client(gas: GAS, info: TBRN, is_fusion: Optional[bool] = None) - """ dataset_client = ( - gas._get_dataset_with_any_type(info.dataset_name) # pylint: disable=protected-access + gas._get_dataset_with_any_type(tbrn_info.dataset_name) # pylint: disable=protected-access if is_fusion is None - else gas.get_dataset(info.dataset_name, is_fusion) + else gas.get_dataset(tbrn_info.dataset_name, is_fusion) ) - if info.is_draft: - dataset_client.checkout(draft_number=info.draft_number) - elif info.revision is not None: - dataset_client.checkout(revision=info.revision) + if tbrn_info.is_draft: + dataset_client.checkout(draft_number=tbrn_info.draft_number) + elif tbrn_info.revision is not None: + dataset_client.checkout(revision=tbrn_info.revision) return dataset_client