from __future__ import absolute_import, division, print_function

from django.core.exceptions import ValidationError
from polyaxon_schemas.exceptions import PolyaxonfileError, PolyaxonConfigurationError
from polyaxon_schemas.polyaxonfile.specification import GroupSpecification


def validate_spec_content(content):
    try:
        spec = GroupSpecification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid specification content.')

    if spec.is_local:
        raise ValidationError('Received specification content for a local environment run.')

    return spec

from __future__ import absolute_import, division, print_function

from django.core.exceptions import ValidationError
from polyaxon_schemas.exceptions import PolyaxonfileError, PolyaxonConfigurationError
from polyaxon_schemas.polyaxonfile.specification import GroupSpecification, Specification


def validate_run_type(spec):
    if spec.is_local:
        raise ValidationError('Received specification content for a local environment run.')


def validate_spec_content(content):
    try:
        spec = GroupSpecification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid specification content.')

    validate_run_type(spec)

    return spec


def validate_tensorboard_spec_content(content):
    try:
        spec = Specification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid tensorboard specification content.')

    validate_run_type(spec)

    return spec

Add tensorboard serializer * Add validation * Add tests
Add tensorboard serializer
 * Add validation
 * Add tests

  from __future__ import absolute_import, division, print_function
  
  from django.core.exceptions import ValidationError
  from polyaxon_schemas.exceptions import PolyaxonfileError, PolyaxonConfigurationError
- from polyaxon_schemas.polyaxonfile.specification import GroupSpecification
+ from polyaxon_schemas.polyaxonfile.specification import GroupSpecification, Specification
+ 
+ 
+ def validate_run_type(spec):
+     if spec.is_local:
+         raise ValidationError('Received specification content for a local environment run.')
  
  
  def validate_spec_content(content):
      try:
          spec = GroupSpecification.read(content)
      except (PolyaxonfileError, PolyaxonConfigurationError):
          raise ValidationError('Received non valid specification content.')
  
+     validate_run_type(spec)
-     if spec.is_local:
-         raise ValidationError('Received specification content for a local environment run.')
  
      return spec
  
+ 
+ def validate_tensorboard_spec_content(content):
+     try:
+         spec = Specification.read(content)
+     except (PolyaxonfileError, PolyaxonConfigurationError):
+         raise ValidationError('Received non valid tensorboard specification content.')
+ 
+     validate_run_type(spec)
+ 
+     return spec
+ 
Add tensorboard serializer * Add validation * Add tests
## Code Before:
from __future__ import absolute_import, division, print_function

from django.core.exceptions import ValidationError
from polyaxon_schemas.exceptions import PolyaxonfileError, PolyaxonConfigurationError
from polyaxon_schemas.polyaxonfile.specification import GroupSpecification


def validate_spec_content(content):
    try:
        spec = GroupSpecification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid specification content.')

    if spec.is_local:
        raise ValidationError('Received specification content for a local environment run.')

    return spec

## Instruction:
Add tensorboard serializer * Add validation * Add tests
## Code After:
from __future__ import absolute_import, division, print_function

from django.core.exceptions import ValidationError
from polyaxon_schemas.exceptions import PolyaxonfileError, PolyaxonConfigurationError
from polyaxon_schemas.polyaxonfile.specification import GroupSpecification, Specification


def validate_run_type(spec):
    if spec.is_local:
        raise ValidationError('Received specification content for a local environment run.')


def validate_spec_content(content):
    try:
        spec = GroupSpecification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid specification content.')

    validate_run_type(spec)

    return spec


def validate_tensorboard_spec_content(content):
    try:
        spec = Specification.read(content)
    except (PolyaxonfileError, PolyaxonConfigurationError):
        raise ValidationError('Received non valid tensorboard specification content.')

    validate_run_type(spec)

    return spec
