From 52e09d500dcc41fb557f3294ef00415b41bf0d28 Mon Sep 17 00:00:00 2001 From: Andrew Barna Date: Fri, 13 Dec 2024 18:58:10 -0800 Subject: [PATCH] Revert "Reapply "convert exchange checker to use web workers"" This causes an infinite loop on github pages as well... This reverts commit b2d059918cdd88615cb5bfdbc282a6873ac6071c. --- docs/_exchange_checker_include.html | 202 ++++++++++++++++++---------- docs/_static/convert_exchange.py | 72 ---------- docs/_static/derrived_makers.py | 31 ----- docs/_static/sw.js | 28 ---- docs/exchange_checker.md | 2 +- 5 files changed, 129 insertions(+), 206 deletions(-) delete mode 100644 docs/_static/convert_exchange.py delete mode 100644 docs/_static/derrived_makers.py delete mode 100644 docs/_static/sw.js diff --git a/docs/_exchange_checker_include.html b/docs/_exchange_checker_include.html index 36a5f57..9393084 100644 --- a/docs/_exchange_checker_include.html +++ b/docs/_exchange_checker_include.html @@ -1,102 +1,151 @@ -

cchdo.hydro version:
cchdo.params version:

- +

Options

- +

- Loading Python Runtime +
-

Log Console

-
-
- - -
-
- - - - + \ No newline at end of file + +

Python Log Console

+ + +packages = ["xarray", "cchdo.hydro<=1.0.2.8", "netcdf4"] + \ No newline at end of file diff --git a/docs/_static/convert_exchange.py b/docs/_static/convert_exchange.py deleted file mode 100644 index bbbd9b3..0000000 --- a/docs/_static/convert_exchange.py +++ /dev/null @@ -1,72 +0,0 @@ -import io -import json -import logging -import traceback -from html import escape - -from js import Uint8Array, console # noqa: F401 -from pyscript import display # type: ignore - -from cchdo.hydro import __version__ as hydro_version -from cchdo.hydro import accessors, read_exchange # noqa: F401 -from cchdo.params import __version__ as params_version - - -def logger(msg): - display(msg, target="log", append=True) - - -class DisplaylHandler(logging.Handler): - def emit(self, record) -> None: - logger(self.formatter.format(record)) # type: ignore - - -root = logging.getLogger() -root.setLevel(logging.DEBUG) - -handler = DisplaylHandler() -handler.setLevel(logging.DEBUG) -formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") -handler.setFormatter(formatter) -root.addHandler(handler) - - -def versions(): - return { - "hydro_version": hydro_version, - "params_version": params_version, - } - - -def to_netcdf(ex): - ex.to_netcdf("out.nc") - with open("out.nc", "rb") as f: - return f.read() - - -class Pre: - def __init__(self, text): - self.value = text - - def _repr_html_(self): - return f"
{escape(self.value)}
" - - -def to_xarray(array_buffer, checks): - checks = json.loads(checks) - logger(checks) - logger("to_xarray called") - bytes = bytearray(Uint8Array.new(array_buffer)) - logger("got bytes") - ex_bytes = io.BytesIO(bytes) - try: - ex = read_exchange(ex_bytes, checks=checks) - logger("success! makeing a netCDF file") - except ValueError as er: - display(Pre("".join(traceback.format_exception(er))), target="log", append=True) - display(er.error_data, target="log", append=True) - raise # this is so the promise rejects and the main thread knows what's up - return to_netcdf(ex), ex.cchdo.gen_fname() - - -__export__ = ["to_xarray", "versions"] diff --git a/docs/_static/derrived_makers.py b/docs/_static/derrived_makers.py deleted file mode 100644 index 258db7a..0000000 --- a/docs/_static/derrived_makers.py +++ /dev/null @@ -1,31 +0,0 @@ -import xarray as xr -from js import Uint8Array -from pyscript import display - -from cchdo.hydro import accessors # noqa: F401 - - -def logger(msg): - display(msg, target="log", append=True) - - -def load_netcdf(array_buffer): - with open("out.nc", "wb") as f: - f.write(bytearray(Uint8Array.new(array_buffer))) - return xr.load_dataset("out.nc") - - -def make_derived(array_buffer, type): - logger(type) - xr = load_netcdf(array_buffer) - if type == "to_sum": - return xr.cchdo.to_sum(), "summary.txt" - if type == "to_woce": - return xr.cchdo.to_woce(), xr.cchdo.gen_fname("woce") - if type == "to_coards": - return xr.cchdo.to_coards(), xr.cchdo.gen_fname("coards") - - -__export__ = [ - "make_derived", -] diff --git a/docs/_static/sw.js b/docs/_static/sw.js deleted file mode 100644 index 9fbfc47..0000000 --- a/docs/_static/sw.js +++ /dev/null @@ -1,28 +0,0 @@ -/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */ -/*! mini-coi - Andrea Giammarchi and contributors, licensed under MIT */ -(({ document: d, navigator: { serviceWorker: s } }) => { - if (d) { - const { currentScript: c } = d; - s.register(c.src, { scope: c.getAttribute('scope') || '.' }).then(r => { - r.addEventListener('updatefound', () => location.reload()); - if (r.active && !s.controller) location.reload(); - }); - } - else { - addEventListener('install', () => skipWaiting()); - addEventListener('activate', e => e.waitUntil(clients.claim())); - addEventListener('fetch', e => { - const { request: r } = e; - if (r.cache === 'only-if-cached' && r.mode !== 'same-origin') return; - e.respondWith(fetch(r).then(r => { - const { body, status, statusText } = r; - if (!status || status > 399) return r; - const h = new Headers(r.headers); - h.set('Cross-Origin-Opener-Policy', 'same-origin'); - h.set('Cross-Origin-Embedder-Policy', 'require-corp'); - h.set('Cross-Origin-Resource-Policy', 'cross-origin'); - return new Response(body, { status, statusText, headers: h }); - })); - }); - } - })(self); \ No newline at end of file diff --git a/docs/exchange_checker.md b/docs/exchange_checker.md index 96996a5..a0aa497 100644 --- a/docs/exchange_checker.md +++ b/docs/exchange_checker.md @@ -4,7 +4,7 @@ It will also output the other legacy formats at CCHDO: WOCE, the COARDS netCDF f This converter is only available in the html/browser versions of the documentation. :::{note} -Processing a CTD file can take a long time. +Processing a CTD file can take a long time and I don't yet know how to show progress in the browser. ::: :::{warning}