You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was messing around on pystac-client and trying to understand what's going on in stac-utils/pystac#1097. I tried looking at earth-search and the _repr_html_ was raising an error:
frompystac_clientimportClient# set pystac_client logger to DEBUG to see API callsimportlogginglogging.basicConfig()
logger=logging.getLogger('pystac_client')
logger.setLevel(logging.DEBUG)
Client.open("https://earth-search.aws.element84.com/v1")
DEBUG:pystac_client.stac_api_io:GET https://earth-search.aws.element84.com/v1 Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
DEBUG:pystac_client.stac_api_io:GET https://earth-search.aws.element84.com/v1/collections/naip Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
DEBUG:pystac_client.stac_api_io:GET https://earth-search.aws.element84.com/v1/collections/naip/items?limit=100 Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
DEBUG:pystac_client.stac_api_io:GET https://earth-search.aws.element84.com/v1/collections/naip/items?limit=100 Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
DEBUG:pystac_client.stac_api_io:POST https://earth-search.aws.element84.com/v1/search Headers: {'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '14', 'Content-Type': 'application/json'} Payload: {"limit": 100}
---------------------------------------------------------------------------
APIError Traceback (most recent call last)
File ~/conda/envs/pystac-client/lib/python3.11/site-packages/IPython/core/formatters.py:344, in BaseFormatter.__call__(self, obj)
342 method = get_real_method(obj, self.print_method)
343if method isnotNone:
--> 344 return method()
345returnNone346else:
File ~/pystac/pystac/catalog.py:214, in Catalog._repr_html_(self)
212if jinja_env:
213 template = jinja_env.get_template("Catalog.jinja2")
--> 214 return str(template.render(catalog=self))
215else:
216return escape(repr(self))
File ~/conda/envs/pystac-client/lib/python3.11/site-packages/jinja2/environment.py:1301, in Template.render(self, *args, **kwargs)
1299 return self.environment.concat(self.root_render_func(ctx)) # type: ignore
1300 except Exception:
-> 1301 self.environment.handle_exception()
File ~/conda/envs/pystac-client/lib/python3.11/site-packages/jinja2/environment.py:936, in Environment.handle_exception(self, source)
931"""Exception handling helper. This is used internally to either raise932 rewritten exceptions orreturn a rendered traceback for the template.
933"""934from .debug import rewrite_traceback_stack
--> 936 raise rewrite_traceback_stack(source=source)
File ~/pystac/pystac/html/Catalog.jinja2:25, in top-level template code()
23 {{ macros.stac_extensions(catalog) }}
24 {{ macros.children(catalog) }}
---> 25 {{ macros.items(catalog) }}
26 {{ macros.links(catalog) }}
27 {% block subclass_details %} {% endblock %}
File ~/conda/envs/pystac-client/lib/python3.11/site-packages/jinja2/runtime.py:777, in Macro._invoke(self, arguments, autoescape)
774ifself._environment.is_async:
775returnself._async_invoke(arguments, autoescape) # type:ignore
--> 777 rv = self._func(*arguments)
779if autoescape:
780 rv = Markup(rv)
File ~/pystac/pystac/html/Macros.jinja2:39, in template()
3738 {% macro items(parent) -%}
---> 39 {% if parent.get_items()|is_nonempty_generator %}
40<details>41<summary style="margin-bottom: 10px; margin-top: 10px">
File ~/pystac/pystac/html/jinja_env.py:17, in get_jinja_env.<locals>.<lambda>(x)
12 environment = Environment(
13 loader=PackageLoader("pystac", "html"), autoescape=select_autoescape()
14 )
16 environment.filters["first"] =lambdax: islice(x, 1)
---> 17 environment.filters["is_nonempty_generator"] = lambda x: next(x, None) is not None
19return environment
File ~/pystac-client/pystac_client/client.py:301, in Client.get_items(self)
299ifself._conforms_to(ConformanceClasses.ITEM_SEARCH):
300 search =self.search()
--> 301 yield from search.items()
302else:
303for item insuper().get_items():
File ~/pystac-client/pystac_client/item_search.py:682, in ItemSearch.items(self)
675defitems(self) -> Iterator[Item]:
676"""Iterator that yields :class:`pystac.Item` instances for each item matching677 the given search parameters.
678679 Yields:
680 Item : each Item matching the search criteria
681"""
--> 682 for item in self.items_as_dicts():
683# already signed in items_as_dicts684yield Item.from_dict(item, root=self.client, preserve_dict=False)
File ~/pystac-client/pystac_client/item_search.py:694, in ItemSearch.items_as_dicts(self)
687"""Iterator that yields :class:`dict` instances for each item matching688 the given search parameters.
689690 Yields:
691 Item : each Item matching the search criteria
692"""693 nitems =0
--> 694 for page in self._stac_io.get_pages(
695self.url, self.method, self.get_parameters()
696 ):
697for item in page.get("features", []):
698 call_modifier(self.modifier, item)
File ~/pystac-client/pystac_client/stac_api_io.py:246, in StacApiIO.get_pages(self, url, method, parameters)
234defget_pages(
235self,
236 url: str,
237 method: Optional[str] =None,
238 parameters: Optional[Dict[str, Any]] =None,
239 ) -> Iterator[Dict[str, Any]]:
240"""Iterator that yields dictionaries for each page at a STAC paging241 endpoint, e.g., /collections, /search
242243 Return:
244 Dict[str, Any] : JSON content from a single page
245"""
--> 246 page = self.read_json(url, method=method, parameters=parameters)
247ifnot (page.get("features") or page.get("collections")):
248returnNone
File ~/pystac/pystac/stac_io.py:206, in StacIO.read_json(self, source, *args, **kwargs)
189defread_json(self, source: HREF, *args: Any, **kwargs: Any) -> Dict[str, Any]:
190"""Read a dict from the given source.191192 See :func:`StacIO.read_text <pystac.StacIO.read_text>`for usage of
(...)
204 given source.
205"""
--> 206 txt = self.read_text(source, *args, **kwargs)
207returnself.json_loads(txt)
File ~/pystac-client/pystac_client/stac_api_io.py:123, in StacApiIO.read_text(self, source, *args, **kwargs)
121 href =str(source)
122if _is_url(href):
--> 123 return self.request(href, *args, **kwargs)
124else:
125withopen(href) as f:
File ~/pystac-client/pystac_client/stac_api_io.py:169, in StacApiIO.request(self, href, method, headers, parameters)
167raise APIError(str(err))
168if resp.status_code !=200:
--> 169 raise APIError.from_response(resp)
170try:
171return resp.content.decode("utf-8")
APIError: {"message":"Forbidden"}
that I think essentially boils down to the API needing the value for Content-Type to end in ;
I was messing around on pystac-client and trying to understand what's going on in stac-utils/pystac#1097. I tried looking at earth-search and the
_repr_html_
was raising an error:that I think essentially boils down to the API needing the value for
Content-Type
to end in;
The text was updated successfully, but these errors were encountered: