Rename git app (#2243)

* renamed application git -> git_manager

* removed _GitImportFix class

* fixed cli tests

* git_manager -> dataset_repo

* updated changelog

* fixed dataset manager tests
main
Andrey Zhavoronkov 5 years ago committed by GitHub
parent f138859c1a
commit a222741f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -50,6 +50,7 @@ filters and searching the nearest frame without any annotations (<https://github
- Fixed use case when UI throws exception: Cannot read property 'objectType' of undefined #2053 (<https://github.com/openvinotoolkit/cvat/pull/2203>)
- Fixed use case when logs could be saved twice or more times #2202 (<https://github.com/openvinotoolkit/cvat/pull/2203>)
- Fixed issues from #2112 (<https://github.com/openvinotoolkit/cvat/pull/2217>)
- Git application name (renamed to dataset_repo) (<https://github.com/openvinotoolkit/cvat/pull/2243>)
### Security
-

@ -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

@ -6,4 +6,4 @@ from django.apps import AppConfig
class GitConfig(AppConfig):
name = 'git'
name = 'dataset_repo'

@ -21,7 +21,7 @@ from cvat.apps.dataset_manager.task import export_task
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):

@ -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

@ -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',
},
),
]

@ -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),
),
]

@ -6,9 +6,11 @@ from django.db import migrations, models
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',

@ -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),
]

@ -8,7 +8,7 @@ from django.test import TestCase
# Create your tests here.
from cvat.apps.git.git import Git
from cvat.apps.dataset_repo.dataset_repo import Git
class GitUrlTest(TestCase):

@ -8,9 +8,9 @@ from rules.contrib.views import permission_required, objectgetter
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

@ -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 @@ from cvat.apps.engine.models import (AttributeType, Data, Job, Project,
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")

@ -177,7 +177,7 @@ class ServerViewSet(viewsets.ViewSet):
@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,
}

@ -93,7 +93,7 @@ INSTALLED_APPS = [
'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',

@ -29,8 +29,8 @@ urlpatterns = [
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')))

@ -12,7 +12,7 @@ from django.conf import settings
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
Loading…
Cancel
Save