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

Rename git app #2243

Merged
merged 7 commits into from
Oct 3, 2020
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
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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
-
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cvat/apps/git/apps.py → cvat/apps/dataset_repo/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@


class GitConfig(AppConfig):
name = 'git'
name = 'dataset_repo'
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Migration(migrations.Migration):
('engine', '0014_job_max_shape_id'),
]

replaces = [('git', '0001_initial')]

operations = [
migrations.CreateModel(
name='GitData',
Expand All @@ -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',
},
),
]
Original file line number Diff line number Diff line change
@@ -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),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 16 additions & 0 deletions cvat/apps/dataset_repo/migrations/0004_rename.py
Original file line number Diff line number Diff line change
@@ -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),
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cvat/apps/git/views.py → cvat/apps/dataset_repo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions cvat/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down