-
|
Hello, not sure if blind or misunderstanding something, but I fail when trying to export a marimo notebook that imports a python file with some extra functions to html-wasm. Project layout: In the marimo notebook If I convert now to html-wasm and then try to use the generated stuff $ marimo export html-wasm marimo_nb.py -o build_marimo --mode run
$ cd build_marimo
$ python -m http.serverI get an Is this an error on my side (I mean I can also add the helpfunctions into the marimo notebook but it clutters things up) or should marimo export those functions (according to the documentation "The exported HTML file will run your notebook using WebAssembly, making it completely self-contained and executable in the browser.") |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
hey @q-wertz - we should update our documentation, but it only packages your notebook.py and does not traverse for other files in your directory. this is something we could potentially support in future, but for now you can:
|
Beta Was this translation helpful? Give feedback.
-
|
Just in case anyone else is looking for ways to do this, the following bash script may be useful. The script does some basic level of error checking, and asks the user to confirm the list of files to be inserted, but please read the script it before using it to make sure it fits your use case. The only argument accepted by the script is #!/bin/bash
file="notebook.py"
pkgdir="mypackage"
# Check that the specified file and directory exists
if [[ ! -f "$file" ]]; then
echo "Error: your must specify in the script an exisiting file to process"
exit 1
fi
if [[ ! -d $pkgdir ]]; then
echo "Error: your must specify in the script a directory which has the source files"
echo ' You can specify "." for the current directory'
exit 1
fi
# First we read the file and get a list of what to insert where
linenum=0
declare -a linenums
declare -a inserts
while IFS= read -r line; do
((linenum ++))
if [[ "$line" == "#inline "* ]]; then
linenums+=($linenum)
linearr=($line)
inserts+=(${linearr[1]})
fi
done < "$file"
# If the "-f" flag has not been given, ask the user if they want to proceed
if [[ $1 == "-f" ]]; then
response="y"
else
echo "The program will perform the following inlining:"
echo "Files to insert:" "${inserts[@]}"
echo "After line numbers:" "${linenums[@]}"
read -r -p "Do you want to proceed? [y/N] " response
fi
if [[ "$response" =~ ^(yes|y)$ ]]; then
# Do the actual processing. First make a copy of our file, restore it at the end.
cp $file $file.bak
# Loop over filenames to insert
for ins in "${inserts[@]}"; do
if [[ ! -f $pkgdir/$ins ]]; then
echo "Error: could not find $pkgdir/$ins, skipping..."
else
# This inserts the file
sed -i -e "/#inline $ins/r $pkgdir/$ins" $file
# This changes the comment string, so you could run this multiple times
sed -i "/#inline $ins/#Have inlined $ins" $file
fi
done
# Move result to output_ file and restore copy of original file
mv $file output_$file
mv $file.bak $file
else
echo "Cancelled the process."
exit 1
fi |
Beta Was this translation helpful? Give feedback.
hey @q-wertz - we should update our documentation, but it only packages your notebook.py and does not traverse for other files in your directory. this is something we could potentially support in future, but for now you can: