Collaborative Coding

99 views
Skip to first unread message

Ian Page

unread,
Mar 5, 2024, 12:59:52 AMMar 5
to VPython-users
Is there any platform that allows students collaboratively code together in VPython (on the same program)?  Trinket and Web VPython do not appear to allows students to code collaboratively. 

Just curious if anyone has suggestions.

Ian Page
HS Physics Teacher
Singapore American School

John

unread,
Mar 6, 2024, 4:02:01 PMMar 6
to VPython-users
You can try using this


The next release of vpython which will be released soon will work with JupyterLab v4.

John

Message has been deleted

John

unread,
Mar 6, 2024, 5:18:12 PMMar 6
to VPython-users
It looks like it works. Attached are screen captures from two different browsers collaborating on a file in JupyterLab v4. All you need to do to collaborate is to click on the "Generate a Shared Link" icon in the upper right hand side of the JupyterLab interface and share the link with your collaborator.

John
colab1.jpg
colab2.jpg

John

unread,
Mar 6, 2024, 7:26:59 PMMar 6
to VPython-users
You can try it out yourself with this demo of vpython running on mybinder.org by going to this link.

https://mybinder.org/v2/gh/jcoady/vpbindercolab/HEAD

After the demo opens in your browser open one of the demo vpython notebooks (e.g. Bounce-VPython.ipynb  file). Then click on the "Generate a Shared Link" icon in the upper right hand side of the JupyterLab4 interface. When the dialog box opens, select "include token in URL" checkbox and then click the "Copy Link" button.

Paste the link into another browser browser address bar on the same or another computer. It should open the same notebook file in the other browser. Run the vpython simulation in the notebook from either browser interface. You should see it running in all browsers opened to a copy of the link.

Edit one of the notebook cells by adding python code. ( e.g.  print("Hello World") ). You should see the edit in all browsers opened to a copy of the link.

In addition to mybinder you should also be able to do this on JupyterHub if you set it up and install it on one of your computers on your network. Note that the mybinder simulation will halt after a certain timeout of inactivity of not using the interface. If it times out you will need to launch it again by clicking on the link. Here is the github repository I set up for this demo. You can just copy it and set up your own repository on github and just provide a link to the repository in the mybinder.org and click launch button.


You can also click on the "launch binder" badge in this github repository to launch the demo on mybinder in rather than clicking on the URL link provided above.

John

John

unread,
Mar 6, 2024, 7:57:41 PMMar 6
to VPython-users
Here is some more information on collaboration using JupyterHub and JupyterLab

Ian Page

unread,
Mar 7, 2024, 12:01:52 AMMar 7
to vpytho...@googlegroups.com
Thanks!  Much appreciated,

Ian Page

--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/7ddd111b-8bc5-46f1-852e-9ab581bd6b53n%40googlegroups.com.


--
AP Physics 2, Accelerated Physics, and Forensic Science Teacher
Singapore American School
40 Woodlands Street 41
Singapore 738547


CONFIDENTIALITY CAUTION: This message is intended only for the use of the individual or entity to whom it is addressed and contains information that is privileged and confidential. If you, the reader of this message, are not the intended recipient, you should not disseminate, distribute or copy this communication. If you have received this communication in error, please notify us immediately by return email and delete the original message. Unless it relates to the official business of Singapore American School, any opinions or matters expressed in this message are those of the individual sender.

John

