Skip to content

Commit

Permalink
#58 Add plugin jobs signals
Browse files Browse the repository at this point in the history
  • Loading branch information
mmourafiq committed Mar 6, 2018
1 parent f28fb56 commit b507ddf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions polyaxon/plugins/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
class PluginsConfig(AppConfig):
name = 'plugins'
verbose_name = 'Plugins'

def ready(self):
from plugins.signals import (
new_tensorboard_job,
new_notebook_job,
)
39 changes: 39 additions & 0 deletions polyaxon/plugins/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import logging

from django.db.models.signals import post_save
from django.dispatch import receiver

from libs.decorators import ignore_raw
from plugins.models import TensorboardJob, NotebookJob
from spawner.utils.constants import JobLifeCycle

logger = logging.getLogger('polyaxon.plugins')


@receiver(post_save, sender=TensorboardJob, dispatch_uid="tensorboard_job_saved")
@ignore_raw
def new_tensorboard_job(sender, **kwargs):
instance = kwargs['instance']
created = kwargs.get('created', False)

# Check if the experiment job
if not created:
return

instance.set_status(status=JobLifeCycle.CREATED)


@receiver(post_save, sender=NotebookJob, dispatch_uid="notebook_job_saved")
@ignore_raw
def new_notebook_job(sender, **kwargs):
instance = kwargs['instance']
created = kwargs.get('created', False)

# Check if the experiment job
if not created:
return

instance.set_status(status=JobLifeCycle.CREATED)

0 comments on commit b507ddf

Please sign in to comment.