sy-nb-sy
Synapse -> Jupyter notebook -> Synapse
An open-source Python utility for converting Microsoft Azure Synapse Notebook JSON files to and
from Jupyter Notebook .ipynb files. Conversion parses notebook structures and maps cells and
metadata; it does not execute notebook code.
Features
- Convert individual Synapse JSON and Jupyter notebook files in either direction.
- Bulk and optional recursive Synapse-to-Jupyter conversion.
- Preserve cell order, code, Markdown, outputs, execution counts, and supported metadata.
- Preserve Synapse-only notebook and cell properties in a namespaced Jupyter metadata field for round trips.
- Create destination directories and write output atomically.
- Refuse to overwrite existing output unless
--forceis supplied. - Python 3.10+; lightweight runtime dependency on
nbformat.
Installation
Once published on PyPI:
python -m pip install sy-nb-sy
To install from this repository:
python -m pip install .
For development, install the editable package and test tools:
python -m pip install -e ".[dev]"
Quick Start
sy-nb-sy --help
sy-nb-sy --version
The CLI works with absolute and relative paths. On Windows PowerShell:
sy-nb-sy synapse-to-ipynb --source ".\Notebook_json\Sales.json" --target ".\Notebook_ipynb\Sales.ipynb"
On Windows Command Prompt:
sy-nb-sy synapse-to-ipynb --source ".\Notebook_json\Sales.json" --target ".\Notebook_ipynb\Sales.ipynb"
On macOS/Linux:
sy-nb-sy synapse-to-ipynb \
--source "./Notebook_json/Sales.json" \
--target "./Notebook_ipynb/Sales.ipynb"
Synapse JSON -> Jupyter IPYNB
sy-nb-sy synapse-to-ipynb --source <source.json> --target <target.ipynb>
Example:
sy-nb-sy synapse-to-ipynb --source "./Notebook_json/Kundan_TimeGEN_Mantis_1.json" --target "./Notebook_ipynb/Kundan_TimeGEN_Mantis_1.ipynb"
Jupyter IPYNB -> Synapse JSON
sy-nb-sy ipynb-to-synapse --source <source.ipynb> --target <target.json>
Example:
sy-nb-sy ipynb-to-synapse --source "./Notebook_ipynb/Sales.ipynb" --target "./Notebook_json/Sales.json"
Bulk Conversion
Convert each .json file in a source directory. Unrelated files are ignored; a failed notebook
does not prevent other files from being converted.
sy-nb-sy bulk --source "./Notebook_json" --target "./Notebook_ipynb"
Existing targets are skipped. Add --force to replace them.
Recursive Conversion
Use --recursive to also search subdirectories. Relative directory structure is retained under
the target directory:
sy-nb-sy bulk --source "./Notebook_json" --target "./Notebook_ipynb" --recursive
Examples
The Example folder contains three Synapse JSON inputs, matching converted Jupyter notebooks, and a runnable testing walkthrough. The supplied sales-analysis example has sanitized Azure identifiers; the other demos use fictional data. Conversion and walkthrough checks do not execute source notebook code.
sy-nb-sy bulk --source ".\Example\source" --target ".\Example\Target" --force
CLI Reference
| Command | Purpose |
|---|---|
synapse-to-ipynb --source PATH --target PATH |
Convert a single Synapse JSON notebook |
ipynb-to-synapse --source PATH --target PATH |
Convert a single Jupyter notebook |
bulk --source DIR --target DIR |
Convert .json files in a directory |
Common options are --force (replace existing targets) and --verbose (show diagnostics).
bulk additionally supports --recursive. --help is available for the application and each
command; --version prints the installed version.
Python API
from sy_nb_sy import ipynb_to_synapse, synapse_to_ipynb
synapse_to_ipynb("Notebook_json/test.json", "Notebook_ipynb/test.ipynb")
ipynb_to_synapse("Notebook_ipynb/test.ipynb", "Notebook_json/test.json")
For batch conversion, use synapse_to_ipynb_bulk(source, target, recursive=False, force=False).
It returns a BulkConversionResult with succeeded, skipped, and failed items.
Conversion Behavior
- The Synapse parser accepts the common exported shape with root-level
nameand apropertiesobject containingcells. It also accepts a properties-like root object withcells. codeandmarkdowncell types are mapped directly. Source strings and arrays of source lines are accepted. Jupyter outputs and execution counts are retained for code cells.- Synapse
properties.metadatais mapped to Jupyter notebook metadata, and cell metadata maps directly to Jupyter cell metadata. - Additional Synapse root fields,
propertiesfields (including Spark pool/session configuration), and cell-level fields are carried in the_synapse_notebook_convertermetadata namespace so they can be restored when converting back. This internal file-format key is intentionally unchanged from the original project name for compatibility with previously converted notebooks. - Jupyter notebook metadata and cell metadata are retained in Synapse
properties.metadataand cell metadata, respectively. - A Jupyter notebook converted to Synapse without prior Synapse metadata gets a standard
name/propertiesenvelope and a notebook name based on the target filename.
Limitations
- This tool only transforms files; it never runs notebook code.
- Cell types other than code and Markdown cannot be converted to Synapse and produce an explicit error.
- Platform features that have no Jupyter equivalent are retained as namespaced metadata when present, but may not be interpreted by Jupyter or Synapse.
- Conversion is semantic rather than byte-for-byte; formatting, line-ending representation, and generated envelope defaults can differ.
- Generated Synapse JSON uses the exported notebook structure and may need adjustment for a specific Synapse workspace or runtime configuration.
Development
python -m pip install -e ".[dev]"
pytest
ruff check .
Testing
Tests use realistic Synapse/Jupyter fixtures and cover both directions, metadata, round trips, bulk/recursive operation, error cases, safe overwrite behavior, and the CLI.
Contributing
See CONTRIBUTING.md for setup and contribution guidance.
License
This project is licensed under the MIT License. See LICENSE.
Metadata
Release files for sy-nb-sy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sy_nb_sy-0.1.0.tar.gz | 18.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sy_nb_sy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.4 kB
Release files / sy_nb_sy-0.1.0.tar.gz
| Download URL | sy_nb_sy-0.1.0.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
346376be470da08e502d0a1291a078cded35b0571678735ff956e9237990c881
|
|
BLAKE2b-256 checksum How to use checksums |
9ede0733db0a2e376b858908c7fe11e7c7bb13d092d0fbcd70e96ecb85cc7f60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Release files / sy_nb_sy-0.1.0-py3-none-any.whl
| Download URL | sy_nb_sy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
402850239895538ad752d4de9d7b8ebbbf31cde37b750a05b090926ac0c9274c
|
|
BLAKE2b-256 checksum How to use checksums |
fa5263b83b5a2fbc7a3f4ab410b59c4374f478ac517e147b817236749ff938e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Security for sy-nb-sy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.