Skip to content

Commit 9d24228

Browse files
authored
Switch examples to Binder (#98)
1 parent cc0598b commit 9d24228

File tree

13 files changed

+259302
-2012
lines changed

13 files changed

+259302
-2012
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# StackSTAC
22

3-
[![Documentation Status](https://readthedocs.org/projects/stackstac/badge/?version=latest)](https://stackstac.readthedocs.io/en/latest/?badge=latest)
3+
[![Documentation Status](https://readthedocs.org/projects/stackstac/badge/?version=latest)](https://stackstac.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/gjoseph92/stackstac/main?labpath=%2Fdocs%2Fbasic.ipynb%3Ffile-browser-path%3D%2Fexamples)
44

55
Turn a list of [STAC](http://stacspec.org) items into a 4D [xarray](http://xarray.pydata.org/en/stable/) DataArray (dims: `time, band, y, x`), including reprojection to a common grid. The array is a lazy [Dask array](https://docs.dask.org/en/latest/array.html), so loading and processing the data in parallel—locally or [on a cluster](https://coiled.io/)—is just a `compute()` call away.
66

binder/postBuild

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
set -ex
3+
4+
poetry config virtualenvs.create false
5+
poetry install -E binder -E viz

binder/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
.[binder]
2-
# ^ installs the project using poetry
1+
poetry

docs/conf.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = "stackstac"
21-
copyright = "2021, Gabe Joseph"
22-
author = "Gabe Joseph"
20+
import importlib.metadata
21+
import datetime
2322

23+
DISTRIBUTION_METADATA = importlib.metadata.metadata("stackstac")
24+
25+
author = DISTRIBUTION_METADATA["Author"]
26+
project = DISTRIBUTION_METADATA["Name"]
27+
version = DISTRIBUTION_METADATA["Version"]
28+
copyright = f"{datetime.datetime.now().year}, {author}"
2429

2530
# -- General configuration ---------------------------------------------------
2631

@@ -73,43 +78,33 @@
7378
# Gotta fight fire with fire. nbsphinx injects their CSS directly into the page...
7479
# https://github.com/spatialaudio/nbsphinx/blob/master/src/nbsphinx.py#L437-L683
7580
# so we just inject after it to undo their settings that look bad in dark mode.
76-
nbsphinx_prolog = """
81+
nbsphinx_prolog = f"""
7782
.. raw:: html
7883
7984
<style>
80-
@media (prefers-color-scheme: dark) {
85+
@media (prefers-color-scheme: dark) {{
8186
/* input area */
82-
div.nbinput.container div.input_area {
87+
div.nbinput.container div.input_area {{
8388
border: unset;
8489
border-radius: unset;
85-
}
86-
}
90+
}}
91+
}}
8792
8893
</style>
8994
90-
{% set docname = env.doc2path(env.docname, base=False) %}
95+
{{% set docname = env.doc2path(env.docname, base=False) %}}
9196
.. note::
92-
You can view & download the original notebook
93-
`on Github <https://github.com/gjoseph92/stackstac/blob/main/docs/{{
97+
You can run this notebook interactively: |Binder|, or view & download the original
98+
`on GitHub <https://github.com/gjoseph92/stackstac/blob/v{version}/docs/{{{{
9499
"../" + docname if docname.startswith("examples") else docname
95-
}}>`_.
100+
}}}}>`_.
96101
97-
Or, `click here <https://cloud.coiled.io/gjoseph92/jobs/stackstac>`_
98-
to run these notebooks on Coiled with access to Dask clusters.
102+
.. |Binder| image:: https://mybinder.org/badge_logo.svg
103+
:target: https://mybinder.org/v2/gh/gjoseph92/stackstac/v{version}?urlpath=lab/tree/docs/{{{{
104+
"../" + docname if docname.startswith("examples") else docname
105+
}}}}
99106
"""
100107

101-
# TODO enable binder once Coiled supports websocket clusters over 443.
102-
# (Binder blocks outbound traffic on all ports besides 22, 80, and 443, so we can't connect to Coiled on 8786.)
103-
# nbsphinx_prolog = """
104-
# {% set docname = env.doc2path(env.docname, base=False) %}
105-
# .. note::
106-
# You can run this notebook interactively here: |Binder|, or view & download the original
107-
# `on Github <https://github.com/gjoseph92/stackstac/blob/main/docs/{{ docname }}>`_.
108-
109-
# .. |Binder| image:: https://mybinder.org/badge_logo.svg
110-
# :target: https://mybinder.org/v2/gh/gjoseph92/stackstac/main?urlpath=lab/tree/docs/{{ docname }}
111-
# """
112-
113108

114109
# Add any paths that contain custom static files (such as style sheets) here,
115110
# relative to this directory. They are copied after the builtin static files,

examples/cluster.ipynb

Lines changed: 804 additions & 293 deletions
Large diffs are not rendered by default.

examples/gif.ipynb

Lines changed: 245615 additions & 1067 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)