from __future__ import unicode_literals import logging from django.contrib.staticfiles.storage import staticfiles_storage from rest_framework import serializers from rest_framework.reverse import reverse as reverse from waves.wcore.api.share import DynamicFieldsModelSerializer from waves.wcore.api.v1.serializers.inputs import InputSerializer from waves.wcore.models import get_service_model, get_submission_model from waves.wcore.models.services import SubmissionOutput as ServiceOutput from waves.wcore.settings import waves_settings Service = get_service_model() ServiceSubmission = get_submission_model() logger = logging.getLogger(__name__) class InputFormatField(serializers.Field): def to_representation(self, instance): return ', '.join(instance.splitlines()) if instance is not None else '' def to_internal_value(self, data): return data.replace(', ', '\n') if data else '' class OutputSerializer(DynamicFieldsModelSerializer): """ Serialize an service expected output """ class Meta:
""" WAVES API services related serializers""" from __future__ import unicode_literals import collections from rest_framework import serializers from rest_framework.reverse import reverse from waves.wcore.api.share import DynamicFieldsModelSerializer from waves.wcore.api.v2.serializers.inputs import InputSerializer as DetailInputSerializer from waves.wcore.models import get_service_model, get_submission_model from waves.wcore.models.services import SubmissionOutput Service = get_service_model() Submission = get_submission_model() __all__ = ['OutputSerializer', 'ServiceSerializer', 'ServiceSubmissionSerializer'] class OutputSerializer(DynamicFieldsModelSerializer): """ Serialize an service expected output """ class Meta: model = SubmissionOutput fields = ('name', 'file_pattern') def to_representation(self, instance): """ Representation for a output """ to_repr = {} outputs = instance.all() if outputs:
def running_submissions(self): from waves.wcore.models import get_submission_model return get_submission_model().objects.filter(runner=self)