Skip to content

Commit

Permalink
Merge pull request #321 from asfadmin/chore-better-search-log-level
Browse files Browse the repository at this point in the history
change log level on search timing messages
  • Loading branch information
SpicyGarlicAlbacoreRoll authored Jan 13, 2025
2 parents bcebd43 + 7e7dace commit 147da5e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-->
------
## [v8.1.0](https://github.com/asfadmin/Discovery-asf_search/compare/v8.0.1...v8.1.0)
### Changed
- Changed log level from warning to debug/info for search timing log messages
- Raised minimum Python version to 3.9 from 3.8, which reached EOL last year (see the official [Status of Python versions](https://devguide.python.org/versions/) for the Python version release cycle)

------
## [v8.0.1](https://github.com/asfadmin/Discovery-asf_search/compare/v8.0.0...v8.0.1)
### Fixed
- Fixed setting end date timezone when translating search opts to CMR opts

------
## [v8.0.0](https://github.com/asfadmin/Discovery-asf_search/compare/v7.1.0...v7.2.0)
## [v8.0.0](https://github.com/asfadmin/Discovery-asf_search/compare/v7.1.0...v8.0.0)
### Added
- Added `asf.ASFSearchOptions(circle=[lat, long, radius])` search param. Takes list of exactly 3 numbers.
- Exposed `asf.validator_map`, which given a ops search param, can be used to look up which method we're going to validate it against.
Expand Down
4 changes: 0 additions & 4 deletions asf_search/ASFProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,10 @@ def get_classname(cls):
- `path`: the expected path in the CMR UMM json granule response as a list
- `cast`: (optional): the optional type casting method
<<<<<<< HEAD
Defining `_base_properties` in subclasses allows for
defining custom properties or overiding existing ones.
See `S1Product.get_property_paths()` on how subclasses are expected to
combine `ASFProduct._base_properties` with their own separately defined `_base_properties`
=======
Defining `_properties_paths` in subclasses allows for defining custom properties or overiding existing ones.
>>>>>>> master
"""

def __init__(self, args: Dict = {}, session: ASFSession = ASFSession()):
Expand Down
2 changes: 1 addition & 1 deletion asf_search/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def search(
# The last page will be marked as complete if results sucessful
perf = time.time()
for page in search_generator(opts=opts):
ASF_LOGGER.warning(f'Page Time Elapsed {time.time() - perf}')
ASF_LOGGER.debug(f'Page Time Elapsed {time.time() - perf}')
results.extend(page)
results.searchComplete = page.searchComplete
results.searchOptions = page.searchOptions
Expand Down
6 changes: 3 additions & 3 deletions asf_search/search/search_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def search_generator(
last_page = process_page(
items, maxResults, subquery_max_results, total, subquery_count, opts
)
ASF_LOGGER.warning(f'Page Processing Time {time.time() - perf}')
ASF_LOGGER.info(f'Page Processing Time {time.time() - perf}')
subquery_count += len(last_page)
total += len(last_page)
last_page.searchComplete = subquery_count == subquery_max_results or total == maxResults
Expand Down Expand Up @@ -296,7 +296,7 @@ def query_cmr(

perf = time.time()
items = [as_ASFProduct(f, session=session) for f in response.json()['items']]
ASF_LOGGER.warning(f'Product Subclassing Time {time.time() - perf}')
ASF_LOGGER.debug(f'Product Subclassing Time {time.time() - perf}')
hits: int = response.json()['hits'] # total count of products given search opts
# 9-10 per process
# 3.9-5 per process
Expand Down Expand Up @@ -354,7 +354,7 @@ def get_page(session: ASFSession, url: str, translated_opts: List) -> Response:
f'Connection Error (Timeout): CMR took too long to respond. Set asf constant "asf_search.constants.INTERNAL.CMR_TIMEOUT" to increase. ({url=}, timeout={CMR_TIMEOUT})'
) from exc

ASF_LOGGER.warning(f'Query Time Elapsed {time.time() - perf}')
ASF_LOGGER.info(f'Query Time Elapsed {time.time() - perf}')
return response


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'pytest-cov',
'pytest-xdist',
'coverage',
'requests-mock',
'requests-mock==1.11.0',
'nbformat',
'nbconvert',
'ipykernel',
Expand Down
13 changes: 9 additions & 4 deletions tests/ASFSearchResults/test_ASFSearchResults.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from shapely.geometry.base import BaseGeometry
from asf_search.CMR.translate import try_parse_date
from asf_search.constants import PLATFORM
from asf_search import ASF_LOGGER
import re

from asf_search.exceptions import ASFSearchError
Expand Down Expand Up @@ -211,15 +212,19 @@ def run_test_ASFSearchResults_intersection(wkt: str):
def overlap_check(s1: BaseGeometry, s2: BaseGeometry):
return s1.overlaps(s2) or s1.touches(s2) or s2.distance(s1) <= 0.005

asf.constants.INTERNAL.CMR_TIMEOUT = 60
for platform in platforms:
asf.constants.INTERNAL.CMR_TIMEOUT = 120
try:
results = asf.geo_search(intersectsWith=wkt, platform=platform, maxResults=250)
except ASFSearchError as exc:
asf.constants.INTERNAL.CMR_TIMEOUT = 30
raise BaseException(
f'Failed to perform intersection test with wkt: {wkt}\nplatform: {platform}.\nOriginal exception: {exc}'
)
if str(exc).startswith("Connection Error (Timeout):"):
ASF_LOGGER.warning('CMR timeout while running intersection test')
continue
else:
raise BaseException(
f'Failed to perform intersection test with wkt: {wkt}\nplatform: {platform}.\nOriginal exception: {exc}'
)

asf.constants.INTERNAL.CMR_TIMEOUT = 30
for product in results:
Expand Down

0 comments on commit 147da5e

Please sign in to comment.