cboettig commited on
Commit
f02aa40
·
1 Parent(s): b635b8e

direct render

Browse files
Files changed (2) hide show
  1. app.py +15 -17
  2. requirements.txt +156 -15
app.py CHANGED
@@ -10,8 +10,6 @@ from matplotlib import cm
10
  import ibis
11
  from ibis import _
12
 
13
- from huggingface_hub import HfApi, login
14
-
15
  from langchain_openai import ChatOpenAI
16
  from langchain_community.utilities import SQLDatabase
17
  from langchain.chains import create_sql_query_chain
@@ -33,7 +31,6 @@ gbif_h3 = con.read_parquet(h3_parquet, "gbif_h3")
33
 
34
 
35
 
36
- login(st.secrets["HF_TOKEN"])
37
 
38
 
39
 
@@ -126,21 +123,22 @@ def host_df(df, filename = "live.json", repo_id="boettiger-lab/gbif"):
126
  # to avoid cache, use unique commit url
127
  commit_hash = info.oid
128
  return f"https://huggingface.co/datasets/{repo_id}/resolve/{commit_hash}/live/{filename}"
129
-
 
130
  def hex_layer(m, df: pd.DataFrame, v_scale = 1):
131
- url = host_df(df)
132
-
133
- deck_grid_layer = {
134
- "@@type": "H3HexagonLayer",
135
- "id": "my-layer",
136
- "data": url,
137
- "getHexagon": "@@=hex",
138
- "getFillColor": "@@=rgb",
139
- "getElevation": "@@=normalized_values",
140
- "elevationScale": 5000 * 10 ** v_scale,
141
- "elevationRange": [0,1],
142
- }
143
- return m.add_deck_layers([deck_grid_layer])
144
 
145
 
146
  # +
 
10
  import ibis
11
  from ibis import _
12
 
 
 
13
  from langchain_openai import ChatOpenAI
14
  from langchain_community.utilities import SQLDatabase
15
  from langchain.chains import create_sql_query_chain
 
31
 
32
 
33
 
 
34
 
35
 
36
 
 
123
  # to avoid cache, use unique commit url
124
  commit_hash = info.oid
125
  return f"https://huggingface.co/datasets/{repo_id}/resolve/{commit_hash}/live/{filename}"
126
+
127
+ import pydeck as pdk
128
  def hex_layer(m, df: pd.DataFrame, v_scale = 1):
129
+
130
+ layer = pdk.Layer(
131
+ "H3HexagonLayer",
132
+ df,
133
+ get_hexagon="hex",
134
+ get_fill_color="rgb",
135
+ extruded=True,
136
+ get_elevation="normalized_values",
137
+ elevation_scale= 5000 * 10 ** v_scale,
138
+ elevation_range = [0,1]
139
+ )
140
+
141
+ return m.add_deck_layers([layer])
142
 
143
 
144
  # +
requirements.txt CHANGED
@@ -1,18 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  duckdb==1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  pandas==2.2.2
3
- git+https://github.com/eodaGmbH/py-maplibregl@v0.2.6.1-pre-release
4
- leafmap[maplibre]
5
- ibis-framework[duckdb]==9.1.0
6
- streamlit==1.35.0
7
- streamlit_folium==0.20.0
8
- altair==5.3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  referencing==0.35.1
10
- rasterio==1.3.10
11
- shapely==2.0.4
12
- shiny==0.10.2
13
- huggingface_hub
14
- duckdb-engine
15
- langchain
16
- langchain-community
17
- langchain-openai
18
- streamlit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohappyeyeballs==2.4.0
2
+ aiohttp==3.10.5
3
+ aiosignal==1.3.1
4
+ altair==5.4.1
5
+ annotated-types==0.7.0
6
+ anyio==4.4.0
7
+ anywidget==0.9.13
8
+ appdirs==1.4.4
9
+ asgiref==3.8.1
10
+ asttokens==2.4.1
11
+ async-timeout==4.0.3
12
+ atpublic==5.0
13
+ attrs==24.2.0
14
+ beautifulsoup4==4.12.3
15
+ blinker==1.8.2
16
+ bqplot==0.12.43
17
+ branca==0.7.2
18
+ cachetools==5.5.0
19
+ certifi==2024.8.30
20
+ charset-normalizer==3.3.2
21
+ click==8.1.7
22
+ colour==0.1.5
23
+ comm==0.2.2
24
+ contourpy==1.3.0
25
+ cycler==0.12.1
26
+ dataclasses-json==0.6.7
27
+ decorator==5.1.1
28
+ distro==1.9.0
29
  duckdb==1.0.0
