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

_repr_html_ causes GETs #1097

Closed
jsignell opened this issue Apr 17, 2023 · 4 comments · Fixed by #1142
Closed

_repr_html_ causes GETs #1097

jsignell opened this issue Apr 17, 2023 · 4 comments · Fixed by #1142
Assignees
Milestone

Comments

@jsignell
Copy link
Member

Kind of hard to figure out where this issue should go since the code in question is in pystac itself. But the repercussions are more obvious on the pystac-client side.

The issue is that _repr_html_ implicitly triggers 5 GETs:

image

Just using pystac it looks like there are only two requests:

image

but I added the logging myself (#1096) so I might have missed some calls.

@gadomski
Copy link
Member

Stuff like this is usually related to link resolution, especially w.r.t. getting the root (see: #960). But haven't looked at this specific issue yet, I'll update if/when I do.

@jsignell
Copy link
Member Author

jsignell commented Apr 17, 2023

I think it comes from these bits in the jinja template:

{% macro items(parent) -%}
{% if parent.get_items()|is_nonempty_generator %}
<details>
<summary style="margin-bottom: 10px; margin-top: 10px">
<h4 style="margin-bottom: 0px; display: inline;">Items</h4>
</summary>
<i> Only the first item shown </i>
{% for item in parent.get_items()|first %}
{{ item._repr_html_() }}
{% endfor %}
</details>
{% endif %}
{%- endmacro %}
{% macro children(parent) -%}
{% if parent.get_children()|is_nonempty_generator %}
<details>
<summary style="margin-bottom: 10px; margin-top: 10px">
<h4 style="margin-bottom: 0px; display: inline;">Children</h4>
</summary>
<i> Only the first child shown </i>
{% for child in parent.get_children()|first %}
{{ child._repr_html_() }}
{% endfor %}
</details>
{% endif %}
{%- endmacro %}

specifically these: parent.get_items()|first parent.get_children()|first

@gadomski
Copy link
Member

Transferring to pystac as it's all related to code in that repo.

Two comments:

  • High level, this seems like intentional behavior to produce rich HTML representations, so I'm not sure it's a bug/problem.
  • Lower level, those double-requests (for the search and for the root) seem problematic and probably are a bug.

@gadomski gadomski transferred this issue from stac-utils/pystac-client Apr 17, 2023
@gadomski gadomski changed the title PySTAC _repr_html_ causes GETs _repr_html_ causes GETs Apr 17, 2023
@pjhartzell pjhartzell added this to the 1.8 milestone May 9, 2023
@jsignell
Copy link
Member Author

I have an extreme proposal. Opening a PR now

@jsignell jsignell linked a pull request May 23, 2023 that will close this issue
5 tasks
@jsignell jsignell removed a link to a pull request Jun 1, 2023
5 tasks
@jsignell jsignell self-assigned this Jun 5, 2023
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 a pull request may close this issue.

3 participants