Exemple #1
0
    def _handle_job_post_run(cls, event: 'Event') -> None:
        instance = event.instance
        if not instance or not instance.has_specification:
            return

        workers.send(SchedulerCeleryTasks.JOBS_STOP,
                     kwargs={
                         'project_name': instance.project.unique_name,
                         'project_uuid': instance.project.uuid.hex,
                         'job_name': instance.unique_name,
                         'job_uuid': instance.uuid.hex,
                         'update_status': False,
                         'collect_logs': True,
                         'is_managed': instance.is_managed,
                     },
                     countdown=RedisTTL.get_for_job(job_id=instance.id))
Exemple #2
0
    def _handle_build_job_post_run(cls, event: 'Event') -> None:
        instance = event.instance
        if not instance or not instance.has_specification:
            return

        celery_app.send_task(
            SchedulerCeleryTasks.BUILD_JOBS_STOP,
            kwargs={
                'project_name': instance.project.unique_name,
                'project_uuid': instance.project.uuid.hex,
                'build_job_name': instance.unique_name,
                'build_job_uuid': instance.uuid.hex,
                'update_status': False,
                'collect_logs': True,
            },
            countdown=RedisTTL.get_for_build(build_id=instance.id))
Exemple #3
0
    def _handle_experiment_post_run(cls, event: 'Event') -> None:
        instance = event.instance
        if not instance or not instance.has_specification or not instance.jobs.count() > 0:
            return

        # Schedule stop for this experiment because other jobs may be still running
        group = instance.experiment_group
        celery_app.send_task(
            SchedulerCeleryTasks.EXPERIMENTS_STOP,
            kwargs={
                'project_name': instance.project.unique_name,
                'project_uuid': instance.project.uuid.hex,
                'experiment_name': instance.unique_name,
                'experiment_uuid': instance.uuid.hex,
                'experiment_group_name': group.unique_name if group else None,
                'experiment_group_uuid': group.uuid.hex if group else None,
                'specification': instance.config,
                'update_status': False,
                'collect_logs': True,
            },
            countdown=RedisTTL.get_for_experiment(experiment_id=instance.id))
    def test_validate_ttl(self):
        with self.assertRaises(ValueError):
            RedisTTL.validate_ttl(None)

        with self.assertRaises(ValueError):
            RedisTTL.validate_ttl('sdf')
 def test_set_for_build(self):
     RedisTTL.set_for_build(build_id=1, value=10)
     assert RedisTTL.get_for_build(build_id=1) == 10
     assert RedisTTL.get_for_build(
         build_id=2) == conf.get('GLOBAL_COUNTDOWN')
     assert RedisTTL(build=10).get_value() is None
    def test_redis_ttl_build(self):
        ttl = RedisTTL(build=1)
        assert ttl.redis_key == RedisTTL.KEY_BUILD.format(1)

        ttl.set_value(10)
        assert ttl.get_value() == 10

        ttl.set_value(13)
        assert ttl.get_value() == 13

        ttl.clear()

        assert ttl.get_value() is None
    def test_redis_ttl_job(self):
        ttl = RedisTTL(job=1)
        assert ttl.redis_key == RedisTTL.KEY_JOB.format(1)

        ttl.set_value(10)
        assert ttl.get_value() == 10

        ttl.set_value(13)
        assert ttl.get_value() == 13

        ttl.clear()

        assert ttl.get_value() is None
 def test_set_for_experiment(self):
     RedisTTL.set_for_experiment(experiment_id=1, value=10)
     assert RedisTTL.get_for_experiment(experiment_id=1) == 10
     assert RedisTTL.get_for_experiment(
         experiment_id=2) == conf.get('GLOBAL_COUNTDOWN')
     assert RedisTTL(experiment=10).get_value() is None
    def test_redis_ttl_experiment(self):
        ttl = RedisTTL(experiment=1)
        assert ttl.redis_key == RedisTTL.KEY_EXPERIMENT.format(1)

        ttl.set_value(10)
        assert ttl.get_value() == 10

        ttl.set_value(13)
        assert ttl.get_value() == 13

        ttl.clear()

        assert ttl.get_value() is None
Exemple #10
0
 def test_set_for_job(self):
     RedisTTL.set_for_job(job_id=1, value=10)
     assert RedisTTL.get_for_job(job_id=1) == 10
     assert RedisTTL.get_for_job(
         job_id=2) == conf.get(SCHEDULER_GLOBAL_COUNTDOWN)
     assert RedisTTL(job=10).get_value() is None
Exemple #11
0
 def test_set_for_build(self):
     RedisTTL.set_for_build(build_id=1, value=10)
     assert RedisTTL.get_for_build(build_id=1) == 10
     assert RedisTTL.get_for_build(build_id=2) == 2
     assert RedisTTL(build=10).get_value() is None
Exemple #12
0
 def test_set_for_job(self):
     RedisTTL.set_for_job(job_id=1, value=10)
     assert RedisTTL.get_for_job(job_id=1) == 10
     assert RedisTTL.get_for_job(job_id=2) == 2
     assert RedisTTL(job=10).get_value() is None
Exemple #13
0
 def test_set_for_experiment(self):
     RedisTTL.set_for_experiment(experiment_id=1, value=10)
     assert RedisTTL.get_for_experiment(experiment_id=1) == 10
     assert RedisTTL.get_for_experiment(experiment_id=2) == 2
     assert RedisTTL(experiment=10).get_value() is None