Skip to content

Commit

Permalink
Removed training app (#4330)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich authored Feb 11, 2022
1 parent 331e4ca commit e9ef925
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 979 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed
- Review rating, reviewer field from the job instance (use assignee field together with stage field instead) (<https://github.com/openvinotoolkit/cvat/pull/3788>)
- Training django app (<https://github.com/openvinotoolkit/cvat/pull/4330>)

### Fixed
- Fixed Interaction handler keyboard handlers (<https://github.com/openvinotoolkit/cvat/pull/3881>)
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def _write_tasks(self, zip_object):
def _write_manifest(self, zip_object):
def serialize_project():
project_serializer = ProjectSerializer(self._db_project)
for field in ('assignee', 'owner', 'tasks', 'training_project', 'url'):
for field in ('assignee', 'owner', 'tasks', 'url'):
project_serializer.fields.pop(field)

project = self._prepare_project_meta(project_serializer.data)
Expand Down
34 changes: 34 additions & 0 deletions cvat/apps/engine/migrations/0050_auto_20220211_1425.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.12 on 2022-02-11 14:25

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('engine', '0049_auto_20220202_0710'),
]

operations = [
migrations.RemoveField(
model_name='trainingprojectimage',
name='task',
),
migrations.RemoveField(
model_name='trainingprojectlabel',
name='cvat_label',
),
migrations.RemoveField(
model_name='project',
name='training_project',
),
migrations.DeleteModel(
name='TrainingProject',
),
migrations.DeleteModel(
name='TrainingProjectImage',
),
migrations.DeleteModel(
name='TrainingProjectLabel',
),
]
28 changes: 0 additions & 28 deletions cvat/apps/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.db.models.fields import FloatField
from django.utils.translation import gettext_lazy as _
from cvat.apps.engine.utils import parse_specific_attributes
from cvat.apps.organizations.models import Organization

Expand Down Expand Up @@ -223,19 +222,6 @@ class Image(models.Model):
class Meta:
default_permissions = ()


class TrainingProject(models.Model):
class ProjectClass(models.TextChoices):
DETECTION = 'OD', _('Object Detection')

host = models.CharField(max_length=256)
username = models.CharField(max_length=256)
password = models.CharField(max_length=256)
training_id = models.CharField(max_length=64)
enabled = models.BooleanField(null=True)
project_class = models.CharField(max_length=2, choices=ProjectClass.choices, null=True, blank=True)


class Project(models.Model):

name = SafeCharField(max_length=256)
Expand All @@ -250,7 +236,6 @@ class Project(models.Model):
default=StatusChoice.ANNOTATION)
organization = models.ForeignKey(Organization, null=True, default=None,
blank=True, on_delete=models.SET_NULL, related_name="projects")
training_project = models.ForeignKey(TrainingProject, null=True, blank=True, on_delete=models.SET_NULL)

def get_project_dirname(self):
return os.path.join(settings.PROJECTS_ROOT, str(self.id))
Expand Down Expand Up @@ -318,13 +303,6 @@ def get_task_artifacts_dirname(self):
def __str__(self):
return self.name


class TrainingProjectImage(models.Model):
task = models.ForeignKey(Task, on_delete=models.CASCADE)
idx = models.PositiveIntegerField()
training_image_id = models.CharField(max_length=64)


# Redefined a couple of operation for FileSystemStorage to avoid renaming
# or other side effects.
class MyFileSystemStorage(FileSystemStorage):
Expand Down Expand Up @@ -429,12 +407,6 @@ class Meta:
default_permissions = ()
unique_together = ('task', 'name')


class TrainingProjectLabel(models.Model):
cvat_label = models.ForeignKey(Label, on_delete=models.CASCADE, related_name='training_project_label')
training_label_id = models.CharField(max_length=64)


class AttributeType(str, Enum):
CHECKBOX = 'checkbox'
RADIO = 'radio'
Expand Down
24 changes: 2 additions & 22 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,30 +559,20 @@ class Meta:
fields = ('id', 'name')
read_only_fields = ('name',)


class TrainingProjectSerializer(serializers.ModelSerializer):
class Meta:
model = models.TrainingProject
fields = ('host', 'username', 'password', 'enabled', 'project_class')
write_once_fields = ('host', 'username', 'password', 'project_class')


class ProjectSerializer(serializers.ModelSerializer):
labels = LabelSerializer(many=True, source='label_set', partial=True, default=[])
owner = BasicUserSerializer(required=False, read_only=True)
owner_id = serializers.IntegerField(write_only=True, allow_null=True, required=False)
assignee = BasicUserSerializer(allow_null=True, required=False)
assignee_id = serializers.IntegerField(write_only=True, allow_null=True, required=False)
task_subsets = serializers.ListField(child=serializers.CharField(), required=False)
training_project = TrainingProjectSerializer(required=False, allow_null=True)
dimension = serializers.CharField(max_length=16, required=False)

class Meta:
model = models.Project
fields = ('url', 'id', 'name', 'labels', 'tasks', 'owner', 'assignee',
'owner_id', 'assignee_id', 'bug_tracker', 'task_subsets',
'created_date', 'updated_date', 'status', 'training_project',
'dimension', 'organization')
'created_date', 'updated_date', 'status', 'dimension', 'organization')
read_only_fields = ('created_date', 'updated_date', 'status', 'owner',
'assignee', 'task_subsets', 'dimension', 'organization', 'tasks')

Expand All @@ -597,17 +587,7 @@ def to_representation(self, instance):
# pylint: disable=no-self-use
def create(self, validated_data):
labels = validated_data.pop('label_set')
training_data = validated_data.pop('training_project', {})
if training_data.get('enabled'):
host = training_data.pop('host').strip('/')
username = training_data.pop('username').strip()
password = training_data.pop('password').strip()
tr_p = models.TrainingProject.objects.create(**training_data,
host=host, username=username, password=password)
db_project = models.Project.objects.create(**validated_data,
training_project=tr_p)
else:
db_project = models.Project.objects.create(**validated_data)
db_project = models.Project.objects.create(**validated_data)
label_colors = list()
for label in labels:
if label.get('id', None):
Expand Down
1 change: 0 additions & 1 deletion cvat/apps/engine/tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,6 @@ def _run_api_v2_projects_id_export_import(self, user):
"assignee",
"created_date",
"updated_date",
"training_project",
"project_id",
"tasks",
),
Expand Down
2 changes: 0 additions & 2 deletions cvat/apps/engine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.conf import settings
from cvat.apps.restrictions.views import RestrictionsViewSet
from cvat.apps.iam.decorators import login_required
from cvat.apps.training.views import PredictView

