Giter VIP home page Giter VIP logo

ortholang-jupyter-kernel's Introduction

ortholang_jupyter_kernel

A Jupyter Lab kernel for OrthoLang. Still a work in progress, but ready for testing by a few intrepid biologists!

Initial setup

It could be installed using the regular Jupyter kernel method:

python -m ortholang_jupyter_kernel.install

... But since OrthoLang already requires Nix, we might as well do it the reproducible Nix way instead! NixOS has a Jupyter server module. Just add something like this to your /etc/nixos/configuration.nix:

services.jupyter = {
  enable = true;

  # This is where the notebooks + checkpoint files go.
  # Users will have write access to any files in here.
  notebookDir = "/PATH/TO/YOUR/JUPYTER/NOTEBOOKS/DIR";

  # This enables access from localhost; see Nginx config below for remote access
  port = 8888;
  ip = "127.0.0.1";

  # generated with `jupyter notebook password`
  # see the password entry here for details:
  # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/development/jupyter/default.nix#L77
  password = "'sha1:YOURSHA1PASSWORDHASHHERE'";

  notebookConfig = '' 
    c.NotebookApp.open_browser=False 
    c.NotebookApp.allow_remote_access=True 
    c.NotebookApp.disable_check_xsrf=True 
  '';

  kernels = {

    ortholang =
      let kernel = pkgs.callPackage /PATH/TO/YOUR/ORTHOLANG_KERNEL/REPO/default.nix {
        inherit pkgs;
        pythonPackages = pkgs.python3Packages;
      };
      in {
        displayName = "OrthoLang 0.9.5";
        argv = [ "${kernel}/bin/ortholang_jupyter_kernel" "-f" "{connection_file}" ];
        language = "ortholang";
      };

  };
};

Clone this repo somewhere, fill in the variables above, and do sudo nixos-rebuild test to start it. Go to localhost:8888 in your browser, or see journalctl -f | grep -i jupyter for debugging information if it doesn't work.

Complete webserver

Once you have the server running, you'll probably want other people to be able to access it! Assuming you already have a domain name, adding something like this to the config should set it up properly for the public internet:

services.nginx = {
  enable = true;
  recommendedTlsSettings   = true;
  recommendedOptimisation  = true;
  recommendedGzipSettings  = true;
  recommendedProxySettings = true;
  virtualHosts = {
    "YOUR.DOMAIN.NAME.HERE" = {
      forceSSL = true;
      enableACME = true;
      default = true;
      locations = {
        "/" = {
          proxyPass = "http://localhost:8888"; # matches the jupyter service port above
          proxyWebsockets = true;
        };
      };
    };
  };
};

security.acme = {
  acceptTerms = true;
  certs = {
    "YOUR.DOMAIN.NAME.HERE" = {
      email = "[email protected]";
    };
  };
};

The virtualHosts section is useful if you want to tack this server on to an existing site. In that case you might also want useACMEHost to re-use an existing SSL certificate instead.

Usage

There's one extra rule for parsing in the notebook interface: when a cell contains multiple statements, they must be separated by blank lines. For example the blank lines here are important:

test1 = ["one",
         "two"]

test2 = ["two", "three"]

:show

Otherwise we have no obvious way to know how many prompts to expect without re-implementing the OrthoLang parser in Python!

TODO the "can't return both text and data" gotcha

ortholang-jupyter-kernel's People

Contributors

jefdaj avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.