Skip to content

Commit

Permalink
Merge branch '01-12-feat_task_and_use_task_for_better_asyncio_task_a_…
Browse files Browse the repository at this point in the history
…thread_execution' into 02-05-feat_support_theming_solara
  • Loading branch information
iisakkirotko authored Feb 16, 2024
2 parents d03f038 + a9f836f commit f9b54bf
Show file tree
Hide file tree
Showing 36 changed files with 1,288 additions and 395 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.25.1
current_version = 1.26.1
commit = True
tag = True
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))((?P<release>.)(?P<build>\d+))?
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codequality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, "3.9"]
python-version: [3.8, "3.9"]

steps:
- uses: actions/checkout@v2
Expand All @@ -25,7 +25,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install ".[dev]" mypy==1.1.1 black==22.12.0 codespell==2.2.4 "click<8.1.4" "traitlets<5.10.0" "matplotlib<3.8.0"
pip install ".[dev]" mypy==1.6.0 black==22.12.0 codespell==2.2.4 "click<8.1.4" "traitlets<5.10.0" "matplotlib<3.8.0"
mypy --install-types --non-interactive solara
- name: Run codespell
run: codespell
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
files: \.py$
args: [--profile=black]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.1.1" # Use the sha / tag you want to point at
rev: "v1.6.0" # Use the sha / tag you want to point at
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
Expand Down
4 changes: 2 additions & 2 deletions packages/assets/hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface

packages = [
["@widgetti/solara-vuetify-app", "6.1.0"],
["@widgetti/solara-vuetify3-app", "1.1.0"],
["@widgetti/solara-vuetify-app", "7.0.0"],
["@widgetti/solara-vuetify3-app", "2.0.0"],
["requirejs", "2.3.6"],
["mermaid", "8.6.4"],
["codemirror", "5.65.3"],
Expand Down
2 changes: 1 addition & 1 deletion packages/assets/solara_assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"CDN assets for Solara"
__version__ = "1.25.1"
__version__ = "1.26.1"
2 changes: 1 addition & 1 deletion packages/solara-enterprise/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = {file = "LICENSE"}
classifiers = ["License :: Free for non-commercial use"]
dynamic = ["version", "description"]
dependencies = [
"solara==1.25.1",
"solara==1.26.1",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion packages/solara-enterprise/solara_enterprise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"Enterprise features for Solara"
__version__ = "1.25.1"
__version__ = "1.26.1"
2 changes: 1 addition & 1 deletion packages/solara-vuetify-app/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 6.1.0
current_version = 7.0.0
commit = True
tag = True
tag_name = @widgetti/solara-vuetify-app@{new_version}
Expand Down
4 changes: 2 additions & 2 deletions packages/solara-vuetify-app/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@widgetti/solara-vuetify-app",
"version": "6.1.0",
"version": "7.0.0",
"description": "Solara Vuetify App",
"main": "dist/solara-vuetify-app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"watch": "webpack --watch --mode=development",
"devlink": "TARGET_DIR=`python -c \"import sys; print(sys.prefix)\"`/share/solara/cdn/@widgetti/solara-vuetify-app@6.1.0/; mkdir -p $TARGET_DIR && rm -rf $TARGET_DIR/dist && ln -sf $PWD/dist $TARGET_DIR/dist"
"devlink": "TARGET_DIR=`python -c \"import sys; print(sys.prefix)\"`/share/solara/cdn/@widgetti/solara-vuetify-app@7.0.0/; mkdir -p $TARGET_DIR && rm -rf $TARGET_DIR/dist && ln -sf $PWD/dist $TARGET_DIR/dist"
},
"author": "",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/solara-vuetify3-app/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.0
current_version = 2.0.0
commit = True
tag = True
tag_name = @widgetti/solara-vuetify3-app@{new_version}
Expand Down
4 changes: 2 additions & 2 deletions packages/solara-vuetify3-app/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@widgetti/solara-vuetify3-app",
"version": "1.1.0",
"version": "2.0.0",
"description": "Solara Vuetify App",
"main": "dist/solara-vuetify-app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"watch": "webpack --watch --mode=development",
"devlink": "TARGET_DIR=`python -c \"import sys; print(sys.prefix)\"`/share/solara/cdn/@widgetti/solara-vuetify3-app@1.1.0/; mkdir -p $TARGET_DIR && rm -rf $TARGET_DIR/dist && ln -sf $PWD/dist $TARGET_DIR/dist"
"devlink": "TARGET_DIR=`python -c \"import sys; print(sys.prefix)\"`/share/solara/cdn/@widgetti/solara-vuetify3-app@2.0.0/; mkdir -p $TARGET_DIR && rm -rf $TARGET_DIR/dist && ln -sf $PWD/dist $TARGET_DIR/dist"
},
"author": "",
"license": "MIT",
Expand Down
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build-backend = "hatchling.build"

