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

Adding custom links between sibling catalogs creates absolute HREFs #1112

Closed
constantinius opened this issue May 3, 2023 · 2 comments · Fixed by #1169
Closed

Adding custom links between sibling catalogs creates absolute HREFs #1112

constantinius opened this issue May 3, 2023 · 2 comments · Fixed by #1169
Assignees
Milestone

Comments

@constantinius
Copy link

In the following example, we have a root catalog which includes two sub-catalogs a and b. I now want to highlight a reference between the two siblings, which cannot be replaced by a parent-child link:

import pystac

root = pystac.Catalog("root", "root")
a = pystac.Catalog("a", "a")
b = pystac.Catalog("b", "b")

root.add_child(a)
root.add_child(b)

a.add_link(pystac.Link("related", b))

root.normalize_and_save("test_out", pystac.CatalogType.SELF_CONTAINED)

Even when I now save it as "self-contained", I now have an absolute link from a to b:

{
  "type": "Catalog",
  "id": "a",
  "stac_version": "1.0.0",
  "description": "a",
  "links": [
    {
      "rel": "root",
      "href": "../catalog.json",
      "type": "application/json"
    },
    {
      "rel": "related",
      "href": "/home/<user>/test_out/b/catalog.json"
    },
    {
      "rel": "parent",
      "href": "../catalog.json",
      "type": "application/json"
    }
  ],
  "stac_extensions": []
}

I would have expected something like that:

...
   {
      "rel": "related",
      "href": "../b/catalog.json"
    },
...

I can't seem to get rid of the absolute links, even when using stac copy or similar commands.

@constantinius
Copy link
Author

I found the following workaround (fix?)

if "related" not in pystac.link.HIERARCHICAL_LINKS:
    pystac.link.HIERARCHICAL_LINKS.append("related")

@gadomski
Copy link
Member

gadomski commented May 3, 2023

It does seem reasonable to expect normalization to resolve all object hrefs the same way (relative or absolute). Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants