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
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 image: my_image """ spec_parsed_content = BuildSpecification.read(spec_content) project = ProjectFactory(user=self.auth_client.user) obj = self.factory_class(project=project, content=spec_parsed_content.raw_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
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) job_spec_resources_parsed_content.parse_data() build_spec_content = """--- version: 1 kind: build tags: [fixtures] image: my_image build_steps: ['step1', 'step2'] """ build_spec_parsed_content = BuildSpecification.read(build_spec_content) build_spec_parsed_content.parse_data()