Skip to content

Remove unintended changes to local exceedance value tutorial

b259cb7
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

Add generalized Pareto fit to frequency curve tails #1288

Remove unintended changes to local exceedance value tutorial
b259cb7
Select commit
Loading
Failed to load commit list.
GitHub Actions / Petals / Unit Test Results (3.11) failed May 6, 2026 in 0s

1 fail, 3 skipped, 291 pass in 5m 54s

295 tests  ±0   291 ✅ ±0   5m 54s ⏱️ +5s
  1 suites ±0     3 💤 ±0 
  1 files   ±0     1 ❌ ±0 

Results for commit b259cb7. ± Comparison against earlier commit bfd2849.

Annotations

Check warning on line 0 in climada_petals.entity.exposures.test.test_osm_dataloader.TestOSMApiQuery

See this annotation in the file changed.

@github-actions github-actions / Petals / Unit Test Results (3.11)

test_get_data_overpass (climada_petals.entity.exposures.test.test_osm_dataloader.TestOSMApiQuery) failed

climada_petals/tests_xml/tests.xml [took 2m 8s]
Raw output
Exception: The Overpass API is consistently unavailable
self = <climada_petals.entity.exposures.osm_dataloader.OSMApiQuery object at 0x7ff7a6523010>
query_clause = '[out:json][timeout:180];(nwr["building"](47.36826, 8.5327506, 47.376877, 8.5486078);(._;>;););out;'
read_chunk_size = 100000, end_of_patience = 127

    def _insistent_osm_api_query(self, query_clause, read_chunk_size=100000,
                                 end_of_patience=127):
        """Runs a single Overpass API query through overpy.Overpass.query.
        In case of failure it tries again after an ever increasing waiting period.
        If the waiting period surpasses a given limit an exception is raised.
    
        Parameters:
            query_clause (str): the query
            read_chunk_size (int): paramter passed over to overpy.Overpass.query
            end_of_patience (int): upper limit for the next waiting period to proceed.
    
        Returns:
            result as returned by overpy.Overpass.query
        """
        api = overpy.Overpass(read_chunk_size=read_chunk_size)
        waiting_period = 1
        while True:
            try:
>               return api.query(query_clause)
                       ^^^^^^^^^^^^^^^^^^^^^^^

climada_petals/entity/exposures/osm_dataloader.py:102: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <overpy.Overpass object at 0x7ff7a6522590>
query = b'[out:json][timeout:180];(nwr["building"](47.36826, 8.5327506, 47.376877, 8.5486078);(._;>;););out;'

    def query(self, query: Union[bytes, str]) -> "Result":
        """
        Query the Overpass API
    
        :param query: The query string in Overpass QL
        :return: The parsed result
        """
        if not isinstance(query, bytes):
            query = query.encode("utf-8")
    
        retry_num: int = 0
        retry_exceptions: List[exception.OverPyException] = []
        do_retry: bool = True if self.max_retry_count > 0 else False
        while retry_num <= self.max_retry_count:
            if retry_num > 0:
                time.sleep(self.retry_timeout)
            retry_num += 1
            try:
                f = urlopen(self.url, query)
            except HTTPError as e:
                f = e
    
            response = f.read(self.read_chunk_size)
            while True:
                data = f.read(self.read_chunk_size)
                if len(data) == 0:
                    break
                response = response + data
            f.close()
    
            current_exception: exception.OverPyException
            if f.code == 200:
                content_type = f.getheader("Content-Type")
    
                if content_type == "application/json":
                    return self.parse_json(response)
    
                if content_type == "application/osm3s+xml":
                    return self.parse_xml(response)
    
                current_exception = exception.OverpassUnknownContentType(content_type)
                if not do_retry:
                    raise current_exception
                retry_exceptions.append(current_exception)
                continue
    
            if f.code == 400:
                msgs: List[str] = []
                for msg_raw in self._regex_extract_error_msg.finditer(response):
                    msg_clean_bytes = self._regex_remove_tag.sub(b"", msg_raw.group("msg"))
                    try:
                        msg = msg_clean_bytes.decode("utf-8")
                    except UnicodeDecodeError:
                        msg = repr(msg_clean_bytes)
                    msgs.append(msg)
    
                current_exception = exception.OverpassBadRequest(
                    query,
                    msgs=msgs
                )
                if not do_retry:
                    raise current_exception
                retry_exceptions.append(current_exception)
                continue
    
            if f.code == 429:
                current_exception = exception.OverpassTooManyRequests()
                if not do_retry:
                    raise current_exception
                retry_exceptions.append(current_exception)
                continue
    
            if f.code == 504:
                current_exception = exception.OverpassGatewayTimeout()
                if not do_retry:
                    raise current_exception
                retry_exceptions.append(current_exception)
                continue
    
            current_exception = exception.OverpassUnknownHTTPStatusCode(f.code)
            if not do_retry:
