iSwift icon indicating copy to clipboard operation
iSwift copied to clipboard

Docker image for running Swift, and Swift For TensorFlow, in Jupyter.

iSwift is the kernel IPython/Notebook implementation for Swift programming language.

It can:

  • Execute swift code on the Jupyter Notebook web editor, Jupyter console as well as Jupyter qtconsole.
  • Import Foundatation/Dispatch and other Buildin libraries.
  • Autocomplete swift code by pressing tab ↹.
  • Support encryption.
  • Support Linux/macOS

This project is based off KelvinJin/iSwift but makes a few changes:

  • Updates to support Swift 4.1
  • Base the docker image off jupyter/minimal-notebook

Note: This is rough work-in-progress. What you're looking at is unlikely to be the latest and greatest. I'd suggest checking the Swift for TensorFlow google group, and the fork tree from KelvinJin's original verison, to understand what is the best version of this.

Quick Start

The easiest way of using this is via the docker image, which is already built and hosted on docker hub. Assuming you have docker installed on your machine, all you need to do is run:

$ docker run -t -i -p 8888:8888 --privileged algalgal/swift-notebook:b767ba373ced

This will download the image if needed, and then run it, starting Jupyter. (FYI, this runs an image based roughly on the github repo commit 6a08a20.)

Then copy and paste the URL from the console into your browser to access the notebook. From there you can select New -> Swift.

To build and run images locally, you can use the helper scripts build-jupyter-swift-notebook.sh and run-jupyter-swift-notebook.sh.

Requirements

These are requirement if you do not want to use docker:

  • macOS/Linux
  • Swift 4.1
  • ZMQ  + Jupyter 5.0

macOS Installation

Clone this repo locally. And:

  1. Follow this script to install the libzmq on your machine.

  2. Build the project.

swift build
  1. Currently, in order to run swift kernel locally, you need to create a file named kernel.json. Put the following content to the file and replace the Path/to/iSwift with your local clone path.
{
 "argv": ["Path/to/iSwift/.build/debug/iSwift", "-f", "{connection_file}"],
 "display_name": "Swift",
 "language": "swift"
}
  1. Install Jupyter kernel: (replace the Folder/that/has/kernel/json with the path of the folder that contains the kernel.json file)
jupyter-kernelspec install Folder/that/has/kernel.json
  1. Run Jupyter Notebook (token needs to be empty):
jupyter notebook --NotebookApp.token=

Linux Installation

  1. Install Swift 3.0.
  2. Check if you have libzmq installed.
  3. Continue from step 2 in the section above.

Docker Installation

Simply clone this repo and run docker build -t iswift .. It will build the docker image.

Author

Jin Wang

Contribution

Contributions are welcome. Simply create an issue if you have ideas on how we can improve iSwift.

License

MIT