<commit_before>from django.shortcuts import render, get_object_or_404
from rest_framework import viewsets, generics
from grabbers.serializers import SequenceSerializer, MapperSerializer
from grabbers.models import Sequence, Mapper
from rest_framework.response import Response
from rest_framework import status


# Create your views here.

class SequenceViewSet(viewsets.ModelViewSet):
    """
    endpoint that allows SEQUENCE to be viewed or edited.
    """
    queryset = Sequence.objects.all().order_by('-id')
    serializer_class = SequenceSerializer
    lookup_field='name'

    def retrieve(self, request, name=None):
        """
        """
        seq = get_object_or_404(Sequence, name=name)
        serializer = SequenceSerializer(seq)
        return Response(serializer.data)

    def create(self, request):
        '''
        '''
        seqse=SequenceSerializer(data=request.data)
        if seqse.is_valid():
            seqse.save()
            return Response(seqse.data, status=status.HTTP_201_CREATED)
        else:
            return Response(
                seqse.errors, status=status.HTTP_400_BAD_REQUEST)


class MapperViewSet(viewsets.ModelViewSet):
    """
    endpoint that allows SEQUENCE to be viewed or edited.
    """
    queryset = Mapper.objects.all().order_by('id')
    serializer_class = MapperSerializer
    lookup_field='name'

    def retrieve(self, request, name=None):
        """
        """
        mapis = get_object_or_404(Mapper, name=name)
        serializer = MapperSerializer(mapis)
        return Response(serializer.data)<commit_msg>First steps for taskConfig post/save<commit_after>from django.shortcuts import render, get_object_or_404
from rest_framework import viewsets, generics
from grabbers.serializers import SequenceSerializer, MapperSerializer
from grabbers.models import Sequence, Mapper
from rest_framework.response import Response
from rest_framework import status

# Create your views here.

class SequenceViewSet(viewsets.ModelViewSet):
    """
    endpoint that allows SEQUENCE to be viewed or edited.
    """
    queryset = Sequence.objects.all().order_by('-id')
    serializer_class = SequenceSerializer
    lookup_field='name'

    def retrieve(self, request, name=None):
        """
        """
        seq = get_object_or_404(Sequence, name=name)
        serializer = SequenceSerializer(seq)
        return Response(serializer.data)

    def create(self, request):
        '''
        '''
        datis=request.data
        seqse=SequenceSerializer(data=datis)
        if seqse.is_valid():
            seqse.save()
            return Response(seqse.data, status=status.HTTP_201_CREATED)
        else:
            return Response(
                seqse.errors, status=status.HTTP_400_BAD_REQUEST)


class MapperViewSet(viewsets.ModelViewSet):
    """
    endpoint that allows SEQUENCE to be viewed or edited.
    """
    queryset = Mapper.objects.all().order_by('id')
    serializer_class = MapperSerializer
    lookup_field='name'

    def retrieve(self, request, name=None):
        """
        """
        mapis = get_object_or_404(Mapper, name=name)
        serializer = MapperSerializer(mapis)
        return Response(serializer.data)
{'fraction_non_alphanumeric': 0.09096573208722741, 'fraction_numerical': 0.009345794392523364, 'mean_word_length': 3.10613810741688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2709885', 'n_tokens_mistral': 934, 'n_tokens_neox': 883, 'n_words': 206}