Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change log level on search timing messages #321

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ 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

------
## [v8.0.1](https://github.com/asfadmin/Discovery-asf_search/compare/v8.0.0...v8.0.1)
### Fixed
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
Loading