11# /// script
22# requires-python = ">=3.12"
33# dependencies = [
4- # "bedrock-ge==0.3.1
4+ # "bedrock-ge==0.3.1",
55# "folium==0.20.0",
66# "geopandas==1.1.0",
77# "mapclassify==2.9.0",
88# "marimo",
99# "matplotlib==3.10.3",
10- # "numpy==2.3.1",
11- # "pandas==2.3.0",
1210# "pyproj==3.7.1",
1311# "requests==2.32.4",
1412# "shapely==2.1.1",
@@ -31,19 +29,14 @@ def _():
3129 import platform
3230 import sys
3331 import zipfile
34- from pathlib import Path
3532
3633 import folium
3734 import geopandas as gpd
3835 import mapclassify
3936 import marimo as mo
4037 import matplotlib
41- import numpy as np
42- import pandas as pd
43- import requests
44- from pyproj import CRS , Transformer
45- from pyproj .crs .crs import CompoundCRS
46- from shapely import Point , wkt
38+ from pyproj import CRS
39+ from shapely import Point
4740
4841 from bedrock_ge .gi .ags import ags_to_brgi_db_mapping
4942 from bedrock_ge .gi .db_operations import merge_dbs
@@ -52,7 +45,8 @@ def _():
5245 from bedrock_ge .gi .mapper import map_to_brgi_db
5346 from bedrock_ge .gi .write import write_brgi_db_to_file
5447
55- print (platform .system ())
48+ platform_system = platform .system ()
49+ print (platform_system )
5650 print (sys .version )
5751 # print(sys.executable)
5852 return (
@@ -67,7 +61,7 @@ def _():
6761 merge_dbs ,
6862 mo ,
6963 platform ,
70- requests ,
64+ platform_system ,
7165 write_brgi_db_to_file ,
7266 zipfile ,
7367 )
@@ -122,13 +116,20 @@ def _(mo):
122116
123117
124118@app .cell
125- def _ (io , requests ):
119+ async def _ (io , platform_system ):
126120 # Read ZIP from disk after downloading manually
127121 # zip = Path.home() / "Downloads" / "kaitak_ags3.zip"
128122
129123 # Request ZIP from GitHub
130124 raw_githubusercontent_url = "https://raw.githubusercontent.com/bedrock-engineer/bedrock-ge/main/examples/hk_kaitak_ags3/kaitak_ags3.zip"
131- zip = io .BytesIO (requests .get (raw_githubusercontent_url ).content )
125+ # When running this marimo notebook in WebAssembly (WASM, a.k.a. Emscripten), use pyodide to request the data
126+ if platform_system == "Emscripten" :
127+ from pyodide .http import pyfetch
128+ response = await pyfetch (raw_githubusercontent_url )
129+ zip = io .BytesIO (await response .bytes ())
130+ else :
131+ import requests
132+ zip = io .BytesIO (requests .get (raw_githubusercontent_url ).content )
132133 return (zip ,)
133134
134135
0 commit comments