Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
revert later
  • Loading branch information
kiendang committed Jul 19, 2021
1 parent 2c8d365 commit 624c197
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 119 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r examples/requirements.txt --no-dependencies
pip install papermill
- uses: coursier/[email protected]
- uses: laughedelic/coursier-setup@v1
with:
Expand Down
152 changes: 41 additions & 111 deletions examples/scalapy-displays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,45 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n",
"\u001b[39m\n",
"\u001b[32mimport \u001b[39m\u001b[36mai.kien.python.Python\n",
"\n",
"\u001b[39m"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import $ivy.`ai.kien::python-native-libs:0.1.2`\n",
"import ai.kien.python.Python\n",
"\n",
"Python().scalapyProperties.fold(\n",
" ex => println(s\"Error while getting ScalaPy properties: $ex\"),\n",
" props => props.foreach(Function.tupled(System.setProperty _))\n",
")"
"val props = Python(\"/home/kien/.pyenv/versions/miniconda3-latest/envs/almond/bin/python3\").scalapyProperties.get\n",
"\n",
"props.foreach(Function.tupled(System.setProperty _))\n",
"\n",
"// Python().scalapyProperties.fold(\n",
"// ex => println(s\"Error while getting ScalaPy properties: $ex\"),\n",
"// props => {\n",
"// print(props)\n",
"// props.foreach(Function.tupled(System.setProperty _))\n",
"// }\n",
"// )\n",
"\n",
"props.map { case (k, _) => k -> System.getProperty(k) }"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n",
"\u001b[39m\n",
"\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py\n",
"\u001b[39m\n",
"\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py.PyQuote\n",
"\u001b[39m\n",
"\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py.SeqConverters\u001b[39m"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"props(\"jna.library.path\")\n",
" .split(java.io.File.pathSeparator)\n",
" .flatMap(p => os.list(os.Path(p)))\n",
" .filter(_.baseName contains props(\"scalapy.python.library\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import $ivy.`me.shadaj::scalapy-core:0.5.0`\n",
"import me.shadaj.scalapy.py\n",
Expand All @@ -61,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -70,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -80,63 +69,27 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"......"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"val display = py.module(\"IPython.display\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<b>hello</b>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display.HTML(\"<b>hello</b>\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"\\begin{eqnarray}\n",
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
"\\end{eqnarray}"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display.Latex(\"\"\"\\begin{eqnarray}\n",
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n",
Expand All @@ -148,41 +101,18 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle a = b + c$"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display.Math(\"a = b + c\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"\n",
"# title\n",
"## subsec\n",
"foo\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display.Markdown(\"\"\"\n",
"# title\n",
Expand Down
17 changes: 9 additions & 8 deletions scripts/validate-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ KERNEL_ID="almond-sources-tmp"
--jupyter-path "$JUPYTER_PATH/kernels" \
--id "$KERNEL_ID" \
--install --force \
--trap-output \
--predef-code 'sys.props("almond.ids.random") = "0"'

echo "publishLocal almond-scalapy"
Expand All @@ -45,12 +44,14 @@ cd .. && ./mill -i 'scala0.almond-scalapy['"$SCALA_VERSION"'].publishLocal' && c
ERRORS=0

while read f; do
jupyter nbconvert \
--to notebook \
--execute \
--ExecutePreprocessor.kernel_name="$KERNEL_ID" \
"$f" \
--output="$OUTPUT"
# jupyter nbconvert \
# --to notebook \
# --execute \
# --ExecutePreprocessor.kernel_name="$KERNEL_ID" \
# "$f" \
# --output="$OUTPUT"

papermill "$f" "$OUTPUT" -k "$KERNEL_ID" --log-output

sed -i "s@\\\\r\\\\n@\\\\n@g" "$OUTPUT"

Expand All @@ -59,7 +60,7 @@ while read f; do
else
echo "$f differs"
echo
diff -u "$f" "$OUTPUT"
# diff -u "$f" "$OUTPUT"
echo
echo

Expand Down

0 comments on commit 624c197

Please sign in to comment.