Spaces:
Running
Running
Download web/js/data.js from FineEnvs/RL-Explorer: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/FineEnvs/RL-Explorer/resolve/main/web/js/data.js
- Command line
-
hf download hf://spaces/FineEnvs/RL-Explorer/web/js/data.js
-
curl -L -o data.js https://huggingface.co/spaces/FineEnvs/RL-Explorer/resolve/main/web/js/data.js
1.06 kB
| // Data more than one view reads: every Harbor dataset on the Hub, and the signed-in visitor's own. Fetched once. | |
| import { api } from "./util.js"; | |
| import { getSession } from "./session.js"; | |
| let envs = null, mine = null; | |
| export function environments() { | |
| if (!envs) { | |
| envs = api("/api/environments").then((d) => { | |
| d.datasets.forEach((x) => { x._blob = `${x.id} ${x.heading || ""} ${x.brief} ${x.tags.join(" ")}`.toLowerCase(); }); | |
| d.byKey = Object.fromEntries(d.datasets.map((x) => [x.key, x])); | |
| return d; | |
| }).catch((e) => { envs = null; throw e; }); | |
| } | |
| return envs; | |
| } | |
| // the visitor's own Harbor datasets and their organizations', private ones included; [] when signed out | |
| export function myDatasets() { | |
| if (!getSession().user) return Promise.resolve([]); | |
| if (!mine) mine = api("/api/environments/mine").then((d) => d.datasets).catch(() => { mine = null; return []; }); | |
| return mine; | |
| } | |
| export function forgetMine() { mine = null; } | |
| // Ranking is centralized in /api/search so list, filters and individual ranks agree. | |