>               raise current_exception
E               overpy.exception.OverpassUnknownHTTPStatusCode: Unknown/Unhandled status code: 406

../../../../micromamba/envs/climada_env_3.11/lib/python3.11/site-packages/overpy/__init__.py:195: OverpassUnknownHTTPStatusCode

During handling of the above exception, another exception occurred:

self = <climada_petals.entity.exposures.test.test_osm_dataloader.TestOSMApiQuery testMethod=test_get_data_overpass>

    def test_get_data_overpass(self):
        """test methods of OSMApiQuery"""
    
        area_bbox = (8.5327506, 47.368260, 8.5486078, 47.376877)
        area_poly = shapely.geometry.Polygon(
            [(8.5327506, 47.368260),
             (8.5486078, 47.376877),
             (8.5486078, 47.39)])
        condition_building = '["building"]'
        condition_church = '["amenity"="place_of_worship"]'
        gdf1 = osm_dl.OSMApiQuery.from_bounding_box(
>           area_bbox, condition_building).get_data_overpass()
                                           ^^^^^^^^^^^^^^^^^^^

climada_petals/entity/exposures/test/test_osm_dataloader.py:123: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada_petals/entity/exposures/osm_dataloader.py:368: in get_data_overpass
    result = self._insistent_osm_api_query(query_clause)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <climada_petals.entity.exposures.osm_dataloader.OSMApiQuery object at 0x7ff7a6523010>
query_clause = '[out:json][timeout:180];(nwr["building"](47.36826, 8.5327506, 47.376877, 8.5486078);(._;>;););out;'
read_chunk_size = 100000, end_of_patience = 127

    def _insistent_osm_api_query(self, query_clause, read_chunk_size=100000,
                                 end_of_patience=127):
        """Runs a single Overpass API query through overpy.Overpass.query.
        In case of failure it tries again after an ever increasing waiting period.
        If the waiting period surpasses a given limit an exception is raised.
    
        Parameters:
            query_clause (str): the query
            read_chunk_size (int): paramter passed over to overpy.Overpass.query
            end_of_patience (int): upper limit for the next waiting period to proceed.
    
        Returns:
            result as returned by overpy.Overpass.query
        """
        api = overpy.Overpass(read_chunk_size=read_chunk_size)
        waiting_period = 1
        while True:
            try:
                return api.query(query_clause)
            except overpy.exception.OverpassTooManyRequests:
                if waiting_period < end_of_patience:
                    LOGGER.warning("""Too many Overpass API requests -
                                   trying again in {waiting_period} seconds """)
                else:
                    raise Exception("Overpass API is consistently unavailable")
            except Exception as exc:
                if waiting_period < end_of_patience:
                    LOGGER.warning(f"""{exc}
                                   Trying again in {waiting_period} seconds""")
                else:
>                   raise Exception(
                        "The Overpass API is consistently unavailable")
E                   Exception: The Overpass API is consistently unavailable

climada_petals/entity/exposures/osm_dataloader.py:114: Exception