def test_validate_process_graph_remote(self):
     """ Validate a process graph using remote specified processes and collections. """
     # TODO: vito processes are taken at the moment for validation, change this in the future to GEE
     _, valid = validate_process_graph(
         self.max_ndvi_pg_filepath,
         "https://earthengine.openeo.org/v1.0/collections",
         processes_src="https://openeo.vito.be/openeo/1.0/processes")
     assert valid
    def test_validate_process_graph_local(self):
        """ Validate a process graph using processes defined on a backend. """

        collections_url = "https://earthengine.openeo.org/v1.0/collections"

        _, valid = validate_process_graph(self.max_ndvi_pg_filepath,
                                          collections_url)
        assert valid
 def test_validate_process_graph_remote(self):
     """ Validate a process graph using remote specified processes and collections. """
     pg_filepath = os.path.join(self.pg_dirpath, "s2_max_ndvi.json")
     valid, _ = validate_process_graph(
         pg_filepath,
         "https://earthengine.openeo.org/v1.0/collections",
         processes_src="https://openeo.vito.be/openeo/1.0/processes")
     assert valid
    def test_validate_process_graph_local(self):
        """ Validate a process graph using processes defined on a backend. """

        collections_url = "https://earthengine.openeo.org/v1.0/collections"
        pg_filepath = os.path.join(self.pg_dirpath, "s2_max_ndvi.json")

        valid, _ = validate_process_graph(pg_filepath, collections_url)

        assert valid
Esempio n. 5
0
    def validate(self, user: Dict[str, Any], **process: dict) -> dict:
        """Validate the provided process graph.

        Args:
            user: The user object.
            process: The process graph to validated.

        Returns:
            A dictionary including the status of the request and validation errors or a serialized service exception.
        """
        # TODO: RESPONSE HEADERS -> OpenEO-Costs
        try:
            # Get all processes
            process_response = self.get_all_predefined()
            if process_response["status"] == "error":
                return process_response
            processes = process_response["data"]["processes"]

            # Get all collections (full metadata)
            data_response = self.data_service.get_all_products()
            if data_response["status"] == "error":
                return data_response
            collections_full_md = []
            for col in data_response["data"]["collections"]:
                data_response = self.data_service.get_product_detail(
                    collection_id=col['id'])
                if data_response["status"] == "error":
                    return data_response
                collections_full_md.append(data_response['data'])
            try:
                _ = validate_process_graph(process,
                                           processes_src=processes,
                                           collections_src=collections_full_md)
                output_errors: list = []
            except ValidationError as exp:
                output_errors = [{'code': 400, 'message': str(exp)}]

            return {
                "status": "success",
                "code": 200,
                "data": {
                    'errors': output_errors
                }
            }
        except ValidationError as exp:
            return ServiceException(
                ProcessesService.name,
                400,
                user["id"],
                str(exp),
                internal=False,
                links=["#tag/EO-Data-Discovery/paths/~1process_graph/post"
                       ]).to_dict()
        except Exception as exp:
            return ServiceException(ProcessesService.name, 500, user["id"],
                                    str(exp)).to_dict()
    def test_validate_missing_bands(self):
        """ Validate a process graph, which does not have any bands information stored. """

        pg_filepath = os.path.join(self.pg_dirpath, "s2_missing_bands.json")
        valid, _ = validate_process_graph(
            pg_filepath,
            "https://earthengine.openeo.org/v1.0/collections",
            processes_src="https://openeo.vito.be/openeo/1.0/processes")

        assert valid