30
+ duckdb_engine==0.13.1
31
+ exceptiongroup==1.2.2
32
+ executing==2.0.1
33
+ filelock==3.15.4
34
+ folium==0.17.0
35
+ fonttools==4.53.1
36
+ frozenlist==1.4.1
37
+ gdown==5.2.0
38
+ geojson==3.1.0
39
+ geopandas==1.0.1
40
+ gitdb==4.0.11
41
+ GitPython==3.1.43
42
+ greenlet==3.0.3
43
+ h11==0.14.0
44
+ htmltools==0.5.3
45
+ httpcore==1.0.5
46
+ httpx==0.27.2
47
+ ibis-framework==9.4.0
48
+ idna==3.8
49
+ ipyevents==2.0.2
50
+ ipyfilechooser==0.6.0
51
+ ipyleaflet==0.19.2
52
+ ipython==8.18.0
53
+ ipytree==0.2.2
54
+ ipyvue==1.11.1
55
+ ipyvuetify==1.10.0
56
+ ipywidgets==8.1.5
57
+ jedi==0.19.1
58
+ Jinja2==3.1.4
59
+ jiter==0.5.0
60
+ jsonpatch==1.33
61
+ jsonpointer==3.0.0
62
+ jsonschema==4.23.0
63
+ jsonschema-specifications==2023.12.1
64
+ jupyter-leaflet==0.19.2
65
+ jupyterlab_widgets==3.0.13
66
+ kiwisolver==1.4.6
67
+ langchain==0.2.16
68
+ langchain-community==0.2.16
69
+ langchain-core==0.2.38
70
+ langchain-openai==0.1.23
71
+ langchain-text-splitters==0.2.4
72
+ langsmith==0.1.110
73
+ leafmap==0.37.1
74
+ linkify-it-py==2.0.3
75
+ maplibre @ git+https://github.com/eodaGmbH/py-maplibregl@f7a514d4db1d7df06f70c293be9e4f9f1bc23c12
76
+ markdown-it-py==3.0.0
77
+ MarkupSafe==2.1.5
78
+ marshmallow==3.22.0
79
+ matplotlib==3.9.2
80
+ matplotlib-inline==0.1.7
81
+ mdit-py-plugins==0.4.1
82
+ mdurl==0.1.2
83
+ multidict==6.0.5
84
+ mypy-extensions==1.0.0
85
+ narwhals==1.6.2
86
+ numpy==1.26.4
87
+ openai==1.43.0
88
+ orjson==3.10.7
89
+ packaging==24.1
90
  pandas==2.2.2
91
+ parso==0.8.4
92
+ parsy==2.1
93
+ pexpect==4.9.0
94
+ pillow==10.4.0
95
+ plotly==5.24.0
96
+ prompt-toolkit==3.0.36
97
+ protobuf==5.28.0
98
+ psygnal==0.11.1
99
+ ptyprocess==0.7.0
100
+ pure_eval==0.2.3
101
+ pyarrow==17.0.0
102
+ pyarrow-hotfix==0.6
103
+ pydantic==2.8.2
104
+ pydantic_core==2.20.1
105
+ pydeck==0.9.1
106
+ Pygments==2.18.0
107
+ pyogrio==0.9.0
108
+ pyparsing==3.1.4
109
+ pyproj==3.6.1
110
+ pyshp==2.3.1
111
+ PySocks==1.7.1
112
+ pystac==1.10.1
113
+ pystac-client==0.8.3
114
+ python-box==7.2.0
115
+ python-dateutil==2.9.0.post0
116
+ python-multipart==0.0.9
117
+ pytz==2024.1
118
+ PyYAML==6.0.2
119
+ questionary==2.0.1
120
  referencing==0.35.1
121
+ regex==2024.7.24
122
+ requests==2.32.3
123
+ rich==13.8.0
124
+ rpds-py==0.20.0
125
+ scooby==0.10.0
126
+ shapely==2.0.6
127
+ shiny==1.0.0
128
+ six==1.16.0
129
+ smmap==5.0.1
130
+ sniffio==1.3.1
131
+ soupsieve==2.6
132
+ SQLAlchemy==2.0.33
133
+ sqlglot==25.18.0
134
+ stack-data==0.6.3
135
+ starlette==0.38.2
136
+ streamlit==1.38.0
137
+ tenacity==8.5.0
138
+ tiktoken==0.7.0
139
+ toml==0.10.2
140
+ toolz==0.12.1
141
+ tornado==6.4.1
142
+ tqdm==4.66.5
143
+ traitlets==5.14.3
144
+ traittypes==0.2.1
145
+ typing-inspect==0.9.0
146
+ typing_extensions==4.12.2
147
+ tzdata==2024.1
148
+ uc-micro-py==1.0.3
149
+ urllib3==2.2.2
150
+ uvicorn==0.30.6
151
+ watchdog==4.0.2
152
+ watchfiles==0.24.0
153
+ wcwidth==0.2.13
154
+ websockets==13.0.1
155
+ whitebox==2.3.5
156
+ whiteboxgui==2.3.0
157
+ widgetsnbextension==4.0.13
158
+ xyzservices==2024.9.0
159
+ yarl==1.9.7