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

Proof-of-concept prototype of crosslinking capability to provide applicable tools for a specific product (/products/{lidvid}/tools) #498

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

tariqksoliman
Copy link

@tariqksoliman tariqksoliman commented Jul 17, 2024

Staging

🗒️ Summary

  • Adds a new endpoint: /products/{lidvid}/tools
  • Adds a json file to configure lidvid -> tool mappings. Located at /service/cross-links.json
  • Adds a CrossLinksLoader.java file to load that file on start
  • Adds a CrossLinks.java file to represent that json file and perform the mapping logic
  • Adds a productCrossLinks() method to ProductsController.java
    • Queries opensearch for the full document associated with the lidvid
    • Passes that document in to CrossLinks to get all tool cross-links.

⚙️ Test Data and/or Report

Sample curls:

curl -GET http://localhost:8081/products/urn:nasa:pds:insight_rad::2.1/tools | jq
[
  {
    "link": "https://an.rsl.wustl.edu/ins/AN/an3.aspx?it=B1&ii=readme",
    "description": "A tool for accessing the science data archives from NASA landed Mars and lunar missions.",
    "tool": "analysts_notebook"
  },
  {
    "link": "https://pds-imaging.jpl.nasa.gov/beta/record?lidvid=urn:nasa:pds:insight_rad::2.1",
    "description": "The Official Image Search of the PDS Cartography and Imaging Sciences Node (PDSIMG)",
    "tool": "atlas4"
  }
]

curl -GET http://localhost:8081/products/urn:nasa:pds:epoxi_mri::1.0/tools | jq
[
  {
    "link": "https://pds-imaging.jpl.nasa.gov/beta/record?lidvid=urn:nasa:pds:epoxi_mri::1.0",
    "description": "The Official Image Search of the PDS Cartography and Imaging Sciences Node (PDSIMG)",
    "tool": "atlas4"
  }
]

Explanation of cross-links.json

Sample:

{
  "injectableParams": [
    "vid",
    "lid",
    "lidvid",
    "mission",
    "spacecraft",
    "bundle",
    "collection",
    "target",
    "filename",
    "filenameWithoutFileExtension",
    "fileExtension",
    "fileRef",
    "productClass",
    "productType",
    "nodeName"
  ],
  "tools": [
    {
      "name": "analysts_notebook",
      "base": "https://an.rsl.wustl.edu/{mission}/AN/an3.aspx?it=B1&ii={filenameWithoutFileExtension}",
      "description": "A tool for accessing the science data archives from NASA landed Mars and lunar missions.",
      "aliases": [
        {
          "field": "mission",
          "alias": "m20",
          "from": ["mars_2020", "m2020", "mars2020", "Mars2020"]
        },
        {
          "field": "mission",
          "alias": "ins",
          "from": ["InSight"]
        }
      ],
      "acceptOnly": [
        { "field": "mission", "match": "m20" },
        { "field": "mission", "match": "ins" },
        { "field": "fileExtension", "match": "\\.IMG" }
      ],
      "reject": [{ "field": "lidvid", "match": ".*mars2020_helicam.*" }]
    },
    {
      "name": "atlas4",
      "base": "https://pds-imaging.jpl.nasa.gov/beta/record?lidvid={lidvid}",
      "description": "The Official Image Search of the PDS Cartography and Imaging Sciences Node (PDSIMG)",
      "aliases": [],
      "acceptOnly": [],
      "reject": []
    }
  ]
}
  • injectableParams: Doesn't nothing but indicate with params can be set in a tool's "base" url.
  • tools
    • name: tool name that just gets passed to the response
    • base: Base template url to deep link to the given lidvid product in the tool. injectableParams can be templated by wrapping it in curly brackets: {injectableVariable}
    • description: tool description that just gets passed to the response
    • aliases: Sometimes tools have slightly different names for things. If a tool requires "m20" in their url, aliases allows such mapping.
    • acceptOnly: Leave as empty array to accept all, otherwise if a lidvid's field's value does not match what's configured here, the tool entry will not show in the response. acceptOnlys are ANDed together. "match" supports java regexes
    • reject: Leave as empty array to not specify any rejections. Otherwise if any lidvid's field matches a reject case, the tool entry will not show up in the response. "match" supports java regexes

♻️ Related Issues

Fixes #472

Note: This is my first PR and first time using Java in over a decade so please review this with extra caution.

@tloubrieu-jpl
Copy link
Member

Thanks @tariqksoliman !
Just last week, we made some optimization of the opensearch request builder that are conflicting with your code. Do you mind to pull the latest develop branch and rebase it in your branch ? Let me know if you have questions on that.

Copy link
Contributor

@alexdunnjpl alexdunnjpl left a comment

Choose a reason for hiding this comment

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

Some comments - will look closely at the meat of CrossLinks.java once doco is there

service/for Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Request: remove extraneous file

Copy link
Contributor

Choose a reason for hiding this comment

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

Branch needs to be rebased on #489

@tariqksoliman @tloubrieu-jpl this should be simple - if it isn't and you'd like to get this in before taking the time to understand the new approach, let me know and I should be able to sort out the conflict pretty quickly

Copy link
Contributor

Choose a reason for hiding this comment

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

Docstring please - ideally I should be able to read it and walk away with a good understanding of what it is/does (for the class, and any inobvious methods)

https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer: remove file and add path to .gitignore

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be configurable, or is this behaviour a relatively-immutable structured collection of values which could be defined within the Java code?

I'm taking it on faith that loading from a JSON configuration is the way to go here vs defining a constant - as long as that question was considered that's fine.

@jordanpadams
Copy link
Member

@tariqksoliman we can talk more about this offline at the next IMG - EN tag-up, but for an operational deployment to enable supporting this at scale across the PDS, we will need to refactor this to use Product_Service, e.g. this one for analyst's notebook. I thought I documented this in the ticket, but looks like this was just an offline discussion at our last meeting. Thanks for the PR!

@jordanpadams jordanpadams changed the title #472 Crosslinks to other tools via lidvid - (/products/{lidvid}/tools) Proof-of-concept prototype of crosslinking capability to provide applicable tools for a specific product (/products/{lidvid}/tools) Jul 23, 2024
@tariqksoliman
Copy link
Author

@tloubrieu-jpl As request, I've moved cross-links.json into /service/src/main/resources.

@jordanpadams
Copy link
Member

Switching this PR to draft for the time being until we are able to get this into a more production-ready state

@jordanpadams jordanpadams marked this pull request as draft August 8, 2024 17:00
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.

As a user, I want to know the applicable tools that can be used on a specific product
4 participants