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

iteration on has_target from keyword #84

Merged
merged 1 commit into from
Jan 29, 2025
Merged

iteration on has_target from keyword #84

merged 1 commit into from
Jan 29, 2025

Conversation

tloubrieu-jpl
Copy link
Member

@tloubrieu-jpl tloubrieu-jpl commented Jan 28, 2025

🗒️ Summary

  • merge the has_target with lid argument with the has_target with the keyword argument
  • use description/title instead or target/name to retrieve the target
  • add alt_title to retrieve target
  • create a contexts() method to help to retrieve the targets
  • add warning log when no target was found
  • other minor updates

⚙️ Test Data and/or Report

Test available in unittest.

♻️ Related Issues

improves #74

@tloubrieu-jpl tloubrieu-jpl requested a review from a team as a code owner January 28, 2025 14:57
return " or ".join(f'{property_name} eq "{s}"' for s in _canonicalize_string(value))

q_string = eq_cannonical_string_clause("pds:Identification_Area.pds:title", keyword)
q_string += f"or {eq_cannonical_string_clause('pds:Alias.pds:alternate_title', keyword)}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a leading space before or needed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that works without but that will be cleaner with.

Copy link
Member

@nutjob4life nutjob4life left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual inspection: ✓
Tests: ✓

  py39: OK (15.34=setup[2.02]+cmd[13.33] seconds)
  congratulations :) (15.48 seconds)

Approval: ✓ 🎉

identifiers = [identifiers]

if len(identifiers) > 0:
clause = "or ".join([f'ref_lid_target eq "{identifier}"' for identifier in identifiers])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A leading space before the or here might be needed here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that works without but that will be cleaner with.

@@ -12,7 +12,7 @@
# in the `PDS keyword search <https://pds.nasa.gov/datasearch/keyword-search/search.jsp>`_
mercury_id = "urn:nasa:pds:context:target:planet.mercury"
# filter here:
products = pep.Products(client).has_target(mercury_id).before(date1).observationals()
products = pep.Products(client).has_target("Mercury").before(date1).observationals()
Copy link
Contributor

@collinss-jpl collinss-jpl Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since mercury_id is still defined, maybe we should include an example of both variations of the new has_target convention here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I will fix that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I removed it for now since the plan is to have only the keyword search in the quickstart. As we need to enrich the quickstart we can had back new cases as they come in the quickstart in the online doc.

import unittest
from datetime import datetime
from typing import get_args

import pds.peppi as pep # type: ignore
from pds.api_client import PdsProduct

logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this added? I don't see any logging going on in this test suite now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove that, I think I added when I was unable to assert something in the logs, I need to check that this works without that.

Copy link
Contributor

@collinss-jpl collinss-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New approach looks fine to me

@tloubrieu-jpl tloubrieu-jpl merged commit 578e76f into main Jan 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants