Skip to content

Commit

Permalink
Add popular collection script proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 committed Jul 6, 2024
1 parent f0e53bd commit 2d372df
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
100 changes: 100 additions & 0 deletions tests/integration/popular_collections/NSIDC_ECS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
C2559919423-NSIDC_ECS
C2565090645-NSIDC_ECS
C2564427300-NSIDC_ECS
C2564625052-NSIDC_ECS
C1646610417-NSIDC_ECS
C1646610079-NSIDC_ECS
C2650116584-NSIDC_ECS
C2776463943-NSIDC_ECS
C1646610415-NSIDC_ECS
C2531308461-NSIDC_ECS
C2317038246-NSIDC_ECS
C1600510471-NSIDC_ECS
C2541211133-NSIDC_ECS
C1000000443-NSIDC_ECS
C2750966856-NSIDC_ECS
C1000000461-NSIDC_ECS
C2607017115-NSIDC_ECS
C2738530540-NSIDC_ECS
C2561045326-NSIDC_ECS
C2399557265-NSIDC_ECS
C2136471727-NSIDC_ECS
C2560378689-NSIDC_ECS
C2136471705-NSIDC_ECS
C2776464171-NSIDC_ECS
C1931663473-NSIDC_ECS
C2567856357-NSIDC_ECS
C1646610394-NSIDC_ECS
C1431539277-NSIDC_ECS
C2666857908-NSIDC_ECS
C2176562253-NSIDC_ECS
C2537927247-NSIDC_ECS
C1000000400-NSIDC_ECS
C2776463935-NSIDC_ECS
C1542606326-NSIDC_ECS
C2623698025-NSIDC_ECS
C1000000445-NSIDC_ECS
C2737912334-NSIDC_ECS
C2776464127-NSIDC_ECS
C1431413941-NSIDC_ECS
C2737997483-NSIDC_ECS
C2509060594-NSIDC_ECS
C1000000460-NSIDC_ECS
C1646609734-NSIDC_ECS
C1631093696-NSIDC_ECS
C189991864-NSIDC_ECS
C1449515322-NSIDC_ECS
C2737997243-NSIDC_ECS
C189991870-NSIDC_ECS
C1000000420-NSIDC_ECS
C1646610247-NSIDC_ECS
C189991869-NSIDC_ECS
C2420522159-NSIDC_ECS
C189991871-NSIDC_ECS
C1000000464-NSIDC_ECS
C1365767075-NSIDC_ECS
C189991863-NSIDC_ECS
C1371883515-NSIDC_ECS
C1646609754-NSIDC_ECS
C1646610390-NSIDC_ECS
C1646583410-NSIDC_ECS
C1452437262-NSIDC_ECS
C2548345108-NSIDC_ECS
C1646609808-NSIDC_ECS
C1574621139-NSIDC_ECS
C2794540918-NSIDC_ECS
C2776463773-NSIDC_ECS
C1601063219-NSIDC_ECS
C2776463679-NSIDC_ECS
C2534576405-NSIDC_ECS
C2037494637-NSIDC_ECS
C1646610101-NSIDC_ECS
C2253727823-NSIDC_ECS
C179014688-NSIDC_ECS
C2692731693-NSIDC_ECS
C1542606320-NSIDC_ECS
C1432250096-NSIDC_ECS
C1723866830-NSIDC_ECS
C2817412114-NSIDC_ECS
C179014696-NSIDC_ECS
C2076118670-NSIDC_ECS
C179014698-NSIDC_ECS
C128599377-NSIDC_ECS
C2519306057-NSIDC_ECS
C1454773262-NSIDC_ECS
C130038008-NSIDC_ECS
C179014694-NSIDC_ECS
C1646610212-NSIDC_ECS
C1995259960-NSIDC_ECS
C179014690-NSIDC_ECS
C1997893797-NSIDC_ECS
C1489170961-NSIDC_ECS
C2559364353-NSIDC_ECS
C2295286903-NSIDC_ECS
C2137003017-NSIDC_ECS
C2136471686-NSIDC_ECS
C186584407-NSIDC_ECS
C1000001740-NSIDC_ECS
C1442092309-NSIDC_ECS
C1703031106-NSIDC_ECS
C2776463734-NSIDC_ECS
41 changes: 41 additions & 0 deletions tests/integration/popular_collections/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Generate lists of most popular collections for each of the hardcoded DAACs."""

from pathlib import Path

import requests

THIS_DIR = Path(__file__).parent


def top_collections(*, provider: str, num: int = 100) -> list[str]:
response = requests.post(
"https://cmr.earthdata.nasa.gov/search/collections.json",
data={
"provider": provider,
"has_granules_or_cwic": True,
"include_facets": "v2",
"include_granule_counts": True,
"include_has_granules": True,
"include_tags": "edsc.*,opensearch.granule.osdd",
"page_num": 1,
"page_size": 100,
"sort_key[]": "-usage_score",
},
)
collection_ids = [
collection["id"] for collection in response.json()["feed"]["entry"]
]
return collection_ids


def main():
for provider in ["NSIDC_ECS"]:
collection_ids = top_collections(provider="NSIDC_ECS")

output = THIS_DIR / f"{provider}.txt"
with output.open("w") as f:
f.write("\n".join(collection_ids))


if __name__ == "__main__":
main()

0 comments on commit 2d372df

Please sign in to comment.