MCPcopy
hub / github.com/WebODM/WebODM / TaskSerializer

Class TaskSerializer

app/api/tasks.py:54–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 return obj.id
53
54class TaskSerializer(serializers.ModelSerializer):
55 project = serializers.PrimaryKeyRelatedField(queryset=models.Project.objects.all())
56 processing_node = serializers.PrimaryKeyRelatedField(queryset=ProcessingNode.objects.all())
57 processing_node_name = serializers.SerializerMethodField()
58 can_rerun_from = serializers.SerializerMethodField()
59 statistics = serializers.SerializerMethodField()
60 extent = serializers.SerializerMethodField()
61 media = serializers.SerializerMethodField()
62 tags = TagsField(required=False)
63 crop = PolygonGeometryField(required=False, allow_null=True)
64 srs = serializers.SerializerMethodField()
65
66 def get_processing_node_name(self, obj):
67 if obj.processing_node is not None:
68 return str(obj.processing_node)
69 else:
70 return None
71
72 def get_statistics(self, obj):
73 return obj.get_statistics()
74
75 def get_can_rerun_from(self, obj):
76 """
77 When a task has been associated with a processing node
78 and if the processing node supports the "rerun-from" parameter
79 this method returns the valid values for "rerun-from" for that particular
80 processing node.
81
82 TODO: this could be improved by returning an empty array if a task was created
83 and purged by the processing node (which would require knowing how long a task is being kept
84 see https://github.com/OpenDroneMap/NodeODM/issues/32
85 :return: array of valid rerun-from parameters
86 """
87 if obj.processing_node is not None:
88 rerun_from_option = list(filter(lambda d: 'name' in d and d['name'] == 'rerun-from', obj.processing_node.available_options))
89 if len(rerun_from_option) > 0 and 'domain' in rerun_from_option[0]:
90 return rerun_from_option[0]['domain']
91
92 return []
93
94 def get_extent(self, obj):
95 return obj.get_extent()
96
97 def get_srs(self, obj):
98 return get_srs_name_units_from_epsg_or_wkt(obj.epsg, obj.wkt)
99
100 def get_media(self, obj):
101 return len(obj.media) if obj.media else 0
102
103 class Meta:
104 model = models.Task
105 exclude = ('orthophoto_extent', 'dsm_extent', 'dtm_extent', )
106 read_only_fields = ('processing_time', 'status', 'last_error', 'created_at', 'pending_action', 'available_assets', 'size', )
107
108
109def check_processing_node_perms(request):

Callers 11

task_jsonFunction · 0.90
test_mocksMethod · 0.90
listMethod · 0.85
retrieveMethod · 0.85
commitMethod · 0.85
uploadMethod · 0.85
duplicateMethod · 0.85
createMethod · 0.85
updateMethod · 0.85
postMethod · 0.85
postMethod · 0.85

Calls 2

TagsFieldClass · 0.90

Tested by 1

test_mocksMethod · 0.72