Fix/tissue in files#99
Conversation
Convert various models' tissues from ManyToMany to a nullable ForeignKey (Experiment, Biomarker, CGDSStudy, DifferentialExpressionExperiment, UserFile) and add the corresponding Django migrations. Update admin classes to surface tissues in list_filter/list_display and remove M2M helper UI code. Add lightweight SimpleTissueSerializer and include tissues in multiple serializers' representations and fields. Adjust CGDSStudy serializer create/update logic to handle FK instead of M2M. Update DifferentialExpression API to accept and persist tissues and return tissues in the response. Also add a ChatWidget import/use in the frontend Base component.
Rename model field `tissues` to singular `tissue` in api_service, biomarkers, datasets_synchronization, differential_expression and user_files. Updated models, admin list_filters, serializers and views to use `tissue` and added corresponding Django rename migrations (api_service/migrations/0064_..., biomarkers/migrations/0024_..., datasets_synchronization/migrations/0040_..., differential_expression/migrations/0003_..., user_files/migrations/0019_...). Note: this changes API payloads/serializers (clients should use `tissue` now). Run `python manage.py migrate` to apply DB migrations.
…nce/multiomix into fix/tissueInFiles
| fields = ['id', 'username'] | ||
|
|
||
|
|
||
| class SimpleTissueSerializer(serializers.Serializer): |
There was a problem hiding this comment.
- Mover este serializer a serializers.py dentro de la app tissues
- Ya que no hay comportamiento customizado ni nada, que herede de
serializers.ModelSerializery definir los campos como se hizo en la claseExperimentSerializerDetail
| exclude = ['biomarker'] | ||
|
|
||
|
|
||
| class SimpleTissueSerializer(serializers.Serializer): |
There was a problem hiding this comment.
Usar el mismo serializer que está tissues/serializers.py. Ya que es el mismo
| model = Biomarker | ||
| fields = '__all__' | ||
|
|
||
| def to_representation(self, instance): |
There was a problem hiding this comment.
No hace fatla esto, poner tissue = SimpleTissueSerializer(read_only=True), como se hace en ExperimentSerializer y borrar este to_representation. Si es null en la DB el serializer de Django REST Framework ya sabe que tiene que devolver None
| model = Biomarker | ||
| exclude = ['user'] | ||
|
|
||
| def to_representation(self, instance): |
| @property | ||
| def file_type(self) -> FileType: | ||
| if hasattr(self, 'mrna_dataset'): | ||
| study = self.study |
There was a problem hiding this comment.
Nono, deshacer todos los cambios hecho en file_type y __get_reverse_study. Estaban andando bien. Acá explotaría en caso de que no exista un relacionado. Si se necesita otra cosa, armar otra función que haga lo requerido
| props.newCGDSStudy.clinical_patient_dataset === null && | ||
| props.newCGDSStudy.clinical_sample_dataset === null | ||
| props.newCGDSStudy.clinical_sample_dataset === null && | ||
| tissues.length === 0 |
There was a problem hiding this comment.
Tissues no debería ser obligatorio, sacar esta última condición
| selection | ||
| clearable | ||
| name='tissue' | ||
| value={typeof tissues[0] === 'number' |
There was a problem hiding this comment.
Por qué podrían venir un ID o un objeto? En caso de que esto sea correcto y no se pueda estandarizar a un solo tipo, agregar un comentario arriba explicando por qué es así (en inglés!)
| const datasetRowDescriptionInPlural = getFileRowDescriptionInPlural(datasetObj.file_type) | ||
|
|
||
| const tissue = normalizeTissues(datasetObj.tissue)[0] | ||
| const tissueName = typeof tissue === 'number' ? undefined : tissue?.name |
There was a problem hiding this comment.
Me preocupa que siempre esté apareciendo este chequeo, desde el backend no siempre se retorna un objeto? Estandarizar el tipo y sacar estos chequeos
| instance.institutions.set(validated_data.get('institutions', [])) | ||
| instance.is_cpg_site_id = validated_data.get('is_cpg_site_id') | ||
| instance.platform = validated_data.get('platform') | ||
| if 'tag' in validated_data: |
There was a problem hiding this comment.
Dejar el código anterior que era más limpio. Si no está en validated_data está perfecto que se setee en None, que es el valor por defecto que se retorna en el .get()
There was a problem hiding this comment.
Eliminar este archivo, se pusheó por equivocación
No description provided.