class WorkflowJobSerializer(serializers.HyperlinkedModelSerializer): job_settings = TransparentField(required=False) input_ports = InputPortSerializer(many=True, read_only=True) output_ports = OutputPortSerializer(many=True, read_only=True) class Meta: model = WorkflowJob read_only_fields = ( "created", "updated", "input_ports", "output_ports", "group", ) # group is read only. To set group, use workflowjobgroup view. fields = ( "url", "uuid", "workflow", "input_ports", "output_ports", "job_name", "job_description", "job", "job_settings", "name", "group", "created", "updated", )
class WorkflowJobGroupCoordinateSetSerializer( serializers.HyperlinkedModelSerializer): data = TransparentField(required=False) class Meta: model = WorkflowJobGroupCoordinateSet read_only_fields = ('created', 'updated') fields = ("url", "uuid", "workflow_job_group", "data", "user_agent", "created", "updated")
class WorkflowRunSerializer(serializers.HyperlinkedModelSerializer): uuid = serializers.CharField(read_only=True) origin_resources = TransparentField(read_only=True) creator = serializers.SlugRelatedField(slug_field="username", read_only=True) class Meta: model = WorkflowRun read_only_fields = ("created", "updated", "creator", "project") extra_kwargs = {"workflow": {"allow_null": False, "required": True}}
class WorkflowRunByPageSerializer(serializers.HyperlinkedModelSerializer): uuid = serializers.CharField(read_only=True) origin_resources = TransparentField(read_only=True) creator = serializers.SlugRelatedField(slug_field="username", read_only=True) class Meta: model = WorkflowRun read_only_fields = ("created", "updated", 'creator', 'project') extra_kwargs = {'workflow': {'allow_null': False, 'required': True}}
class JobSerializer(serializers.HyperlinkedModelSerializer): settings = TransparentField(required=False) input_port_types = InputPortTypeSerializer(many=True) output_port_types = OutputPortTypeSerializer(many=True) class Meta: model = Job fields = ("url", "uuid", "name", "settings", "description", "input_port_types", "output_port_types", "category", 'enabled', 'interactive')
class RunJobSerializer(serializers.HyperlinkedModelSerializer): job = serializers.HyperlinkedRelatedField( view_name="job-detail", read_only=True, lookup_field="uuid", lookup_url_kwarg="pk", ) job_settings = TransparentField(required=False) project = serializers.HyperlinkedRelatedField( view_name="project-detail", read_only=True, lookup_field="uuid", lookup_url_kwarg="pk", ) interactive_acquire = serializers.SerializerMethodField() def get_interactive_acquire(self, obj): if obj.status is task_status.WAITING_FOR_INPUT: relative_url = reverse("interactive-acquire", kwargs={"run_job_uuid": obj.pk}) request = self.context["request"] return request.build_absolute_uri(relative_url) else: return None class Meta: model = RunJob fields = ( "url", "uuid", "job", "job_name", "workflow_run", "project", "workflow_job_uuid", "resource_uuid", "inputs", "outputs", "job_settings", "status", "created", "updated", "error_summary", "error_details", "working_user", "working_user_expiry", "interactive_acquire", )
class RunJobSerializer(serializers.HyperlinkedModelSerializer): job = serializers.HyperlinkedRelatedField(view_name='job-detail', read_only=True, lookup_field="uuid", lookup_url_kwarg="pk") job_settings = TransparentField(required=False) project = serializers.HyperlinkedRelatedField(view_name='project-detail', read_only=True, lookup_field="uuid", lookup_url_kwarg="pk") interactive_acquire = serializers.SerializerMethodField() def get_interactive_acquire(self, obj): if obj.status is task_status.WAITING_FOR_INPUT: relative_url = reverse('interactive-acquire', kwargs={'run_job_uuid': obj.pk}) request = self.context['request'] return request.build_absolute_uri(relative_url) else: return None class Meta: model = RunJob fields = ('url', 'uuid', 'job', 'job_name', 'workflow_run', 'project', 'workflow_job_uuid', 'resource_uuid', 'inputs', 'outputs', 'job_settings', 'status', 'created', 'updated', 'error_summary', 'error_details', 'working_user', 'working_user_expiry', 'interactive_acquire' )