schema_view = get_schema_view(
openapi.Info(
Expand Down Expand Up @@ -53,7 +52,6 @@ def _map_format_to_schema(request, scheme=None):
router.register('issues', views.IssueViewSet)
router.register('comments', views.CommentViewSet)
router.register('restrictions', RestrictionsViewSet, basename='restrictions')
router.register('predict', PredictView, basename='predict')
router.register('cloudstorages', views.CloudStorageViewSet)

urlpatterns = [
Expand Down
10 changes: 3 additions & 7 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,10 @@ def annotation_formats(request):
def plugins(request):
response = {
'GIT_INTEGRATION': apps.is_installed('cvat.apps.dataset_repo'),
'ANALYTICS': False,
'MODELS': False,
'PREDICT': apps.is_installed('cvat.apps.training')
'ANALYTICS': strtobool(os.environ.get("CVAT_ANALYTICS", '0')),
'MODELS': strtobool(os.environ.get("CVAT_SERVERLESS", '0')),
'PREDICT':False # FIXME: it is unused anymore (for UI only)
}
if strtobool(os.environ.get("CVAT_ANALYTICS", '0')):
response['ANALYTICS'] = True
if strtobool(os.environ.get("CVAT_SERVERLESS", '0')):
response['MODELS'] = True
return Response(response)


Expand Down
4 changes: 0 additions & 4 deletions cvat/apps/training/__init__.py

This file was deleted.

Loading

0 comments on commit e9ef925

Please sign in to comment.