Spaces:
Running
Running
Initial commit (#1)
Browse files- .github/workflows/sync-hf.yml +20 -0
- .gitignore +2 -2
- .pre-commit-config.yaml +32 -0
- Dockerfile +26 -0
- README.md +35 -0
- environment.yml +12 -0
- notebooks/dashboard.ipynb +119 -0
- notebooks/leafmap.ipynb +51 -0
- voila.json +11 -0
.github/workflows/sync-hf.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches: [main]
|
| 5 |
+
|
| 6 |
+
# to run this workflow manually from the Actions tab
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
sync-to-hub:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v4
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
- name: Push to hub
|
| 18 |
+
env:
|
| 19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push --force https://giswqs:[email protected]/spaces/giswqs/duckdb-voila main
|
.gitignore
CHANGED
|
@@ -182,9 +182,9 @@ cython_debug/
|
|
| 182 |
.abstra/
|
| 183 |
|
| 184 |
# Visual Studio Code
|
| 185 |
-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
| 186 |
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
| 187 |
-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
| 188 |
# you could uncomment the following to ignore the entire vscode folder
|
| 189 |
# .vscode/
|
| 190 |
|
|
|
|
| 182 |
.abstra/
|
| 183 |
|
| 184 |
# Visual Studio Code
|
| 185 |
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
| 186 |
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
| 187 |
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
| 188 |
# you could uncomment the following to ignore the entire vscode folder
|
| 189 |
# .vscode/
|
| 190 |
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
repos:
|
| 2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
| 3 |
+
rev: v6.0.0
|
| 4 |
+
hooks:
|
| 5 |
+
- id: check-toml
|
| 6 |
+
- id: check-yaml
|
| 7 |
+
- id: end-of-file-fixer
|
| 8 |
+
types: [python]
|
| 9 |
+
- id: trailing-whitespace
|
| 10 |
+
- id: requirements-txt-fixer
|
| 11 |
+
- id: check-added-large-files
|
| 12 |
+
args: ["--maxkb=500"]
|
| 13 |
+
|
| 14 |
+
- repo: https://github.com/psf/black-pre-commit-mirror
|
| 15 |
+
rev: 25.11.0
|
| 16 |
+
hooks:
|
| 17 |
+
- id: black-jupyter
|
| 18 |
+
|
| 19 |
+
- repo: https://github.com/codespell-project/codespell
|
| 20 |
+
rev: v2.4.1
|
| 21 |
+
hooks:
|
| 22 |
+
- id: codespell
|
| 23 |
+
args:
|
| 24 |
+
[
|
| 25 |
+
"--ignore-words-list=aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask,tre,mape",
|
| 26 |
+
"--skip=*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf",
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
- repo: https://github.com/kynan/nbstripout
|
| 30 |
+
rev: 0.8.1
|
| 31 |
+
hooks:
|
| 32 |
+
- id: nbstripout
|
Dockerfile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM condaforge/mambaforge:latest
|
| 2 |
+
|
| 3 |
+
# The HF Space container runs with user ID 1000.
|
| 4 |
+
# Use jovyan as the username to match Jupyter convention
|
| 5 |
+
RUN useradd -m -u 1000 jovyan
|
| 6 |
+
USER jovyan
|
| 7 |
+
|
| 8 |
+
# Set home to the user's home directory
|
| 9 |
+
ENV HOME=/home/jovyan \
|
| 10 |
+
PATH=/home/jovyan/.local/bin:$PATH
|
| 11 |
+
|
| 12 |
+
# Set the working directory to the user's home directory
|
| 13 |
+
WORKDIR $HOME/app
|
| 14 |
+
COPY --chown=jovyan . .
|
| 15 |
+
|
| 16 |
+
RUN mamba env create --prefix $HOME/env -f ./environment.yml
|
| 17 |
+
|
| 18 |
+
# Create notebooks directory and copy notebooks there for Hugging Face deployment
|
| 19 |
+
# (local volume mounts will override this)
|
| 20 |
+
RUN mkdir -p /home/jovyan/notebooks && \
|
| 21 |
+
cp -r /home/jovyan/app/notebooks/* /home/jovyan/notebooks/ 2>/dev/null || true
|
| 22 |
+
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
WORKDIR $HOME/app
|
| 25 |
+
|
| 26 |
+
CMD ["mamba", "run", "-p", "/home/jovyan/env", "--no-capture-output", "voila", "--no-browser", "/home/jovyan/notebooks/"]
|
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DuckDB Voila
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
tags:
|
| 9 |
+
- leafmap
|
| 10 |
+
pinned: false
|
| 11 |
+
short_description: A Voila template for DuckDB
|
| 12 |
+
license: mit
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# duckdb-voila
|
| 16 |
+
|
| 17 |
+
Build a docker image for using DuckDB with Voila
|
| 18 |
+
|
| 19 |
+
To build the image:
|
| 20 |
+
|
| 21 |
+
```bash
|
| 22 |
+
docker buildx build --platform linux/amd64,linux/arm64 -t giswqs/duckdb:voila --push .
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
To run the image:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
docker run -it -p 7860:7860 -v $(pwd):/home/jovyan/notebooks giswqs/duckdb:voila
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
To push the image to the registry:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
docker push giswqs/duckdb:voila
|
| 35 |
+
```
|
environment.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: voila
|
| 2 |
+
channels:
|
| 3 |
+
- conda-forge
|
| 4 |
+
dependencies:
|
| 5 |
+
- python=3.12
|
| 6 |
+
- pip
|
| 7 |
+
- ipykernel
|
| 8 |
+
- jupyterlab
|
| 9 |
+
- leafmap
|
| 10 |
+
- maplibre
|
| 11 |
+
- voila
|
| 12 |
+
- voila_topbar
|
notebooks/dashboard.ipynb
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"id": "0",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": [
|
| 10 |
+
"# %pip install leafmap"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"cell_type": "code",
|
| 15 |
+
"execution_count": null,
|
| 16 |
+
"id": "1",
|
| 17 |
+
"metadata": {},
|
| 18 |
+
"outputs": [],
|
| 19 |
+
"source": [
|
| 20 |
+
"import leafmap.maplibregl as leafmap\n",
|
| 21 |
+
"import ipywidgets as widgets"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "code",
|
| 26 |
+
"execution_count": null,
|
| 27 |
+
"id": "2",
|
| 28 |
+
"metadata": {},
|
| 29 |
+
"outputs": [],
|
| 30 |
+
"source": [
|
| 31 |
+
"tw = leafmap.TabWidget(\n",
|
| 32 |
+
" title=\"Interactive Dashboard\",\n",
|
| 33 |
+
" tabs=(\"Home\", \"Map\", \"Population\", \"Settings\"),\n",
|
| 34 |
+
" icons=(\"mdi-home\", \"mdi-airplane\", \"mdi-account-box\", \"mdi-cog\"),\n",
|
| 35 |
+
" show_panel_titles=False,\n",
|
| 36 |
+
")\n",
|
| 37 |
+
"\n",
|
| 38 |
+
"# Customize dialog\n",
|
| 39 |
+
"tw.set_help_title(\"About this dashboard\")\n",
|
| 40 |
+
"tw.set_help_content(\n",
|
| 41 |
+
" widgets.HTML(\n",
|
| 42 |
+
" \"\"\"\n",
|
| 43 |
+
" <p><b>User Guide</b></p>\n",
|
| 44 |
+
" <ul>\n",
|
| 45 |
+
" <li>Step 1: Click on the tab</li>\n",
|
| 46 |
+
" <li>Navigate the map</li>\n",
|
| 47 |
+
" <li>? — help</li>\n",
|
| 48 |
+
" </ul>\n",
|
| 49 |
+
" \"\"\"\n",
|
| 50 |
+
" )\n",
|
| 51 |
+
")\n",
|
| 52 |
+
"\n",
|
| 53 |
+
"m = leafmap.Map(projection=\"globe\", sidebar_visible=True, height=\"600px\")\n",
|
| 54 |
+
"m.add_overture_3d_buildings()\n",
|
| 55 |
+
"m.create_container()\n",
|
| 56 |
+
"\n",
|
| 57 |
+
"home_tab = widgets.HTML(\n",
|
| 58 |
+
" \"\"\"\n",
|
| 59 |
+
" <h1>Welcome to the Leafmap Visualization Dashboard</h1>\n",
|
| 60 |
+
" <p>This is the home tab.</p>\n",
|
| 61 |
+
" <img src=\"https://assets.gishub.org/images/geog-312.png\" width=\"100%\">\n",
|
| 62 |
+
" \"\"\"\n",
|
| 63 |
+
")\n",
|
| 64 |
+
"\n",
|
| 65 |
+
"settings_tab = widgets.HTML(\n",
|
| 66 |
+
" \"\"\"\n",
|
| 67 |
+
" <h1>Settings</h1>\n",
|
| 68 |
+
" <p>This is the settings tab.</p>\n",
|
| 69 |
+
" \"\"\"\n",
|
| 70 |
+
")\n",
|
| 71 |
+
"\n",
|
| 72 |
+
"data = \"https://github.com/opengeos/datasets/releases/download/vector/countries.geojson\"\n",
|
| 73 |
+
"\n",
|
| 74 |
+
"m2 = leafmap.Map(style=\"liberty\", projection=\"globe\")\n",
|
| 75 |
+
"first_symbol_id = m2.find_first_symbol_layer()[\"id\"]\n",
|
| 76 |
+
"m2.add_data(\n",
|
| 77 |
+
" data,\n",
|
| 78 |
+
" column=\"POP_EST\",\n",
|
| 79 |
+
" scheme=\"Quantiles\",\n",
|
| 80 |
+
" cmap=\"Blues\",\n",
|
| 81 |
+
" legend_title=\"Population\",\n",
|
| 82 |
+
" name=\"population\",\n",
|
| 83 |
+
" # before_id=first_symbol_id,\n",
|
| 84 |
+
" extrude=True,\n",
|
| 85 |
+
" scale_factor=1000,\n",
|
| 86 |
+
")\n",
|
| 87 |
+
"container = m2.create_container()\n",
|
| 88 |
+
"\n",
|
| 89 |
+
"tw.set_tab_content(0, home_tab)\n",
|
| 90 |
+
"tw.set_tab_content(1, m.container)\n",
|
| 91 |
+
"tw.set_tab_content(3, settings_tab)\n",
|
| 92 |
+
"tw.set_tab_content(2, m2.container)\n",
|
| 93 |
+
"\n",
|
| 94 |
+
"tw.widget"
|
| 95 |
+
]
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"metadata": {
|
| 99 |
+
"kernelspec": {
|
| 100 |
+
"display_name": "geo",
|
| 101 |
+
"language": "python",
|
| 102 |
+
"name": "python3"
|
| 103 |
+
},
|
| 104 |
+
"language_info": {
|
| 105 |
+
"codemirror_mode": {
|
| 106 |
+
"name": "ipython",
|
| 107 |
+
"version": 3
|
| 108 |
+
},
|
| 109 |
+
"file_extension": ".py",
|
| 110 |
+
"mimetype": "text/x-python",
|
| 111 |
+
"name": "python",
|
| 112 |
+
"nbconvert_exporter": "python",
|
| 113 |
+
"pygments_lexer": "ipython3",
|
| 114 |
+
"version": "3.12.2"
|
| 115 |
+
}
|
| 116 |
+
},
|
| 117 |
+
"nbformat": 4,
|
| 118 |
+
"nbformat_minor": 5
|
| 119 |
+
}
|
notebooks/leafmap.ipynb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import leafmap.maplibregl as leafmap"
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": null,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"m = leafmap.Map(\n",
|
| 19 |
+
" style=\"liberty\", projection=\"globe\", sidebar_visible=True, height=\"750px\"\n",
|
| 20 |
+
")\n",
|
| 21 |
+
"m.add_basemap(\"USGS.Imagery\")\n",
|
| 22 |
+
"cities = (\n",
|
| 23 |
+
" \"https://github.com/opengeos/datasets/releases/download/world/world_cities.geojson\"\n",
|
| 24 |
+
")\n",
|
| 25 |
+
"m.add_geojson(cities, name=\"Cities\")\n",
|
| 26 |
+
"m"
|
| 27 |
+
]
|
| 28 |
+
}
|
| 29 |
+
],
|
| 30 |
+
"metadata": {
|
| 31 |
+
"kernelspec": {
|
| 32 |
+
"display_name": "geo",
|
| 33 |
+
"language": "python",
|
| 34 |
+
"name": "python3"
|
| 35 |
+
},
|
| 36 |
+
"language_info": {
|
| 37 |
+
"codemirror_mode": {
|
| 38 |
+
"name": "ipython",
|
| 39 |
+
"version": 3
|
| 40 |
+
},
|
| 41 |
+
"file_extension": ".py",
|
| 42 |
+
"mimetype": "text/x-python",
|
| 43 |
+
"name": "python",
|
| 44 |
+
"nbconvert_exporter": "python",
|
| 45 |
+
"pygments_lexer": "ipython3",
|
| 46 |
+
"version": "3.12.2"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"nbformat": 4,
|
| 50 |
+
"nbformat_minor": 2
|
| 51 |
+
}
|
voila.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Voila": {
|
| 3 |
+
"ip":"0.0.0.0",
|
| 4 |
+
"port": 7860,
|
| 5 |
+
"tornado_settings": {
|
| 6 |
+
"headers": {
|
| 7 |
+
"Content-Security-Policy": "frame-ancestors self *"
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
}
|