<commit_before>"""
Serializers
===========

Turn our models into objects that are consumed by the api routes.
"""

from rest_framework import serializers

from dtrove.models import Cluster, Instance, Datastore


class DatastoreSerializer(serializers.HyperlinkedModelSerializer):
    name = serializers.Field(source='name')

    class Meta:
        model = Datastore
        fields = ['id', 'name', 'version', 'url']


class ClusterSerializer(serializers.ModelSerializer):
    datastore = DatastoreSerializer()

    class Meta:
        model = Cluster
        fields = ['id', 'name', 'size', 'datastore', 'created']<commit_msg>Adding a write only field for adding clusters<commit_after>"""
Serializers
===========

Turn our models into objects that are consumed by the api routes.
"""

from rest_framework import serializers

from dtrove.models import Cluster, Instance, Datastore


class DatastoreSerializer(serializers.HyperlinkedModelSerializer):
    name = serializers.Field(source='name')

    class Meta:
        model = Datastore
        fields = ['id', 'name', 'version', 'url']


class ClusterSerializer(serializers.ModelSerializer):
    datastore = DatastoreSerializer(read_only=True)
    datastore_id = serializers.PrimaryKeyRelatedField(source='datastore',
                                                      write_only=True)

    class Meta:
        model = Cluster
        fields = ['id', 'name', 'size', 'datastore', 'datastore_id', 'created']
{'fraction_non_alphanumeric': 0.11446196024674435, 'fraction_numerical': 0.0, 'mean_word_length': 3.6794871794871793, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7626962', 'n_tokens_mistral': 404, 'n_tokens_neox': 383, 'n_words': 112}