[project]
name = "solara"
readme = "README.md"
authors = [{name = "Maarten A. Breddels", email = "[email protected]"}]
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
Expand Down Expand Up @@ -49,6 +50,18 @@ path = "solara/__init__.py"
[tool.hatch.build]
ignore-vcs = true

[tool.hatch.build.targets.sdist]
# unclear from hatch docs, but README.md and LICENSE are included by default
# even when we explicitly have an include list
include = [
"solara",
"tests",
"prefix",
]
# and even when we have an include list, we still need to exclude
# packages (which I think makes no sense)
exclude = ["packages"]

[project.optional-dependencies]
extra = [
"pygments",
Expand Down Expand Up @@ -84,7 +97,7 @@ dev = [
"pytest-playwright; python_version > '3.6'",
]
assets = [
"solara-assets==1.25.1"
"solara-assets==1.26.1"
]
flask = [
"flask",
Expand Down
6 changes: 3 additions & 3 deletions release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
## Making an alpha release


$ ./release.sh patch --new-version 1.25.1a1
$ ./release.sh patch --new-version 1.26.1a1


# semi automated
To make a new release
```
# update solara/__init__.py
$ git add -u && git commit -m 'Release v1.25.1' && git tag v1.25.1 && git push upstream master v1.25.1
$ git add -u && git commit -m 'Release v1.26.1' && git tag v1.26.1 && git push upstream master v1.26.1
```


If a problem happens, and you want to keep the history clean
```
# do fix
$ git rebase -i HEAD~3
$ git tag v1.25.1 -f && git push upstream master v1.25.1 -f
$ git tag v1.26.1 -f && git push upstream master v1.26.1 -f
```
3 changes: 2 additions & 1 deletion solara/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Build webapps using IPywidgets"""
__version__ = "1.25.1"
__version__ = "1.26.1"
github_url = "https://github.com/widgetti/solara"
git_branch = "master"

Expand Down Expand Up @@ -61,6 +61,7 @@ def _using_solara_server():
from .routing import use_route, use_router, use_route_level, find_route, use_pathname, resolve_path
from .autorouting import generate_routes, generate_routes_directory, RenderPage, RoutingProvider, DefaultLayout
from .checks import check_jupyter
from .scope import get_kernel_id, get_session_id


def display(*objs, **kwargs):
Expand Down
13 changes: 12 additions & 1 deletion solara/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ def cli():
pass


production_default = False
if "SOLARA_MODE" in os.environ:
# settings.main.mode by default is set to production,
# which is a good default for when you embed in a flask
# app for instance, but not for the CLI, which app developers
# usually run.
production_default = settings.main.mode == "production"
# Note that in the CLI we do set this value to "development"
# or "production" based on the --production flag


@cli.command()
@click.option("--port", default=int(os.environ.get("PORT", 8765)))
@click.option(
Expand All @@ -126,7 +137,7 @@ def cli():
help="Host to listen on. Defaults to the $HOST environment or $SOLARA_HOST when available or localhost when not given.",
)
@click.option("--dev/--no-dev", default=None, help="Deprecated: use --auto-restart/-a", hidden=True)
@click.option("--production", is_flag=True, default=False, help="Run in production mode: https://solara.dev/docs/understanding/solara-server")
@click.option("--production", is_flag=True, default=production_default, help="Run in production mode: https://solara.dev/docs/understanding/solara-server")
@click.option("--reload", is_flag=True, default=None, help="Deprecated: use --auto-restart/-a", hidden=True)
@click.option("-a", "--auto-restart", is_flag=True, default=False, help="Enable auto-restarting of server when the solara server code changes.")
@click.option("--tracer/--no-tracer", default=False)
Expand Down
2 changes: 1 addition & 1 deletion solara/components/cross_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def update_filter():
v.Select(v_model=column, items=columns_numeric, on_v_model=set_column, label="Choose column")
v.Switch(v_model=invert, on_v_model=set_invert, label="Invert filter")
v.Switch(v_model=enable, on_v_model=set_enable, label="Enable filter")
with solara.ToggleButtonsSingle(value=mode, on_value=set_mode):
with solara.ToggleButtonsSingle(value=mode, on_value=set_mode): # type: ignore
solara.Button(icon_name="mdi-code-equal", icon=True, value="==")
solara.Button(icon_name="mdi-code-not-equal", icon=True, value="!=")
solara.Button(icon_name="mdi-code-less-than", icon=True, value="<")
Expand Down
113 changes: 101 additions & 12 deletions solara/components/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,42 @@ def _run_solara(code):
)


def _markdown_template(html, style=""):
return (
def _markdown_template(
html,
style="",
):
template = (
"""
<template>
<div class="solara-markdown rendered_html jp-RenderedHTMLCommon" style=\""""
+ style
+ """\">"""
+ html
+ """</div>
+ r"""</div>
</template>
<script>
module.exports = {
mounted() {
if(window.mermaid)
mermaid.init()
if(window.MathJax && MathJax.Hub) {
async mounted() {
await this.loadRequire();
this.mermaid = await this.loadMermaid();
this.mermaid.init();
this.latexSettings = {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "$", right: "$", display: false},
{left: "\\[", right: "\\]", display: true},
{left: "\\(", right: "\\)", display: false}
]
};
if (window.renderMathInElement) {
window.renderMathInElement(this.$el, this.latexSettings);
} else if (window.MathJax && MathJax.Hub) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]);
} else {
console.log("MathJax not loaded, loading Katex instead")
window.renderMathInElement = await this.loadKatexExt();
window.renderMathInElement(this.$el, this.latexSettings);
}
this.$el.querySelectorAll("a").forEach(a => this.setupRouter(a))
window.md = this.$el
Expand All @@ -95,10 +113,8 @@ def _markdown_template(html, style=""):
// TODO: should we really do this?
href = location.pathname + href.substr(1);
a.attributes['href'].href = href;
// console.log("change href to", href);
}
if(href.startsWith("./") || href.startsWith("/")) {
// console.log("connect link with href=", href, "to router")
a.onclick = e => {
console.log("clicked", href)
if(href.startsWith("./")) {
Expand All @@ -109,26 +125,99 @@ def _markdown_template(html, style=""):
e.preventDefault()
}
} else if(href.startsWith("#")) {
// console.log("connect anchor with href=", href, "to custom javascript due to using <base>")
href = location.pathname + href;
a.attributes['href'].value = href;
} else {
console.log("href", href, "is not a local link")
}
},
async loadKatex() {
require.config({
map: {
'*': {
'katex': `${this.getCdn()}/[email protected]/dist/katex.min.js`,
}
}
});
const link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet";
link.href = `${this.getCdn()}/[email protected]/dist/katex.min.css`;
document.head.appendChild(link);
},
async loadKatexExt() {
this.loadKatex();
return (await this.import([`${this.getCdn()}/[email protected]/dist/contrib/auto-render.min.js`]))[0]
},
async loadMermaid() {
return (await this.import([`${this.getCdn()}/[email protected]/dist/mermaid.min.js`]))[0]
},
import(dependencies) {
return this.loadRequire().then(
() => {
if (window.jupyterVue) {
// in jupyterlab, we take Vue from ipyvue/jupyterVue
define("vue", [], () => window.jupyterVue.Vue);
} else {
define("vue", ['jupyter-vue'], jupyterVue => jupyterVue.Vue);
}
return new Promise((resolve, reject) => {
requirejs(dependencies, (...modules) => resolve(modules));
})
}
);
},
loadRequire() {
if (window.requirejs) {
console.log('require found');
return Promise.resolve();
}
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = `${this.getCdn()}/[email protected]/require.min.js`;
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
},
getBaseUrl() {
if (window.solara && window.solara.rootPath !== undefined) {
return solara.rootPath + "/";
}
// if base url is set, we use ./ for relative paths compared to the base url
if (document.getElementsByTagName("base").length) {
return "./";
}
const labConfigData = document.getElementById('jupyter-config-data');
if (labConfigData) {
/* lab and Voila */
return JSON.parse(labConfigData.textContent).baseUrl;
}
let base = document.body.dataset.baseUrl || document.baseURI;
if (!base.endsWith('/')) {
base += '/';
}
return base
},
getCdn() {
return this.cdn || (typeof solara_cdn !== "undefined" && solara_cdn) || `${this.getBaseUrl()}_solara/cdn`;
}
},
updated() {
// if the html gets update, re-run mermaid
if(window.mermaid)
mermaid.init()
this.mermaid.init();
if(window.MathJax && MathJax.Hub) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, this.$el]);
} else {
window.renderMathInElement(this.$el, this.latexSettings);
}
}
}
</script>
"""
)
return template


def _highlight(src, language, unsafe_solara_execute, extra, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions solara/lab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# isort: skip_file
from ..server.kernel_context import on_kernel_start # noqa: F401
from .components import * # noqa: F401, F403
from ..tasks import task, use_task, Task # noqa: F401, F403
from ..server.kernel_context import on_kernel_start # noqa: F401
from ..tasks import task, use_task, Task, TaskResult # noqa: F401, F403
from ..toestand import computed # noqa: F401


Expand Down
Loading

0 comments on commit f9b54bf

Please sign in to comment.