SaulLu commited on
Commit
c48bbc0
β€’
2 Parent(s): f3aa1a2 b3bb8cb

Add a fix to avoid "component Error" (#4)

Browse files
.gitignore CHANGED
@@ -1,10 +1,10 @@
1
  streamlit_observable/frontend/node_modules/*
2
  streamlit_observable/frontend/public/*
3
- streamlit_observable/frontend/src/*
4
  streamlit_observable/frontend/.env*
5
  streamlit_observable/frontend/.prettierrc*
6
  streamlit_observable/frontend/package.json*
7
  streamlit_observable/frontend/package-lock.json*
8
  streamlit_observable/frontend/tsconfig.json*
9
-
 
10
  *__pycache__*
 
1
  streamlit_observable/frontend/node_modules/*
2
  streamlit_observable/frontend/public/*
 
3
  streamlit_observable/frontend/.env*
4
  streamlit_observable/frontend/.prettierrc*
5
  streamlit_observable/frontend/package.json*
6
  streamlit_observable/frontend/package-lock.json*
7
  streamlit_observable/frontend/tsconfig.json*
8
+ streamlit_observable/frontend/src/observable_code*
9
+ .streamlit/secrets.toml*
10
  *__pycache__*
app.py CHANGED
@@ -137,6 +137,7 @@ observable(
137
  notebook="d/9ae236a507f54046", # "@huggingface/participants-bubbles-chart",
138
  targets=["c_noaws"],
139
  redefine={"serializedData": serialized_data, "profileSimple": profiles, "width": 0},
 
140
  )
141
  placeholder_chart_c2_3.dataframe(df_leaderboard[["User", "Total time contributed"]])
142
 
 
137
  notebook="d/9ae236a507f54046", # "@huggingface/participants-bubbles-chart",
138
  targets=["c_noaws"],
139
  redefine={"serializedData": serialized_data, "profileSimple": profiles, "width": 0},
140
+ render_empty=True,
141
  )
142
  placeholder_chart_c2_3.dataframe(df_leaderboard[["User", "Total time contributed"]])
143
 
dashboard_utils/bubbles.py CHANGED
@@ -11,7 +11,7 @@ from requests_futures.sessions import FuturesSession
11
  from dashboard_utils.time_tracker import _log, simple_time_tracker
12
 
13
  URL_QUICKSEARCH = "https://huggingface.co/api/quicksearch?"
14
- WANDB_REPO = "learning-at-home/Worker_logs"
15
  CACHE_TTL = 100
16
  MAX_DELTA_ACTIVE_RUN_SEC = 60 * 5
17
 
 
11
  from dashboard_utils.time_tracker import _log, simple_time_tracker
12
 
13
  URL_QUICKSEARCH = "https://huggingface.co/api/quicksearch?"
14
+ WANDB_REPO = st.secrets["WANDB_REPO_INDIVIDUAL_METRICS"]
15
  CACHE_TTL = 100
16
  MAX_DELTA_ACTIVE_RUN_SEC = 60 * 5
17
 
dashboard_utils/main_metrics.py CHANGED
@@ -5,7 +5,7 @@ import wandb
5
 
6
  from dashboard_utils.time_tracker import _log, simple_time_tracker
7
 
8
- WANDB_REPO = "learning-at-home/Main_metrics"
9
  CACHE_TTL = 100
10
 
11
 
 
5
 
6
  from dashboard_utils.time_tracker import _log, simple_time_tracker
7
 
8
+ WANDB_REPO = st.secrets["WANDB_REPO_MAIN_METRICS"]
9
  CACHE_TTL = 100
10
 
11
 
streamlit_observable/__init__.py CHANGED
@@ -15,7 +15,7 @@ else:
15
  _component_func = components.declare_component("observable", path=build_dir)
16
 
17
 
18
- def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[]):
19
  """Create a new instance of "observable".
20
 
21
  Parameters
@@ -49,7 +49,7 @@ def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[]):
49
 
50
  """
51
  component_value = _component_func(
52
- notebook=notebook, targets=targets, observe=observe, redefine=redefine, hide=hide, key=key, name=key
53
  )
54
 
55
  if component_value is None:
 
15
  _component_func = components.declare_component("observable", path=build_dir)
16
 
17
 
18
+ def observable(key, notebook, targets=None, redefine={}, observe=[], hide=[], render_empty=False):
19
  """Create a new instance of "observable".
20
 
21
  Parameters
 
49
 
50
  """
51
  component_value = _component_func(
52
+ notebook=notebook, targets=targets, observe=observe, redefine=redefine, hide=hide, render_empty=render_empty, key=key, name=key
53
  )
54
 
55
  if component_value is None:
streamlit_observable/frontend/build/asset-manifest.json CHANGED
@@ -1,20 +1,20 @@
1
  {
2
  "files": {
3
- "main.js": "./static/js/main.5bdac2e3.chunk.js",
4
- "main.js.map": "./static/js/main.5bdac2e3.chunk.js.map",
5
  "runtime-main.js": "./static/js/runtime-main.11ec9aca.js",
6
  "runtime-main.js.map": "./static/js/runtime-main.11ec9aca.js.map",
7
  "static/js/2.b1c975ff.chunk.js": "./static/js/2.b1c975ff.chunk.js",
8
  "static/js/2.b1c975ff.chunk.js.map": "./static/js/2.b1c975ff.chunk.js.map",
9
  "index.html": "./index.html",
10
- "precache-manifest.8096ee623e3f349cc3813a91ceb00929.js": "./precache-manifest.8096ee623e3f349cc3813a91ceb00929.js",
11
  "service-worker.js": "./service-worker.js",
12
  "static/js/2.b1c975ff.chunk.js.LICENSE.txt": "./static/js/2.b1c975ff.chunk.js.LICENSE.txt",
13
- "static/js/main.5bdac2e3.chunk.js.LICENSE.txt": "./static/js/main.5bdac2e3.chunk.js.LICENSE.txt"
14
  },
15
  "entrypoints": [
16
  "static/js/runtime-main.11ec9aca.js",
17
  "static/js/2.b1c975ff.chunk.js",
18
- "static/js/main.5bdac2e3.chunk.js"
19
  ]
20
  }
 
1
  {
2
  "files": {
3
+ "main.js": "./static/js/main.fc603b94.chunk.js",
4
+ "main.js.map": "./static/js/main.fc603b94.chunk.js.map",
5
  "runtime-main.js": "./static/js/runtime-main.11ec9aca.js",
6
  "runtime-main.js.map": "./static/js/runtime-main.11ec9aca.js.map",
7
  "static/js/2.b1c975ff.chunk.js": "./static/js/2.b1c975ff.chunk.js",
8
  "static/js/2.b1c975ff.chunk.js.map": "./static/js/2.b1c975ff.chunk.js.map",
9
  "index.html": "./index.html",
10
+ "precache-manifest.2e1db2924cb1e112608cee049b0d33cc.js": "./precache-manifest.2e1db2924cb1e112608cee049b0d33cc.js",
11
  "service-worker.js": "./service-worker.js",
12
  "static/js/2.b1c975ff.chunk.js.LICENSE.txt": "./static/js/2.b1c975ff.chunk.js.LICENSE.txt",
13
+ "static/js/main.fc603b94.chunk.js.LICENSE.txt": "./static/js/main.fc603b94.chunk.js.LICENSE.txt"
14
  },
15
  "entrypoints": [
16
  "static/js/runtime-main.11ec9aca.js",
17
  "static/js/2.b1c975ff.chunk.js",
18
+ "static/js/main.fc603b94.chunk.js"
19
  ]
20
  }
streamlit_observable/frontend/build/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><title>Streamlit Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit Component"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@observablehq/inspector@3/dist/inspector.css"/></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,l,a=t[0],p=t[1],i=t[2],c=0,s=[];c<a.length;c++)l=a[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(f&&f(t);s.length;)s.shift()();return u.push.apply(u,i||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,a=1;a<r.length;a++){var p=r[a];0!==o[p]&&(n=!1)}n&&(u.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},o={1:0},u=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="./";var a=this.webpackJsonpstreamlit_component_template=this.webpackJsonpstreamlit_component_template||[],p=a.push.bind(a);a.push=t,a=a.slice();for(var i=0;i<a.length;i++)t(a[i]);var f=p;r()}([])</script><script src="./static/js/2.b1c975ff.chunk.js"></script><script src="./static/js/main.5bdac2e3.chunk.js"></script></body></html>
 
1
+ <!doctype html><html lang="en"><head><title>Streamlit Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit Component"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@observablehq/inspector@3/dist/inspector.css"/></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,l,a=t[0],p=t[1],i=t[2],c=0,s=[];c<a.length;c++)l=a[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(f&&f(t);s.length;)s.shift()();return u.push.apply(u,i||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,a=1;a<r.length;a++){var p=r[a];0!==o[p]&&(n=!1)}n&&(u.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},o={1:0},u=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="./";var a=this.webpackJsonpstreamlit_component_template=this.webpackJsonpstreamlit_component_template||[],p=a.push.bind(a);a.push=t,a=a.slice();for(var i=0;i<a.length;i++)t(a[i]);var f=p;r()}([])</script><script src="./static/js/2.b1c975ff.chunk.js"></script><script src="./static/js/main.fc603b94.chunk.js"></script></body></html>
streamlit_observable/frontend/build/{precache-manifest.8096ee623e3f349cc3813a91ceb00929.js β†’ precache-manifest.2e1db2924cb1e112608cee049b0d33cc.js} RENAMED
@@ -1,6 +1,6 @@
1
  self.__precacheManifest = (self.__precacheManifest || []).concat([
2
  {
3
- "revision": "2ec6acc026cff43b53185364bb91d16e",
4
  "url": "./index.html"
5
  },
6
  {
@@ -12,12 +12,12 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
12
  "url": "./static/js/2.b1c975ff.chunk.js.LICENSE.txt"
13
  },
14
  {
15
- "revision": "36b8de6fe4fc2eeae54b",
16
- "url": "./static/js/main.5bdac2e3.chunk.js"
17
  },
18
  {
19
  "revision": "6515c66d2a8747a146d578e1c038a822",
20
- "url": "./static/js/main.5bdac2e3.chunk.js.LICENSE.txt"
21
  },
22
  {
23
  "revision": "7c26bca7e16783d14d15",
 
1
  self.__precacheManifest = (self.__precacheManifest || []).concat([
2
  {
3
+ "revision": "1c6ba26604bc12847ab74fcdb45b2542",
4
  "url": "./index.html"
5
  },
6
  {
 
12
  "url": "./static/js/2.b1c975ff.chunk.js.LICENSE.txt"
13
  },
14
  {
15
+ "revision": "3301eac1eaca974776ae",
16
+ "url": "./static/js/main.fc603b94.chunk.js"
17
  },
18
  {
19
  "revision": "6515c66d2a8747a146d578e1c038a822",
20
+ "url": "./static/js/main.fc603b94.chunk.js.LICENSE.txt"
21
  },
22
  {
23
  "revision": "7c26bca7e16783d14d15",
streamlit_observable/frontend/build/service-worker.js CHANGED
@@ -14,7 +14,7 @@
14
  importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
 
16
  importScripts(
17
- "./precache-manifest.8096ee623e3f349cc3813a91ceb00929.js"
18
  );
19
 
20
  self.addEventListener('message', (event) => {
 
14
  importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
 
16
  importScripts(
17
+ "./precache-manifest.2e1db2924cb1e112608cee049b0d33cc.js"
18
  );
19
 
20
  self.addEventListener('message', (event) => {
streamlit_observable/frontend/build/static/js/main.5bdac2e3.chunk.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["streamlit/streamlit.ts","streamlit/ArrowTable.ts","streamlit/StreamlitReact.tsx","Observable.tsx","index.tsx"],"names":["ComponentMessageType","ArrowTable","dataBuffer","indexBuffer","columnsBuffer","styler","dataTable","indexTable","columnsTable","getCell","rowIndex","columnIndex","isBlankCell","headerRows","headerColumns","isIndexCell","isColumnsCell","classNames","push","type","join","content","dataColumnIndex","getContent","dataRowIndex","id","uuid","displayValuesTable","table","column","getColumnAt","getColumnTypeId","Type","Timestamp","nanosToDate","get","this","Table","from","caption","styles","undefined","length","numCols","rows","dataRows","columns","dataColumns","schema","fields","typeId","nanos","Date","Streamlit","API_VERSION","RENDER_EVENT","events","EventTarget","registeredMessageListener","lastFrameHeight","setComponentReady","window","addEventListener","onMessageEvent","sendBackMsg","COMPONENT_READY","apiVersion","setFrameHeight","height","document","body","scrollHeight","SET_FRAME_HEIGHT","setComponentValue","value","SET_COMPONENT_VALUE","event","data","onRenderMessage","args","console","error","dataframeArgs","argsDataframeToObject","eventData","disabled","Boolean","CustomEvent","detail","dispatchEvent","argsDataframe","argsDataframeArrow","map","key","toArrowTable","Object","fromEntries","df","index","parent","postMessage","isStreamlitMessage","StreamlitComponentBase","React","PureComponent","withStreamlitConnection","WrappedComponent","ComponentWrapper","props","componentDidMount","onRenderEvent","componentDidUpdate","prevProps","state","componentError","componentWillUnmount","removeEventListener","renderEvent","setState","renderData","render","message","width","innerWidth","getDerivedStateFromError","hoistNonReactStatics","Observable","observeValue","notebookRef","createRef","runtime","main","style","border","borderRadius","padding","ref","marginTop","backgroundColor","fontWeight","gridTemplateColumns","display","textAlign","name","href","notebook","color","dispose","redefineCells","redefine","targets","observe","hide","a","targetSet","Set","observeSet","hideSet","Runtime","eval","define","default","module","has","fulfilled","size","el","createElement","current","appendChild","i","Inspector","e","pending","rejected","Promise","all","Array","then","initial","cell","embedNotebook","ReactDOM","StrictMode","getElementById"],"mappings":";uPA4BKA,E,sFCoBQC,EAAb,WAME,WACEC,EACAC,EACAC,EACAC,GACC,IAAD,gCAVeC,eAUf,OATeC,gBASf,OAReC,kBAQf,OAPeH,YAOf,OA8DKI,QAAU,SAACC,EAAkBC,GAClC,IAAMC,EACJF,EAAW,EAAKG,YAAcF,EAAc,EAAKG,cAC7CC,EACJL,GAAY,EAAKG,YAAcF,EAAc,EAAKG,cAC9CE,EACJN,EAAW,EAAKG,YAAcF,GAAe,EAAKG,cAEpD,GAAIF,EAAa,CACf,IAAMK,EAAa,CAAC,SAKpB,OAJIN,EAAc,GAChBM,EAAWC,KAAK,QAAUR,GAGrB,CACLS,KAAM,QACNF,WAAYA,EAAWG,KAAK,KAC5BC,QAAS,IAEN,GAAIL,EAAe,CACxB,IAAMM,EAAkBX,EAAc,EAAKG,cAO3C,MAAO,CACLK,KAAM,UACNF,WARiB,CACjB,cACA,QAAUP,EACV,MAAQY,GAKeF,KAAK,KAC5BC,QAAS,EAAKE,WAAW,EAAKf,aAAcc,EAAiBZ,IAE1D,GAAIK,EAAa,CACtB,IAAMS,EAAed,EAAW,EAAKG,WAC/BI,EAAa,CACjB,cACA,QAAUN,EACV,MAAQa,GAGV,MAAO,CACLL,KAAM,QACNM,GAAG,KAAD,OAAO,EAAKC,KAAZ,gBAAwBf,EAAxB,eAA0Ca,GAC5CP,WAAYA,EAA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A2B,OAAKZ,KAAKzD,MAAMqE,GAA3C,oGAA3B,wDAA+EmC,MAAK,SAAAC,GAAY,IAAD,kSAC7EA,GAD6E,IACzG,2BAAqC,CAAC,IAAD,+RAAzBpC,EAAyB,KAAnBrE,EAAmB,KAEnC,OAAKqD,aAAagB,GAAQrE,GAH6E,8BAKzGrB,0CAAUoB,kBAAkB,OAAKsD,iBAnDvC,gE,gIAwDA,SAAcI,GAA2B,IAAhBkB,EAAe,uDAAJ,GAClC,IAAK,IAAI+B,KAAQ/B,EAEflB,EAAKkB,SAAS+B,EAAM/B,EAAS+B,M,+BAGjC,WAAqB,IAAD,OAClB,EAAyEhJ,KAAKwE,MAAM7B,KAA5EkE,EAAR,EAAQA,SAAR,IAAkBK,eAAlB,MAA4B,GAA5B,MAAgCC,eAAhC,MAA0C,GAA1C,MAA8CF,gBAA9C,MAAyD,GAAzD,MAA8DG,YAA9D,MAAmE,GAAnE,EACAnG,0CAAUoB,kBAAkBrC,KAAK2F,cACjC3F,KAAKiJ,cAAcpC,EAAUK,EAASC,EAASC,GAAM0B,MAAK,WACxD,EAAK9B,cAAc,EAAKjB,KAAMkB,U,YApFX/C,2CAoHVG,wEAAwBqB,a,oEC5HvC,qDAIAwD,IAAS9D,OACP,kBAAC,IAAM+D,WAAP,KACE,kBAAC,IAAD,OAEFlH,SAASmH,eAAe,W","file":"static/js/main.5bdac2e3.chunk.js","sourcesContent":["/**\n * @license\n * Copyright 2018-2020 Streamlit Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Safari doesn't support the EventTarget class, so we use a shim.\nimport { EventTarget } from \"event-target-shim\"\nimport { ArrowDataframeProto, ArrowTable } from \"./ArrowTable\"\n\n/** Data sent in the custom Streamlit render event. */\nexport interface RenderData {\n args: any\n disabled: boolean\n}\n\n/** Messages from Component -> Streamlit */\nenum ComponentMessageType {\n // A component sends this message when it's ready to receive messages\n // from Streamlit. Streamlit won't send any messages until it gets this.\n // Data: { apiVersion: number }\n COMPONENT_READY = \"streamlit:componentReady\",\n\n // The component has a new widget value. Send it back to Streamlit, which\n // will then re-run the app.\n // Data: { value: any }\n SET_COMPONENT_VALUE = \"streamlit:setComponentValue\",\n\n // The component has a new height for its iframe.\n // Data: { height: number }\n SET_FRAME_HEIGHT = \"streamlit:setFrameHeight\",\n}\n\n/**\n * Streamlit communication API.\n *\n * Components can send data to Streamlit via the functions defined here,\n * and receive data from Streamlit via the `events` property.\n */\nexport class Streamlit {\n /**\n * The Streamlit component API version we're targetting.\n * There's currently only 1!\n */\n public static readonly API_VERSION = 1\n\n public static readonly RENDER_EVENT = \"streamlit:render\"\n\n /** Dispatches events received from Streamlit. */\n public static readonly events = new EventTarget()\n\n private static registeredMessageListener = false\n private static lastFrameHeight?: number\n\n /**\n * Tell Streamlit that the component is ready to start receiving data.\n * Streamlit will defer emitting RENDER events until it receives the\n * COMPONENT_READY message.\n */\n public static setComponentReady = (): void => {\n if (!Streamlit.registeredMessageListener) {\n // Register for message events if we haven't already\n window.addEventListener(\"message\", Streamlit.onMessageEvent)\n Streamlit.registeredMessageListener = true\n }\n\n Streamlit.sendBackMsg(ComponentMessageType.COMPONENT_READY, {\n apiVersion: Streamlit.API_VERSION,\n })\n }\n\n /**\n * Report the component's height to Streamlit.\n * This should be called every time the component changes its DOM - that is,\n * when it's first loaded, and any time it updates.\n */\n public static setFrameHeight = (height?: number): void => {\n if (height === undefined) {\n // `height` is optional. If undefined, it defaults to scrollHeight,\n // which is the entire height of the element minus its border,\n // scrollbar, and margin.\n height = document.body.scrollHeight + 10;\n }\n\n if (height === Streamlit.lastFrameHeight) {\n // Don't bother updating if our height hasn't changed.\n return\n }\n\n Streamlit.lastFrameHeight = height\n Streamlit.sendBackMsg(ComponentMessageType.SET_FRAME_HEIGHT, { height })\n }\n\n /**\n * Set the component's value. This value will be returned to the Python\n * script, and the script will be re-run.\n *\n * For example:\n *\n * JavaScript:\n * Streamlit.setComponentValue(\"ahoy!\")\n *\n * Python:\n * value = st.my_component(...)\n * st.write(value) # -> \"ahoy!\"\n *\n * The value must be serializable into JSON.\n */\n public static setComponentValue = (value: any): void => {\n Streamlit.sendBackMsg(ComponentMessageType.SET_COMPONENT_VALUE, { value })\n }\n\n /** Receive a ForwardMsg from the Streamlit app */\n private static onMessageEvent = (event: MessageEvent): void => {\n const type = event.data[\"type\"]\n switch (type) {\n case Streamlit.RENDER_EVENT:\n Streamlit.onRenderMessage(event.data)\n break\n }\n }\n\n /**\n * Handle an untyped Streamlit render event and redispatch it as a\n * StreamlitRenderEvent.\n */\n private static onRenderMessage = (data: any): void => {\n let args = data[\"args\"]\n if (args == null) {\n console.error(\n `Got null args in onRenderMessage. This should never happen`\n )\n args = {}\n }\n\n // Parse our dataframe arguments with arrow, and merge them into our args dict\n const dataframeArgs =\n data[\"dfs\"] && data[\"dfs\"].length > 0\n ? Streamlit.argsDataframeToObject(data[\"dfs\"])\n : {}\n\n args = {\n ...args,\n ...dataframeArgs,\n }\n\n const disabled = Boolean(data[\"disabled\"])\n\n // Dispatch a render event!\n const eventData = { disabled, args }\n const event = new CustomEvent<RenderData>(Streamlit.RENDER_EVENT, {\n detail: eventData,\n })\n Streamlit.events.dispatchEvent(event)\n }\n\n private static argsDataframeToObject = (\n argsDataframe: ArgsDataframe[]\n ): object => {\n const argsDataframeArrow = argsDataframe.map(\n ({ key, value }: ArgsDataframe) => [key, Streamlit.toArrowTable(value)]\n )\n return Object.fromEntries(argsDataframeArrow)\n }\n\n private static toArrowTable = (df: ArrowDataframeProto): ArrowTable => {\n const { data, index, columns } = df.data\n return new ArrowTable(data, index, columns)\n }\n\n /** Post a message to the Streamlit app. */\n private static sendBackMsg = (type: string, data?: any): void => {\n window.parent.postMessage(\n {\n isStreamlitMessage: true,\n type: type,\n ...data,\n },\n \"*\"\n )\n }\n}\n\ninterface ArgsDataframe {\n key: string\n value: ArrowDataframeProto\n}\n","/**\n * @license\n * Copyright 2018-2019 Streamlit Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Table, Type } from \"apache-arrow\"\n\ntype CellType = \"blank\" | \"index\" | \"columns\" | \"data\"\n\nexport interface ArrowDataframeProto {\n data: ArrowTableProto\n height: string\n width: string\n}\n\nexport interface ArrowTableProto {\n data: Uint8Array\n index: Uint8Array\n columns: Uint8Array\n styler: Styler\n}\n\ninterface Cell {\n classNames: string\n content: string\n id?: string\n type: CellType\n}\n\ninterface Styler {\n caption?: string\n displayValuesTable: Table\n styles?: string\n uuid: string\n}\n\nexport class ArrowTable {\n private readonly dataTable: Table\n private readonly indexTable: Table\n private readonly columnsTable: Table\n private readonly styler?: Styler\n\n constructor(\n dataBuffer: Uint8Array,\n indexBuffer: Uint8Array,\n columnsBuffer: Uint8Array,\n styler?: any\n ) {\n this.dataTable = Table.from(dataBuffer)\n this.indexTable = Table.from(indexBuffer)\n this.columnsTable = Table.from(columnsBuffer)\n this.styler = styler\n ? {\n caption: styler.get(\"caption\"),\n displayValuesTable: Table.from(styler.get(\"displayValues\")),\n styles: styler.get(\"styles\"),\n uuid: styler.get(\"uuid\"),\n }\n : undefined\n }\n\n get rows(): number {\n return this.indexTable.length + this.columnsTable.numCols\n }\n\n get columns(): number {\n return this.indexTable.numCols + this.columnsTable.length\n }\n\n get headerRows(): number {\n return this.rows - this.dataRows\n }\n\n get headerColumns(): number {\n return this.columns - this.dataColumns\n }\n\n get dataRows(): number {\n return this.dataTable.length\n }\n\n get dataColumns(): number {\n return this.dataTable.numCols\n }\n\n get uuid(): string | undefined {\n return this.styler && this.styler.uuid\n }\n\n get caption(): string | undefined {\n return this.styler && this.styler.caption\n }\n\n get styles(): string | undefined {\n return this.styler && this.styler.styles\n }\n\n get table(): Table {\n return this.dataTable\n }\n\n get index(): Table {\n return this.indexTable\n }\n\n get columnTable(): Table {\n return this.columnsTable\n }\n\n public getCell = (rowIndex: number, columnIndex: number): Cell => {\n const isBlankCell =\n rowIndex < this.headerRows && columnIndex < this.headerColumns\n const isIndexCell =\n rowIndex >= this.headerRows && columnIndex < this.headerColumns\n const isColumnsCell =\n rowIndex < this.headerRows && columnIndex >= this.headerColumns\n\n if (isBlankCell) {\n const classNames = [\"blank\"]\n if (columnIndex > 0) {\n classNames.push(\"level\" + rowIndex)\n }\n\n return {\n type: \"blank\",\n classNames: classNames.join(\" \"),\n content: \"\",\n }\n } else if (isColumnsCell) {\n const dataColumnIndex = columnIndex - this.headerColumns\n const classNames = [\n \"col_heading\",\n \"level\" + rowIndex,\n \"col\" + dataColumnIndex,\n ]\n\n return {\n type: \"columns\",\n classNames: classNames.join(\" \"),\n content: this.getContent(this.columnsTable, dataColumnIndex, rowIndex),\n }\n } else if (isIndexCell) {\n const dataRowIndex = rowIndex - this.headerRows\n const classNames = [\n \"row_heading\",\n \"level\" + columnIndex,\n \"row\" + dataRowIndex,\n ]\n\n return {\n type: \"index\",\n id: `T_${this.uuid}level${columnIndex}_row${dataRowIndex}`,\n classNames: classNames.join(\" \"),\n content: this.getContent(this.indexTable, dataRowIndex, columnIndex),\n }\n } else {\n const dataRowIndex = rowIndex - this.headerRows\n const dataColumnIndex = columnIndex - this.headerColumns\n const classNames = [\n \"data\",\n \"row\" + dataRowIndex,\n \"col\" + dataColumnIndex,\n ]\n const content = this.styler\n ? this.getContent(\n this.styler.displayValuesTable,\n dataRowIndex,\n dataColumnIndex\n )\n : this.getContent(this.dataTable, dataRowIndex, dataColumnIndex)\n\n return {\n type: \"data\",\n id: `T_${this.uuid}row${dataRowIndex}_col${dataColumnIndex}`,\n classNames: classNames.join(\" \"),\n content,\n }\n }\n }\n\n public getContent = (\n table: Table,\n rowIndex: number,\n columnIndex: number\n ): any => {\n const column = table.getColumnAt(columnIndex)\n if (column === null) {\n return \"\"\n }\n\n const columnTypeId = this.getColumnTypeId(table, columnIndex)\n switch (columnTypeId) {\n case Type.Timestamp: {\n return this.nanosToDate(column.get(rowIndex))\n }\n default: {\n return column.get(rowIndex)\n }\n }\n }\n\n /**\n * Returns apache-arrow specific typeId of column.\n */\n private getColumnTypeId(table: Table, columnIndex: number): Type {\n return table.schema.fields[columnIndex].type.typeId\n }\n\n private nanosToDate(nanos: number): Date {\n return new Date(nanos / 1e6)\n }\n}\n","import hoistNonReactStatics from \"hoist-non-react-statics\"\nimport React, { ReactNode } from \"react\"\nimport { RenderData, Streamlit } from \"./streamlit\"\n\n/**\n * Props passed to custom Streamlit components.\n */\nexport interface ComponentProps {\n /** Named dictionary of arguments passed from Python. */\n args: any\n\n /** The component's width. */\n width: number\n\n /**\n * True if the component should be disabled.\n * All components get disabled while the app is being re-run,\n * and become re-enabled when the re-run has finished.\n */\n disabled: boolean\n}\n\n/**\n * Optional Streamlit React-based component base class.\n *\n * You are not required to extend this base class to create a Streamlit\n * component. If you decide not to extend it, you should implement the\n * `componentDidMount` and `componentDidUpdate` functions in your own class,\n * so that your plugin properly resizes.\n */\nexport class StreamlitComponentBase<S = {}> extends React.PureComponent<\n ComponentProps,\n S\n > {\n public componentDidMount(): void {\n // After we're rendered for the first time, tell Streamlit that our height\n // has changed.\n Streamlit.setFrameHeight()\n }\n\n public componentDidUpdate(): void {\n // After we're updated, tell Streamlit that our height may have changed.\n Streamlit.setFrameHeight()\n }\n}\n\n/**\n * Wrapper for React-based Streamlit components.\n *\n * Bootstraps the communication interface between Streamlit and the component.\n */\nexport function withStreamlitConnection(\n WrappedComponent: React.ComponentType<ComponentProps>\n): React.ComponentType {\n interface WrapperProps { }\n\n interface WrapperState {\n renderData?: RenderData\n componentError?: Error\n }\n\n class ComponentWrapper extends React.PureComponent<\n WrapperProps,\n WrapperState\n > {\n public constructor(props: WrapperProps) {\n super(props)\n this.state = {\n renderData: undefined,\n componentError: undefined,\n }\n }\n\n /**\n * Error boundary function. This will be called if our wrapped\n * component throws an error. We store the caught error in our state,\n * and display it in the next render().\n */\n public static getDerivedStateFromError = (\n error: Error\n ): Partial<WrapperState> => {\n return { componentError: error }\n }\n\n public componentDidMount = (): void => {\n // Set up event listeners, and signal to Streamlit that we're ready.\n // We won't render the component until we receive the first RENDER_EVENT.\n Streamlit.events.addEventListener(\n Streamlit.RENDER_EVENT,\n this.onRenderEvent\n )\n Streamlit.setComponentReady()\n }\n\n public componentDidUpdate = (prevProps: any): void => {\n // If our child threw an error, we display it in render(). In this\n // case, the child won't be mounted and therefore won't call\n // `setFrameHeight` on its own. We do it here so that the rendered\n // error will be visible.\n if (this.state.componentError != null) {\n Streamlit.setFrameHeight()\n }\n }\n\n public componentWillUnmount = (): void => {\n Streamlit.events.removeEventListener(\n Streamlit.RENDER_EVENT,\n this.onRenderEvent\n )\n }\n\n /**\n * Streamlit is telling this component to redraw.\n * We save the render data in State, so that it can be passed to the\n * component in our own render() function.\n */\n private onRenderEvent = (event: Event): void => {\n // Update our state with the newest render data\n const renderEvent = event as CustomEvent<RenderData>\n this.setState({ renderData: renderEvent.detail })\n }\n\n public render = (): ReactNode => {\n // If our wrapped component threw an error, display it.\n if (this.state.componentError != null) {\n return (\n <div>\n <h1>Component Error</h1>\n <span>{this.state.componentError.message}</span>\n </div>\n )\n }\n\n // Don't render until we've gotten our first RENDER_EVENT from Streamlit.\n if (this.state.renderData == null) {\n return null\n }\n\n return (\n <WrappedComponent\n width={window.innerWidth}\n disabled={this.state.renderData.disabled}\n args={this.state.renderData.args}\n />\n )\n }\n }\n\n return hoistNonReactStatics(ComponentWrapper, WrappedComponent)\n}\n","import React, { ReactNode } from \"react\"\nimport {\n withStreamlitConnection,\n StreamlitComponentBase,\n Streamlit,\n} from \"./streamlit\"\nimport { Runtime, Inspector } from \"@observablehq/runtime\";\n\nclass Observable extends StreamlitComponentBase<{}> {\n public observeValue = {};\n private notebookRef = React.createRef<HTMLDivElement>();\n private runtime: any = null;\n private main: any = null;\n\n componentWillUnmount() {\n this.runtime?.dispose();\n }\n // @ts-ignore\n public componentDidUpdate(prevProps: any) {\n const { args: prevArgs } = prevProps;\n if (prevArgs.notebook !== this.props.args.notebook) {\n // TODO handle new notebook\n }\n this.redefineCells(this.main, this.props.args.redefine);\n }\n\n async embedNotebook(notebook: string, targets: string[], observe: string[], hide:string[]) {\n if (this.runtime) {\n this.runtime.dispose();\n }\n const targetSet = new Set(targets);\n const observeSet = new Set(observe);\n const hideSet = new Set(hide);\n this.runtime = new Runtime();\n const { default: define } = await eval(`import(\"https://api.observablehq.com/${notebook}.js?v=3\")`);\n this.main = this.runtime.module(define, (name: string) => {\n if (observeSet.has(name) && !targetSet.has(name)) {\n const observeValue = this.observeValue;\n return {\n fulfilled: (value: any) => {\n //@ts-ignore\n observeValue[name] = value;\n //@ts-ignore\n Streamlit.setComponentValue(observeValue);\n }\n }\n }\n if (targetSet.size > 0 && !targetSet.has(name)) return;\n if(hideSet.has(name)) return true;\n const el = document.createElement('div');\n this.notebookRef.current?.appendChild(el);\n\n const i = new Inspector(el);\n el.addEventListener('input', e => {\n Streamlit.setFrameHeight();\n })\n return {\n pending() {\n i.pending();\n Streamlit.setFrameHeight();\n },\n fulfilled(value: any) {\n i.fulfilled(value);\n Streamlit.setFrameHeight();\n },\n rejected(error: any) {\n i.rejected(error);\n Streamlit.setFrameHeight();\n },\n };\n });\n if (observeSet.size > 0) {\n Promise.all(Array.from(observeSet).map(async name => [name, await this.main.value(name)])).then(initial => {\n for (const [name, value] of initial) {\n // @ts-ignore\n this.observeValue[name] = value\n };\n Streamlit.setComponentValue(this.observeValue);\n })\n }\n }\n\n redefineCells(main: any, redefine = {}) {\n for (let cell in redefine) {\n //@ts-ignore\n main.redefine(cell, redefine[cell]);\n }\n }\n componentDidMount() {\n const { notebook, targets = [], observe = [], redefine = {} , hide=[]} = this.props.args;\n Streamlit.setComponentValue(this.observeValue);\n this.embedNotebook(notebook, targets, observe, hide).then(() => {\n this.redefineCells(this.main, redefine);\n });\n\n }\n\n public render = (): ReactNode => {\n return (\n <div style={{ border: '1px solid gray', borderRadius: '4px' }}>\n <div style={{ padding: '9px 12px' }}>\n <div ref={this.notebookRef}></div>\n </div>\n <div style={{ marginTop: '4px' }}>\n \n <div style={{\n backgroundColor: '#ddd',\n fontWeight: 700,\n padding: \".25rem .5rem\",\n borderRadius: '0 0 4px 4px',\n gridTemplateColumns: \"auto auto\",\n display:\"grid\"\n }}>\n <div style={{textAlign:\"left\"}}>{this.props.args.name}</div>\n <div style={{textAlign:\"right\"}}>\n <a href={`https://observablehq.com/${this.props.args.notebook}`} style={{ color: '#666', }}></a>\n </div>\n </div>\n </div>\n </div >\n )\n }\n}\n\nexport default withStreamlitConnection(Observable)\n","import React from \"react\"\nimport ReactDOM from \"react-dom\"\nimport Observable from \"./Observable\"\n\nReactDOM.render(\n <React.StrictMode>\n <Observable />\n </React.StrictMode>,\n document.getElementById(\"root\")\n)\n"],"sourceRoot":""}
 
 
streamlit_observable/frontend/build/static/js/{main.5bdac2e3.chunk.js β†’ main.fc603b94.chunk.js} RENAMED
@@ -1,3 +1,3 @@
1
- /*! For license information please see main.5bdac2e3.chunk.js.LICENSE.txt */
2
- (this.webpackJsonpstreamlit_component_template=this.webpackJsonpstreamlit_component_template||[]).push([[0],{18:function(e,_,t){"use strict";t.d(_,"b",(function(){return p})),t.d(_,"c",(function(){return E})),t.d(_,"a",(function(){return h}));var r,n=t(0),a=t(4),o=t(2),s=t(3),i=t(36),l=t.n(i),u=t(12),d=t.n(u),c=t(10),m=t(37),b=t(24),g=function(){function e(_,t,r,a){var o=this;Object(n.a)(this,e),this.dataTable=void 0,this.indexTable=void 0,this.columnsTable=void 0,this.styler=void 0,this.getCell=function(e,_){var t=e<o.headerRows&&_<o.headerColumns,r=e>=o.headerRows&&_<o.headerColumns,n=e<o.headerRows&&_>=o.headerColumns;if(t){var a=["blank"];return _>0&&a.push("level"+e),{type:"blank",classNames:a.join(" "),content:""}}if(n){var s=_-o.headerColumns;return{type:"columns",classNames:["col_heading","level"+e,"col"+s].join(" "),content:o.getContent(o.columnsTable,s,e)}}if(r){var i=e-o.headerRows,l=["row_heading","level"+_,"row"+i];return{type:"index",id:"T_".concat(o.uuid,"level").concat(_,"_row").concat(i),classNames:l.join(" "),content:o.getContent(o.indexTable,i,_)}}var u=e-o.headerRows,d=_-o.headerColumns,c=["data","row"+u,"col"+d],m=o.styler?o.getContent(o.styler.displayValuesTable,u,d):o.getContent(o.dataTable,u,d);return{type:"data",id:"T_".concat(o.uuid,"row").concat(u,"_col").concat(d),classNames:c.join(" "),content:m}},this.getContent=function(e,_,t){var r=e.getColumnAt(t);if(null===r)return"";switch(o.getColumnTypeId(e,t)){case b.b.Timestamp:return o.nanosToDate(r.get(_));default:return r.get(_)}},this.dataTable=b.a.from(_),this.indexTable=b.a.from(t),this.columnsTable=b.a.from(r),this.styler=a?{caption:a.get("caption"),displayValuesTable:b.a.from(a.get("displayValues")),styles:a.get("styles"),uuid:a.get("uuid")}:void 0}return Object(a.a)(e,[{key:"rows",get:function(){return this.indexTable.length+this.columnsTable.numCols}},{key:"columns",get:function(){return this.indexTable.numCols+this.columnsTable.length}},{key:"headerRows",get:function(){return this.rows-this.dataRows}},{key:"headerColumns",get:function(){return this.columns-this.dataColumns}},{key:"dataRows",get:function(){return this.dataTable.length}},{key:"dataColumns",get:function(){return this.dataTable.numCols}},{key:"uuid",get:function(){return this.styler&&this.styler.uuid}},{key:"caption",get:function(){return this.styler&&this.styler.caption}},{key:"styles",get:function(){return this.styler&&this.styler.styles}},{key:"table",get:function(){return this.dataTable}},{key:"index",get:function(){return this.indexTable}},{key:"columnTable",get:function(){return this.columnsTable}},{key:"getColumnTypeId",value:function(e,_){return e.schema.fields[_].type.typeId}},{key:"nanosToDate",value:function(e){return new Date(e/1e6)}}]),e}();!function(e){e.COMPONENT_READY="streamlit:componentReady",e.SET_COMPONENT_VALUE="streamlit:setComponentValue",e.SET_FRAME_HEIGHT="streamlit:setFrameHeight"}(r||(r={}));var h=function e(){Object(n.a)(this,e)};h.API_VERSION=1,h.RENDER_EVENT="streamlit:render",h.events=new m.a,h.registeredMessageListener=!1,h.lastFrameHeight=void 0,h.setComponentReady=function(){h.registeredMessageListener||(window.addEventListener("message",h.onMessageEvent),h.registeredMessageListener=!0),h.sendBackMsg(r.COMPONENT_READY,{apiVersion:h.API_VERSION})},h.setFrameHeight=function(e){void 0===e&&(e=document.body.scrollHeight+10),e!==h.lastFrameHeight&&(h.lastFrameHeight=e,h.sendBackMsg(r.SET_FRAME_HEIGHT,{height:e}))},h.setComponentValue=function(e){h.sendBackMsg(r.SET_COMPONENT_VALUE,{value:e})},h.onMessageEvent=function(e){switch(e.data.type){case h.RENDER_EVENT:h.onRenderMessage(e.data)}},h.onRenderMessage=function(e){var _=e.args;null==_&&(console.error("Got null args in onRenderMessage. This should never happen"),_={});var t=e.dfs&&e.dfs.length>0?h.argsDataframeToObject(e.dfs):{};_=Object(c.a)(Object(c.a)({},_),t);var r={disabled:Boolean(e.disabled),args:_},n=new CustomEvent(h.RENDER_EVENT,{detail:r});h.events.dispatchEvent(n)},h.argsDataframeToObject=function(e){var _=e.map((function(e){var _=e.key,t=e.value;return[_,h.toArrowTable(t)]}));return Object.fromEntries(_)},h.toArrowTable=function(e){var _=e.data,t=_.data,r=_.index,n=_.columns;return new g(t,r,n)},h.sendBackMsg=function(e,_){window.parent.postMessage(Object(c.a)({isStreamlitMessage:!0,type:e},_),"*")};var p=function(e){Object(o.a)(t,e);var _=Object(s.a)(t);function t(){return Object(n.a)(this,t),_.apply(this,arguments)}return Object(a.a)(t,[{key:"componentDidMount",value:function(){h.setFrameHeight()}},{key:"componentDidUpdate",value:function(){h.setFrameHeight()}}]),t}(d.a.PureComponent);function E(e){var _=function(_){Object(o.a)(r,_);var t=Object(s.a)(r);function r(_){var a;return Object(n.a)(this,r),(a=t.call(this,_)).componentDidMount=function(){h.events.addEventListener(h.RENDER_EVENT,a.onRenderEvent),h.setComponentReady()},a.componentDidUpdate=function(e){null!=a.state.componentError&&h.setFrameHeight()},a.componentWillUnmount=function(){h.events.removeEventListener(h.RENDER_EVENT,a.onRenderEvent)},a.onRenderEvent=function(e){var _=e;a.setState({renderData:_.detail})},a.render=function(){return null!=a.state.componentError?d.a.createElement("div",null,d.a.createElement("h1",null,"Component Error"),d.a.createElement("span",null,a.state.componentError.message)):null==a.state.renderData?null:d.a.createElement(e,{width:window.innerWidth,disabled:a.state.renderData.disabled,args:a.state.renderData.args})},a.state={renderData:void 0,componentError:void 0},a}return r}(d.a.PureComponent);return _.getDerivedStateFromError=function(e){return{componentError:e}},l()(_,e)}},35:function(module,__webpack_exports__,__webpack_require__){"use strict";var _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createForOfIteratorHelper__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(8),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(1),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(5),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(0),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(4),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(2),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(3),react__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(12),react__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_8__),_streamlit__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(18),_observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(30),Observable=function(_StreamlitComponentBa){Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_6__.a)(Observable,_StreamlitComponentBa);var _super=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_7__.a)(Observable);function Observable(){var e;Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_4__.a)(this,Observable);for(var _=arguments.length,t=new Array(_),r=0;r<_;r++)t[r]=arguments[r];return(e=_super.call.apply(_super,[this].concat(t))).observeValue={},e.notebookRef=react__WEBPACK_IMPORTED_MODULE_8___default.a.createRef(),e.runtime=null,e.main=null,e.render=function(){return react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{border:"1px solid gray",borderRadius:"4px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{padding:"9px 12px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{ref:e.notebookRef})),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{marginTop:"4px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{backgroundColor:"#ddd",fontWeight:700,padding:".25rem .5rem",borderRadius:"0 0 4px 4px",gridTemplateColumns:"auto auto",display:"grid"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"left"}},e.props.args.name),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"right"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("a",{href:"https://observablehq.com/".concat(e.props.args.notebook),style:{color:"#666"}})))))},e}return Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_5__.a)(Observable,[{key:"componentWillUnmount",value:function(){var e;null===(e=this.runtime)||void 0===e||e.dispose()}},{key:"componentDidUpdate",value:function(e){e.args.notebook,this.props.args.notebook,this.redefineCells(this.main,this.props.args.redefine)}},{key:"embedNotebook",value:function(){var _embedNotebook=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__.a)(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark((function _callee2(notebook,targets,observe,hide){var _this2=this,targetSet,observeSet,hideSet,_yield$eval,define;return _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:return this.runtime&&this.runtime.dispose(),targetSet=new Set(targets),observeSet=new Set(observe),hideSet=new Set(hide),this.runtime=new _observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__.b,_context2.next=7,eval('import("https://api.observablehq.com/'.concat(notebook,'.js?v=3")'));case 7:_yield$eval=_context2.sent,define=_yield$eval.default,this.main=this.runtime.module(define,(function(e){var _;if(observeSet.has(e)&&!targetSet.has(e)){var t=_this2.observeValue;return{fulfilled:function(_){t[e]=_,_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(t)}}}if(!(targetSet.size>0)||targetSet.has(e)){if(hideSet.has(e))return!0;var r=document.createElement("div");null===(_=_this2.notebookRef.current)||void 0===_||_.appendChild(r);var n=new _observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__.a(r);return r.addEventListener("input",(function(e){_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()})),{pending:function(){n.pending(),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()},fulfilled:function(e){n.fulfilled(e),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()},rejected:function(e){n.rejected(e),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()}}}})),observeSet.size>0&&Promise.all(Array.from(observeSet).map(function(){var e=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__.a)(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark((function e(_){return _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=_,e.next=3,_this2.main.value(_);case 3:return e.t1=e.sent,e.abrupt("return",[e.t0,e.t1]);case 5:case"end":return e.stop()}}),e)})));return function(_){return e.apply(this,arguments)}}())).then((function(e){var _,t=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createForOfIteratorHelper__WEBPACK_IMPORTED_MODULE_1__.a)(e);try{for(t.s();!(_=t.n()).done;){var r=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__.a)(_.value,2),n=r[0],a=r[1];_this2.observeValue[n]=a}}catch(o){t.e(o)}finally{t.f()}_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(_this2.observeValue)}));case 11:case"end":return _context2.stop()}}),_callee2,this)})));function embedNotebook(e,_,t,r){return _embedNotebook.apply(this,arguments)}return embedNotebook}()},{key:"redefineCells",value:function(e){var _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var t in _)e.redefine(t,_[t])}},{key:"componentDidMount",value:function(){var e=this,_=this.props.args,t=_.notebook,r=_.targets,n=void 0===r?[]:r,a=_.observe,o=void 0===a?[]:a,s=_.redefine,i=void 0===s?{}:s,l=_.hide,u=void 0===l?[]:l;_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(this.observeValue),this.embedNotebook(t,n,o,u).then((function(){e.redefineCells(e.main,i)}))}}]),Observable}(_streamlit__WEBPACK_IMPORTED_MODULE_9__.b);__webpack_exports__.a=Object(_streamlit__WEBPACK_IMPORTED_MODULE_9__.c)(Observable)},40:function(e,_,t){e.exports=t(41)},41:function(e,_,t){"use strict";t.r(_);var r=t(12),n=t.n(r),a=t(34),o=t.n(a),s=t(35);o.a.render(n.a.createElement(n.a.StrictMode,null,n.a.createElement(s.a,null)),document.getElementById("root"))}},[[40,1,2]]]);
3
- //# sourceMappingURL=main.5bdac2e3.chunk.js.map
 
1
+ /*! For license information please see main.fc603b94.chunk.js.LICENSE.txt */
2
+ (this.webpackJsonpstreamlit_component_template=this.webpackJsonpstreamlit_component_template||[]).push([[0],{18:function(e,_,t){"use strict";t.d(_,"b",(function(){return h})),t.d(_,"c",(function(){return E})),t.d(_,"a",(function(){return p}));var r,a=t(0),n=t(4),o=t(2),s=t(3),i=t(36),l=t.n(i),u=t(12),d=t.n(u),c=t(10),m=t(37),b=t(24),g=function(){function e(_,t,r,n){var o=this;Object(a.a)(this,e),this.dataTable=void 0,this.indexTable=void 0,this.columnsTable=void 0,this.styler=void 0,this.getCell=function(e,_){var t=e<o.headerRows&&_<o.headerColumns,r=e>=o.headerRows&&_<o.headerColumns,a=e<o.headerRows&&_>=o.headerColumns;if(t){var n=["blank"];return _>0&&n.push("level"+e),{type:"blank",classNames:n.join(" "),content:""}}if(a){var s=_-o.headerColumns;return{type:"columns",classNames:["col_heading","level"+e,"col"+s].join(" "),content:o.getContent(o.columnsTable,s,e)}}if(r){var i=e-o.headerRows,l=["row_heading","level"+_,"row"+i];return{type:"index",id:"T_".concat(o.uuid,"level").concat(_,"_row").concat(i),classNames:l.join(" "),content:o.getContent(o.indexTable,i,_)}}var u=e-o.headerRows,d=_-o.headerColumns,c=["data","row"+u,"col"+d],m=o.styler?o.getContent(o.styler.displayValuesTable,u,d):o.getContent(o.dataTable,u,d);return{type:"data",id:"T_".concat(o.uuid,"row").concat(u,"_col").concat(d),classNames:c.join(" "),content:m}},this.getContent=function(e,_,t){var r=e.getColumnAt(t);if(null===r)return"";switch(o.getColumnTypeId(e,t)){case b.b.Timestamp:return o.nanosToDate(r.get(_));default:return r.get(_)}},this.dataTable=b.a.from(_),this.indexTable=b.a.from(t),this.columnsTable=b.a.from(r),this.styler=n?{caption:n.get("caption"),displayValuesTable:b.a.from(n.get("displayValues")),styles:n.get("styles"),uuid:n.get("uuid")}:void 0}return Object(n.a)(e,[{key:"rows",get:function(){return this.indexTable.length+this.columnsTable.numCols}},{key:"columns",get:function(){return this.indexTable.numCols+this.columnsTable.length}},{key:"headerRows",get:function(){return this.rows-this.dataRows}},{key:"headerColumns",get:function(){return this.columns-this.dataColumns}},{key:"dataRows",get:function(){return this.dataTable.length}},{key:"dataColumns",get:function(){return this.dataTable.numCols}},{key:"uuid",get:function(){return this.styler&&this.styler.uuid}},{key:"caption",get:function(){return this.styler&&this.styler.caption}},{key:"styles",get:function(){return this.styler&&this.styler.styles}},{key:"table",get:function(){return this.dataTable}},{key:"index",get:function(){return this.indexTable}},{key:"columnTable",get:function(){return this.columnsTable}},{key:"getColumnTypeId",value:function(e,_){return e.schema.fields[_].type.typeId}},{key:"nanosToDate",value:function(e){return new Date(e/1e6)}}]),e}();!function(e){e.COMPONENT_READY="streamlit:componentReady",e.SET_COMPONENT_VALUE="streamlit:setComponentValue",e.SET_FRAME_HEIGHT="streamlit:setFrameHeight"}(r||(r={}));var p=function e(){Object(a.a)(this,e)};p.API_VERSION=1,p.RENDER_EVENT="streamlit:render",p.events=new m.a,p.registeredMessageListener=!1,p.lastFrameHeight=void 0,p.setComponentReady=function(){p.registeredMessageListener||(window.addEventListener("message",p.onMessageEvent),p.registeredMessageListener=!0),p.sendBackMsg(r.COMPONENT_READY,{apiVersion:p.API_VERSION})},p.setFrameHeight=function(e){void 0===e&&(e=document.body.scrollHeight+10),e!==p.lastFrameHeight&&(p.lastFrameHeight=e,p.sendBackMsg(r.SET_FRAME_HEIGHT,{height:e}))},p.setComponentValue=function(e){p.sendBackMsg(r.SET_COMPONENT_VALUE,{value:e})},p.onMessageEvent=function(e){switch(e.data.type){case p.RENDER_EVENT:p.onRenderMessage(e.data)}},p.onRenderMessage=function(e){var _=e.args;null==_&&(console.error("Got null args in onRenderMessage. This should never happen"),_={});var t=e.dfs&&e.dfs.length>0?p.argsDataframeToObject(e.dfs):{};_=Object(c.a)(Object(c.a)({},_),t);var r={disabled:Boolean(e.disabled),args:_},a=new CustomEvent(p.RENDER_EVENT,{detail:r});p.events.dispatchEvent(a)},p.argsDataframeToObject=function(e){var _=e.map((function(e){var _=e.key,t=e.value;return[_,p.toArrowTable(t)]}));return Object.fromEntries(_)},p.toArrowTable=function(e){var _=e.data,t=_.data,r=_.index,a=_.columns;return new g(t,r,a)},p.sendBackMsg=function(e,_){window.parent.postMessage(Object(c.a)({isStreamlitMessage:!0,type:e},_),"*")};var h=function(e){Object(o.a)(t,e);var _=Object(s.a)(t);function t(){return Object(a.a)(this,t),_.apply(this,arguments)}return Object(n.a)(t,[{key:"componentDidMount",value:function(){p.setFrameHeight()}},{key:"componentDidUpdate",value:function(){p.setFrameHeight()}}]),t}(d.a.PureComponent);function E(e){var _=function(_){Object(o.a)(r,_);var t=Object(s.a)(r);function r(_){var n;return Object(a.a)(this,r),(n=t.call(this,_)).componentDidMount=function(){p.events.addEventListener(p.RENDER_EVENT,n.onRenderEvent),p.setComponentReady()},n.componentDidUpdate=function(e){null!=n.state.componentError&&p.setFrameHeight()},n.componentWillUnmount=function(){p.events.removeEventListener(p.RENDER_EVENT,n.onRenderEvent)},n.onRenderEvent=function(e){var _=e;n.setState({renderData:_.detail})},n.render=function(){return null!=n.state.componentError?d.a.createElement("div",null,d.a.createElement("h1",null,"Component Error"),d.a.createElement("span",null,n.state.componentError.message)):null==n.state.renderData?null:d.a.createElement(e,{width:window.innerWidth,disabled:n.state.renderData.disabled,args:n.state.renderData.args})},n.state={renderData:void 0,componentError:void 0},n}return r}(d.a.PureComponent);return _.getDerivedStateFromError=function(e){return{componentError:e}},l()(_,e)}},35:function(module,__webpack_exports__,__webpack_require__){"use strict";var _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createForOfIteratorHelper__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(8),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(1),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(5),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(0),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(4),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(2),_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(3),react__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(12),react__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_8__),_streamlit__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(18),_observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(30),Observable=function(_StreamlitComponentBa){Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_inherits__WEBPACK_IMPORTED_MODULE_6__.a)(Observable,_StreamlitComponentBa);var _super=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createSuper__WEBPACK_IMPORTED_MODULE_7__.a)(Observable);function Observable(){var e;Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_4__.a)(this,Observable);for(var _=arguments.length,t=new Array(_),r=0;r<_;r++)t[r]=arguments[r];return(e=_super.call.apply(_super,[this].concat(t))).observeValue={},e.notebookRef=react__WEBPACK_IMPORTED_MODULE_8___default.a.createRef(),e.runtime=null,e.main=null,e.render=function(){return console.log("this.props.args.render_empty: ",e.props.args.render_empty),e.props.args.render_empty?react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{padding:"9px 12px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{ref:e.notebookRef})),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{marginTop:"4px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",null,react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"left"}},e.props.args.name),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"right"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("a",{href:"https://observablehq.com/".concat(e.props.args.notebook),style:{color:"#666"}}))))):react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{border:"1px solid gray",borderRadius:"4px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{padding:"9px 12px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{ref:e.notebookRef})),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{marginTop:"4px"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{backgroundColor:"#ddd",fontWeight:700,padding:".25rem .5rem",borderRadius:"0 0 4px 4px",gridTemplateColumns:"auto auto",display:"grid"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"left"}},e.props.args.name),react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("div",{style:{textAlign:"right"}},react__WEBPACK_IMPORTED_MODULE_8___default.a.createElement("a",{href:"https://observablehq.com/".concat(e.props.args.notebook),style:{color:"#666"}})))))},e}return Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_5__.a)(Observable,[{key:"componentWillUnmount",value:function(){var e;null===(e=this.runtime)||void 0===e||e.dispose()}},{key:"componentDidUpdate",value:function(e){e.args.notebook,this.props.args.notebook,console.log("this.props.args.redefine: ",this.props.args.redefine),null!==this.main&&this.redefineCells(this.main,this.props.args.redefine)}},{key:"embedNotebook",value:function(){var _embedNotebook=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__.a)(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark((function _callee2(notebook,targets,observe,hide){var _this2=this,targetSet,observeSet,hideSet,_yield$eval,define;return _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap((function _callee2$(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:return this.runtime&&this.runtime.dispose(),console.log("Console says hi!"),targetSet=new Set(targets),observeSet=new Set(observe),hideSet=new Set(hide),this.runtime=new _observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__.b,_context2.next=8,eval('import("https://api.observablehq.com/'.concat(notebook,'.js?v=3")'));case 8:_yield$eval=_context2.sent,define=_yield$eval.default,this.main=this.runtime.module(define,(function(e){var _;if(console.log("name: ",e),console.log("observeSet.has(name: ",observeSet.has(e)),console.log("targetSet.has(name): ",targetSet.has(e)),observeSet.has(e)&&!targetSet.has(e)){var t=_this2.observeValue;return console.log("observeValue: ",t),{fulfilled:function(_){t[e]=_,_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(t)}}}if(!(targetSet.size>0)||targetSet.has(e)){if(hideSet.has(e))return!0;var r=document.createElement("div");null===(_=_this2.notebookRef.current)||void 0===_||_.appendChild(r);var a=new _observablehq_runtime__WEBPACK_IMPORTED_MODULE_10__.a(r);return r.addEventListener("input",(function(e){_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()})),{pending:function(){a.pending(),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()},fulfilled:function(e){a.fulfilled(e),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()},rejected:function(e){a.rejected(e),_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setFrameHeight()}}}})),observeSet.size>0&&Promise.all(Array.from(observeSet).map(function(){var e=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__.a)(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark((function e(_){return _mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=_,e.next=3,_this2.main.value(_);case 3:return e.t1=e.sent,e.abrupt("return",[e.t0,e.t1]);case 5:case"end":return e.stop()}}),e)})));return function(_){return e.apply(this,arguments)}}())).then((function(e){var _,t=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_createForOfIteratorHelper__WEBPACK_IMPORTED_MODULE_1__.a)(e);try{for(t.s();!(_=t.n()).done;){var r=Object(_mnt_storage_Documents_hugging_face_colaborative_hub_training_demo_neurips_training_transformers_together_dashboard_streamlit_observable_frontend_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__.a)(_.value,2),a=r[0],n=r[1];_this2.observeValue[a]=n}}catch(o){t.e(o)}finally{t.f()}_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(_this2.observeValue)}));case 12:case"end":return _context2.stop()}}),_callee2,this)})));function embedNotebook(e,_,t,r){return _embedNotebook.apply(this,arguments)}return embedNotebook}()},{key:"redefineCells",value:function(e){var _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var t in console.log("Console says hi 2 !"),_)e.redefine(t,_[t])}},{key:"componentDidMount",value:function(){var e=this,_=this.props.args,t=_.notebook,r=_.targets,a=void 0===r?[]:r,n=_.observe,o=void 0===n?[]:n,s=_.redefine,i=void 0===s?{}:s,l=_.hide,u=void 0===l?[]:l;_streamlit__WEBPACK_IMPORTED_MODULE_9__.a.setComponentValue(this.observeValue),this.embedNotebook(t,a,o,u).then((function(){e.redefineCells(e.main,i)}))}}]),Observable}(_streamlit__WEBPACK_IMPORTED_MODULE_9__.b);__webpack_exports__.a=Object(_streamlit__WEBPACK_IMPORTED_MODULE_9__.c)(Observable)},40:function(e,_,t){e.exports=t(41)},41:function(e,_,t){"use strict";t.r(_);var r=t(12),a=t.n(r),n=t(34),o=t.n(n),s=t(35);o.a.render(a.a.createElement(a.a.StrictMode,null,a.a.createElement(s.a,null)),document.getElementById("root"))}},[[40,1,2]]]);
3
+ //# sourceMappingURL=main.fc603b94.chunk.js.map
streamlit_observable/frontend/build/static/js/{main.5bdac2e3.chunk.js.LICENSE.txt β†’ main.fc603b94.chunk.js.LICENSE.txt} RENAMED
File without changes
streamlit_observable/frontend/build/static/js/main.fc603b94.chunk.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["streamlit/streamlit.ts","streamlit/ArrowTable.ts","streamlit/StreamlitReact.tsx","Observable.tsx","index.tsx"],"names":["ComponentMessageType","ArrowTable","dataBuffer","indexBuffer","columnsBuffer","styler","dataTable","indexTable","columnsTable","getCell","rowIndex","columnIndex","isBlankCell","headerRows","headerColumns","isIndexCell","isColumnsCell","classNames","push","type","join","content","dataColumnIndex","getContent","dataRowIndex","id","uuid","displayValuesTable","table","column","getColumnAt","getColumnTypeId","Type","Timestamp","nanosToDate","get","this","Table","from","caption","styles","undefined","length","numCols","rows","dataRows","columns","dataColumns","schema","fields","typeId","nanos","Date","Streamlit","API_VERSION","RENDER_EVENT","events","EventTarget","registeredMessageListener","lastFrameHeight","setComponentReady","window","addEventListener","onMessageEvent","sendBackMsg","COMPONENT_READY","apiVersion","setFrameHeight","height","document","body","scrollHeight","SET_FRAME_HEIGHT","setComponentValue","value","SET_COMPONENT_VALUE","event","data","onRenderMessage","args","console","error","dataframeArgs","argsDataframeToObject","eventData","disabled","Boolean","CustomEvent","detail","dispatchEvent","argsDataframe","argsDataframeArrow","map","key","toArrowTable","Object","fromEntries","df","index","parent","postMessage","isStreamlitMessage","StreamlitComponentBase","React","PureComponent","withStreamlitConnection","WrappedComponent","ComponentWrapper","props","componentDidMount","onRenderEvent","componentDidUpdate","prevProps","state","componentError","componentWillUnmount","removeEventListener","renderEvent","setState","renderData","render","message","width","innerWidth","getDerivedStateFromError","hoistNonReactStatics","Observable","observeValue","notebookRef","createRef","runtime","main","log","render_empty","style","padding","ref","marginTop","textAlign","name","href","notebook","color","border","borderRadius","backgroundColor","fontWeight","gridTemplateColumns","display","dispose","redefine","redefineCells","targets","observe","hide","a","targetSet","Set","observeSet","hideSet","Runtime","eval","define","default","module","has","fulfilled","size","el","createElement","current","appendChild","i","Inspector","e","pending","rejected","Promise","all","Array","then","initial","cell","embedNotebook","ReactDOM","StrictMode","getElementById"],"mappings":";uPA4BKA,E,sFCoBQC,EAAb,WAME,WACEC,EACAC,EACAC,EACAC,GACC,IAAD,gCAVeC,eAUf,OATeC,gBASf,OAReC,kBAQf,OAPeH,YAOf,OA8DKI,QAAU,SAACC,EAAkBC,GAClC,IAAMC,EACJF,EAAW,EAAKG,YAAcF,EAAc,EAAKG,cAC7CC,EACJL,GAAY,EAAKG,YAAcF,EAAc,EAAKG,cAC9CE,EACJN,EAAW,EAAKG,YAAcF,GAAe,EAAKG,cAEpD,GAAIF,EAAa,CACf,IAAMK,EAAa,CAAC,SAKpB,OAJIN,EAAc,GAChBM,EAAWC,KAAK,QAAUR,GAGrB,CACLS,KAAM,QACNF,WAAYA,EAAWG,KAAK,KAC5BC,QAAS,IAEN,GAAIL,EAAe,CACxB,IAAMM,EAAkBX,EAAc,EAAKG,cAO3C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7DvC,gE,gIAkEA,SAAcI,GAA2B,IAAhBmB,EAAe,uDAAJ,GAIlC,IAAK,IAAIgC,KAFTtG,QAAQoD,IAAI,uBAEKkB,EAEfnB,EAAKmB,SAASgC,EAAMhC,EAASgC,M,+BAGjC,WAAqB,IAAD,OAClB,EAAyElJ,KAAKwE,MAAM7B,KAA5E8D,EAAR,EAAQA,SAAR,IAAkBW,eAAlB,MAA4B,GAA5B,MAAgCC,eAAhC,MAA0C,GAA1C,MAA8CH,gBAA9C,MAAyD,GAAzD,MAA8DI,YAA9D,MAAmE,GAAnE,EACArG,0CAAUoB,kBAAkBrC,KAAK2F,cACjC3F,KAAKmJ,cAAc1C,EAAUW,EAASC,EAASC,GAAM0B,MAAK,WACxD,EAAK7B,cAAc,EAAKpB,KAAMmB,U,YApGXhD,2CAwJVG,wEAAwBqB,a,oEChKvC,qDAIA0D,IAAShE,OACP,kBAAC,IAAMiE,WAAP,KACE,kBAAC,IAAD,OAEFpH,SAASqH,eAAe,W","file":"static/js/main.fc603b94.chunk.js","sourcesContent":["/**\n * @license\n * Copyright 2018-2020 Streamlit Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Safari doesn't support the EventTarget class, so we use a shim.\nimport { EventTarget } from \"event-target-shim\"\nimport { ArrowDataframeProto, ArrowTable } from \"./ArrowTable\"\n\n/** Data sent in the custom Streamlit render event. */\nexport interface RenderData {\n args: any\n disabled: boolean\n}\n\n/** Messages from Component -> Streamlit */\nenum ComponentMessageType {\n // A component sends this message when it's ready to receive messages\n // from Streamlit. Streamlit won't send any messages until it gets this.\n // Data: { apiVersion: number }\n COMPONENT_READY = \"streamlit:componentReady\",\n\n // The component has a new widget value. Send it back to Streamlit, which\n // will then re-run the app.\n // Data: { value: any }\n SET_COMPONENT_VALUE = \"streamlit:setComponentValue\",\n\n // The component has a new height for its iframe.\n // Data: { height: number }\n SET_FRAME_HEIGHT = \"streamlit:setFrameHeight\",\n}\n\n/**\n * Streamlit communication API.\n *\n * Components can send data to Streamlit via the functions defined here,\n * and receive data from Streamlit via the `events` property.\n */\nexport class Streamlit {\n /**\n * The Streamlit component API version we're targetting.\n * There's currently only 1!\n */\n public static readonly API_VERSION = 1\n\n public static readonly RENDER_EVENT = \"streamlit:render\"\n\n /** Dispatches events received from Streamlit. */\n public static readonly events = new EventTarget()\n\n private static registeredMessageListener = false\n private static lastFrameHeight?: number\n\n /**\n * Tell Streamlit that the component is ready to start receiving data.\n * Streamlit will defer emitting RENDER events until it receives the\n * COMPONENT_READY message.\n */\n public static setComponentReady = (): void => {\n if (!Streamlit.registeredMessageListener) {\n // Register for message events if we haven't already\n window.addEventListener(\"message\", Streamlit.onMessageEvent)\n Streamlit.registeredMessageListener = true\n }\n\n Streamlit.sendBackMsg(ComponentMessageType.COMPONENT_READY, {\n apiVersion: Streamlit.API_VERSION,\n })\n }\n\n /**\n * Report the component's height to Streamlit.\n * This should be called every time the component changes its DOM - that is,\n * when it's first loaded, and any time it updates.\n */\n public static setFrameHeight = (height?: number): void => {\n if (height === undefined) {\n // `height` is optional. If undefined, it defaults to scrollHeight,\n // which is the entire height of the element minus its border,\n // scrollbar, and margin.\n height = document.body.scrollHeight + 10;\n }\n\n if (height === Streamlit.lastFrameHeight) {\n // Don't bother updating if our height hasn't changed.\n return\n }\n\n Streamlit.lastFrameHeight = height\n Streamlit.sendBackMsg(ComponentMessageType.SET_FRAME_HEIGHT, { height })\n }\n\n /**\n * Set the component's value. This value will be returned to the Python\n * script, and the script will be re-run.\n *\n * For example:\n *\n * JavaScript:\n * Streamlit.setComponentValue(\"ahoy!\")\n *\n * Python:\n * value = st.my_component(...)\n * st.write(value) # -> \"ahoy!\"\n *\n * The value must be serializable into JSON.\n */\n public static setComponentValue = (value: any): void => {\n Streamlit.sendBackMsg(ComponentMessageType.SET_COMPONENT_VALUE, { value })\n }\n\n /** Receive a ForwardMsg from the Streamlit app */\n private static onMessageEvent = (event: MessageEvent): void => {\n const type = event.data[\"type\"]\n switch (type) {\n case Streamlit.RENDER_EVENT:\n Streamlit.onRenderMessage(event.data)\n break\n }\n }\n\n /**\n * Handle an untyped Streamlit render event and redispatch it as a\n * StreamlitRenderEvent.\n */\n private static onRenderMessage = (data: any): void => {\n let args = data[\"args\"]\n if (args == null) {\n console.error(\n `Got null args in onRenderMessage. This should never happen`\n )\n args = {}\n }\n\n // Parse our dataframe arguments with arrow, and merge them into our args dict\n const dataframeArgs =\n data[\"dfs\"] && data[\"dfs\"].length > 0\n ? Streamlit.argsDataframeToObject(data[\"dfs\"])\n : {}\n\n args = {\n ...args,\n ...dataframeArgs,\n }\n\n const disabled = Boolean(data[\"disabled\"])\n\n // Dispatch a render event!\n const eventData = { disabled, args }\n const event = new CustomEvent<RenderData>(Streamlit.RENDER_EVENT, {\n detail: eventData,\n })\n Streamlit.events.dispatchEvent(event)\n }\n\n private static argsDataframeToObject = (\n argsDataframe: ArgsDataframe[]\n ): object => {\n const argsDataframeArrow = argsDataframe.map(\n ({ key, value }: ArgsDataframe) => [key, Streamlit.toArrowTable(value)]\n )\n return Object.fromEntries(argsDataframeArrow)\n }\n\n private static toArrowTable = (df: ArrowDataframeProto): ArrowTable => {\n const { data, index, columns } = df.data\n return new ArrowTable(data, index, columns)\n }\n\n /** Post a message to the Streamlit app. */\n private static sendBackMsg = (type: string, data?: any): void => {\n window.parent.postMessage(\n {\n isStreamlitMessage: true,\n type: type,\n ...data,\n },\n \"*\"\n )\n }\n}\n\ninterface ArgsDataframe {\n key: string\n value: ArrowDataframeProto\n}\n","/**\n * @license\n * Copyright 2018-2019 Streamlit Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Table, Type } from \"apache-arrow\"\n\ntype CellType = \"blank\" | \"index\" | \"columns\" | \"data\"\n\nexport interface ArrowDataframeProto {\n data: ArrowTableProto\n height: string\n width: string\n}\n\nexport interface ArrowTableProto {\n data: Uint8Array\n index: Uint8Array\n columns: Uint8Array\n styler: Styler\n}\n\ninterface Cell {\n classNames: string\n content: string\n id?: string\n type: CellType\n}\n\ninterface Styler {\n caption?: string\n displayValuesTable: Table\n styles?: string\n uuid: string\n}\n\nexport class ArrowTable {\n private readonly dataTable: Table\n private readonly indexTable: Table\n private readonly columnsTable: Table\n private readonly styler?: Styler\n\n constructor(\n dataBuffer: Uint8Array,\n indexBuffer: Uint8Array,\n columnsBuffer: Uint8Array,\n styler?: any\n ) {\n this.dataTable = Table.from(dataBuffer)\n this.indexTable = Table.from(indexBuffer)\n this.columnsTable = Table.from(columnsBuffer)\n this.styler = styler\n ? {\n caption: styler.get(\"caption\"),\n displayValuesTable: Table.from(styler.get(\"displayValues\")),\n styles: styler.get(\"styles\"),\n uuid: styler.get(\"uuid\"),\n }\n : undefined\n }\n\n get rows(): number {\n return this.indexTable.length + this.columnsTable.numCols\n }\n\n get columns(): number {\n return this.indexTable.numCols + this.columnsTable.length\n }\n\n get headerRows(): number {\n return this.rows - this.dataRows\n }\n\n get headerColumns(): number {\n return this.columns - this.dataColumns\n }\n\n get dataRows(): number {\n return this.dataTable.length\n }\n\n get dataColumns(): number {\n return this.dataTable.numCols\n }\n\n get uuid(): string | undefined {\n return this.styler && this.styler.uuid\n }\n\n get caption(): string | undefined {\n return this.styler && this.styler.caption\n }\n\n get styles(): string | undefined {\n return this.styler && this.styler.styles\n }\n\n get table(): Table {\n return this.dataTable\n }\n\n get index(): Table {\n return this.indexTable\n }\n\n get columnTable(): Table {\n return this.columnsTable\n }\n\n public getCell = (rowIndex: number, columnIndex: number): Cell => {\n const isBlankCell =\n rowIndex < this.headerRows && columnIndex < this.headerColumns\n const isIndexCell =\n rowIndex >= this.headerRows && columnIndex < this.headerColumns\n const isColumnsCell =\n rowIndex < this.headerRows && columnIndex >= this.headerColumns\n\n if (isBlankCell) {\n const classNames = [\"blank\"]\n if (columnIndex > 0) {\n classNames.push(\"level\" + rowIndex)\n }\n\n return {\n type: \"blank\",\n classNames: classNames.join(\" \"),\n content: \"\",\n }\n } else if (isColumnsCell) {\n const dataColumnIndex = columnIndex - this.headerColumns\n const classNames = [\n \"col_heading\",\n \"level\" + rowIndex,\n \"col\" + dataColumnIndex,\n ]\n\n return {\n type: \"columns\",\n classNames: classNames.join(\" \"),\n content: this.getContent(this.columnsTable, dataColumnIndex, rowIndex),\n }\n } else if (isIndexCell) {\n const dataRowIndex = rowIndex - this.headerRows\n const classNames = [\n \"row_heading\",\n \"level\" + columnIndex,\n \"row\" + dataRowIndex,\n ]\n\n return {\n type: \"index\",\n id: `T_${this.uuid}level${columnIndex}_row${dataRowIndex}`,\n classNames: classNames.join(\" \"),\n content: this.getContent(this.indexTable, dataRowIndex, columnIndex),\n }\n } else {\n const dataRowIndex = rowIndex - this.headerRows\n const dataColumnIndex = columnIndex - this.headerColumns\n const classNames = [\n \"data\",\n \"row\" + dataRowIndex,\n \"col\" + dataColumnIndex,\n ]\n const content = this.styler\n ? this.getContent(\n this.styler.displayValuesTable,\n dataRowIndex,\n dataColumnIndex\n )\n : this.getContent(this.dataTable, dataRowIndex, dataColumnIndex)\n\n return {\n type: \"data\",\n id: `T_${this.uuid}row${dataRowIndex}_col${dataColumnIndex}`,\n classNames: classNames.join(\" \"),\n content,\n }\n }\n }\n\n public getContent = (\n table: Table,\n rowIndex: number,\n columnIndex: number\n ): any => {\n const column = table.getColumnAt(columnIndex)\n if (column === null) {\n return \"\"\n }\n\n const columnTypeId = this.getColumnTypeId(table, columnIndex)\n switch (columnTypeId) {\n case Type.Timestamp: {\n return this.nanosToDate(column.get(rowIndex))\n }\n default: {\n return column.get(rowIndex)\n }\n }\n }\n\n /**\n * Returns apache-arrow specific typeId of column.\n */\n private getColumnTypeId(table: Table, columnIndex: number): Type {\n return table.schema.fields[columnIndex].type.typeId\n }\n\n private nanosToDate(nanos: number): Date {\n return new Date(nanos / 1e6)\n }\n}\n","import hoistNonReactStatics from \"hoist-non-react-statics\"\nimport React, { ReactNode } from \"react\"\nimport { RenderData, Streamlit } from \"./streamlit\"\n\n/**\n * Props passed to custom Streamlit components.\n */\nexport interface ComponentProps {\n /** Named dictionary of arguments passed from Python. */\n args: any\n\n /** The component's width. */\n width: number\n\n /**\n * True if the component should be disabled.\n * All components get disabled while the app is being re-run,\n * and become re-enabled when the re-run has finished.\n */\n disabled: boolean\n}\n\n/**\n * Optional Streamlit React-based component base class.\n *\n * You are not required to extend this base class to create a Streamlit\n * component. If you decide not to extend it, you should implement the\n * `componentDidMount` and `componentDidUpdate` functions in your own class,\n * so that your plugin properly resizes.\n */\nexport class StreamlitComponentBase<S = {}> extends React.PureComponent<\n ComponentProps,\n S\n > {\n public componentDidMount(): void {\n // After we're rendered for the first time, tell Streamlit that our height\n // has changed.\n Streamlit.setFrameHeight()\n }\n\n public componentDidUpdate(): void {\n // After we're updated, tell Streamlit that our height may have changed.\n Streamlit.setFrameHeight()\n }\n}\n\n/**\n * Wrapper for React-based Streamlit components.\n *\n * Bootstraps the communication interface between Streamlit and the component.\n */\nexport function withStreamlitConnection(\n WrappedComponent: React.ComponentType<ComponentProps>\n): React.ComponentType {\n interface WrapperProps { }\n\n interface WrapperState {\n renderData?: RenderData\n componentError?: Error\n }\n\n class ComponentWrapper extends React.PureComponent<\n WrapperProps,\n WrapperState\n > {\n public constructor(props: WrapperProps) {\n super(props)\n this.state = {\n renderData: undefined,\n componentError: undefined,\n }\n }\n\n /**\n * Error boundary function. This will be called if our wrapped\n * component throws an error. We store the caught error in our state,\n * and display it in the next render().\n */\n public static getDerivedStateFromError = (\n error: Error\n ): Partial<WrapperState> => {\n return { componentError: error }\n }\n\n public componentDidMount = (): void => {\n // Set up event listeners, and signal to Streamlit that we're ready.\n // We won't render the component until we receive the first RENDER_EVENT.\n Streamlit.events.addEventListener(\n Streamlit.RENDER_EVENT,\n this.onRenderEvent\n )\n Streamlit.setComponentReady()\n }\n\n public componentDidUpdate = (prevProps: any): void => {\n // If our child threw an error, we display it in render(). In this\n // case, the child won't be mounted and therefore won't call\n // `setFrameHeight` on its own. We do it here so that the rendered\n // error will be visible.\n if (this.state.componentError != null) {\n Streamlit.setFrameHeight()\n }\n }\n\n public componentWillUnmount = (): void => {\n Streamlit.events.removeEventListener(\n Streamlit.RENDER_EVENT,\n this.onRenderEvent\n )\n }\n\n /**\n * Streamlit is telling this component to redraw.\n * We save the render data in State, so that it can be passed to the\n * component in our own render() function.\n */\n private onRenderEvent = (event: Event): void => {\n // Update our state with the newest render data\n const renderEvent = event as CustomEvent<RenderData>\n this.setState({ renderData: renderEvent.detail })\n }\n\n public render = (): ReactNode => {\n // If our wrapped component threw an error, display it.\n if (this.state.componentError != null) {\n return (\n <div>\n <h1>Component Error</h1>\n <span>{this.state.componentError.message}</span>\n </div>\n )\n }\n\n // Don't render until we've gotten our first RENDER_EVENT from Streamlit.\n if (this.state.renderData == null) {\n return null\n }\n\n return (\n <WrappedComponent\n width={window.innerWidth}\n disabled={this.state.renderData.disabled}\n args={this.state.renderData.args}\n />\n )\n }\n }\n\n return hoistNonReactStatics(ComponentWrapper, WrappedComponent)\n}\n","import React, { ReactNode } from \"react\"\nimport {\n withStreamlitConnection,\n StreamlitComponentBase,\n Streamlit,\n} from \"./streamlit\"\nimport { Runtime, Inspector } from \"@observablehq/runtime\";\n\nclass Observable extends StreamlitComponentBase<{}> {\n public observeValue = {};\n private notebookRef = React.createRef<HTMLDivElement>();\n private runtime: any = null;\n private main: any = null;\n\n componentWillUnmount() {\n this.runtime?.dispose();\n }\n // @ts-ignore\n public componentDidUpdate(prevProps: any) {\n const { args: prevArgs } = prevProps;\n if (prevArgs.notebook !== this.props.args.notebook) {\n // TODO handle new notebook\n }\n console.log('this.props.args.redefine: ', this.props.args.redefine);\n if (this.main !== null) {\n this.redefineCells(this.main, this.props.args.redefine);\n }\n }\n\n async embedNotebook(notebook: string, targets: string[], observe: string[], hide:string[]) {\n if (this.runtime) {\n this.runtime.dispose();\n }\n \n console.log('Console says hi!');\n\n const targetSet = new Set(targets);\n const observeSet = new Set(observe);\n const hideSet = new Set(hide);\n this.runtime = new Runtime();\n const { default: define } = await eval(`import(\"https://api.observablehq.com/${notebook}.js?v=3\")`);\n\n this.main = this.runtime.module(define, (name: string) => {\n console.log('name: ', name);\n console.log('observeSet.has(name: ', observeSet.has(name));\n console.log('targetSet.has(name): ', targetSet.has(name));\n if (observeSet.has(name) && !targetSet.has(name)) {\n const observeValue = this.observeValue;\n \n console.log('observeValue: ', observeValue);\n \n return {\n fulfilled: (value: any) => {\n //@ts-ignore\n observeValue[name] = value;\n //@ts-ignore\n Streamlit.setComponentValue(observeValue);\n }\n }\n }\n if (targetSet.size > 0 && !targetSet.has(name)) return;\n if(hideSet.has(name)) return true;\n const el = document.createElement('div');\n this.notebookRef.current?.appendChild(el);\n\n const i = new Inspector(el);\n el.addEventListener('input', e => {\n Streamlit.setFrameHeight();\n })\n return {\n pending() {\n i.pending();\n Streamlit.setFrameHeight();\n },\n fulfilled(value: any) {\n i.fulfilled(value);\n Streamlit.setFrameHeight();\n },\n rejected(error: any) {\n i.rejected(error);\n Streamlit.setFrameHeight();\n },\n };\n });\n if (observeSet.size > 0) {\n Promise.all(Array.from(observeSet).map(async name => [name, await this.main.value(name)])).then(initial => {\n for (const [name, value] of initial) {\n // @ts-ignore\n this.observeValue[name] = value\n };\n Streamlit.setComponentValue(this.observeValue);\n })\n }\n }\n\n redefineCells(main: any, redefine = {}) {\n \n console.log('Console says hi 2 !');\n\n for (let cell in redefine) {\n //@ts-ignore\n main.redefine(cell, redefine[cell]);\n }\n }\n componentDidMount() {\n const { notebook, targets = [], observe = [], redefine = {} , hide=[]} = this.props.args;\n Streamlit.setComponentValue(this.observeValue);\n this.embedNotebook(notebook, targets, observe, hide).then(() => {\n this.redefineCells(this.main, redefine);\n });\n\n }\n\n public render = (): ReactNode => {\n \n console.log('this.props.args.render_empty: ', this.props.args.render_empty);\n if (this.props.args.render_empty) {\n return (\n <div >\n <div style={{ padding: '9px 12px' }}>\n <div ref={this.notebookRef}></div>\n </div>\n <div style={{ marginTop: '4px' }}>\n \n <div >\n <div style={{textAlign:\"left\"}}>{this.props.args.name}</div>\n <div style={{textAlign:\"right\"}}>\n <a href={`https://observablehq.com/${this.props.args.notebook}`} style={{ color: '#666', }}></a>\n </div>\n </div>\n </div>\n </div >\n )\n }\n return (\n <div style={{ border: '1px solid gray', borderRadius: '4px' }}>\n <div style={{ padding: '9px 12px' }}>\n <div ref={this.notebookRef}></div>\n </div>\n <div style={{ marginTop: '4px' }}>\n \n <div style={{\n backgroundColor: '#ddd',\n fontWeight: 700,\n padding: \".25rem .5rem\",\n borderRadius: '0 0 4px 4px',\n gridTemplateColumns: \"auto auto\",\n display:\"grid\"\n }}>\n <div style={{textAlign:\"left\"}}>{this.props.args.name}</div>\n <div style={{textAlign:\"right\"}}>\n <a href={`https://observablehq.com/${this.props.args.notebook}`} style={{ color: '#666', }}></a>\n </div>\n </div>\n </div>\n </div >\n )\n }\n}\n\nexport default withStreamlitConnection(Observable)\n","import React from \"react\"\nimport ReactDOM from \"react-dom\"\nimport Observable from \"./Observable\"\n\nReactDOM.render(\n <React.StrictMode>\n <Observable />\n </React.StrictMode>,\n document.getElementById(\"root\")\n)\n"],"sourceRoot":""}
streamlit_observable/frontend/src/Observable.tsx ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { ReactNode } from "react"
2
+ import {
3
+ withStreamlitConnection,
4
+ StreamlitComponentBase,
5
+ Streamlit,
6
+ } from "./streamlit"
7
+ import { Runtime, Inspector } from "@observablehq/runtime";
8
+
9
+ class Observable extends StreamlitComponentBase<{}> {
10
+ public observeValue = {};
11
+ private notebookRef = React.createRef<HTMLDivElement>();
12
+ private runtime: any = null;
13
+ private main: any = null;
14
+
15
+ componentWillUnmount() {
16
+ this.runtime?.dispose();
17
+ }
18
+ // @ts-ignore
19
+ public componentDidUpdate(prevProps: any) {
20
+ const { args: prevArgs } = prevProps;
21
+ if (prevArgs.notebook !== this.props.args.notebook) {
22
+ // TODO handle new notebook
23
+ }
24
+ console.log('this.props.args.redefine: ', this.props.args.redefine);
25
+ if (this.main !== null) {
26
+ this.redefineCells(this.main, this.props.args.redefine);
27
+ }
28
+ }
29
+
30
+ async embedNotebook(notebook: string, targets: string[], observe: string[], hide:string[]) {
31
+ if (this.runtime) {
32
+ this.runtime.dispose();
33
+ }
34
+
35
+ console.log('Console says hi!');
36
+
37
+ const targetSet = new Set(targets);
38
+ const observeSet = new Set(observe);
39
+ const hideSet = new Set(hide);
40
+ this.runtime = new Runtime();
41
+ const { default: define } = await eval(`import("https://api.observablehq.com/${notebook}.js?v=3")`);
42
+
43
+ this.main = this.runtime.module(define, (name: string) => {
44
+ console.log('name: ', name);
45
+ console.log('observeSet.has(name: ', observeSet.has(name));
46
+ console.log('targetSet.has(name): ', targetSet.has(name));
47
+ if (observeSet.has(name) && !targetSet.has(name)) {
48
+ const observeValue = this.observeValue;
49
+
50
+ console.log('observeValue: ', observeValue);
51
+
52
+ return {
53
+ fulfilled: (value: any) => {
54
+ //@ts-ignore
55
+ observeValue[name] = value;
56
+ //@ts-ignore
57
+ Streamlit.setComponentValue(observeValue);
58
+ }
59
+ }
60
+ }
61
+ if (targetSet.size > 0 && !targetSet.has(name)) return;
62
+ if(hideSet.has(name)) return true;
63
+ const el = document.createElement('div');
64
+ this.notebookRef.current?.appendChild(el);
65
+
66
+ const i = new Inspector(el);
67
+ el.addEventListener('input', e => {
68
+ Streamlit.setFrameHeight();
69
+ })
70
+ return {
71
+ pending() {
72
+ i.pending();
73
+ Streamlit.setFrameHeight();
74
+ },
75
+ fulfilled(value: any) {
76
+ i.fulfilled(value);
77
+ Streamlit.setFrameHeight();
78
+ },
79
+ rejected(error: any) {
80
+ i.rejected(error);
81
+ Streamlit.setFrameHeight();
82
+ },
83
+ };
84
+ });
85
+ if (observeSet.size > 0) {
86
+ Promise.all(Array.from(observeSet).map(async name => [name, await this.main.value(name)])).then(initial => {
87
+ for (const [name, value] of initial) {
88
+ // @ts-ignore
89
+ this.observeValue[name] = value
90
+ };
91
+ Streamlit.setComponentValue(this.observeValue);
92
+ })
93
+ }
94
+ }
95
+
96
+ redefineCells(main: any, redefine = {}) {
97
+
98
+ console.log('Console says hi 2 !');
99
+
100
+ for (let cell in redefine) {
101
+ //@ts-ignore
102
+ main.redefine(cell, redefine[cell]);
103
+ }
104
+ }
105
+ componentDidMount() {
106
+ const { notebook, targets = [], observe = [], redefine = {} , hide=[]} = this.props.args;
107
+ Streamlit.setComponentValue(this.observeValue);
108
+ this.embedNotebook(notebook, targets, observe, hide).then(() => {
109
+ this.redefineCells(this.main, redefine);
110
+ });
111
+
112
+ }
113
+
114
+ public render = (): ReactNode => {
115
+
116
+ console.log('this.props.args.render_empty: ', this.props.args.render_empty);
117
+ if (this.props.args.render_empty) {
118
+ return (
119
+ <div >
120
+ <div style={{ padding: '9px 12px' }}>
121
+ <div ref={this.notebookRef}></div>
122
+ </div>
123
+ <div style={{ marginTop: '4px' }}>
124
+
125
+ <div >
126
+ <div style={{textAlign:"left"}}>{this.props.args.name}</div>
127
+ <div style={{textAlign:"right"}}>
128
+ <a href={`https://observablehq.com/${this.props.args.notebook}`} style={{ color: '#666', }}></a>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div >
133
+ )
134
+ }
135
+ return (
136
+ <div style={{ border: '1px solid gray', borderRadius: '4px' }}>
137
+ <div style={{ padding: '9px 12px' }}>
138
+ <div ref={this.notebookRef}></div>
139
+ </div>
140
+ <div style={{ marginTop: '4px' }}>
141
+
142
+ <div style={{
143
+ backgroundColor: '#ddd',
144
+ fontWeight: 700,
145
+ padding: ".25rem .5rem",
146
+ borderRadius: '0 0 4px 4px',
147
+ gridTemplateColumns: "auto auto",
148
+ display:"grid"
149
+ }}>
150
+ <div style={{textAlign:"left"}}>{this.props.args.name}</div>
151
+ <div style={{textAlign:"right"}}>
152
+ <a href={`https://observablehq.com/${this.props.args.notebook}`} style={{ color: '#666', }}></a>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </div >
157
+ )
158
+ }
159
+ }
160
+
161
+ export default withStreamlitConnection(Observable)
streamlit_observable/frontend/src/index.tsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react"
2
+ import ReactDOM from "react-dom"
3
+ import Observable from "./Observable"
4
+
5
+ ReactDOM.render(
6
+ <React.StrictMode>
7
+ <Observable />
8
+ </React.StrictMode>,
9
+ document.getElementById("root")
10
+ )
streamlit_observable/frontend/src/react-app-env.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ /// <reference types="react-scripts" />
streamlit_observable/frontend/src/streamlit/ArrowTable.ts ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2018-2019 Streamlit Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { Table, Type } from "apache-arrow"
19
+
20
+ type CellType = "blank" | "index" | "columns" | "data"
21
+
22
+ export interface ArrowDataframeProto {
23
+ data: ArrowTableProto
24
+ height: string
25
+ width: string
26
+ }
27
+
28
+ export interface ArrowTableProto {
29
+ data: Uint8Array
30
+ index: Uint8Array
31
+ columns: Uint8Array
32
+ styler: Styler
33
+ }
34
+
35
+ interface Cell {
36
+ classNames: string
37
+ content: string
38
+ id?: string
39
+ type: CellType
40
+ }
41
+
42
+ interface Styler {
43
+ caption?: string
44
+ displayValuesTable: Table
45
+ styles?: string
46
+ uuid: string
47
+ }
48
+
49
+ export class ArrowTable {
50
+ private readonly dataTable: Table
51
+ private readonly indexTable: Table
52
+ private readonly columnsTable: Table
53
+ private readonly styler?: Styler
54
+
55
+ constructor(
56
+ dataBuffer: Uint8Array,
57
+ indexBuffer: Uint8Array,
58
+ columnsBuffer: Uint8Array,
59
+ styler?: any
60
+ ) {
61
+ this.dataTable = Table.from(dataBuffer)
62
+ this.indexTable = Table.from(indexBuffer)
63
+ this.columnsTable = Table.from(columnsBuffer)
64
+ this.styler = styler
65
+ ? {
66
+ caption: styler.get("caption"),
67
+ displayValuesTable: Table.from(styler.get("displayValues")),
68
+ styles: styler.get("styles"),
69
+ uuid: styler.get("uuid"),
70
+ }
71
+ : undefined
72
+ }
73
+
74
+ get rows(): number {
75
+ return this.indexTable.length + this.columnsTable.numCols
76
+ }
77
+
78
+ get columns(): number {
79
+ return this.indexTable.numCols + this.columnsTable.length
80
+ }
81
+
82
+ get headerRows(): number {
83
+ return this.rows - this.dataRows
84
+ }
85
+
86
+ get headerColumns(): number {
87
+ return this.columns - this.dataColumns
88
+ }
89
+
90
+ get dataRows(): number {
91
+ return this.dataTable.length
92
+ }
93
+
94
+ get dataColumns(): number {
95
+ return this.dataTable.numCols
96
+ }
97
+
98
+ get uuid(): string | undefined {
99
+ return this.styler && this.styler.uuid
100
+ }
101
+
102
+ get caption(): string | undefined {
103
+ return this.styler && this.styler.caption
104
+ }
105
+
106
+ get styles(): string | undefined {
107
+ return this.styler && this.styler.styles
108
+ }
109
+
110
+ get table(): Table {
111
+ return this.dataTable
112
+ }
113
+
114
+ get index(): Table {
115
+ return this.indexTable
116
+ }
117
+
118
+ get columnTable(): Table {
119
+ return this.columnsTable
120
+ }
121
+
122
+ public getCell = (rowIndex: number, columnIndex: number): Cell => {
123
+ const isBlankCell =
124
+ rowIndex < this.headerRows && columnIndex < this.headerColumns
125
+ const isIndexCell =
126
+ rowIndex >= this.headerRows && columnIndex < this.headerColumns
127
+ const isColumnsCell =
128
+ rowIndex < this.headerRows && columnIndex >= this.headerColumns
129
+
130
+ if (isBlankCell) {
131
+ const classNames = ["blank"]
132
+ if (columnIndex > 0) {
133
+ classNames.push("level" + rowIndex)
134
+ }
135
+
136
+ return {
137
+ type: "blank",
138
+ classNames: classNames.join(" "),
139
+ content: "",
140
+ }
141
+ } else if (isColumnsCell) {
142
+ const dataColumnIndex = columnIndex - this.headerColumns
143
+ const classNames = [
144
+ "col_heading",
145
+ "level" + rowIndex,
146
+ "col" + dataColumnIndex,
147
+ ]
148
+
149
+ return {
150
+ type: "columns",
151
+ classNames: classNames.join(" "),
152
+ content: this.getContent(this.columnsTable, dataColumnIndex, rowIndex),
153
+ }
154
+ } else if (isIndexCell) {
155
+ const dataRowIndex = rowIndex - this.headerRows
156
+ const classNames = [
157
+ "row_heading",
158
+ "level" + columnIndex,
159
+ "row" + dataRowIndex,
160
+ ]
161
+
162
+ return {
163
+ type: "index",
164
+ id: `T_${this.uuid}level${columnIndex}_row${dataRowIndex}`,
165
+ classNames: classNames.join(" "),
166
+ content: this.getContent(this.indexTable, dataRowIndex, columnIndex),
167
+ }
168
+ } else {
169
+ const dataRowIndex = rowIndex - this.headerRows
170
+ const dataColumnIndex = columnIndex - this.headerColumns
171
+ const classNames = [
172
+ "data",
173
+ "row" + dataRowIndex,
174
+ "col" + dataColumnIndex,
175
+ ]
176
+ const content = this.styler
177
+ ? this.getContent(
178
+ this.styler.displayValuesTable,
179
+ dataRowIndex,
180
+ dataColumnIndex
181
+ )
182
+ : this.getContent(this.dataTable, dataRowIndex, dataColumnIndex)
183
+
184
+ return {
185
+ type: "data",
186
+ id: `T_${this.uuid}row${dataRowIndex}_col${dataColumnIndex}`,
187
+ classNames: classNames.join(" "),
188
+ content,
189
+ }
190
+ }
191
+ }
192
+
193
+ public getContent = (
194
+ table: Table,
195
+ rowIndex: number,
196
+ columnIndex: number
197
+ ): any => {
198
+ const column = table.getColumnAt(columnIndex)
199
+ if (column === null) {
200
+ return ""
201
+ }
202
+
203
+ const columnTypeId = this.getColumnTypeId(table, columnIndex)
204
+ switch (columnTypeId) {
205
+ case Type.Timestamp: {
206
+ return this.nanosToDate(column.get(rowIndex))
207
+ }
208
+ default: {
209
+ return column.get(rowIndex)
210
+ }
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Returns apache-arrow specific typeId of column.
216
+ */
217
+ private getColumnTypeId(table: Table, columnIndex: number): Type {
218
+ return table.schema.fields[columnIndex].type.typeId
219
+ }
220
+
221
+ private nanosToDate(nanos: number): Date {
222
+ return new Date(nanos / 1e6)
223
+ }
224
+ }
streamlit_observable/frontend/src/streamlit/StreamlitReact.tsx ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hoistNonReactStatics from "hoist-non-react-statics"
2
+ import React, { ReactNode } from "react"
3
+ import { RenderData, Streamlit } from "./streamlit"
4
+
5
+ /**
6
+ * Props passed to custom Streamlit components.
7
+ */
8
+ export interface ComponentProps {
9
+ /** Named dictionary of arguments passed from Python. */
10
+ args: any
11
+
12
+ /** The component's width. */
13
+ width: number
14
+
15
+ /**
16
+ * True if the component should be disabled.
17
+ * All components get disabled while the app is being re-run,
18
+ * and become re-enabled when the re-run has finished.
19
+ */
20
+ disabled: boolean
21
+ }
22
+
23
+ /**
24
+ * Optional Streamlit React-based component base class.
25
+ *
26
+ * You are not required to extend this base class to create a Streamlit
27
+ * component. If you decide not to extend it, you should implement the
28
+ * `componentDidMount` and `componentDidUpdate` functions in your own class,
29
+ * so that your plugin properly resizes.
30
+ */
31
+ export class StreamlitComponentBase<S = {}> extends React.PureComponent<
32
+ ComponentProps,
33
+ S
34
+ > {
35
+ public componentDidMount(): void {
36
+ // After we're rendered for the first time, tell Streamlit that our height
37
+ // has changed.
38
+ Streamlit.setFrameHeight()
39
+ }
40
+
41
+ public componentDidUpdate(): void {
42
+ // After we're updated, tell Streamlit that our height may have changed.
43
+ Streamlit.setFrameHeight()
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Wrapper for React-based Streamlit components.
49
+ *
50
+ * Bootstraps the communication interface between Streamlit and the component.
51
+ */
52
+ export function withStreamlitConnection(
53
+ WrappedComponent: React.ComponentType<ComponentProps>
54
+ ): React.ComponentType {
55
+ interface WrapperProps { }
56
+
57
+ interface WrapperState {
58
+ renderData?: RenderData
59
+ componentError?: Error
60
+ }
61
+
62
+ class ComponentWrapper extends React.PureComponent<
63
+ WrapperProps,
64
+ WrapperState
65
+ > {
66
+ public constructor(props: WrapperProps) {
67
+ super(props)
68
+ this.state = {
69
+ renderData: undefined,
70
+ componentError: undefined,
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Error boundary function. This will be called if our wrapped
76
+ * component throws an error. We store the caught error in our state,
77
+ * and display it in the next render().
78
+ */
79
+ public static getDerivedStateFromError = (
80
+ error: Error
81
+ ): Partial<WrapperState> => {
82
+ return { componentError: error }
83
+ }
84
+
85
+ public componentDidMount = (): void => {
86
+ // Set up event listeners, and signal to Streamlit that we're ready.
87
+ // We won't render the component until we receive the first RENDER_EVENT.
88
+ Streamlit.events.addEventListener(
89
+ Streamlit.RENDER_EVENT,
90
+ this.onRenderEvent
91
+ )
92
+ Streamlit.setComponentReady()
93
+ }
94
+
95
+ public componentDidUpdate = (prevProps: any): void => {
96
+ // If our child threw an error, we display it in render(). In this
97
+ // case, the child won't be mounted and therefore won't call
98
+ // `setFrameHeight` on its own. We do it here so that the rendered
99
+ // error will be visible.
100
+ if (this.state.componentError != null) {
101
+ Streamlit.setFrameHeight()
102
+ }
103
+ }
104
+
105
+ public componentWillUnmount = (): void => {
106
+ Streamlit.events.removeEventListener(
107
+ Streamlit.RENDER_EVENT,
108
+ this.onRenderEvent
109
+ )
110
+ }
111
+
112
+ /**
113
+ * Streamlit is telling this component to redraw.
114
+ * We save the render data in State, so that it can be passed to the
115
+ * component in our own render() function.
116
+ */
117
+ private onRenderEvent = (event: Event): void => {
118
+ // Update our state with the newest render data
119
+ const renderEvent = event as CustomEvent<RenderData>
120
+ this.setState({ renderData: renderEvent.detail })
121
+ }
122
+
123
+ public render = (): ReactNode => {
124
+ // If our wrapped component threw an error, display it.
125
+ if (this.state.componentError != null) {
126
+ return (
127
+ <div>
128
+ <h1>Component Error</h1>
129
+ <span>{this.state.componentError.message}</span>
130
+ </div>
131
+ )
132
+ }
133
+
134
+ // Don't render until we've gotten our first RENDER_EVENT from Streamlit.
135
+ if (this.state.renderData == null) {
136
+ return null
137
+ }
138
+
139
+ return (
140
+ <WrappedComponent
141
+ width={window.innerWidth}
142
+ disabled={this.state.renderData.disabled}
143
+ args={this.state.renderData.args}
144
+ />
145
+ )
146
+ }
147
+ }
148
+
149
+ return hoistNonReactStatics(ComponentWrapper, WrappedComponent)
150
+ }
streamlit_observable/frontend/src/streamlit/index.tsx ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2018-2020 Streamlit Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ // Workaround for type-only exports:
19
+ // https://stackoverflow.com/questions/53728230/cannot-re-export-a-type-when-using-the-isolatedmodules-with-ts-3-2-2
20
+ import { ComponentProps as ComponentProps_ } from "./StreamlitReact"
21
+ import { RenderData as RenderData_ } from "./streamlit"
22
+
23
+ export {
24
+ StreamlitComponentBase,
25
+ withStreamlitConnection,
26
+ } from "./StreamlitReact"
27
+ export { ArrowTable } from "./ArrowTable"
28
+ export { Streamlit } from "./streamlit"
29
+ export type ComponentProps = ComponentProps_
30
+ export type RenderData = RenderData_
streamlit_observable/frontend/src/streamlit/streamlit.ts ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2018-2020 Streamlit Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ // Safari doesn't support the EventTarget class, so we use a shim.
19
+ import { EventTarget } from "event-target-shim"
20
+ import { ArrowDataframeProto, ArrowTable } from "./ArrowTable"
21
+
22
+ /** Data sent in the custom Streamlit render event. */
23
+ export interface RenderData {
24
+ args: any
25
+ disabled: boolean
26
+ }
27
+
28
+ /** Messages from Component -> Streamlit */
29
+ enum ComponentMessageType {
30
+ // A component sends this message when it's ready to receive messages
31
+ // from Streamlit. Streamlit won't send any messages until it gets this.
32
+ // Data: { apiVersion: number }
33
+ COMPONENT_READY = "streamlit:componentReady",
34
+
35
+ // The component has a new widget value. Send it back to Streamlit, which
36
+ // will then re-run the app.
37
+ // Data: { value: any }
38
+ SET_COMPONENT_VALUE = "streamlit:setComponentValue",
39
+
40
+ // The component has a new height for its iframe.
41
+ // Data: { height: number }
42
+ SET_FRAME_HEIGHT = "streamlit:setFrameHeight",
43
+ }
44
+
45
+ /**
46
+ * Streamlit communication API.
47
+ *
48
+ * Components can send data to Streamlit via the functions defined here,
49
+ * and receive data from Streamlit via the `events` property.
50
+ */
51
+ export class Streamlit {
52
+ /**
53
+ * The Streamlit component API version we're targetting.
54
+ * There's currently only 1!
55
+ */
56
+ public static readonly API_VERSION = 1
57
+
58
+ public static readonly RENDER_EVENT = "streamlit:render"
59
+
60
+ /** Dispatches events received from Streamlit. */
61
+ public static readonly events = new EventTarget()
62
+
63
+ private static registeredMessageListener = false
64
+ private static lastFrameHeight?: number
65
+
66
+ /**
67
+ * Tell Streamlit that the component is ready to start receiving data.
68
+ * Streamlit will defer emitting RENDER events until it receives the
69
+ * COMPONENT_READY message.
70
+ */
71
+ public static setComponentReady = (): void => {
72
+ if (!Streamlit.registeredMessageListener) {
73
+ // Register for message events if we haven't already
74
+ window.addEventListener("message", Streamlit.onMessageEvent)
75
+ Streamlit.registeredMessageListener = true
76
+ }
77
+
78
+ Streamlit.sendBackMsg(ComponentMessageType.COMPONENT_READY, {
79
+ apiVersion: Streamlit.API_VERSION,
80
+ })
81
+ }
82
+
83
+ /**
84
+ * Report the component's height to Streamlit.
85
+ * This should be called every time the component changes its DOM - that is,
86
+ * when it's first loaded, and any time it updates.
87
+ */
88
+ public static setFrameHeight = (height?: number): void => {
89
+ if (height === undefined) {
90
+ // `height` is optional. If undefined, it defaults to scrollHeight,
91
+ // which is the entire height of the element minus its border,
92
+ // scrollbar, and margin.
93
+ height = document.body.scrollHeight + 10;
94
+ }
95
+
96
+ if (height === Streamlit.lastFrameHeight) {
97
+ // Don't bother updating if our height hasn't changed.
98
+ return
99
+ }
100
+
101
+ Streamlit.lastFrameHeight = height
102
+ Streamlit.sendBackMsg(ComponentMessageType.SET_FRAME_HEIGHT, { height })
103
+ }
104
+
105
+ /**
106
+ * Set the component's value. This value will be returned to the Python
107
+ * script, and the script will be re-run.
108
+ *
109
+ * For example:
110
+ *
111
+ * JavaScript:
112
+ * Streamlit.setComponentValue("ahoy!")
113
+ *
114
+ * Python:
115
+ * value = st.my_component(...)
116
+ * st.write(value) # -> "ahoy!"
117
+ *
118
+ * The value must be serializable into JSON.
119
+ */
120
+ public static setComponentValue = (value: any): void => {
121
+ Streamlit.sendBackMsg(ComponentMessageType.SET_COMPONENT_VALUE, { value })
122
+ }
123
+
124
+ /** Receive a ForwardMsg from the Streamlit app */
125
+ private static onMessageEvent = (event: MessageEvent): void => {
126
+ const type = event.data["type"]
127
+ switch (type) {
128
+ case Streamlit.RENDER_EVENT:
129
+ Streamlit.onRenderMessage(event.data)
130
+ break
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Handle an untyped Streamlit render event and redispatch it as a
136
+ * StreamlitRenderEvent.
137
+ */
138
+ private static onRenderMessage = (data: any): void => {
139
+ let args = data["args"]
140
+ if (args == null) {
141
+ console.error(
142
+ `Got null args in onRenderMessage. This should never happen`
143
+ )
144
+ args = {}
145
+ }
146
+
147
+ // Parse our dataframe arguments with arrow, and merge them into our args dict
148
+ const dataframeArgs =
149
+ data["dfs"] && data["dfs"].length > 0
150
+ ? Streamlit.argsDataframeToObject(data["dfs"])
151
+ : {}
152
+
153
+ args = {
154
+ ...args,
155
+ ...dataframeArgs,
156
+ }
157
+
158
+ const disabled = Boolean(data["disabled"])
159
+
160
+ // Dispatch a render event!
161
+ const eventData = { disabled, args }
162
+ const event = new CustomEvent<RenderData>(Streamlit.RENDER_EVENT, {
163
+ detail: eventData,
164
+ })
165
+ Streamlit.events.dispatchEvent(event)
166
+ }
167
+
168
+ private static argsDataframeToObject = (
169
+ argsDataframe: ArgsDataframe[]
170
+ ): object => {
171
+ const argsDataframeArrow = argsDataframe.map(
172
+ ({ key, value }: ArgsDataframe) => [key, Streamlit.toArrowTable(value)]
173
+ )
174
+ return Object.fromEntries(argsDataframeArrow)
175
+ }
176
+
177
+ private static toArrowTable = (df: ArrowDataframeProto): ArrowTable => {
178
+ const { data, index, columns } = df.data
179
+ return new ArrowTable(data, index, columns)
180
+ }
181
+
182
+ /** Post a message to the Streamlit app. */
183
+ private static sendBackMsg = (type: string, data?: any): void => {
184
+ window.parent.postMessage(
185
+ {
186
+ isStreamlitMessage: true,
187
+ type: type,
188
+ ...data,
189
+ },
190
+ "*"
191
+ )
192
+ }
193
+ }
194
+
195
+ interface ArgsDataframe {
196
+ key: string
197
+ value: ArrowDataframeProto
198
+ }
streamlit_observable/frontend/src/types.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ declare module '@observablehq/runtime';