unread,
Mar 7, 2024, 1:56:40 PMMar 7
to VPython-users
You can also collaborate between computers connected to the same wifi with jupyterlab v4 running on one of the connected computers, (for instance having different computers connected to wifi on a home network). Assuming you are running jupyterlab from a python environment such as Anaconda or Miniconda ( https://docs.anaconda.com/free/miniconda/miniconda-install/ ) installed on one of the machines you will need to get that machines ip address. On Windows or Mac you can use the ipconfig command from the Command Prompt to obtain the computers ip address.

ipconfig
...
   IPv4 Address. . . . . . . . . . . : 192.168.0.29
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

Ensure you have the jupyter-collaboration extension installed in jupyterlab v4.
pip install jupyter-collaboration
Then launch jupyter lab using the IPv4 Address. You can run

jupyter lab --no-browser --ip="<remote server ip>"

which in this case will be

jupyter lab --no-browser --ip="192.168.0.29"

and you will get the something like this in the output

    To access the server, open this file in a browser:
        file:///C:/Users/GuestUser/AppData/Roaming/jupyter/runtime/jpserver-11068-open.html
    Or copy and paste one of these URLs:
        http://192.168.0.29:8888/lab?token=c205b561c7d2363dcf1e2a3958c89b871aea20d64733461f
        http://127.0.0.1:8888/lab?token=c205b561c7d2363dcf1e2a3958c89b871aea20d64733461f
[
Then copy the link with the ip  address of the host machine in a browser address bar to get jupyterlab interface in a browser of any of the computers connected to the same wifi network. (e.g. a computer with a ip address of 192.168.0.23 for instance)


Then you should see the JupyterLab interface in the browser and you can open notebooks and share links using  jupyter-collaboration icon in upper right side of interface to collaborate with others just as before.

This way if students are in a classroom setting with computers connected via wifi or ethernet and one or more of the computers has jupyterlab v4 installed on it with the jupyter-collaboration extension in a python environment such as Anaconda or Miniconda, then you can launch jupyterlab on these computers with it's ip address with one these commands.

jupyter lab --no-browser --ip="<remote server ip>"

as explained above or with just

jupyter lab --ip="<remote server ip>"

and then share links of notebooks with collaborators.

The alternative is to set up a JupyterHub with JupyterLab on a powerful computer or cluster of computers with sufficient compute resources for your students to run vpython on JupyterLab. On the other hand if some of the students can have a local copy of JupyterLab and vpython installed and running on their own computer they can share links with other collaborators connected to the same wifi network and use the compute resources of the computer running the JupyterLab server and vpython on that local machine.

John

John

unread,
Mar 8, 2024, 5:00:14 PMMar 8
to VPython-users
One thing about Jupyter Notebooks that you should probably be aware of is that a notebook cell must run to completion before another cell can run it's code. If a VPython program has a simulation loop that never ends then that cell will run forever until the kernel is halted. A simulation loop with code like

while True:
    rate(200)
     ...

in a VPython program will run forever in a notebook cell. An example of this is the Bounce-VPython demo notebook.


 If the simulation is running then you won't be able to execute other cells in the notebook until you "Restart the kernel" by clicking the appropriate icon at the top in the notebook toolbar. This may be an issue of you are working in collaboration with other users who would like to would like to execute code in other cells in the notebook. One solution is to add asynchronous code to the simulation loop as shown in this asynchronous version of the above demo program.


If you run this version then you can execute other cells in the notebook while the VPython simulation is running. So in this case a collaborator can change the color of the bouncing ball or clear the trail of the ball by executing the code in the other code cells in the Jupyter notebook.  I have added this Async version of Bounce-VPython along with other VPython demo programs to the github repository and you can try them out on mybinder.org using the same link as before.


The updated github repository for this demo is here.


and you can also click on the "launch binder" badge in this repository to run it on mybinder.org.


John




John

unread,
Mar 11, 2024, 9:29:11 AMMar 11
to VPython-users
If your working with vpython in a jupyter notebook on mybinder.org and the mybinder session times out then you can still save your work and recover the notebook it if you click on the File -> Download menu item in the JupyterLab interface or you can click on the cloud shape icon in the notebook toolbar to "Save to browser storage" and then restart the mybinder session, open the notebook and click on the "Restore from browser storage" icon in the notebook toolbar to recover your work in the notebook. You can find out more about persistent storage on mybinder in this article.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages