diff --git a/.travis.yml b/.travis.yml index 665ca9eeaaf..1f715bd1841 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,7 @@ before_script: - chmod a+rwx ${HOST_COVERAGE_DATA_DIR} script: - # FIXME: Git package and application name conflict in PATH and try to leave only one python test execution - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps && coverage run -a manage.py test --pattern="_test*.py" cvat/apps/dataset_manager/tests cvat/apps/engine/tests utils/cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}' + - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps utils/cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}' - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && coveralls-lcov -v -n ./reports/coverage/lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json' # Up all containers - docker-compose up -d diff --git a/CHANGELOG.md b/CHANGELOG.md index 87dc74e161e..8239f75730a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ filters and searching the nearest frame without any annotations () - Fixed use case when logs could be saved twice or more times #2202 () - Fixed issues from #2112 () +- Git application name (renamed to dataset_repo) () ### Security - diff --git a/cvat/apps/dataset_manager/__init__.py b/cvat/apps/dataset_manager/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/cvat/apps/dataset_manager/tests/__init__.py b/cvat/apps/dataset_manager/tests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/cvat/apps/dataset_manager/tests/_test_formats.py b/cvat/apps/dataset_manager/tests/test_formats.py similarity index 91% rename from cvat/apps/dataset_manager/tests/_test_formats.py rename to cvat/apps/dataset_manager/tests/test_formats.py index 3b4ea5487ae..34eea1bfd86 100644 --- a/cvat/apps/dataset_manager/tests/_test_formats.py +++ b/cvat/apps/dataset_manager/tests/test_formats.py @@ -3,81 +3,21 @@ # # SPDX-License-Identifier: MIT -# FIXME: Git application and package name clash in tests -class _GitImportFix: - import sys - former_path = sys.path[:] - - @classmethod - def apply(cls): - # HACK: fix application and module name clash - # 'git' app is found earlier than a library in the path. - # The clash is introduced by unittest discover - import sys - print('apply') - - apps_dir = __file__[:__file__.rfind('/dataset_manager/')] - assert 'apps' in apps_dir - try: - sys.path.remove(apps_dir) - except ValueError: - pass - - for name in list(sys.modules): - if name.startswith('git.') or name == 'git': - m = sys.modules.pop(name, None) - del m - - import git - assert apps_dir not in git.__file__ - - @classmethod - def restore(cls): - import sys - print('restore') - - for name in list(sys.modules): - if name.startswith('git.') or name == 'git': - m = sys.modules.pop(name) - del m - - sys.path.insert(0, __file__[:__file__.rfind('/dataset_manager/')]) - - import importlib - importlib.invalidate_caches() - -def _setUpModule(): - _GitImportFix.apply() - import cvat.apps.dataset_manager as dm - globals()['dm'] = dm - - import datumaro - globals()['datumaro'] = datumaro - - import sys - sys.path.insert(0, __file__[:__file__.rfind('/dataset_manager/')]) - -# def tearDownModule(): - # _GitImportFix.restore() from io import BytesIO import os.path as osp import tempfile import zipfile +import datumaro from PIL import Image from django.contrib.auth.models import User, Group from rest_framework.test import APITestCase, APIClient from rest_framework import status +import cvat.apps.dataset_manager as dm from cvat.apps.dataset_manager.annotation import AnnotationIR -from cvat.apps.dataset_manager.bindings import TaskData, find_dataset_root -from cvat.apps.engine.models import Task - -_setUpModule() - -from cvat.apps.dataset_manager.annotation import AnnotationIR -from cvat.apps.dataset_manager.bindings import TaskData, CvatTaskDataExtractor +from cvat.apps.dataset_manager.bindings import TaskData, find_dataset_root, CvatTaskDataExtractor from cvat.apps.dataset_manager.task import TaskAnnotation from cvat.apps.engine.models import Task diff --git a/cvat/apps/git/README.md b/cvat/apps/dataset_repo/README.md similarity index 100% rename from cvat/apps/git/README.md rename to cvat/apps/dataset_repo/README.md diff --git a/cvat/apps/git/__init__.py b/cvat/apps/dataset_repo/__init__.py similarity index 100% rename from cvat/apps/git/__init__.py rename to cvat/apps/dataset_repo/__init__.py diff --git a/cvat/apps/git/apps.py b/cvat/apps/dataset_repo/apps.py similarity index 84% rename from cvat/apps/git/apps.py rename to cvat/apps/dataset_repo/apps.py index 9ef81587947..6b021856f0d 100644 --- a/cvat/apps/git/apps.py +++ b/cvat/apps/dataset_repo/apps.py @@ -6,4 +6,4 @@ class GitConfig(AppConfig): - name = 'git' + name = 'dataset_repo' diff --git a/cvat/apps/git/git.py b/cvat/apps/dataset_repo/dataset_repo.py similarity index 99% rename from cvat/apps/git/git.py rename to cvat/apps/dataset_repo/dataset_repo.py index c43c9c093f0..4b2790b463f 100644 --- a/cvat/apps/git/git.py +++ b/cvat/apps/dataset_repo/dataset_repo.py @@ -21,7 +21,7 @@ from cvat.apps.engine.log import slogger from cvat.apps.engine.models import Job, Task, User from cvat.apps.engine.plugins import add_plugin -from cvat.apps.git.models import GitData, GitStatusChoice +from cvat.apps.dataset_repo.models import GitData, GitStatusChoice def _have_no_access_exception(ex): diff --git a/cvat/apps/git/management/__init__.py b/cvat/apps/dataset_repo/management/__init__.py similarity index 100% rename from cvat/apps/git/management/__init__.py rename to cvat/apps/dataset_repo/management/__init__.py diff --git a/cvat/apps/git/management/commands/__init__.py b/cvat/apps/dataset_repo/management/commands/__init__.py similarity index 100% rename from cvat/apps/git/management/commands/__init__.py rename to cvat/apps/dataset_repo/management/commands/__init__.py diff --git a/cvat/apps/git/management/commands/update_git_states.py b/cvat/apps/dataset_repo/management/commands/update_git_states.py similarity index 89% rename from cvat/apps/git/management/commands/update_git_states.py rename to cvat/apps/dataset_repo/management/commands/update_git_states.py index 68263eef719..939d60a475d 100644 --- a/cvat/apps/git/management/commands/update_git_states.py +++ b/cvat/apps/dataset_repo/management/commands/update_git_states.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT from django.core.management.base import BaseCommand -from cvat.apps.git.git import update_states +from cvat.apps.dataset_repo.dataset_repo import update_states import time INTERVAL_SEC = 600 diff --git a/cvat/apps/git/migrations/0001_initial.py b/cvat/apps/dataset_repo/migrations/0001_initial.py similarity index 86% rename from cvat/apps/git/migrations/0001_initial.py rename to cvat/apps/dataset_repo/migrations/0001_initial.py index 10daa9c61e0..2ecf9c17c9b 100644 --- a/cvat/apps/git/migrations/0001_initial.py +++ b/cvat/apps/dataset_repo/migrations/0001_initial.py @@ -12,6 +12,8 @@ class Migration(migrations.Migration): ('engine', '0014_job_max_shape_id'), ] + replaces = [('git', '0001_initial')] + operations = [ migrations.CreateModel( name='GitData', @@ -22,5 +24,8 @@ class Migration(migrations.Migration): ('sync_date', models.DateTimeField(auto_now_add=True)), ('status', models.CharField(default='!sync', max_length=20)), ], + options={ + 'db_table': 'git_gitdata', + }, ), ] diff --git a/cvat/apps/git/migrations/0002_auto_20190123_1305.py b/cvat/apps/dataset_repo/migrations/0002_auto_20190123_1305.py similarity index 53% rename from cvat/apps/git/migrations/0002_auto_20190123_1305.py rename to cvat/apps/dataset_repo/migrations/0002_auto_20190123_1305.py index f7156064ea7..114ae7a3ff1 100644 --- a/cvat/apps/git/migrations/0002_auto_20190123_1305.py +++ b/cvat/apps/dataset_repo/migrations/0002_auto_20190123_1305.py @@ -1,19 +1,21 @@ # Generated by Django 2.1.3 on 2019-01-23 10:05 -import cvat.apps.git.models +import cvat.apps.dataset_repo.models from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('git', '0001_initial'), + ('dataset_repo', '0001_initial'), ] + replaces = [('git', '0002_auto_20190123_1305')] + operations = [ migrations.AlterField( model_name='gitdata', name='status', - field=models.CharField(default=cvat.apps.git.models.GitStatusChoice('!sync'), max_length=20), + field=models.CharField(default=cvat.apps.dataset_repo.models.GitStatusChoice('!sync'), max_length=20), ), ] diff --git a/cvat/apps/git/migrations/0003_gitdata_lfs.py b/cvat/apps/dataset_repo/migrations/0003_gitdata_lfs.py similarity index 77% rename from cvat/apps/git/migrations/0003_gitdata_lfs.py rename to cvat/apps/dataset_repo/migrations/0003_gitdata_lfs.py index 84da1c7ba72..b42ebd30db2 100644 --- a/cvat/apps/git/migrations/0003_gitdata_lfs.py +++ b/cvat/apps/dataset_repo/migrations/0003_gitdata_lfs.py @@ -6,9 +6,11 @@ class Migration(migrations.Migration): dependencies = [ - ('git', '0002_auto_20190123_1305'), + ('dataset_repo', '0002_auto_20190123_1305'), ] + replaces = [('git', '0003_gitdata_lfs')] + operations = [ migrations.AddField( model_name='gitdata', diff --git a/cvat/apps/dataset_repo/migrations/0004_rename.py b/cvat/apps/dataset_repo/migrations/0004_rename.py new file mode 100644 index 00000000000..9629165722d --- /dev/null +++ b/cvat/apps/dataset_repo/migrations/0004_rename.py @@ -0,0 +1,16 @@ +from django.db import migrations + +def update_contenttypes_table(apps, schema_editor): + content_type_model = apps.get_model('contenttypes', 'ContentType') + content_type_model.objects.filter(app_label='git').update(app_label='dataset_repo') + +class Migration(migrations.Migration): + + dependencies = [ + ('dataset_repo', '0003_gitdata_lfs'), + ] + + operations = [ + migrations.AlterModelTable('gitdata', 'dataset_repo_gitdata'), + migrations.RunPython(update_contenttypes_table), + ] diff --git a/cvat/apps/git/migrations/__init__.py b/cvat/apps/dataset_repo/migrations/__init__.py similarity index 100% rename from cvat/apps/git/migrations/__init__.py rename to cvat/apps/dataset_repo/migrations/__init__.py diff --git a/cvat/apps/git/models.py b/cvat/apps/dataset_repo/models.py similarity index 100% rename from cvat/apps/git/models.py rename to cvat/apps/dataset_repo/models.py diff --git a/cvat/apps/git/tests.py b/cvat/apps/dataset_repo/tests.py similarity index 97% rename from cvat/apps/git/tests.py rename to cvat/apps/dataset_repo/tests.py index 7d47c1691f4..8c5b1bef140 100644 --- a/cvat/apps/git/tests.py +++ b/cvat/apps/dataset_repo/tests.py @@ -8,7 +8,7 @@ # Create your tests here. -from cvat.apps.git.git import Git +from cvat.apps.dataset_repo.dataset_repo import Git class GitUrlTest(TestCase): diff --git a/cvat/apps/git/urls.py b/cvat/apps/dataset_repo/urls.py similarity index 100% rename from cvat/apps/git/urls.py rename to cvat/apps/dataset_repo/urls.py diff --git a/cvat/apps/git/views.py b/cvat/apps/dataset_repo/views.py similarity index 97% rename from cvat/apps/git/views.py rename to cvat/apps/dataset_repo/views.py index 770f0678f3e..39ced8c4f5a 100644 --- a/cvat/apps/git/views.py +++ b/cvat/apps/dataset_repo/views.py @@ -8,9 +8,9 @@ from cvat.apps.authentication.decorators import login_required from cvat.apps.engine.log import slogger from cvat.apps.engine import models -from cvat.apps.git.models import GitData +from cvat.apps.dataset_repo.models import GitData -import cvat.apps.git.git as CVATGit +import cvat.apps.dataset_repo.dataset_repo as CVATGit import django_rq import json diff --git a/cvat/apps/engine/tests/_test_rest_api.py b/cvat/apps/engine/tests/test_rest_api.py similarity index 99% rename from cvat/apps/engine/tests/_test_rest_api.py rename to cvat/apps/engine/tests/test_rest_api.py index 8518c9746ba..e22b3af26e3 100644 --- a/cvat/apps/engine/tests/_test_rest_api.py +++ b/cvat/apps/engine/tests/test_rest_api.py @@ -2,57 +2,6 @@ # # SPDX-License-Identifier: MIT -# FIXME: Git application and package name clash in tests -class _GitImportFix: - import sys - former_path = sys.path[:] - - @classmethod - def apply(cls): - # HACK: fix application and module name clash - # 'git' app is found earlier than a library in the path. - # The clash is introduced by unittest discover - import sys - print('apply') - - apps_dir = __file__[:__file__.rfind('/engine/')] - assert 'apps' in apps_dir - try: - sys.path.remove(apps_dir) - except ValueError: - pass - - for name in list(sys.modules): - if name.startswith('git.') or name == 'git': - m = sys.modules.pop(name, None) - del m - - import git - assert apps_dir not in git.__file__ - - @classmethod - def restore(cls): - import sys - print('restore') - - for name in list(sys.modules): - if name.startswith('git.') or name == 'git': - m = sys.modules.pop(name) - del m - - sys.path.insert(0, __file__[:__file__.rfind('/engine/')]) - - import importlib - importlib.invalidate_caches() - -def _setUpModule(): - _GitImportFix.apply() - - import sys - sys.path.insert(0, __file__[:__file__.rfind('/engine/')]) - -# def tearDownModule(): - # _GitImportFix.restore() import io import os @@ -83,8 +32,6 @@ def _setUpModule(): Segment, StatusChoice, Task, StorageMethodChoice) from cvat.apps.engine.prepare import prepare_meta, prepare_meta_for_upload -_setUpModule() - def create_db_users(cls): (group_admin, _) = Group.objects.get_or_create(name="admin") (group_user, _) = Group.objects.get_or_create(name="user") diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 6b74443cbad..6e328f62f16 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -177,7 +177,7 @@ def annotation_formats(request): @action(detail=False, methods=['GET'], url_path='plugins', serializer_class=PluginsSerializer) def plugins(request): response = { - 'GIT_INTEGRATION': apps.is_installed('cvat.apps.git'), + 'GIT_INTEGRATION': apps.is_installed('cvat.apps.dataset_repo'), 'ANALYTICS': False, 'MODELS': False, } diff --git a/cvat/settings/base.py b/cvat/settings/base.py index 7df157097cf..2b49c78f48c 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -93,7 +93,7 @@ def generate_ssh_keys(): 'cvat.apps.documentation', 'cvat.apps.dataset_manager', 'cvat.apps.engine', - 'cvat.apps.git', + 'cvat.apps.dataset_repo', 'cvat.apps.restrictions', 'cvat.apps.lambda_manager', 'django_rq', diff --git a/cvat/urls.py b/cvat/urls.py index bb0b2210353..627c4c7ad53 100644 --- a/cvat/urls.py +++ b/cvat/urls.py @@ -29,8 +29,8 @@ path('documentation/', include('cvat.apps.documentation.urls')), ] -if apps.is_installed('cvat.apps.git'): - urlpatterns.append(path('git/repository/', include('cvat.apps.git.urls'))) +if apps.is_installed('cvat.apps.dataset_repo'): + urlpatterns.append(path('git/repository/', include('cvat.apps.dataset_repo.urls'))) if apps.is_installed('cvat.apps.log_viewer'): urlpatterns.append(path('analytics/', include('cvat.apps.log_viewer.urls'))) diff --git a/utils/cli/tests/_test_cli.py b/utils/cli/tests/test_cli.py similarity index 98% rename from utils/cli/tests/_test_cli.py rename to utils/cli/tests/test_cli.py index a792633dc40..0e86bd65eba 100644 --- a/utils/cli/tests/_test_cli.py +++ b/utils/cli/tests/test_cli.py @@ -12,7 +12,7 @@ from PIL import Image from rest_framework.test import APITestCase, RequestsClient -from cvat.apps.engine.tests._test_rest_api import (create_db_users, +from cvat.apps.engine.tests.test_rest_api import (create_db_users, generate_image_file) from utils.cli.core import CLI, CVAT_API_V1, ResourceType