Ejemplo n.º 1
0
def validate_build_spec_config(config, raise_for_rest: bool = False):
    try:
        spec = BuildSpecification.read(config)
    except (MarshmallowValidationError, PolyaxonfileError,
            PolyaxonConfigurationError) as e:
        message_error = 'Received non valid build specification config. %s' % e
        if raise_for_rest:
            raise ValidationError(message_error)
        else:
            raise DjangoValidationError(message_error)

    return spec
Ejemplo n.º 2
0
    def test_get_with_environment(self):
        spec_content = """---
            version: 1

            kind: build

            environment:
              node_selector: 
                foo: bar
              tolerations:
                - key: "key"
                  operator: "Equal"
                  value: "value"
                  effect: "NoSchedule"
              affinity:
                foo: bar
              resources:
                gpu:
                  requests: 1
                  limits: 1
                tpu:
                  requests: 1
                  limits: 1

            build:
              image: my_image
        """
        spec_parsed_content = BuildSpecification.read(spec_content)

        project = ProjectFactory(user=self.auth_client.user)
        obj = self.factory_class(project=project, config=spec_parsed_content.parsed_data)
        url = '/{}/{}/{}/builds/{}/'.format(API_V1,
                                            project.user.username,
                                            project.name,
                                            obj.id)
        obj_query = queries.builds_details.get(id=obj.id)

        resp = self.auth_client.get(url)
        assert resp.status_code == status.HTTP_200_OK
        assert resp.data == self.serializer_class(obj_query).data
Ejemplo n.º 3
0
        cpu:
          requests: 1
          limits: 1    
        memory:
          requests: 100
          limits: 200

    build:
      image: my_image

    run:
      cmd: test
"""

job_spec_resources_parsed_content = JobSpecification.read(
    job_spec_resources_content)

build_spec_content = """---
    version: 1

    kind: build
    
    tags: [fixtures]

    build:
      image: my_image
      build_steps: ['step1', 'step2']
"""

build_spec_parsed_content = BuildSpecification.read(build_spec_content)