from django.core.management import BaseCommand

from experiments.models import Experiment
from spawner import scheduler
from spawner.utils.constants import ExperimentLifeCycle


class Command(BaseCommand):
    def handle(self, *args, **options):
        for experiment in Experiment.objects.filter(
                experiment_status__status__in=ExperimentLifeCycle.RUNNING_STATUS):
            scheduler.stop_experiment(experiment)

from django.core.management import BaseCommand

from experiments.models import Experiment
from spawner import scheduler
from spawner.utils.constants import ExperimentLifeCycle


class Command(BaseCommand):
    def handle(self, *args, **options):
        for experiment in Experiment.objects.filter(
                experiment_status__status__in=ExperimentLifeCycle.RUNNING_STATUS):
            scheduler.stop_experiment(experiment, update_status=True)

Update status when stopping experiments
Update status when stopping experiments

  from django.core.management import BaseCommand
  
  from experiments.models import Experiment
  from spawner import scheduler
  from spawner.utils.constants import ExperimentLifeCycle
  
  
  class Command(BaseCommand):
      def handle(self, *args, **options):
          for experiment in Experiment.objects.filter(
                  experiment_status__status__in=ExperimentLifeCycle.RUNNING_STATUS):
-             scheduler.stop_experiment(experiment)
+             scheduler.stop_experiment(experiment, update_status=True)
  
Update status when stopping experiments
## Code Before:
from django.core.management import BaseCommand

from experiments.models import Experiment
from spawner import scheduler
from spawner.utils.constants import ExperimentLifeCycle


class Command(BaseCommand):
    def handle(self, *args, **options):
        for experiment in Experiment.objects.filter(
                experiment_status__status__in=ExperimentLifeCycle.RUNNING_STATUS):
            scheduler.stop_experiment(experiment)

## Instruction:
Update status when stopping experiments
## Code After:
from django.core.management import BaseCommand

from experiments.models import Experiment
from spawner import scheduler
from spawner.utils.constants import ExperimentLifeCycle


class Command(BaseCommand):
    def handle(self, *args, **options):
        for experiment in Experiment.objects.filter(
                experiment_status__status__in=ExperimentLifeCycle.RUNNING_STATUS):
            scheduler.stop_experiment(experiment, update_status=True)
