from lungmap_client import lungmap_utils
import django

django.setup()

from analytics import models


image_sets = lungmap_utils.get_image_set_candidates()

for key, value in image_sets.items():
    print('loading imageset ', key)
    image_set = models.ImageSet.objects.get_or_create(
        image_set_name=key,
        magnification=value['magnification'],
        species=value['species'],
        development_stage=value['development_stage']
    )

    for image in value['images']:
        experiment, experiment_create = models.Experiment.objects.get_or_create(
            experiment_id=image['image_id'].split('_')[0]
        )
        imageobject = models.Image.objects.get_or_create(
            s3key=image['s3key'],
            image_name=image['image_name'],
            image_id=image['image_id'],
            x_scaling=image['x_scaling'],
            y_scaling=image['y_scaling'],
            image_set=image_set[0].id,
            experiment_id=experiment.experiment_id
        )

    for probe in value['probes']:
        probeobject, probeobject_create = models.Probe.objects.get_or_create(
            label=probe['probe_label']
        )
        imagesetprobemap = models.ImageSetProbeMap.objects.get_or_create(
            color=probe['color'],
            probe_name=probeobject,
            image_set=image_set[0].id
        )

        for exp in value['experiments']:
            experimentobject = models.Experiment.objects.get(
                experiment_id=exp
            )
            experimentprobemap = models.ExperimentProbeMap.objects.create(
                color=probe['color'],
                experiment_id=experimentobject,
                probe_name=probeobject,
            )

@@ -929,13 +929,10 @@
 t%5B0%5D
-.id
 ,%0A
+
     
@@ -1267,37 +1267,32 @@
            probe
-_name
 =probeobject,%0A  
@@ -1327,11 +1327,8 @@
 t%5B0%5D
-.id
 %0A   
@@ -1639,32 +1639,32 @@
 perimentobject,%0A
+
                 
@@ -1668,21 +1668,16 @@
    probe
-_name
 =probeob

update preload script