├── .gitignore ├── README.md ├── deps.edn ├── docker-base ├── Dockerfile └── deps.edn ├── pom.xml ├── project.clj ├── singularity-base └── clj-py-r_base.def └── src └── clj └── new ├── clj_py_r_template.clj └── clj_py_r_template ├── Dockerfile ├── deps.edn ├── docker_build.sh ├── docker_repl.sh ├── docker_run_xxx.sh ├── gitpod.Dockerfile ├── gitpod.yml ├── my-project.def └── src └── try_py_R.clj /.gitignore: -------------------------------------------------------------------------------- 1 | .cpcache 2 | /target/ 3 | /.nrepl-port 4 | /.lein-failures 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Clojars Project](https://img.shields.io/clojars/v/clj-py-r-template/clj-template.svg)](https://clojars.org/clj-py-r-template/clj-template) 2 | 3 | # Clojure polyglot clj-template 4 | 5 | # Quickstart - Get a working clojure repl supporting Python, R and Julia in 5 lines 6 | 7 | Only requirements is [clojure](https://clojure.org/guides/getting_started) and [docker](https://docs.docker.com/get-docker) installed. 8 | 9 | 1. Create Clojure polyglot project from template 10 | 11 | ```bash 12 | clojure -Sdeps '{:deps {com.github.seancorfield/clj-new {:mvn/version "1.2.362"}}}' -M -m clj-new.create clj-py-r-template me/my-app 13 | ``` 14 | 15 | 2.Build and run Docker image, which starts a headless repl on port 12345 16 | in a docker container 17 | 18 | This assumes a Linux OS and bash as shell. It might be slightly different on 19 | other platforms or shell. 20 | 21 | 22 | 23 | ```bash 24 | cd my-app 25 | docker build -t my-app . 26 | docker run -it -p 12345:12345 my-app 27 | ``` 28 | (in most situations you want to mount some host drives and make the user id of 'user' match your user id, so the invocations becomes (for Linux): ) 29 | 30 | ```bash 31 | docker build -t my-app --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) . 32 | docker run -it --rm -v $HOME/.m2:/home/user/.m2 -v "$(pwd):/workdir" -p 12345:12345 -w /workdir my-app 33 | ``` 34 | 35 | 3. In other shell: Connect normal repl to it 36 | 37 | ```bash 38 | clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.25.2"} }}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" -c -p 12345 39 | ``` 40 | 41 | 😀 Have fun with some interop code: 😀 42 | 43 | ```clojure 44 | ;; go from clj -> python -> clj -> R 45 | (require '[libpython-clj2.require :refer [require-python]] 46 | '[libpython-clj2.python :as py] 47 | '[clojisr.v1.r :as r :refer [r require-r]]) 48 | 49 | (require-python '[numpy :as np]) 50 | (require-r '[base :as base-r]) 51 | 52 | (def r-matrix 53 | (-> (np/array [[1 2 3 4] [5 6 7 8] [9 10 11 12]]) 54 | (py/->jvm) 55 | (r/clj->java->r) 56 | (base-r/simplify2array) 57 | (base-r/t))) 58 | 59 | (println 60 | (base-r/dim r-matrix)) 61 | ``` 62 | 63 | # For non Linux users: 64 | 65 | The `docker run` commands above assume a Linux OS and bash as shell 66 | The same is true for the Dockerfile produced by this template. 67 | Line 15-19 of the Dockerfile 68 | https://github.com/behrica/clj-py-r-template/blob/2f1ec12690c09917c4c7608d6f625e8032d0d294/src/clj/new/clj_py_r_template/Dockerfile#L15 69 | and the `docker run` id settings play together and this 70 | works as-is only on Linux. 71 | 72 | Line 15-19 of the Dockerfile and the `-build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)` 73 | are only needed if volume is mounted as in the example. 74 | Without these, any file written to the shared volume by the container 75 | gets wrong permissions, which is inconvenient. 76 | 77 | # Motivation 78 | This template is the easiest way to use R, python and Julia from Clojure. 79 | 80 | 81 | In the world of Java / Clojure usage of containers is not that common, because on the 82 | JVM platform using Docker instead of a JVM 83 | dependency manger (maven, lein, gradle ...) is not really required. 84 | 85 | This situation changes, the moment we add R / python or Julia into our stack, 86 | because both might have operating system 87 | dependencies in their packages. 88 | 89 | Then containers can be very helpfull to get started quickly and work 90 | in a reproducible manner. 91 | 92 | This template contains a Dockerfile / singularity definition file which has Clojure and all dependencies for [ClojisR](https://github.com/scicloj/clojisr), [libpython-clj](https://github.com/clj-python/libpython-clj), [julia-clj](https://github.com/cnuernber/libjulia-clj) and [ 93 | libapl-clj](https://github.com/jjtolton/libapl-clj) 94 | plus a deps.edn file containing working versions of ClojisR,libpython-clj and Julia-clj. 95 | 96 | ## Clojure and Docker (or other container technology) 97 | Containers can be used in Clojure Devlopment for several purposes: 98 | 99 | 1. Create a (production) runtime environment for a Clojure application 100 | 2. Create a (polyglot) development environment for Clojure 101 | * Flavor a: Run only a nrepl inside container 102 | * Flavor b: Run all (nrepl, editor, git ,...) inside container 103 | 104 | This project is about 2a). 105 | A potential solution for 2b) can be container/ docker based coding platforms such as VSCode, Gitpod, Codespaces 106 | or extensions of the container spec files here and custom addition of the development tools. 107 | 108 | ## Usage 109 | 110 | Clojure projects including libpython-clj, ClojisR and Julia-clj can 111 | now be created quickly in 2 ways from the latest stable template: 112 | 113 | 114 | - **without** clj-new installed in user deps.edn 115 | 116 | ```bash 117 | 118 | clj -Sdeps '{:deps {com.github.seancorfield/clj-new {:mvn/version "1.2.362"}}}' \ 119 | -m clj-new.create clj-py-r-template appcompany.funapp 120 | ``` 121 | 122 | - **with** clj-new [installed](https://github.com/seancorfield/clj-new) in user deps.edn (recommended) 123 | 124 | ```bash 125 | clj -X:new :template clj-py-r-template :name appcompany.funapp 126 | ``` 127 | 128 | - **with** clj-new installed as Clojure **Tool** 129 | ```bash 130 | clj -Tclj-new create :template clj-py-r-template :name appcompany.funapp 131 | ``` 132 | 133 | Specific versions of this template can be used by adding something like "-V 1.0.2" to the upper commands 134 | 135 | The templates provided config files for three different ways to run the container: 136 | 137 | 1. Docker (typically on local machine) 138 | 2. Singularity (typically on local machine) 139 | 3. Gitpod (one way to run Docker cntainers in cloud) 140 | 141 | ### Run polyglot nrepl via Docker 142 | 143 | The template creates a Dockerfile in the project folder. 144 | The docker image can be build with 145 | 146 | ``` 147 | cd appcompany.funapp 148 | docker build -t funapp --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) . 149 | 150 | ``` 151 | 152 | The Dockerfile assumes that the local project directory gets mounted into a 153 | folder in the container and that it becomes the working directory. 154 | The docker image runs a nRepl on port 12345 which can be connected 155 | to by any other nRepl compatible client (including emacs+Cider) 156 | 157 | A typical command line for running the nRepl server in a docker 158 | container is then this: 159 | 160 | ``` 161 | docker run -it --rm -v "$(pwd):/code" -p 12345:12345 funapp 162 | ``` 163 | 164 | The template creates as well 2 bash scripts with some defaults, to: 165 | - build the docker image from the Dockerfile 166 | - run a repl inside Docker container 167 | 168 | Please have a look and adapt to you needs. 169 | 170 | ### Run polyglot nrepl via Singularity 171 | 172 | This 2 lines 173 | ```bash 174 | singularity build /tmp/my-app.sif my-project.def 175 | singularity run /tmp/my-app.sif 176 | ``` 177 | 178 | build first a [Singularity](https://singularity.hpcng.org/) image containing Clojure, python, R, Julia and APL. 179 | Then the image is run, which starts a nrepl on port 12345. 180 | 181 | To get this working the working directory needs: 182 | 183 | - to have a `deps.edn` with all needed Clojure deps (as created by this template) 184 | - be writable by singularity 185 | 186 | 187 | How to make this sure, is installation / project dependent and can be controlled by the options to `singularity run` 188 | 189 | ### Singularity vs Docker 190 | 191 | Be aware that the two differ fundamentaly regarding their default settings of host / container isolation. 192 | In "our use case" here the defaults of Singularity are normaly fine, while we need to tell Docker to share 193 | volumes and ports explicitely. 194 | 195 | 196 | ### Use Gitpod 197 | 198 | The template creates as well the 2 [gitpod](https://gitpod.io/) configuration files. `.gitpod.yml` and 199 | `.gitpod.Dockerfile`. 200 | Launching a workspace pointing to a github repo with them, 201 | configures Gitpod to use the Dockerfile in `.gitpod.Dockerfile`. 202 | So the Gitpod workspace will have Clojure, python, R, Julia and APL setup correctly and 203 | the Clojure polyglot libraries will work out-of-the-box. 204 | 205 | The workspace launch will start the repl automatically an we can use VSCode in browser to connect to it. 206 | 207 | Advanced: 208 | Gitpod can be as well configured and used to expose the nrepl connection and ssh over the Internet. 209 | This allows to connect from local machine to a Gitpod workspace (nrepl + ssh filesystem) with for example Emacs (cider + tramp) 210 | This requires to use [gitpod local-companion](https://www.gitpod.io/blog/local-app) 211 | 212 | ### Using ClojisR,libpython-clj,julia-clj and libapl-clj in repl 213 | 214 | If a local repl was started as described before, 215 | Emacs (or any other nRepl client) can be connected to localhost:12345. 216 | 217 | Example to use clj as nRepl client: 218 | ``` 219 | clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.27.2"} }}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" -c -p 12345 220 | ``` 221 | 222 | 223 | In this connected repl clojisr, libpython-clj , julia-clj and 224 | libapl-clj work out of the box: 225 | 226 | ```clojure 227 | (require '[libpython-clj2.require :refer [require-python]]) 228 | (require-python '[os :as os]) 229 | (os/getcwd) 230 | 231 | (require '[clojisr.v1.r :refer [r]]) 232 | (r "1+1") 233 | 234 | (require '[libjulia-clj.julia :as julia]) 235 | (julia/initialize!) 236 | (def ones-fn (julia/jl "Base.ones")) 237 | (ones-fn 3 4) 238 | 239 | (require '[libapl-clj.apl :as apl]) 240 | (apl/+ [1 2 3] [4 5 6]) 241 | ``` 242 | 243 | ### Customizing the container image 244 | 245 | #### Add some libraries 246 | 247 | The template itself should not contain instructions to install any Python, R, Julia, APL libraries but only the base tool as such. 248 | For Clojure a deps.edn is provided with all polyglot libraries and "some data science libraries from Scicloj". 249 | This should be conidered a template, to be changed. 250 | 251 | 252 | As in the container images one single R version and one single python 253 | version is installed, 254 | libraries can be simply added by adding a few lines to the image configuration file (Dockerfile / my-project.def). 255 | 256 | In case native dependencies are required, they can be added via "apt-get install" 257 | 258 | The following would add a native library, a python library and a R package. 259 | 260 | Example how to add to Dockerfile 261 | ``` 262 | RUN apt-get install libssl-dev 263 | 264 | RUN pip3 install pandas 265 | 266 | RUN Rscript -e "install.packages('dplyr')" 267 | 268 | ``` 269 | 270 | 271 | Example to add to Singularity .def file: 272 | 273 | ``` 274 | %post 275 | apt-get install libssl-dev 276 | pip3 install pandas 277 | Rscript -e "install.packages('dplyr')" 278 | ``` 279 | 280 | The same can be done for additional Julia or APL libraries. 281 | 282 | #### Change versions of Python, Julia, R, Apl 283 | 284 | The installtion of those is done in a base image. 285 | The Dockerfile of the base image is here: 286 | https://github.com/behrica/clj-py-r-template/blob/master/docker-base/Dockerfile 287 | 288 | So customistaion of those could be done by copy/paste of the relevant parts from this. 289 | 290 | The latest version of `clj-py-r-template` itself should always install the latest released version of: 291 | - Java 292 | - Clojure 293 | - Python 294 | - Julia 295 | - APL 296 | 297 | The update frequency of `clj-py-r-template` is nevertheless independent from those and will be done as needed. 298 | Requests for updates can be done via submitting issues here. 299 | 300 | ### Changing Clojure dependencies 301 | Clojure dependencies are currently not specified in the image configuration file, but 302 | can be added as usual to the deps.edn file. 303 | 304 | ### Current versions 305 | 306 | The versions of this template contains the following versions of dependencies 307 | in either image configuration file or deps.end 308 | 309 | #### 1.0.2 310 | 311 | Docker base image: rocker/r-ver:4.0.0 312 | 313 | |dependency|version| 314 | |----------|-------| 315 | | clojure | 1.10.1| 316 | |R | 4.0.0 | 317 | |java | openjdk 11| 318 | | python| 3.8.2| 319 | | RServe| latest from rforge.net| 320 | |clj-python/libpython-clj| 1.45| 321 | |scicloj/clojisr |1.0.0-BETA11| 322 | |cider-nrepl | 0.25.2| 323 | 324 | #### 1.0.3 325 | 326 | Docker base image: rocker/r-ver:4.0.0 327 | 328 | |dependency|version| 329 | |----------|-------| 330 | | clojure | 1.10.1| 331 | |R | 4.0.0 | 332 | |java | openjdk 11| 333 | | python| 3.8.2| 334 | | RServe| 1.8-7| 335 | |clj-python/libpython-clj| 1.45| 336 | |scicloj/clojisr |1.0.0-BETA11| 337 | |cider-nrepl | 0.25.2| 338 | 339 | #### 1.0.5 340 | 341 | Docker base image: rocker/r-ver:4.0.2 342 | 343 | |dependency|version| 344 | |----------|-------| 345 | | clojure | 1.10.1| 346 | |R | 4.0.2 | 347 | |java | openjdk 11| 348 | | python| 3.8.5| 349 | | RServe| 1.8-7| 350 | |clj-python/libpython-clj| 1.45| 351 | |scicloj/clojisr |1.0.0-BETA15| 352 | |cider-nrepl | 0.25.2| 353 | 354 | 355 | #### 1.1.0 356 | 357 | Docker base image: rocker/r-ver:4.0.3 358 | 359 | |dependency|version| 360 | |----------|-------| 361 | | clojure | 1.10.1| 362 | |R | 4.0.3 | 363 | |java | openjdk 11| 364 | |python| 3.8.6| 365 | |RServe| 1.8-7| 366 | |tablecloth | 5.00-beta-5a | 367 | |tech.ml.dataset | 5.00-beta-5 | 368 | |clj-python/libpython-clj| 2.0.0-alpha-6| 369 | |scicloj/clojisr |1.0.0-BETA16| 370 | |notespace | 3-alpha2 | 371 | |cider-nrepl | 0.25.5| 372 | 373 | #### 1.1.1 374 | 375 | Docker base image: rocker/r-ver:4.0.3 376 | 377 | |dependency|version| 378 | |----------|-------| 379 | | clojure | 1.10.1| 380 | |R | 4.0.3 | 381 | |java | openjdk 11| 382 | |python| 3.8.7| 383 | |RServe| 1.8-7| 384 | |tablecloth | 5.00-beta-28| 385 | |tech.ml.dataset | 5.00-beta-5 | 386 | |tech.ml |5.00-beta-14 | 387 | |clj-python/libpython-clj| 2.0.0-alpha-7| 388 | |scicloj/clojisr |1.0.0-BETA16| 389 | |notespace | 3-alpha2 | 390 | |cider-nrepl | 0.25.8| 391 | 392 | ### 1.1.2 393 | 394 | |dependency|version| 395 | |----------|-------| 396 | | clojure | 1.10.1| 397 | |R | 4.0.4 | 398 | |java | openjdk 11| 399 | |python| 3.9.2| 400 | |RServe| 1.8-7| 401 | |tablecloth | 5.05| 402 | |tech.ml.dataset | 5.01 | 403 | |tech.ml |5.05 | 404 | |clj-python/libpython-clj| 2.0.0-beta-8| 405 | |scicloj/clojisr |1.0.0-BETA18| 406 | |notespace | 3-beta4 | 407 | |cider-nrepl | 0.25.9| 408 | 409 | 410 | ### 1.2.0 411 | 412 | |dependency|version| 413 | |----------|-------| 414 | | clojure | 1.10.1| 415 | |R | 4.0.4 | 416 | |java | openjdk 11| 417 | |python| 3.9.2| 418 | |RServe| 1.8-7| 419 | |tablecloth | 5.05| 420 | |tech.ml.dataset | 5.01 | 421 | |tech.ml |5.05 | 422 | |clj-python/libpython-clj| 2.0.0-beta-12| 423 | |scicloj/clojisr |1.0.0-BETA18| 424 | |notespace | 3-beta4 | 425 | |cider-nrepl | 0.25.9| 426 | 427 | ### 1.2.0 428 | 429 | |dependency|version| 430 | |----------|-------| 431 | | clojure | 1.10.1| 432 | |R | 4.0.4 | 433 | |java | openjdk 11| 434 | |python| 3.9.2| 435 | |RServe| 1.8-7| 436 | |tablecloth | 5.05| 437 | |tech.ml.dataset | 5.01 | 438 | |tech.ml |5.05 | 439 | |clj-python/libpython-clj| 2.0.0-beta-12| 440 | |scicloj/clojisr |1.0.0-BETA18| 441 | |notespace | 3-beta4 | 442 | |cider-nrepl | 0.25.9| 443 | 444 | ### 1.3.0 445 | 446 | |dependency|version| 447 | |----------|-------| 448 | | clojure | 1.10.3.967| 449 | |R | 4.1.1 | 450 | |java | openjdk 11| 451 | |python| 3.9.5| 452 | |RServe| 1.8-7| 453 | |tablecloth | 6.012| 454 | |tech.ml.dataset | 6.012 | 455 | |clj-python/libpython-clj| 2.0.0| 456 | |scicloj.ml| 0.1.0-beta4| 457 | |scicloj/clojisr |1.0.0-BETA19| 458 | |notespace | 3-beta9 | 459 | |cider-nrepl | 0.25.9| 460 | 461 | ### 1.4.0 462 | 463 | |dependency|version| 464 | |----------|-------| 465 | | clojure | 1.10.3.981| 466 | |R | 4.1.1 | 467 | |java | openjdk 11| 468 | |python| 3.9.5| 469 | |RServe| 1.8-7| 470 | |tablecloth | 6.012| 471 | |tech.ml.dataset | 6.012 | 472 | |clj-python/libpython-clj| 2.0.0| 473 | |julia-clj| 0.0.7| 474 | |scicloj.ml| 0.1.0-beta4| 475 | |scicloj/clojisr |1.0.0-BETA19| 476 | |notespace | 3-beta9 | 477 | |cider-nrepl | 0.25.9| 478 | 479 | ### 1.5.0 480 | 481 | Added scripts for Docker 482 | 483 | |dependency|version| 484 | |----------|-------| 485 | | clojure | 1.10.3.981| 486 | |R | 4.1.1 | 487 | |java | openjdk 11| 488 | |python| 3.9.5| 489 | |RServe| 1.8-7| 490 | |tablecloth | 6.012| 491 | |tech.ml.dataset | 6.012 | 492 | |clj-python/libpython-clj| 2.0.0| 493 | |julia-clj| 0.0.7| 494 | |scicloj.ml| 0.1.0-beta4| 495 | |scicloj/clojisr |1.0.0-BETA19| 496 | |notespace | 3-beta9 | 497 | |cider-nrepl | 0.25.9| 498 | 499 | ### 1.5.1 500 | 501 | 502 | 503 | |dependency|version| 504 | |----------|-------| 505 | |clojure | 1.10.3.981| 506 | |R | 4.1.1 | 507 | |java | openjdk 11| 508 | |python| 3.10.0| 509 | |julia | 1.5.3 | 510 | |APL | latest | 511 | |RServe| 1.8-7| 512 | |tablecloth | 6.023| 513 | |tech.ml.dataset | 6.023 | 514 | |clj-python/libpython-clj| 2.0.0| 515 | |julia-clj| 0.0.7| 516 | |scicloj.ml| 0.1.0| 517 | |scicloj/clojisr |1.0.0-BETA19| 518 | |notespace | 3-beta9 | 519 | |cider-nrepl | 0.25.9| 520 | |libapl-clj |0.1.2-ALPHA-SNAPSHOT| 521 | 522 | ### 1.5.2 523 | 524 | |dependency|version| 525 | |----------|-------| 526 | |clojure | 1.10.3.981| 527 | |R | 4.1.1 | 528 | |java | openjdk 11| 529 | |python| 3.10.0| 530 | |julia | 1.5.3 | 531 | |APL | latest | 532 | |RServe| 1.8-7| 533 | |tablecloth | 6.025| 534 | |tech.ml.dataset | 6.025 | 535 | |clj-python/libpython-clj| 2.003| 536 | |julia-clj| 0.0.7| 537 | |scicloj.ml| 0.1.1| 538 | |scicloj/clojisr |1.0.0-BETA19| 539 | |notespace | 3-beta9 | 540 | |cider-nrepl | 0.25.9| 541 | |libapl-clj |0.1.2-ALPHA-SNAPSHOT| 542 | 543 | ### 1.6.0 544 | Only changes to the Dockerfiles 545 | Library versions state the same as in 1.5.2 546 | 547 | ### 1.7.0 548 | 549 | |dependency|version| 550 | |----------|-------| 551 | |clojure | 1.10.3.981| 552 | |R | 4.1.2 | 553 | |java | openjdk 11| 554 | |python| 3.10.0| 555 | |julia | 1.7.2 | 556 | |APL | latest | 557 | |RServe| 1.8-7| 558 | |tablecloth | 6.076| 559 | |tech.ml.dataset | 6.076 | 560 | |clj-python/libpython-clj| 2.018| 561 | |com.cnuernber/libjulia-clj| 1.000-beta-8| 562 | |scicloj.ml| 0.2.0| 563 | |scicloj/clojisr |1.0.0-BETA19| 564 | |notespace | 3-beta9 | 565 | |cider-nrepl | 0.25.9| 566 | |libapl-clj |0.1.2-ALPHA-SNAPSHOT| 567 | |clerk|0.6.387| 568 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :mvn/repos {"clojars" {:url "https://repo.clojars.org/"} 3 | "central" {:url "https://repo1.maven.org/maven2/"} 4 | "bedatadriven" {:url "https://nexus.bedatadriven.com/content/groups/public/"}} 5 | 6 | :paths ["src" "resources"] 7 | 8 | :deps { 9 | org.clojure/clojure {:mvn/version "1.10.3"} 10 | clj-python/libpython-clj {:mvn/version "2.018"} 11 | scicloj/clojisr {:mvn/version "1.0.0-BETA19"} 12 | scicloj/tablecloth {:mvn/version "6.076"} 13 | scicloj/notespace {:mvn/version "3-beta9"} 14 | scicloj/scicloj.ml {:mvn/version "0.2.0"} 15 | com.cnuernber/libjulia-clj {:mvn/version "1.000-beta-8"} 16 | behrica/libapl-clj {:git/url "https://github.com/behrica/libapl-clj" 17 | :git/sha "f40e17a95eaab6f81417d315f8499be7141b813c"} 18 | ;; {:mvn/version "0.1.2-ALPHA-SNAPSHOT"} 19 | 20 | io.github.nextjournal/clerk {:mvn/version "0.6.387"}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | :aliases { 28 | :cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.27.2"} 29 | refactor-nrepl {:mvn/version "3.0.0-alpha13"}} 30 | :main-opts ["-m" "nrepl.cmdline" "-b" "0.0.0.0" "-p" "12345" 31 | "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}}} 32 | -------------------------------------------------------------------------------- /docker-base/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rocker/r-ver:4.1.2 2 | RUN apt-get update && apt-get -y install --reinstall ca-certificates && update-ca-certificates 3 | RUN apt-get update && apt-get -y install openjdk-11-jdk curl rlwrap libssl-dev build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libreadline-dev libffi-dev libbz2-dev \ 4 | automake-1.15 git liblzma-dev 5 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install intel-mkl 6 | 7 | # python 8 | RUN curl -O https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz 9 | RUN tar xf Python-3.10.0.tar.xz 10 | RUN cd Python-3.10.0 && ./configure --enable-shared --with-ensurepip=install && make && make install && ldconfig 11 | RUN curl -O https://download.clojure.org/install/linux-install-1.10.3.986.sh && chmod +x linux-install-1.10.3.986.sh && ./linux-install-1.10.3.986.sh 12 | RUN Rscript -e 'install.packages("http://rforge.net/Rserve/snapshot/Rserve_1.8-7.tar.gz")' 13 | RUN clj -P 14 | RUN pip3 install -U numpy wheel scikit-learn cython 15 | 16 | #apl 17 | RUN git clone https://git.savannah.gnu.org/git/apl.git 18 | RUN cd apl/trunk && ./configure && make develop_lib && make install 19 | 20 | RUN curl -O https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.2-linux-x86_64.tar.gz \ 21 | && tar -xvzf julia-1.7.2-linux-x86_64.tar.gz 22 | RUN mv julia-1.7.2/ /opt/ 23 | RUN ln -s /opt/julia-1.7.2/bin/julia /usr/local/bin/julia 24 | 25 | 26 | RUN export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 && pip3 install cljbridge==0.0.7 27 | COPY deps.edn . 28 | RUN clj -P -Srepro -Sdeps '{:mvn/local-repo "/tmp/.m2/repository"}' 29 | 30 | EXPOSE 12345 31 | ENV JULIA_HOME=/opt/julia-1.7.2 32 | 33 | RUN apt-get install -y wget 34 | # CUDA 35 | RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin 36 | RUN mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 37 | RUN wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.1-470.57.02-1_amd64.deb 38 | RUN dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.1-470.57.02-1_amd64.deb 39 | RUN apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub 40 | RUN apt-get update 41 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install cuda 42 | 43 | # opencl 44 | RUN apt-get install -y vim nvidia-opencl-dev leiningen 45 | RUN apt-get install -y software-properties-common intel-opencl-icd 46 | 47 | ENV OS=ubuntu2004 48 | 49 | #cudnn 50 | RUN wget https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin 51 | RUN mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600 52 | RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys A4B469963BF863CC 53 | RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/ /" 54 | RUN apt-get update 55 | 56 | ENV cudnn_version=8.2.4.15 57 | ENV cuda_version=cuda11.4 58 | 59 | RUN apt-get install libcudnn8=${cudnn_version}-1+${cuda_version} 60 | RUN apt-get install libcudnn8-dev=${cudnn_version}-1+${cuda_version} 61 | 62 | # clone deep diamnond 63 | WORKDIR /tmp 64 | RUN git clone https://github.com/uncomplicate/deep-diamond.git 65 | WORKDIR /tmp/deep-diamond 66 | 67 | RUN rm -rf test/uncomplicate/diamond/functional # remove failing tests, as not "data" 68 | 69 | # need t patch dependencies, to make it work "better" 70 | RUN echo 'diff --git a/project.clj b/project.clj \n\ 71 | index 4cfb494..650089c 100644 \n\ 72 | --- a/project.clj\n\ 73 | +++ b/project.clj\n\ 74 | @@ -15,7 +15,8 @@ \n\ 75 | :dependencies [[org.clojure/clojure "1.11.1"] \n\ 76 | [uncomplicate/neanderthal "0.44.0"] \n\ 77 | [org.bytedeco/dnnl-platform "2.5.2-1.5.7"] \n\ 78 | - [org.jcuda/jcudnn "11.6.1"]] \n\ 79 | + [org.jcuda/jcublas "11.4.1"] \n\ 80 | + [org.jcuda/jcudnn "11.4.1"]] \n\ 81 | \n\ 82 | :profiles {:dev {:plugins [[lein-midje "3.2.1"] \n\ 83 | [lein-codox "0.10.7"]]' >> project.clj.patch 84 | 85 | RUN patch -l < project.clj.patch 86 | # having this pass is the goal 87 | # 88 | #RUN lein test 89 | CMD ["python3", "-c", "from clojurebridge import cljbridge;cljbridge.init_jvm(start_repl=True,port=12345,bind='0.0.0.0',mvn_local_repo='/tmp/.m2/repository')"] 90 | 91 | #clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.5"}}}' -Sdeps '{:mvn/local-repo "/tmp/.m2/repository"}' '-Spath' 92 | -------------------------------------------------------------------------------- /docker-base/deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :mvn/repos {"clojars" {:url "https://repo.clojars.org/"} 3 | "central" {:url "https://repo1.maven.org/maven2/"} 4 | "bedatadriven" {:url "https://nexus.bedatadriven.com/content/groups/public/"}} 5 | 6 | :paths ["src" "resources"] 7 | 8 | :deps { 9 | org.clojure/clojure {:mvn/version "1.10.3"} 10 | clj-python/libpython-clj {:mvn/version "2.018"} 11 | scicloj/clojisr {:mvn/version "1.0.0-BETA19"} 12 | scicloj/tablecloth {:mvn/version "6.076"} 13 | scicloj/notespace {:mvn/version "3-beta9"} 14 | scicloj/scicloj.ml {:mvn/version "0.2.0"} 15 | com.cnuernber/libjulia-clj {:mvn/version "1.000-beta-8"} 16 | behrica/libapl-clj {:git/url "https://github.com/behrica/libapl-clj" 17 | :git/sha "f40e17a95eaab6f81417d315f8499be7141b813c"} 18 | ;; {:mvn/version "0.1.2-ALPHA-SNAPSHOT"} 19 | 20 | io.github.nextjournal/clerk {:mvn/version "0.6.387"} 21 | ;; https://mvnrepository.com/artifact/org.jcuda/jcuda 22 | org.jcuda/jcuda {:mvn/version "11.4.1"} 23 | 24 | uncomplicate/clojurecuda {:mvn/version "0.15.0"} 25 | uncomplicate/clojurecl {:mvn/version "0.15.1"} 26 | 27 | uncomplicate/deep-diamond {:mvn/version "0.23.0"}} 28 | 29 | 30 | 31 | 32 | 33 | 34 | :aliases { 35 | :cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.27.2"} 36 | refactor-nrepl {:mvn/version "3.0.0-alpha13"}} 37 | :main-opts ["-m" "nrepl.cmdline" "-b" "0.0.0.0" "-p" "12345" 38 | "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}}} 39 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | clj-py-r-template 5 | clj-template 6 | jar 7 | 1.6.0 8 | clj-template 9 | Template to quickly create clojure data sciene projects with R + python 10 | https://github.com/behrica/clj-py-R-template 11 | 12 | 13 | Eclipse Public License 14 | http://www.eclipse.org/legal/epl-v10.html 15 | 16 | 17 | 18 | https://github.com/behrica/clj-py-r-template 19 | scm:git:git://github.com/behrica/clj-py-r-template.git 20 | scm:git:ssh://git@github.com/behrica/clj-py-r-template.git 21 | b7e84c8ec36cf162a8337e208bafa90ffb18c037 22 | 23 | 24 | src 25 | test 26 | 27 | 28 | resources 29 | 30 | 31 | 32 | 33 | resources 34 | 35 | 36 | target 37 | target/classes 38 | 39 | 40 | org.codehaus.mojo 41 | build-helper-maven-plugin 42 | 1.7 43 | 44 | 45 | add-source 46 | generate-sources 47 | 48 | add-source 49 | 50 | 51 | 52 | src 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | central 63 | https://repo1.maven.org/maven2/ 64 | 65 | false 66 | 67 | 68 | true 69 | 70 | 71 | 72 | clojars 73 | https://repo.clojars.org/ 74 | 75 | true 76 | 77 | 78 | true 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | javax.inject 88 | javax.inject 89 | 1 90 | 91 | 92 | org.clojure 93 | data.json 94 | 1.0.0 95 | 96 | 97 | org.clojure 98 | clojure 99 | 1.10.2 100 | 101 | 102 | commons-codec 103 | commons-codec 104 | 1.11 105 | 106 | 107 | com.cognitect.aws 108 | api 109 | 0.8.484 110 | 111 | 112 | org.clojure 113 | tools.analyzer 114 | 1.0.0 115 | 116 | 117 | org.codehaus.plexus 118 | plexus-component-annotations 119 | 2.1.0 120 | 121 | 122 | junit 123 | junit 124 | 125 | 126 | 127 | 128 | com.cognitect.aws 129 | endpoints 130 | 1.1.11.911 131 | 132 | 133 | com.google.errorprone 134 | error_prone_annotations 135 | 2.1.3 136 | 137 | 138 | org.apache.commons 139 | commons-lang3 140 | 3.8.1 141 | 142 | 143 | org.clojure 144 | tools.logging 145 | 1.1.0 146 | 147 | 148 | org.clojure 149 | core.specs.alpha 150 | 0.2.56 151 | 152 | 153 | org.clojure 154 | spec.alpha 155 | 0.2.194 156 | 157 | 158 | org.clojure 159 | tools.cli 160 | 1.0.206 161 | 162 | 163 | org.codehaus.mojo 164 | animal-sniffer-annotations 165 | 1.14 166 | 167 | 168 | org.eclipse.jetty 169 | jetty-http 170 | 9.4.24.v20191120 171 | 172 | 173 | org.eclipse.jetty 174 | jetty-util 175 | 9.4.24.v20191120 176 | 177 | 178 | org.apache.maven.resolver 179 | maven-resolver-transport-wagon 180 | 1.3.3 181 | 182 | 183 | org.slf4j 184 | jcl-over-slf4j 185 | 1.7.30 186 | 187 | 188 | org.clojure 189 | tools.analyzer.jvm 190 | 1.0.0 191 | 192 | 193 | com.jcraft 194 | jsch.agentproxy.jsch 195 | 0.0.9 196 | 197 | 198 | org.apache.maven.wagon 199 | wagon-provider-api 200 | 3.3.2 201 | 202 | 203 | com.jcraft 204 | jsch.agentproxy.sshagent 205 | 0.0.9 206 | 207 | 208 | org.apache.maven.resolver 209 | maven-resolver-transport-http 210 | 1.6.1 211 | 212 | 213 | org.apache.maven 214 | maven-model-builder 215 | 3.6.3 216 | 217 | 218 | com.googlecode.javaewah 219 | JavaEWAH 220 | 1.1.6 221 | 222 | 223 | org.codehaus.plexus 224 | plexus-utils 225 | 3.2.1 226 | 227 | 228 | org.apache.maven.resolver 229 | maven-resolver-transport-file 230 | 1.6.1 231 | 232 | 233 | org.eclipse.sisu 234 | org.eclipse.sisu.plexus 235 | 0.3.4 236 | 237 | 238 | com.jcraft 239 | jsch.agentproxy.usocket-jna 240 | 0.0.9 241 | 242 | 243 | commons-io 244 | commons-io 245 | 2.6 246 | 247 | 248 | org.apache.maven 249 | maven-settings-builder 250 | 3.6.3 251 | 252 | 253 | org.apache.maven.wagon 254 | wagon-http-shared 255 | 3.3.2 256 | 257 | 258 | org.eclipse.jgit 259 | org.eclipse.jgit 260 | 4.10.0.201712302008-r 261 | 262 | 263 | org.ow2.asm 264 | asm 265 | 5.2 266 | 267 | 268 | javax.enterprise 269 | cdi-api 270 | 1.0 271 | 272 | 273 | jboss-interceptor-api 274 | org.jboss.interceptor 275 | 276 | 277 | el-api 278 | javax.el 279 | 280 | 281 | jboss-ejb3-api 282 | org.jboss.ejb3 283 | 284 | 285 | 286 | 287 | org.apache.maven 288 | maven-settings 289 | 3.6.3 290 | 291 | 292 | org.apache.httpcomponents 293 | httpcore 294 | 4.4.13 295 | 296 | 297 | org.apache.maven 298 | maven-core 299 | 3.6.3 300 | 301 | 302 | org.sonatype.plexus 303 | plexus-cipher 304 | 1.4 305 | 306 | 307 | com.jcraft 308 | jzlib 309 | 1.1.3 310 | 311 | 312 | com.jcraft 313 | jsch.agentproxy.pageant 314 | 0.0.9 315 | 316 | 317 | org.apache.maven.resolver 318 | maven-resolver-api 319 | 1.6.1 320 | 321 | 322 | javax.annotation 323 | jsr250-api 324 | 1.0 325 | 326 | 327 | com.cognitect 328 | http-client 329 | 0.1.104 330 | 331 | 332 | org.apache.maven 333 | maven-resolver-provider 334 | 3.6.3 335 | 336 | 337 | org.checkerframework 338 | checker-compat-qual 339 | 2.0.0 340 | 341 | 342 | org.apache.maven.shared 343 | maven-shared-utils 344 | 3.2.1 345 | 346 | 347 | org.clojure 348 | tools.deps.alpha 349 | 0.9.884 350 | 351 | 352 | commons-logging 353 | commons-logging 354 | 1.2 355 | 356 | 357 | com.google.guava 358 | guava 359 | 25.1-android 360 | 361 | 362 | org.clojure 363 | data.xml 364 | 0.2.0-alpha6 365 | 366 | 367 | org.apache.maven.resolver 368 | maven-resolver-spi 369 | 1.6.1 370 | 371 | 372 | com.google.j2objc 373 | j2objc-annotations 374 | 1.1 375 | 376 | 377 | org.slf4j 378 | slf4j-nop 379 | 1.7.25 380 | 381 | 382 | org.codehaus.plexus 383 | plexus-classworlds 384 | 2.6.0 385 | 386 | 387 | org.apache.maven.wagon 388 | wagon-http 389 | 3.3.2 390 | 391 | 392 | quoin 393 | quoin 394 | 0.1.2 395 | 396 | 397 | org.sonatype.plexus 398 | plexus-sec-dispatcher 399 | 1.4 400 | 401 | 402 | org.codehaus.plexus 403 | plexus-interpolation 404 | 1.25 405 | 406 | 407 | org.apache.httpcomponents 408 | httpclient 409 | 4.5.12 410 | 411 | 412 | commons-logging 413 | commons-logging 414 | 415 | 416 | 417 | 418 | scout 419 | scout 420 | 0.1.0 421 | 422 | 423 | net.java.dev.jna 424 | jna 425 | 4.1.0 426 | 427 | 428 | com.google.inject 429 | guice 430 | 4.2.1 431 | no_aop 432 | 433 | 434 | com.jcraft 435 | jsch.agentproxy.connector-factory 436 | 0.0.9 437 | 438 | 439 | org.eclipse.jetty 440 | jetty-client 441 | 9.4.24.v20191120 442 | 443 | 444 | org.eclipse.jetty 445 | jetty-io 446 | 9.4.24.v20191120 447 | 448 | 449 | org.clojure 450 | tools.reader 451 | 1.3.2 452 | 453 | 454 | org.tcrawley 455 | dynapath 456 | 1.0.0 457 | 458 | 459 | stencil 460 | stencil 461 | 0.5.0 462 | 463 | 464 | org.jsoup 465 | jsoup 466 | 1.11.3 467 | 468 | 469 | net.java.dev.jna 470 | jna-platform 471 | 4.1.0 472 | 473 | 474 | seancorfield 475 | clj-new 476 | 1.1.264 477 | 478 | 479 | org.clojure 480 | tools.gitlibs 481 | 1.0.100 482 | 483 | 484 | org.apache.maven.resolver 485 | maven-resolver-connector-basic 486 | 1.6.1 487 | 488 | 489 | com.cognitect.aws 490 | s3 491 | 810.2.801.0 492 | 493 | 494 | org.apache.maven.resolver 495 | maven-resolver-impl 496 | 1.6.1 497 | 498 | 499 | org.slf4j 500 | slf4j-api 501 | 1.7.30 502 | 503 | 504 | org.apache.maven 505 | maven-model 506 | 3.6.3 507 | 508 | 509 | org.eclipse.sisu 510 | org.eclipse.sisu.inject 511 | 0.3.4 512 | 513 | 514 | org.apache.maven.resolver 515 | maven-resolver-util 516 | 1.6.1 517 | 518 | 519 | clj-commons 520 | pomegranate 521 | 1.2.0 522 | 523 | 524 | org.clojure 525 | core.memoize 526 | 0.8.2 527 | 528 | 529 | org.apache.maven 530 | maven-repository-metadata 531 | 3.6.3 532 | 533 | 534 | org.clojure 535 | data.priority-map 536 | 0.0.7 537 | 538 | 539 | aopalliance 540 | aopalliance 541 | 1.0 542 | 543 | 544 | org.apache.maven 545 | maven-builder-support 546 | 3.6.3 547 | 548 | 549 | com.google.code.findbugs 550 | jsr305 551 | 3.0.2 552 | 553 | 554 | com.jcraft 555 | jsch 556 | 0.1.54 557 | 558 | 559 | com.jcraft 560 | jsch.agentproxy.core 561 | 0.0.9 562 | 563 | 564 | com.jcraft 565 | jsch.agentproxy.usocket-nc 566 | 0.0.9 567 | 568 | 569 | org.clojure 570 | core.cache 571 | 0.8.2 572 | 573 | 574 | org.apache.maven 575 | maven-plugin-api 576 | 3.6.3 577 | 578 | 579 | org.clojure 580 | core.async 581 | 1.2.603 582 | 583 | 584 | org.apache.maven 585 | maven-artifact 586 | 3.6.3 587 | 588 | 589 | org.clojure 590 | data.codec 591 | 0.1.0 592 | 593 | 594 | 595 | 596 | 600 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject clj-py-r-template/clj-template "1.6.0" 2 | :description "Template to quickly create clojure data sciene projects with R + python " 3 | :url "https://github.com/behrica/clj-py-R-template" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :plugins [[lein-tools-deps "0.4.5"]] 7 | :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn] 8 | :lein-tools-deps/config {:config-files [:install :user :project]}) 9 | -------------------------------------------------------------------------------- /singularity-base/clj-py-r_base.def: -------------------------------------------------------------------------------- 1 | Bootstrap: docker 2 | From: behrica/clj-py-r:1.5.1 3 | 4 | %environment 5 | export JULIA_HOME=/opt/julia-1.5.3 6 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template.clj: -------------------------------------------------------------------------------- 1 | (ns clj.new.clj-py-r-template 2 | (:require [clj.new.templates :refer [renderer project-name name-to-path ->files]])) 3 | 4 | (def render (renderer "clj_py_r_template")) 5 | 6 | 7 | (defn file-map->files [data file-map] 8 | (apply ->files data file-map)) 9 | 10 | 11 | (defn clj-py-r-template! [name & {force :force? dir :dir}] 12 | (let [data {:name (project-name name) 13 | :base (clojure.string/replace 14 | (project-name name) 15 | #"(.*?)[.](.*$)" 16 | "$1") 17 | :suffix (clojure.string/replace 18 | (project-name name) 19 | #"(.*?)[.](.*$)" 20 | "$2") 21 | :sanitized (name-to-path name)} 22 | {base :base} data] 23 | 24 | (println (str "Generating clj-py-r template for " 25 | (:name data) " at " (:sanitized data) ".\n\n")) 26 | 27 | 28 | 29 | 30 | 31 | (with-bindings {#'clj.new.templates/*force?* force} 32 | #'clj.new.templates/*dir* dir 33 | (file-map->files 34 | data 35 | [["docker_build.sh" (render "docker_build.sh" data) :executable true] 36 | ["docker_repl.sh" (render "docker_repl.sh" data) :executable true] 37 | ["docker_run_xxx.sh" (render "docker_run_xxx.sh" data) :executable true] 38 | ["Dockerfile" (render "Dockerfile" data)] 39 | ["my-project.def" (render "my-project.def" data)] 40 | ["deps.edn" (render "deps.edn" data)] 41 | [".gitpod.Dockerfile" (render "gitpod.Dockerfile" data)] 42 | [".gitpod.yml" (render "gitpod.yml" data)] 43 | ["src/try_py_R.clj" (render "src/try_py_R.clj" data)]])))) 44 | 45 | 46 | 47 | 48 | (defn clj-py-r-template 49 | ([name] (clj-py-r-template! name)) 50 | ([name & args] (clj-py-r-template name))) 51 | 52 | (comment 53 | (newline) 54 | (clj-py-r-template! 55 | "mydomain.myapp1" 56 | :dir "testdir" 57 | :force? true)) 58 | 59 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM behrica/clj-py-r:1.7.0 2 | 3 | #should be nearly always overridden during `docker build` with YOUR user id via `--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)` or similar 4 | ARG USER_ID=999 5 | ARG GROUP_ID=999 6 | 7 | RUN addgroup --gid $GROUP_ID user 8 | RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user 9 | 10 | RUn chown -R user:user /tmp/.m2/repository 11 | USER user 12 | WORKDIR /home/user 13 | 14 | 15 | RUN cp /usr/local/bin/APserver /home/user 16 | 17 | # RUN apt-get install .... 18 | # RUN pip3 install .... 19 | # RUN Rscript -e 'install.packages("....",repo="http://cran.rstudio.com/")' 20 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :mvn/repos {"clojars" {:url "https://repo.clojars.org/"} 3 | "central" {:url "https://repo1.maven.org/maven2/"} 4 | "bedatadriven" {:url "https://nexus.bedatadriven.com/content/groups/public/"}} 5 | 6 | :paths ["src" "resources"] 7 | 8 | :deps { 9 | org.clojure/clojure {:mvn/version "1.10.3"} 10 | clj-python/libpython-clj {:mvn/version "2.018"} 11 | scicloj/clojisr {:mvn/version "1.0.0-BETA19"} 12 | scicloj/tablecloth {:mvn/version "6.076"} 13 | scicloj/notespace {:mvn/version "3-beta9"} 14 | scicloj/scicloj.ml {:mvn/version "0.2.0"} 15 | com.cnuernber/libjulia-clj {:mvn/version "1.000-beta-8"} 16 | behrica/libapl-clj {:git/url "https://github.com/behrica/libapl-clj" 17 | :git/sha "f40e17a95eaab6f81417d315f8499be7141b813c"} 18 | ;; {:mvn/version "0.1.2-ALPHA-SNAPSHOT"} 19 | 20 | io.github.nextjournal/clerk {:mvn/version "0.6.387"}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | :aliases { 28 | :cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.27.2"} 29 | refactor-nrepl {:mvn/version "3.0.0-alpha13"}} 30 | :main-opts ["-m" "nrepl.cmdline" "-b" "0.0.0.0" "-p" "12345" 31 | "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]}}} 32 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | docker build -t {{name}} --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) . 4 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/docker_repl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | docker run -it --rm -v -v "$(pwd):/workdir" -p 12345:12345 -p 7777:7777 -w /workdir appcompany.funapp 5 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/docker_run_xxx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | docker run -it --rm -v $HOME/.m2:/home/user/.m2 -v "$(pwd):/workdir" -p 12345:12345 -w /workdir {{name}} "$@" 5 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/gitpod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM behrica/clj-py-r:1.5.1 2 | RUN apt-get install sudo 3 | RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \ 4 | # passwordless sudo for users in the 'sudo' group 5 | && sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers 6 | 7 | 8 | RUN cp /usr/local/bin/APserver /home/gitpod 9 | 10 | # RUN apt-get install .... 11 | # RUN pip3 install .... 12 | # RUN Rscript -e 'install.packages("....",repo="http://cran.rstudio.com/")' 13 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/gitpod.yml: -------------------------------------------------------------------------------- 1 | image: 2 | file: .gitpod.Dockerfile 3 | 4 | tasks: 5 | - name: start nrepl 6 | command: python3 -c "import cljbridge;cljbridge.init_jvm(start_repl=True,port=12345,bind='0.0.0.0')" 7 | 8 | vscode: 9 | extensions: 10 | - betterthantomorrow.calva 11 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/my-project.def: -------------------------------------------------------------------------------- 1 | Bootstrap: library 2 | From: behrica/clj-py-r/clj-py-r_base:1.5.1 3 | 4 | %post 5 | cp /usr/local/bin/APserver $HOME 6 | # apt-get install .... 7 | # pip3 install .... 8 | # Rscript -e 'install.packages("....",repo="http://cran.rstudio.com/")' 9 | -------------------------------------------------------------------------------- /src/clj/new/clj_py_r_template/src/try_py_R.clj: -------------------------------------------------------------------------------- 1 | (ns try-py-R) 2 | 3 | 4 | 5 | (require '[libpython-clj2.require :refer [require-python]] 6 | '[libpython-clj2.python :as py]) 7 | 8 | ;;; python 9 | (require-python '[os :as os]) 10 | (os/getcwd) 11 | 12 | (require-python '[numpy :as np]) 13 | 14 | (def a (np/array [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])) 15 | (println a) 16 | (np/shape a) 17 | 18 | 19 | ;; R 20 | (require '[clojisr.v1.r :as r :refer [r require-r]]) 21 | (r "1+1") 22 | 23 | (require-r '[base :as base-r]) 24 | 25 | ;;; numpy -> clj -> R 26 | (def r-matrix 27 | (-> (np/array [[1 2 3 4] [5 6 7 8] [9 10 11 12]]) 28 | (py/->jvm) 29 | (r/clj->java->r) 30 | (base-r/simplify2array) 31 | (base-r/t))) 32 | 33 | (println 34 | (base-r/dim r-matrix)) 35 | 36 | 37 | (require '[libapl-clj.apl :as apl]) 38 | 39 | (apl/+ [1 2 3] [4 5 6]) 40 | 41 | (apl/display! (apl/+ [1 2 3] [4 5 6])) 42 | --------------------------------------------------------------------------------