Closed omarabb315 closed 7 months ago
Hello, could you provide a bit more information about the problem with results not being saved when you close the window. What is a typical workflow where you are encountering this problem? What behaviour are you expecting but is not being provided?
Hello @pauldruce , the environment we are using is a JupyterHub with DockerSpawner that allows a user to login and choose a matlab image as in the photo below:
Then it opens this tab:
Now, the problem appears when a user tries to run a matlab script in the background by closing the tab or the laptop because the run stops for unknown reason, while when the user keep the tab open and wait for the run to finish everything goes well,
I think that the reason behind that is that the JupyterHub server culles any idle session after 10 minutes, so maybe the matlab kernel does not return an active state for the JupyterHub server while it is running the script in the background, and as an evidence for that I tried to disable the feature of culling sessions and then everything became OK, but as you know this is exhausting for the resources if sessions are not closed.
(Again) Additional Note: I am using a Docker Spawner to run images of matlab which are built by Providing MATLAB as a Volume or Bind Mount using the documentation here
Thank you
Hi @omarabb315
If I understood correctly, your users are unable to see the results of their executions on the MATLAB command line when they re-open a session in which they ran a script and closed their browser tab.
I believe you are seeing the another manifestation of mathworks/matlab-proxy#16.
The MATLAB command line does not save "displayed" results when the browser tab is closed, but this does not imply that the execution has not completed!
Any results from running the script should be available in the workspace, or on the file system.
NOTE that, If the only outputs of running a script are print statements to the command line, then it is expected for them to not be visible to the users of a fresh browser session.
Could you please verify my claim by running scripts which leave some noticeable changes to your workspace like returning a value etc ?
For example: In a new session execute the following on the MATLAB command line and close the window:
>> pause(120); x = 123
% Close your browser window after running this
% Note that x = 123 does not terminate with a ;
% which implies a print to the command line should occur after execution.
Then if you start a connect to the session from a new browser window after 120 seconds,
you should be able to see the variable x
in the workspace and can verify its value by executing the following on the command line:
>> x
x =
123
However, you will not see the print of the variable x
from the original execution.
This behavior is not unique to our integration with Jupyter and can be seen on MATLAB Online as well.
Kindly let me know if, the issue you are reporting is different from what I have described above and I'll be happy to reopen this issue to continue investigating.
Thank you for using the MATLAB Integration for Jupyter!!
Thank you @prabhakk-mw , Actually I was using a script that outputs some result files, and those results only appears when I keep the tab open contrary to the situation when I close the tab,
Would it be possible to share a simplified version of this script for us to attempt reproducing this on our end?
Sure, this is the steps of setting up the environment:
1) install JupyterHub (tljh) with docker plug-in, don't forget to set the admin name:
curl -L https://tljh.jupyter.org/bootstrap.py | sudo -E python3 - --admin <admin_name> --plugin git+https://github.com/pennchildlanglab/tljh-datascience
2) install nvidia-container-toolkit as shown here
3) Building the MATLAB image after installing it on host and providing it as a Volume or Bind Mount as shown here:
docker build --build-arg MATLAB_RELEASE=r2023b \
--build-arg PYTHON_VERSION=3.10 \
--build-arg MATLAB_IMAGE_NAME=mathworks/matlab:r2023b \
--build-arg LICENSE_SERVER=12345@hostname.com \
-t matlab-notebook-nomatlab -f Dockerfile.mounted .
5) setting the configuration file of JupyterHub server:
sudo nano /opt/tljh/config/jupyterhub_config.d/dockerspawner_tljh_config.py
then copy this and paste it:
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.image_whitelist = ['matlab-notebook-nomatlab']
from jupyter_client.localinterfaces import public_ips
c.JupyterHub.hub_ip = public_ips()[0]
c.DockerSpawner.name_template = '{prefix}-{username}-{servername}-{imagename}'
c.Spawner.mem_limit = '410G'
c.Spawner.cpu_limit = 64
import docker, os
c.DockerSpawner.extra_create_kwargs = {
'user': 'root',
}
c.DockerSpawner.environment = {
'GRANT_SUDO': 'yes',
'JUPYTER_ENABLE_LAB': 'yes',
}
c.DockerSpawner.extra_host_config = {
"device_requests": [
docker.types.DeviceRequest(
count=-1,
capabilities=[["gpu"]],
),
],
}
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work'
c.DockerSpawner.notebook_dir = notebook_dir
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}' : notebook_dir , '/usr/local/MATLAB/R2023b': {"bind": '/opt/matlab', "mode": "ro"}}
And that's it, please tell me if anything didn't work properly
Hi @omarabb315
Thank you for the detailed steps to recreate the environment! We greatly appreciate that. However, I was requesting for a sample of a MATLAB Script which showcases the FILEIO operation which does not occur unless the browser session with the Desktop is active. Would it be possible to get a sample MATLAB script ?
For example:
% place the following into a script file, start execution and close the browser tab
pause(120);
system('touch testfile.txt')
Re-connect to the MATLAB session after 2 minutes to notice that the file testfile.txt
is created!
Hi @omarabb315,
We have'nt heard from you in a while. Please do reply back with the requested information for us to continue investigating this issue together.
Thanks!
Currently I am using JupyterHub to organize students' access to our university server. When users run a matlab script, it only saves the results if the user continue to open the window, but when he close it the results are not saved. However by default every session in JupyterHub found to be idle for more than 10 minutes will be culled, so could it be that the JupyterHub server does not consider running a script in a session as an active one?
Additional Note: I am using a Docker Spawner to run images of matlab which are built by Providing MATLAB as a Volume or Bind Mount using the documentation here