Skip to content

Commit

Permalink
Added dimension to project
Browse files Browse the repository at this point in the history
  • Loading branch information
ActiveChooN committed Aug 12, 2021
1 parent f1cb156 commit ac2790f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cvat-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.14.0",
"version": "3.15.0",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
16 changes: 14 additions & 2 deletions cvat-core/src/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
task_subsets: undefined,
training_project: undefined,
task_ids: undefined,
dimension: undefined,
};

for (const property in data) {
Expand Down Expand Up @@ -153,7 +154,7 @@
/**
* @name createdDate
* @type {string}
* @memberof module:API.cvat.classes.Task
* @memberof module:API.cvat.classes.Project
* @readonly
* @instance
*/
Expand All @@ -163,13 +164,24 @@
/**
* @name updatedDate
* @type {string}
* @memberof module:API.cvat.classes.Task
* @memberof module:API.cvat.classes.Project
* @readonly
* @instance
*/
updatedDate: {
get: () => data.updated_date,
},
/**
* Dimesion of the tasks in the project, if no task dimension is null
* @name dimension
* @type {string}
* @memberof module:API.cvat.classes.Project
* @readonly
* @instance
*/
dimension: {
get: () => data.dimension,
},
/**
* After project has been created value can be appended only.
* @name labels
Expand Down
47 changes: 26 additions & 21 deletions cvat-ui/src/components/export-dataset/export-dataset-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ function ExportDatasetModal(): JSX.Element {
const instance = useSelector((state: CombinedState) => state.export.instance);
const modalVisible = useSelector((state: CombinedState) => state.export.modalVisible);
const dumpers = useSelector((state: CombinedState) => state.formats.annotationFormats.dumpers);
const {
tasks: taskExportActivities, projects: projectExportActivities,
} = useSelector((state: CombinedState) => state.export);
const { tasks: taskExportActivities, projects: projectExportActivities } = useSelector(
(state: CombinedState) => state.export,
);

const initActivities = (): void => {
if (instance instanceof core.classes.Project) {
Expand All @@ -62,19 +62,28 @@ function ExportDatasetModal(): JSX.Element {
dispatch(exportActions.closeExportModal());
};

const handleExport = useCallback((values: FormValues): void => {
// have to validate format before so it would not be undefined
dispatch(
exportDatasetAsync(instance, values.selectedFormat as string, values.customName ? `${values.customName}.zip` : '', values.saveImages),
);
closeModal();
Notification.info({
message: 'Dataset export started',
description: `Dataset export was started for ${instanceType} #${instance?.id}. ` +
'Download will start automaticly as soon as the dataset is ready.',
className: `cvat-notification-notice-export-${instanceType}-start`,
});
}, [instance?.id, instance instanceof core.classes.Project, instanceType]);
const handleExport = useCallback(
(values: FormValues): void => {
// have to validate format before so it would not be undefined
dispatch(
exportDatasetAsync(
instance,
values.selectedFormat as string,
values.customName ? `${values.customName}.zip` : '',
values.saveImages,
),
);
closeModal();
Notification.info({
message: 'Dataset export started',
description:
`Dataset export was started for ${instanceType} #${instance?.id}. ` +
'Download will start automaticly as soon as the dataset is ready.',
className: `cvat-notification-notice-export-${instanceType}-start`,
});
},
[instance?.id, instance instanceof core.classes.Project, instanceType],
);

return (
<Modal
Expand Down Expand Up @@ -106,11 +115,7 @@ function ExportDatasetModal(): JSX.Element {
<Select placeholder='Select dataset format' className='cvat-modal-export-select'>
{dumpers
.sort((a: any, b: any) => a.name.localeCompare(b.name))
.filter(
(dumper: any): boolean =>
!(instance instanceof core.classes.Task) ||
dumper.dimension === instance?.dimension,
)
.filter((dumper: any): boolean => dumper.dimension === instance?.dimension)
.map(
(dumper: any): JSX.Element => {
const pending = (activities || []).includes(dumper.name);
Expand Down
11 changes: 8 additions & 3 deletions cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,15 @@ class ProjectWithoutTaskSerializer(serializers.ModelSerializer):
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', 'created_date', 'updated_date', 'status', 'training_project')
read_only_fields = ('created_date', 'updated_date', 'status', 'owner', 'asignee')
'bug_tracker', 'task_subsets', 'created_date', 'updated_date', 'status', 'training_project', 'dimension')
read_only_fields = ('created_date', 'updated_date', 'status', 'owner', 'asignee', 'task_subsets', 'dimension')
ordering = ['-id']


Expand All @@ -519,6 +521,7 @@ def to_representation(self, instance):
task_subsets = set(instance.tasks.values_list('subset', flat=True))
task_subsets.discard('')
response['task_subsets'] = list(task_subsets)
response['dimension'] = instance.tasks.first().dimension if instance.tasks.count() else None
return response

class ProjectSerializer(ProjectWithoutTaskSerializer):
Expand Down Expand Up @@ -580,7 +583,9 @@ def validate_labels(self, value):
return value

def to_representation(self, instance):
return serializers.ModelSerializer.to_representation(self, instance) # ignoring subsets here
response = serializers.ModelSerializer.to_representation(self, instance) # ignoring subsets here
response['dimension'] = instance.tasks.first().dimension if instance.tasks.count() else None
return response

class ExceptionSerializer(serializers.Serializer):
system = serializers.CharField(max_length=255)
Expand Down

0 comments on commit ac2790f

Please sign in to comment.