download
raw
1.95 kB
from rest_framework import serializers
from .models import SimulationMethod, SimulationRun
class SimulationMethodSerializer(serializers.ModelSerializer):
class Meta:
model = SimulationMethod
fields = [
'id', 'name', 'slug', 'description', 'theory',
'parameters_schema', 'default_parameters',
'is_active', 'created_at', 'updated_at'
]
read_only_fields = ['id', 'created_at', 'updated_at']
class SimulationRunSerializer(serializers.ModelSerializer):
method_name = serializers.CharField(source='method.name', read_only=True)
method_slug = serializers.CharField(source='method.slug', read_only=True)
class Meta:
model = SimulationRun
fields = [
'id', 'method', 'method_name', 'method_slug',
'name', 'parameters', 'status', 'progress',
'logs', 'result_data', 'error_message',
'input_file', 'output_file', 'created_at',
'started_at', 'completed_at'
]
read_only_fields = [
'id', 'status', 'progress', 'logs',
'result_data', 'error_message', 'output_file',
'created_at', 'started_at', 'completed_at'
]
class SimulationRunCreateSerializer(serializers.ModelSerializer):
class Meta:
model = SimulationRun
fields = ['method', 'name', 'parameters', 'input_file']
def validate_parameters(self, value):
method = self.initial_data.get('method')
if method:
try:
sim_method = SimulationMethod.objects.get(pk=method)
schema = sim_method.parameters_schema
except SimulationMethod.DoesNotExist:
pass
return value
class SimulationRunDetailSerializer(serializers.ModelSerializer):
method = SimulationMethodSerializer(read_only=True)
class Meta:
model = SimulationRun
fields = '__all__'

Xet Storage Details

Size:
1.95 kB
·
Xet hash:
6e5db70de826bdc978a226814df4f26b59cacbc3adfeeb907e26a8cc755d11f0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.