Skip to content

Commit

Permalink
Add collaborative to demo (QuantStack#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl authored Jul 30, 2021
1 parent 0a80d24 commit a23e305
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 16 deletions.
10 changes: 6 additions & 4 deletions .binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ channels:
dependencies:
- python >=3.9
# demo toys
- bqplot
- graphviz2drawio
- jupyter-lsp-python-lsp-server
- jupyterlab-link-share
Expand All @@ -37,11 +36,16 @@ dependencies:
- segno
- shapely
- tabulate
- sphinx-autobuild
### FEDERATED EXTENSIONS ###
- bqplot
- jupyterlab_widgets
- jupyterlab-tour
- wxyz_datagrid
- wxyz_json_schema_form
- wxyz_lab
- wxyz_svg
- sphinx-autobuild
### FEDERATED EXTENSIONS ###
############################################################################
### ipydrawio-docs-deps ###

Expand All @@ -51,8 +55,6 @@ dependencies:
- sphinx
- sphinx-jsonschema
- sphinxext-rediraffe
# for lite
- jupyterlab-tour
# TODO: resolve upstream
- sqlalchemy <1.4
- pip:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__
_output
.cache/
.coverage*
.eslintcache
.ipynb_checkpoints
Expand Down
9 changes: 1 addition & 8 deletions demo/jupyter-lite.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"jupyter-config-data": {
"appName": "IPyDrawioLite",
"disabledExtensions": [
"@deathbeds/ipydrawio-pdf",
"@jupyterlab-classic/lab-extension",
"@jupyterlab/server-proxy",
"@krassowski/jupyterlab-lsp",
"jupyterlab-server-proxy",
"nbdime-jupyterlab"
],
"collaborative": true,
"faviconUrl": "./favicon.ico"
},
"jupyter-lite-schema-version": 0
Expand Down
11 changes: 11 additions & 0 deletions demo/jupyter_lite_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
"LiteBuildConfig": {
"apps": ["lab"],
"contents": ["."],
"federated_extensions": [
"../py_packages/ipydrawio/dist/ipydrawio-1.1.1-py3-none-any.whl",
"https://github.com/conda-forge/releases/releases/download/noarch/bqplot-0.12.30-pyhd8ed1ab_0.tar.bz2/bqplot-0.12.30-pyhd8ed1ab_0.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/jupyterlab-tour-3.1.2-pyhd8ed1ab_0.tar.bz2/jupyterlab-tour-3.1.2-pyhd8ed1ab_0.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/jupyterlab_widgets-1.0.0-pyhd8ed1ab_1.tar.bz2/jupyterlab_widgets-1.0.0-pyhd8ed1ab_1.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/wxyz_datagrid-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_datagrid-0.5.1-pyhd8ed1ab_0.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/wxyz_json_schema_form-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_json_schema_form-0.5.1-pyhd8ed1ab_0.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/wxyz_lab-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_lab-0.5.1-pyhd8ed1ab_0.tar.bz2",
"https://github.com/conda-forge/releases/releases/download/noarch/wxyz_svg-0.5.1-pyhd8ed1ab_0.tar.bz2/wxyz_svg-0.5.1-pyhd8ed1ab_0.tar.bz2"
],
"ignore_contents": [
"(lab/|_output|.gitignore|doit.db|\\.json$|jupyter_config|log$|\\.cache)"
],
"ignore_sys_prefix": true,
"lite_dir": ".",
"output_archive": "../build/demo/ipydrawio-lite-1.1.1.tgz",
"output_dir": "../build/demo"
Expand Down
20 changes: 18 additions & 2 deletions docs/_templates/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
data-toggle="tooltip"
data-placement="right"
title="Try IPyDrawio in your browser. Right now."
id="demo-room-button"
>
<i class="fas fa-lightbulb"></i>
Try <strong>IPyDrawio</strong> Now
Try <strong>IPyDrawio</strong> Now <span id="demo-room-label"></span>
</a>
<details>
<summary><i class="fas fa-users"></i>Collaboration...</summary>
<input type="text" placeholder="room name" id="demo-room-name"></input><br/>
<em>everyone who uses this room name will be able to edit all files</em>
</details>
<br/>
or <a
href="{{ pathto(demo_tarball, True) }}"
Expand All @@ -22,5 +28,15 @@
</a>
<hr/>
<em>Powered by <a href="https://jupyterlite.rtfd.io" target="_blank">JupyterLite</a></em>
<script>$(function() {$('[data-toggle="tooltip"]').tooltip();});</script>
<script>$(function() {
$('[data-toggle="tooltip"]').tooltip();
$("#demo-room-name").on('input', () => {
const room = $("#demo-room-name").val().trim();
$("#demo-room-button").attr(
"href",
`{{ pathto('demo/index') }}` + (room ? `?room=${room}` : '')
);
$("#demo-room-label").text(room ? ` with ${room}` : '');
});
});</script>
</div>
2 changes: 0 additions & 2 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ dependencies:
- sphinx
- sphinx-jsonschema
- sphinxext-rediraffe
# for lite
- jupyterlab-tour
# TODO: resolve upstream
- sqlalchemy <1.4
- pip:
Expand Down
21 changes: 21 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def task_dist():

def task_env():
"""sync environments"""
if P.RTD:
return

for env, inherits in P.ENV_INHERITS.items():
yield dict(
name=f"""{env.parent.name}:{':'.join([inh.parent.name for inh in inherits])}""",
Expand Down Expand Up @@ -677,6 +680,24 @@ def task_demo():
print("jupyterlite not found, this might be okay", flush=True)
return

yield dict(
name="extensions",
doc="update jupyter-lite.json from the conda env",
file_dep=[P.ENV_BINDER, P.PY_WHEEL[P.IPD.name]],
targets=[P.DEMO_CONFIG],
actions=[
(
P._sync_lite_config,
[
P.ENV_BINDER,
P.DEMO_CONFIG,
P.FED_EXT_MARKER,
[P.PY_WHEEL[P.IPD.name]],
],
)
],
)

demo_dest = []
demo_tasks = []
final_dest = []
Expand Down
34 changes: 34 additions & 0 deletions scripts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def _clean(*paths_or_globs):
TESTING_IN_CI = bool(json.loads(os.environ.get("TESTING_IN_CI", "0")))
CI_ARTIFACT = os.environ.get("CI_ARTIFACT", "wheel")
CI = bool(json.loads(os.environ.get("CI", "0")))
RTD = os.environ.get("READTHEDOCS", "build")


# test arg pass-throughs
ATEST_ARGS = json.loads(os.environ.get("ATEST_ARGS", "[]"))
Expand Down Expand Up @@ -331,6 +333,9 @@ def _norm_js_version(pkg):
}

# demo
RE_CONDA_FORGE_URL = r"/conda-forge/(.*/)?(noarch|linux-64|win-64|osx-64)/([^/]+)$"
CONDA_FORGE_RELEASE = "https://github.com/conda-forge/releases/releases/download"
FED_EXT_MARKER = "### FEDERATED EXTENSIONS ###"
DEMO = ROOT / "demo"
DEMO_CONFIG = DEMO / "jupyter_lite_config.json"
DEMO_APPS = ["lab"]
Expand Down Expand Up @@ -806,6 +811,35 @@ def _build_lite():
return False


def _sync_lite_config(from_env, to_json, marker, extras):
"""use conda list to derive tarball names"""
raw_lock = subprocess.check_output(["conda", "list", "--explicit"])
ext_packages = [
p.strip().split(" ")[0]
for p in from_env.read_text(encoding="utf-8").split(marker)[1].split(" - ")
if p.strip()
]

tarball_urls = ["../" + str(extra.relative_to(ROOT).as_posix()) for extra in extras]
for raw_url in sorted(raw_lock.decode("utf-8").splitlines()):
try:
label, subdir, pkg = re.findall(RE_CONDA_FORGE_URL, raw_url)[0]
except IndexError:
continue

if label:
# TODO: haven't looked into this
continue

for ext in ext_packages:
if pkg.startswith(ext):
tarball_urls += ["/".join([CONDA_FORGE_RELEASE, subdir, pkg, pkg])]

config = json.loads(to_json.read_text(encoding="utf-8"))
config["LiteBuildConfig"]["federated_extensions"] = sorted(tarball_urls)
to_json.write_text(json.dumps(config, indent=2, sort_keys=True))


# Late environment hacks
os.environ.update(
CONDARC=str(CONDARC),
Expand Down

0 comments on commit a23e305

Please # to comment.