Skip to main content

No project description provided

Project description

moso

moso provides a %%moso cell magic that lets you build up a Mojo program across multiple notebook cells. All %%moso cells are collected, compiled, and run together as a single Mojo script. The last collected cell is wrapped in def main() raises:.

moso primarily supports SolveIt (from Answer.ai) because it allows the tool to identify which cell is currently executing. In a standard Jupyter Notebook environment, the magic simply collects all cells containing %%moso.

Install

pip install -e .

Usage

SolveIt

from moso.core import *
setup_moso()

Jupyter Notebook

from moso.core import *
setup_moso(nb_path='path/to/your/notebook.ipynb')

Then write Mojo code in %%moso cells:

%%moso
def add(a: Int, b: Int) -> Int:
    return a + b
%%moso
print(add(40, 2))

Remote execution

Pass an SSH host and command template if Mojo runs on another machine:

setup_moso(host="user@host", cmd="cd ~/mojo-gpu-puzzles && /root/.pixi/bin/pixi run mojo run {path}")

How it works

filter_moso strips the %%moso lines, concatenates previous cells, and wraps the current cell in a main() (or the last cell in standard Jupyter Notebook). setup_moso registers the IPython cell magic and runs the generated source either locally or over SSH.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moso-0.0.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moso-0.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file moso-0.0.1.tar.gz.

File metadata

  • Download URL: moso-0.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for moso-0.0.1.tar.gz
Algorithm Hash digest
SHA256 21dccb3c4bff876715d6d1dce6a59d3e5df1eb1e11c24ad2d5559cdb9187a2f7
MD5 fa9aa1a06148cdbc061f0c7b1fb5514a
BLAKE2b-256 8ff8def48c6d272b55897207c8f3794a067e2ce97494320d269f42f5d53787f0

See more details on using hashes here.

File details

Details for the file moso-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: moso-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for moso-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2459c2ece7fa24484d22116987dabafa65c4e31d428bbfa056d2a25ae95115c8
MD5 39925dd75916271b531e280899c2ec0f
BLAKE2b-256 eabb125f55ca8898a259af67fb537d7596566f0aadf6ace644784efb7848e921

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page