aboutsummaryrefslogtreecommitdiff
path: root/gn
diff options
context:
space:
mode:
Diffstat (limited to 'gn')
-rw-r--r--gn/packages/julia.scm71
-rw-r--r--gn/packages/python.scm170
-rw-r--r--gn/services/pluto.scm134
3 files changed, 375 insertions, 0 deletions
diff --git a/gn/packages/julia.scm b/gn/packages/julia.scm
index e2ac956..355a498 100644
--- a/gn/packages/julia.scm
+++ b/gn/packages/julia.scm
@@ -17,6 +17,77 @@
#:use-module (gnu packages video)
#:use-module (ice-9 match))
+(define-public julia-visuals
+ (let ((commit "e7d670eb045a9f8e3a839476dc166318da7fe9dc")
+ (revision "1"))
+ (package
+ (name "julia-visuals")
+ (version (git-version "0.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/sens/visuals")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "15hshm5qrig5qbj02xy4ji79kfc72n93nna5nvxkhvb8gw3vvx07"))))
+ (build-system julia-build-system)
+ (arguments
+ `(#:tests? #f ; no test suite
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-source
+ (lambda* (#:key inputs #:allow-other-keys)
+ (chmod "runpluto.sh" #o755) ; it starts as #o444
+ (substitute* "runpluto.sh"
+ ;(("julia")
+ ; (string-append (assoc-ref inputs "julia") "/bin/julia"))
+ ;(("basename")
+ ; (string-append (assoc-ref inputs "coreutils") "/bin/basename"))
+ ;; The arguments don't pass through the wrapper
+ (("\\$\\{1\\}") "4343")
+ )
+ #t))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (copy-recursively "." (assoc-ref outputs "out"))
+ #t))
+ (add-after 'install 'wrap-program
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (wrap-script (string-append out "/runpluto.sh")
+ `("PATH" ":" prefix (,(string-append (assoc-ref inputs "julia") "/bin")
+ ,(string-append (assoc-ref inputs "coreutils") "/bin")))
+ `("JULIA_LOAD_PATH" ":" prefix (,(getenv "JULIA_LOAD_PATH"))))
+ #t)))
+ (replace 'precompile
+ (lambda _
+ (invoke "julia" "-e" "\"import Pkg; Pkg.instantiate(); Pkg.status(); Pkg.precompile()\"")
+ #t))
+ )
+ ))
+ (propagated-inputs
+ `(
+ ("julia" ,(@ (gnu packages julia) julia))
+ ("julia-latexstrings" ,julia-latexstrings)
+ ("julia-optim" ,julia-optim)
+ ("julia-plots" ,julia-plots)
+ ("julia-pluto" ,julia-pluto)
+ ("julia-plutoui" ,julia-plutoui)
+ ;; Additional packages in generate.jl
+ ;("julia-markdown" ,julia-markdown)
+ ;("julia-interactiveutils" ,julia-interactiveutils)
+ ;("julia-distributions" ,julia-distributions)
+ ;; and from setup.py
+ ("python-jupyter-server-proxy" ,(@ (gn packages python) python-jupyter-server-proxy-1))
+ ))
+ (inputs
+ `(("guile" ,(@ (gnu packages guile) guile-3.0)))) ; for wrap-script
+ (home-page "https://github.com/senresearch/LiteQTL.jl")
+ (synopsis "Visualizations using Pluto.jl notebooks")
+ (description "Visualizations using Pluto.jl notebooks.")
+ (license #f))))
+
(define-public julia-liteqtl
(let ((commit "321a9e0aa87fb4524bec8278e64de76d1a4072b0")
(revision "1"))
diff --git a/gn/packages/python.scm b/gn/packages/python.scm
index bf22ead..2146931 100644
--- a/gn/packages/python.scm
+++ b/gn/packages/python.scm
@@ -9,6 +9,7 @@
#:use-module (gnu packages image)
#:use-module (gnu packages libffi)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages monitoring)
#:use-module (gnu packages pcre)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
@@ -1669,3 +1670,172 @@ sorted order.")
(sha256
(base32
"0l4fvm58fyz044hxpaw3a8w1nlki1n8iikrg9bdd7imz04kqd671"))))))
+
+(define-public python-jupyter-server-proxy
+ (package
+ (name "python-jupyter-server-proxy")
+ (version "3.0.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "jupyter-server-proxy" version))
+ (sha256
+ (base32 "0vglj7v7wq73a9dya60q2vrxxpglg11w66l7crkzzrfpbblr814p"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("python-aiohttp" ,python-aiohttp)
+ ("python-jupyter-server" ,python-jupyter-server)
+ ("python-simpervisor" ,python-simpervisor)))
+ (home-page "https://jupyter-server-proxy.readthedocs.io/")
+ (synopsis "Jupyter server extension to supervise and proxy web services")
+ (description
+ "Jupyter Server Proxy lets you run arbitrary external processes (such as RStudio, Shiny Server, Syncthing, PostgreSQL, Code Server, etc) alongside your notebook server and provide authenticated web access to them using a path like @code{/rstudio} next to others like @code{/lab}. Alongside the python package that provides the main functionality, the JupyterLab extension (@code{@@jupyterlab/server-proxy}) provides buttons in the JupyterLab launcher window to get to RStudio for example.")
+ (license license:bsd-3)))
+
+(define-public python-jupyter-server-proxy-1
+ (package
+ (inherit python-jupyter-server-proxy)
+ (name "python-jupyter-server-proxy")
+ (version "1.6.0")
+ (source
+ (origin
+ ;(method url-fetch)
+ ;(uri (pypi-uri "jupyter-server-proxy" version))
+ ;(sha256
+ ; (base32 "0sdiywnymdqsmdddj1gszb8fj1z3p1njy419q0i921ib4rmdc22y"))))
+ ;; Tests not included in release.
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/jupyterhub/jupyter-server-proxy")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "03yry0jz6xlvy28h3w514pw0q9w51lnr1lpcigqmhnf5x7g9bfyy"))))
+ (arguments
+ `(#:tests? #f ; Running the test suite isn't fully documented.
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (setenv "JUPYTER_TOKEN" "secret")
+ (setenv "HOME" (getcwd))
+ (system "jupyter-notebook --config=./tests/resources/jupyter_server_config.py &")
+ (sleep 5)
+ (invoke "pytest" "--verbose"))
+ #t)))))
+ (propagated-inputs
+ `(("python-aiohttp" ,python-aiohttp)
+ ("python-notebook" ,python-notebook)
+ ("python-simpervisor" ,python-simpervisor)))
+ (native-inputs
+ `(("python-pytest" ,python-pytest)))))
+
+(define-public python-simpervisor ; upstream ready
+ (package
+ (name "python-simpervisor")
+ (version "0.4")
+ (source
+ (origin
+ ;; Tests not included in release.
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/yuvipanda/simpervisor")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1brsisx7saf4ic0dih1n5y7rbdbwn1ywv9pl32bch3061r46prvv"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:tests? #f ; Test suite can't find aiohttp.
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'check
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "--maxfail" "3" "--verbose"))
+ #t)))))
+ (native-inputs
+ `(("python-aiohttp" ,python-aiohttp)
+ ("python-pytest" ,python-pytest)
+ ("python-pytest-asyncio" ,python-pytest-asyncio)))
+ (home-page "https://github.com/yuvipanda/simpervisor")
+ (synopsis "Simple async process supervisor")
+ (description
+ "This package provides a simple async process supervisor in Python.")
+ (license license:bsd-3)))
+
+(define-public python-jupyter-server
+ (package
+ (name "python-jupyter-server")
+ (version "1.8.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "jupyter-server" version))
+ (sha256
+ (base32
+ "0dqj51fj5ikklbl0gnb939pp80ngnzml5932mljn2lvplph7a34g"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("python-anyio" ,python-anyio)
+ ("python-argon2-cffi" ,python-argon2-cffi)
+ ("python-ipython-genutils" ,python-ipython-genutils)
+ ("python-jinja2" ,python-jinja2)
+ ("python-jupyter-client" ,python-jupyter-client)
+ ("python-jupyter-core" ,python-jupyter-core)
+ ("python-nbconvert" ,python-nbconvert)
+ ("python-nbformat" ,python-nbformat)
+ ("python-prometheus-client" ,python-prometheus-client)
+ ("python-pyzmq" ,python-pyzmq)
+ ("python-send2trash" ,python-send2trash)
+ ("python-terminado" ,python-terminado)
+ ("python-tornado" ,python-tornado)
+ ("python-traitlets" ,python-traitlets)
+ ("python-websocket-client" ,python-websocket-client)))
+ (native-inputs
+ `(("python-coverage" ,python-coverage)
+ ("python-ipykernel" ,python-ipykernel)
+ ("python-pytest" ,python-pytest)
+ ("python-pytest-console-scripts" ,python-pytest-console-scripts)
+ ("python-pytest-cov" ,python-pytest-cov)
+ ("python-pytest-mock" ,python-pytest-mock)
+ ("python-pytest-tornasync" ,python-pytest-tornasync)
+ ("python-requests" ,python-requests)))
+ (home-page "https://jupyter.org")
+ (synopsis
+ "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.")
+ (description
+ "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.")
+ (license #f)))
+
+(define-public python-anyio
+ (package
+ (name "python-anyio")
+ (version "3.1.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "anyio" version))
+ (sha256
+ (base32 "03mdklsgm4ik7hqr0lnc7k085as4vib27hclsrcdh0yhm48hgqj3"))))
+ (build-system python-build-system)
+ (propagated-inputs
+ `(("python-idna" ,python-idna)
+ ("python-sniffio" ,python-sniffio)))
+ (native-inputs
+ `(("python-coverage" ,python-coverage)
+ ("python-hypothesis" ,python-hypothesis)
+ ("python-mock" ,python-mock)
+ ("python-pytest" ,python-pytest)
+ ("python-pytest-mock" ,python-pytest-mock)
+ ("python-trustme" ,python-trustme)
+ ("python-uvloop" ,python-uvloop)))
+ (home-page "")
+ (synopsis
+ "High level compatibility layer for multiple asynchronous event loop implementations")
+ (description
+ "High level compatibility layer for multiple asynchronous event loop implementations")
+ (license license:expat)))
diff --git a/gn/services/pluto.scm b/gn/services/pluto.scm
new file mode 100644
index 0000000..3df804c
--- /dev/null
+++ b/gn/services/pluto.scm
@@ -0,0 +1,134 @@
+(define-module (gn services pluto))
+
+(use-modules (gnu)
+ (gn packages julia)
+ (guix modules)
+ (guix records)
+ (ice-9 match))
+(use-service-modules shepherd)
+(use-package-modules
+ admin
+ certs)
+
+(define-record-type* <pluto-configuration>
+ pluto-configuration
+ make-pluto-configuration
+ pluto-configuration?
+ (package pluto-configuration-package ; package
+ (default julia-visuals))
+ (port pluto-configuration-port ; integer
+ (default 80)))
+
+(define %julia-account
+ (list (user-group
+ (name "julia")
+ ;(system? #t)
+ )
+ (user-account
+ (name "julia")
+ (group "julia")
+ ;(system? #t)
+ (comment "Julia User")
+ (home-directory "/home/jovyan")
+ ;(shell (file-append shadow "/sbin/nologin"))
+ )))
+
+;(define pluto-activation
+; (match-lambda
+; (($ <ratspub-configuration> package)
+; #~(begin
+; (let ((nltk_data "/var/cache/nltk_data/tokenizers")
+; (data_dir "/export/ratspub"))
+; (unless (file-exists? "/export2/PubMed")
+; (mkdir-p "/export2/PubMed"))
+; (unless (file-exists? nltk_data)
+; (begin
+; ;; The correct way would be to use python-nltk to download the data
+; ;; python3 -m nltk.downloader -d /var/cache/nltk_data punkt
+; (mkdir-p nltk_data)
+; (chdir nltk_data)
+; (invoke #$(file-append unzip "/bin/unzip") "-q" #$%punkt.zip)))
+; (unless (file-exists? (string-append data_dir "/userspub.sqlite"))
+; (begin
+; (install-file #$(file-append package "/userspub.sqlite") data_dir)
+; (chmod (string-append data_dir "/userspub.sqlite") #o554))))))))
+
+(define pluto-shepherd-service
+ (match-lambda
+ (($ <pluto-configuration> package port)
+ (with-imported-modules (source-module-closure
+ '((gnu build shepherd)
+ (gnu system file-systems)))
+ (list (shepherd-service
+ (provision '(pluto))
+ (requirement '(networking))
+ (modules '((gnu build shepherd)
+ (gnu system file-systems)))
+ (start #~(make-forkexec-constructor/container
+ (list #$(file-append package "/runpluto.sh") #$port)
+ ;; Needs to run from the directory it is located in.
+ ;#:directory #$package
+ #:log-file "/var/log/pluto.log"
+ ;; We don't need to set TMPDIR because we're inside a container.
+ #:user "julia"
+ #:group "julia"
+ #:environment-variables
+ '(;"JULIA_PROJECT=/home/jovyan"
+ ;"JULIA_LOAD_PATH=/run/current-system/profile/share/julia/packages/"
+ )
+ #:mappings (list (file-system-mapping
+ (source "/home/jovyan")
+ (target source)
+ (writable? #t))
+ )
+ ))
+ (stop #~(make-kill-destructor))))))))
+
+(define pluto-service-type
+ (service-type
+ (name 'pluto)
+ (extensions
+ (list
+ (service-extension shepherd-root-service-type
+ pluto-shepherd-service)
+ ;(service-extension activation-service-type
+ ; ratspub-activation)
+ (service-extension account-service-type
+ (const %julia-account))
+ ;; Make sure we get all the dependencies of julia-visuals.
+ (service-extension profile-service-type
+ (compose list pluto-configuration-package))))
+ (default-value (pluto-configuration))
+ (description
+ "Run a Pluto Jupyter Webserver.")))
+
+(operating-system
+ (host-name "pluto")
+ (timezone "Etc/UTC")
+ (locale "en_US.utf8")
+
+ (bootloader (bootloader-configuration
+ (bootloader grub-bootloader)
+ (target "does-not-matter")))
+ (file-systems (list (file-system
+ (device "does-not-matter")
+ (mount-point "/")
+ (type "does-not-matter"))))
+ ;; TODO: A more minimal kernel for use in a docker image
+ ;; (kernel linux-libre-vm)
+ ;; No firmware for VMs.
+ (firmware '())
+ (packages ;(list nss-certs)
+ %base-packages
+ )
+
+ (services (list (service pluto-service-type
+ (pluto-configuration
+ (port "4343"))))))
+
+;; guix system container -L /path/to/guix-bioinformatics/ -L /path/to/guix-past/modules/ /path/to/guix-bioinformatics/gn/services/pluto.scm --network
+;; For docker it isn't necessary to list the shared folders at build time.
+;; guix system docker-image -L /path/to/guix-bioinformatics/ -L /path/to/guix-past/modules/ /path/to/guix-bioinformatics/gn/services/pluto.scm --network
+;; Docker instructions:
+;; docker load --input pluto-docker-image.tar.gz
+;; docker run -d --privileged --net=host --name pluto guix