Skip to content
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
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ minversion = 3.7
log_cli=true
python_files = test_*.py
;pytest_plugins = ['pytest_profiling']
addopts = -n auto --dist=loadscope
;addopts = -n auto --dist=loadscope

48 changes: 35 additions & 13 deletions src/superannotate/lib/app/input_converters/conversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Main module for input converters
"""
import os
import shutil
import tempfile
from argparse import Namespace
from pathlib import Path

Expand Down Expand Up @@ -135,6 +138,16 @@ def _passes_converter_sanity(args, direction):
)


def change_file_extensions(directory, old_extension, new_extension):
for filename in os.listdir(directory):
file_path = os.path.join(directory, filename)
if os.path.isfile(file_path) and filename.endswith(old_extension):
if file_path.endswith(new_extension):
continue
new_file_path = os.path.splitext(file_path)[0] + new_extension
os.rename(file_path, new_file_path)


@Tracker
def export_annotation(
input_dir,
Expand Down Expand Up @@ -208,19 +221,28 @@ def export_annotation(
),
]
_passes_value_sanity(values_info)

args = Namespace(
input_dir=input_dir,
output_dir=output_dir,
dataset_format=dataset_format,
dataset_name=dataset_name,
project_type=project_type,
task=task,
)

_passes_converter_sanity(args, "export")

export_from_sa(args)
if project_type == "Vector":
extension = "___objects.json"
elif project_type == "Pixel":
extension = "___pixel.json"
else:
extension = ".json"
with tempfile.TemporaryDirectory() as tmp_dir:
args = Namespace(
input_dir=Path(tmp_dir),
output_dir=output_dir,
dataset_format=dataset_format,
dataset_name=dataset_name,
project_type=project_type,
task=task,
)
shutil.copytree(input_dir, tmp_dir, dirs_exist_ok=True)
for _path in os.listdir(tmp_dir):
if os.path.isdir(_path) and not _path.endswith("classes"):
change_file_extensions(_path, ".json", extension)
change_file_extensions(tmp_dir, ".json", extension)
_passes_converter_sanity(args, "export")
export_from_sa(args)


@Tracker
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/convertors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import pathlib


DATA_SET_PATH = pathlib.Path(os.getcwd()) / "data_set"


__all__ = ["DATA_SET_PATH"]
Loading