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

[DAR-4040][External] E2E test for pull #956

Merged
merged 1 commit into from
Nov 4, 2024
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
6 changes: 3 additions & 3 deletions e2e_tests/cli/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from e2e_tests.helpers import (
assert_cli,
run_cli_command,
export_and_download_annotations,
export_release,
delete_annotation_uuids,
list_items,
)
Expand Down Expand Up @@ -336,12 +336,12 @@ def run_import_test(
)
with tempfile.TemporaryDirectory() as tmp_dir_str:
actual_annotations_dir = Path(tmp_dir_str)
export_and_download_annotations(
actual_annotations_dir,
release = export_release(
annotation_format, # type: ignore
local_dataset,
config_values,
)
release.download_zip(actual_annotations_dir / "dataset.zip")
compare_annotations_export(
actual_annotations_dir,
expected_annotations_dir,
Expand Down
36 changes: 36 additions & 0 deletions e2e_tests/cli/test_pull.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pathlib import Path

from e2e_tests.helpers import assert_cli, run_cli_command, export_release
from e2e_tests.objects import E2EDataset, ConfigValues


def test_pull_with_remote_folder_structure(
local_dataset: E2EDataset, config_values: ConfigValues
):
"""
Test pulling a dataset release with default arguments.

The remote directory structure should be recreated locally.
"""
pull_dir = Path(
f"{Path.home()}/.darwin/datasets/{config_values.team_slug}/{local_dataset.slug}/images"
)
expected_filepaths = [
f"{pull_dir}/image_1",
f"{pull_dir}/image_2",
f"{pull_dir}/dir1/image_3",
f"{pull_dir}/dir1/image_4",
f"{pull_dir}/dir2/image_5",
f"{pull_dir}/dir2/image_6",
f"{pull_dir}/dir1/dir3/image_7",
f"{pull_dir}/dir1/dir3/image_8",
]
item_type = "single_slotted"
annotation_format = "darwin"
local_dataset.register_read_only_items(config_values, item_type)
release = export_release(annotation_format, local_dataset, config_values)
result = run_cli_command(f"darwin dataset pull {local_dataset.name}:{release.name}")
assert_cli(result, 0)
all_filepaths = list(pull_dir.rglob("*"))
for expected_file in expected_filepaths:
assert Path(expected_file) in all_filepaths
8 changes: 3 additions & 5 deletions e2e_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Optional, Union, Sequence

from attr import dataclass
from pathlib import Path
from darwin.exceptions import DarwinException
import datetime
import json
Expand Down Expand Up @@ -193,12 +192,11 @@ def wait_until_items_processed(
)


def export_and_download_annotations(
actual_annotations_dir: Path,
def export_release(
annotation_format: str,
local_dataset: E2EDataset,
config_values: ConfigValues,
) -> None:
) -> Release:
"""
Creates an export of all items in the given dataset.
Waits for the export to finish, then downloads and the annotation files to
Expand Down Expand Up @@ -261,7 +259,7 @@ def export_and_download_annotations(
latest=export_data["latest"],
format=export_data.get("format", "json"),
)
release.download_zip(actual_annotations_dir / "dataset.zip")
return release


def delete_annotation_uuids(
Expand Down