Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/publish-jupyter-matlab-proxy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2024 The MathWorks, Inc.
# Copyright 2020-2025 The MathWorks, Inc.

name: Publish jupyter-matlab-proxy to PyPI
on:
Expand Down Expand Up @@ -38,10 +38,11 @@ jobs:
- name: Install Python build dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install wheel hatch
python3 -m pip install --upgrade build hatch wheel

- name: Build Source and Binary wheel distributions
run: python3 -m hatch build -t wheel
- name: Build Source and Binary wheel distributions (using recommended tooling)
# https://packaging.python.org/en/latest/guides/tool-recommendations/#building-distributions
run: python3 -m build

- name: Publish to PyPI.
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .github/workflows/test-jupyter-matlab-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- "main"
- "integration/**"
paths:
# Only run tests when there are changes to these folders
- "src/**"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "jupyter-matlab-proxy"
version = "0.17.1"
version = "0.17.2"
description = "MATLAB Integration for Jupyter"
readme = "README.md"
license = { file = "LICENSE.md" }
Expand Down
5 changes: 5 additions & 0 deletions src/jupyter_matlab_kernel/magic_execution_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def get_magics_from_cell(cell_code):
params = magic_dict["params"].strip()
if params:
magic_dict["params"] = re.split("\s+", params)
# transform ? parameter into a help magic, such that %%file? becomes %%help file
if params.startswith("?"):
# Ignore additional parameters after the ? parameter
magic_dict["params"] = [magic_dict.get("name", "")]
magic_dict["name"] = "help"
else:
magic_dict["params"] = []
magic_dict["line_number"] = line_number
Expand Down
16 changes: 7 additions & 9 deletions src/jupyter_matlab_kernel/magics/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Magic Commands for MATLAB Kernel

You can use magic commands with the MATLAB kernel. You can use the predefined magic commands in this folder, and you can implement your own by following the steps below.
This guide shows how to use magic commands with the MATLAB kernel for added functionality.

## Get Started

Magic commands for the MATLAB kernel are prefixed with two percentage symbols `%%` without whitespaces. For example, to list available magic commands, run `%%lsmagic`
Magic commands for the MATLAB kernel are prefixed with two percentage symbols `%%` without whitespaces. For example, to list available magic commands, run `%%lsmagic`. To read the documentation of a magic command, use the help command `?` or `help`, for example `%%lsmagic?` or `%%help lsmagic`.

Note that magic commands will only work at the beginning of cells, and will not work with MATLAB variables.

The magic commands `help` and `file` accept additional parameters. For example, to display information about a magic command, run `%%help` followed by the name of the magic as an argument: `%%help time`
Note that magic commands only work at the beginning of cells.

This table lists the predefined magic commands you can use:


|Name|Description|Additional Parameters|Constraints|Example command|
|---|---|---|---|---|
|lsmagic|List predefined magic commands.|||`%%lsmagic`|
|help|Display information about provided magic command. | Name of magic command.|| `%%help file`|
|time|Display time taken to execute a cell.|||`%%time`|
|file|Save contents of cell as a file in the notebook folder. You can use this command to define and save new functions. For details, see the section below on how to [Create New Functions Using the %%file Magic Command](#create-new-functions-using-the-the-file-magic-command)|Name of saved file|The file magic command will save the contents of the cell, but not execute them in MATLAB|`%%file myfile.m`|
|`?` and `help`| Display documentation of given magic command.|Name of magic command.||`%%lsmagic?` or `%%help lsmagic`|
|`lsmagic`|List predefined magic commands.|||`%%lsmagic`|
|`time`|Display time taken to execute a cell.|||`%%time`|
|`file`|Save contents of cell as a file in the notebook folder. You can use this command to define and save new functions. For details, see the section below on how to [Create New Functions Using the %%file Magic Command](#create-new-functions-using-the-the-file-magic-command)|Name of saved file.|The file magic command will save the contents of the cell, but not execute them in MATLAB.|`%%file myfile.m`|


To request a new magic command, [create an issue](https://github.com/mathworks/jupyter-matlab-proxy/issues/new/choose).
Expand Down
2 changes: 1 addition & 1 deletion src/jupyter_matlab_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def setup_matlab():


def _get_jsp_config(logger):
icon_path = Path(__file__).parent / "icon_open_matlab.svg"
icon_path = str(Path(__file__).parent / "icon_open_matlab.svg")
logger.debug("Icon_path: %s", icon_path)
jsp_config = {}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_jupyter_server_proxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2024 The MathWorks, Inc.
# Copyright 2020-2025 The MathWorks, Inc.

import inspect
import os
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_setup_matlab(set_mwi_use_fallback_kernel):
"""
# Setup
package_path = Path(inspect.getfile(jupyter_matlab_proxy)).parent
icon_path = package_path / "icon_open_matlab.svg"
icon_path = str(package_path / "icon_open_matlab.svg")

expected_matlab_setup = {
"command": [
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_setup_matlab_with_proxy_manager(monkeypatch):
monkeypatch.setattr("jupyter_matlab_proxy._MPM_AUTH_TOKEN", "secret")
monkeypatch.setattr("jupyter_matlab_proxy._JUPYTER_SERVER_PID", "123")
package_path = Path(inspect.getfile(jupyter_matlab_proxy)).parent
icon_path = package_path / "icon_open_matlab.svg"
icon_path = str(package_path / "icon_open_matlab.svg")

expected_matlab_setup = {
"command": [matlab_proxy_manager.get_executable_name()],
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_setup_matlab_with_token_auth_disabled(
"""
# Setup
package_path = Path(inspect.getfile(jupyter_matlab_proxy)).parent
icon_path = package_path / "icon_open_matlab.svg"
icon_path = str(package_path / "icon_open_matlab.svg")
monkeypatch.setattr(jupyter_matlab_proxy, "_mwi_auth_token", None)

expected_matlab_setup = {
Expand Down
Loading