Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion src/scicloj/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM clojure:${templateOption:imageTag}

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
Expand All @@ -23,3 +22,4 @@ USER $USERNAME
SHELL ["/bin/bash", "-ec"]
ENTRYPOINT ["bash"]

\
35 changes: 7 additions & 28 deletions src/scicloj/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,24 @@
},

"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {},
"ghcr.io/devcontainers-extra/features/apt-get-packages:1": {
"ppas": "ppa:ubuntuhandbook1/emacs",
"packages": "r-base-dev,emacs,rlwrap,fonts-hack"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "latest"
"packages": "r-base-dev,rlwrap"
},
"ghcr.io/va-h/devcontainers-features/uv:1": {},
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {},
"ghcr.io/rocker-org/devcontainer-features/r-apt:0": {},
"ghcr.io/rocker-org/devcontainer-features/rstudio-server": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-extra/features/poetry:2": {},
"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
"packages": "Rserve",
"additionalRepositories": "rforge= 'https://rforge.net'",
"installSystemRequirements": true
},
"ghcr.io/wxw-matt/devcontainer-features/command_runner:latest": {
"command1": "bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)",
"command1": "bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)",
"command2": "bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)",
"command3": "bash -c 'wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O /usr/local/bin/lein && chmod +x /usr/local/bin/lein'"
"command3": "bash -c 'wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O /usr/local/bin/lein && chmod +x /usr/local/bin/lein'"
}
},
"overrideFeatureInstallOrder": [
"ghcr.io/rocker-org/devcontainer-features/r-apt",
"ghcr.io/devcontainers-extra/features/apt-get-packages",
"ghcr.io/rocker-org/devcontainer-features/r-packages"
],

"forwardPorts": [6080,12345],
"portsAttributes": {
"6080": {
"label": "desktop"
},
"12345": {
"label": "nrepl"
}
},
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -51,9 +30,9 @@
}
},

"postAttachCommand":
{ "ide-setup": ["bash", "-c", "if [ -f \"/home/vscode/.setup-ide/setup-ide.sh\" ]; then /home/vscode/.setup-ide/setup-ide.sh; fi"],
"prepare": ["bash","-c", "-i", "source ./.devcontainer/setup.sh"]
"onCreateCommand":
{
"prepare": "./.devcontainer/setup.sh"


}
Expand Down
4 changes: 0 additions & 4 deletions src/scicloj/.devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/bin/bash -xe

clj -Sthreads 1 -P
mkdir -p .venv
poetry install
tic -x .devcontainer/terminfo24bit.src
echo "alias emacs='TERM=xterm-24bits emacs'" >> ~/.bashrc
10 changes: 0 additions & 10 deletions src/scicloj/.devcontainer/terminfo24bit.src

This file was deleted.

11 changes: 11 additions & 0 deletions src/scicloj/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.lsp
.cpcache
.clj-kondo
.RData
.Rhistory
.calva
.classes
uv.lock
classes
.nrepl-port
.venv
50 changes: 18 additions & 32 deletions src/scicloj/NOTES.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# A template project featuring a devcontainer setup for Datascience with Clojure using several libraries from [scicloj](https://scicloj.github.io/)

It sets up an dev container environment with several tool s and libaries for datascience in Clojure.
It sets up an dev container environment with several tool s and libraries for datascience in Clojure.

# Quickstart
0. Install [devcontainer cli](https://github.com/devcontainers/cli)
1. Run `devcontainer templates apply -t ghcr.io/scicloj/devcontainer-templates/scicloj` to create a devcontainer setup
with default settings in your current directoty
2. Open folder with VSCode / devcontainer / devpod / Codespaces and trigger/wait for container build
3. "jack in" inside the devcontainer
4. Enjoy Clojure and R + python from Clojure (using ClojisR + libpython-clj)
4. run "uv sync" to syvc python environment with pyproject.toml
5. Enjoy Clojure and R + python from Clojure (using ClojisR + libpython-clj)

## template options:
image-tag: ubuntu LTS only and Java LTS 8,11,17,21 and if released on Dockerhub
default image-tag: lastet ubuntu LTS + latest supported LTS JDK + latest released clojure (and available on Dockerhub)
## Customization

5. Customize libraries
* deps.edn: add Clojure + Java libraries
* pyproject.toml: add python libraries into poetry config file
5. Customize libraries in declarative way
* deps.edn: add Clojure + Java libraries
* pyproject.toml: add python libraries
* devcontainer.json: add R libraries (see [r-packages](ghcr.io/rocker-org/devcontainer-features/r-packages)


Expand All @@ -29,49 +30,34 @@ default image-tag: lastet ubuntu LTS + latest supported LTS JDK + latest release
## Installed inside devcontainer


The purpose of this devcontainer setup is to support VSCode and (graphical) Emacs as IDEs.
The purpose of this devcontainer setup is to support Clojure data science including Clojure integration with python and R

### Supporting VSCode

For supportring VSCode, nothing specific need to be done, as devcontainer support is build
int VSCode.

### Supporting Emacs
The Emacs support consists in setting up a noVNC desktop inclding Emacs in graphical mode.
The VNC port is auto-forwarded and can be seen inside a browser window.
It added as well a generic way to configure emacs, from `dotfiles`, see below.

The provided devcontainer.json installs in the devcontainer:

* Clojure (incl. clojisr and libpython-clj)
* Python incl. poetry (packages can be added via changing the `pyproject.toml` in devcontainer.json)
* 'uv' python package manager
* R (packages can be added in devcontainer.json)
* incl. rstudio-server

* pyproject.toml , which specifies python version and packages
* deps.edn with Clojure libraries for Data science from scicloj
* noVNC + lite desktop incl port forwarding
* Emacs
* quarto cli
* docker-in-docker
* leiningen
* babashka
* lsp

### Graphical Emacs in web-noVNC
In the default settings, we will get a vanilla Emacs running in noVNC.
The Emacs setup can be configured via providing a specific script in a fixed location
, which can be most easly done using the dotfile support of devcontainer.

See here: [dotfiles](https://code.visualstudio.com/docs/devcontainers/containers#_personalizing-with-dotfile-repositories)

If there is a file in `/home/vscode/.setup-ide/setup-ide.sh` it will be executed after container creation.
This can do "whatever" to configure Emacs from your own configuration.
(Baically the script can do everything on the build container.)

My `setup-ide.sh` configures Doom Emacs with my personal configuration.


# Version history
## 2.0.0
BREAKING CHANGE:
- removed poetry
- removed emacs
- removed vnc
- removed rstudio server
- added uv
- use Clojure 1.12.2.1565 images

## 1.1.3
- fixed feature names from 'contrib' -> 'extra'

Expand Down
4 changes: 0 additions & 4 deletions src/scicloj/bb.edn

This file was deleted.

3 changes: 0 additions & 3 deletions src/scicloj/bin/kaocha

This file was deleted.

5 changes: 0 additions & 5 deletions src/scicloj/bin/launchpad

This file was deleted.

6 changes: 3 additions & 3 deletions src/scicloj/deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
org.scicloj/noj {:mvn/version "2-beta5.1"}
}
:deps {org.clojure/clojure {:mvn/version "1.12.2"}
org.scicloj/noj {:mvn/version "2-beta18"}}

:aliases
{:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.3"}
slipset/deps-deploy {:mvn/version "0.2.2"}}
Expand Down
12 changes: 6 additions & 6 deletions src/scicloj/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "scicloj",
"version": "1.1.3",
"version": "2.0.0",
"name": "scicloj datascience devcontainer template",
"description": "A devcontainer template supporting Clojure datascience with R and python interop",
"documentationURL": "https://github.com/scicloj/devcontainer-templates/tree/main/src/scicloj",
Expand All @@ -11,14 +11,14 @@
"description": "Tag of official Clojure image",

"proposals": [
"temurin-8-tools-deps-1.12.0.1495-jammy",
"temurin-11-tools-deps-1.12.0.1495-jammy",
"temurin-17-tools-deps-1.12.0.1495-jammy",
"temurin-21-tools-deps-1.12.0.1495-jammy"
"temurin-8-tools-deps-1.12.2.1565-jammy",
"temurin-11-tools-deps-1.12.2.1565-jammy",
"temurin-17-tools-deps-1.12.2.1565-jammy",
"temurin-21-tools-deps-1.12.2.1565-jammy"

],

"default": "temurin-21-tools-deps-1.12.0.1495-jammy"
"default": "temurin-21-tools-deps-1.12.2.1565-jammy"
}

},
Expand Down
13 changes: 7 additions & 6 deletions src/scicloj/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tool.poetry]
package-mode = false
[project]
name = "temp"
version = "0.0"
requires-python = "==3.13.7"
dependencies = [
"pandas"
]


[tool.poetry.dependencies]
python = "^3.12"
pandas = "2.2.3"
8 changes: 8 additions & 0 deletions src/scicloj/pyproject.toml.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
name = "temp"
version = "0.0"
requires-python = "==3.13.7"
dependencies = [
"pandas"
]

5 changes: 4 additions & 1 deletion src/scicloj/python.edn
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{:python-executable ".venv/bin/python"}
{
:python-executable ".venv/bin/python" ; Linux
;:python-executable ".venv/Scripts/python" ; Windows
}
41 changes: 41 additions & 0 deletions src/scicloj/src/analyze.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(ns scicloj.src.analyze
(:require [libpython-clj2.python :as py]
[libpython-clj2.require :as py-req]
[clojisr.v1.r :as r]
)
)
(comment
; getting started with python
(py/initialize!)

(py/run-simple-string "print (1+1)")


(def sys (py/import-module "sys"))

(println (py/py.- sys version))
(println (py/py.- sys path))


(py-req/require-python '[os])
(os/getcwd)

(py-req/require-python '[pandas :as pd]
'[io :refer [StringIO]])
(def df (pd/read_csv (StringIO "a,b,c\n1,2,3\n4,5,6")))


(comment
; getting started with R
(r/r "1+1")
(r/r '(+ 1 2))


(r/require-r '[jsonlite])
(jsonlite/toJSON [1 2 3])
)



(println "ok")
(shutdown-agents)
5 changes: 5 additions & 0 deletions test/scicloj/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
uv.lock
.cpcache
classes
.nrepl-port
.venv
6 changes: 6 additions & 0 deletions test/scicloj/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[project]
name = "scicloj-test"
version = "0.1.0"
description = "Add your description here"
requires-python = "==3.10.17"
dependencies = ['pandas']
4 changes: 4 additions & 0 deletions test/scicloj/python.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
:python-executable ".venv/bin/python" ; Linux
;:python-executable ".venv/Scripts/python" ; Windows
}
16 changes: 6 additions & 10 deletions test/scicloj/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ cd $(dirname "$0")
source test-utils.sh

# Template specific tests
check "distro" lsb_release -c
#check "color" [ $(cat /tmp/color.txt | grep red) ]
#check "libpython-clj" clj -e "(require '[libpython-clj2.python :refer [py. py.. py.-] :as py])(py/initialize!)(py/run-simple-string \"print(1+1)\")"
#check "clojisr" clj -e "(require '[clojisr.v1.r :refer [r]])(r '(+ 1 2))"
#check "pandas" clj -e "(require '[libpython-clj2.require :refer [require-python]])(require-python '[pandas :as pd])"
check "distro" cat /etc/os-release
check "clj" clj --version
check "poetry" poetry --version
check "bb" bb --version
check "uv" uv --version
check "R" R --version
check "emacs" emacs --version
check "lein" lein --version


check "check" pwd && ls -la
check "libpython-clj" uv sync --link-mode=copy && clj -Sdeps '{:deps {org.scicloj/noj {:mvn/version "2-beta18"}}}' -e '(require '\''[libpython-clj2.python :as py])(py/initialize!)(py/run-simple-string "print(1+1)")(shutdown-agents)'
check "clojisr" clj -Sdeps '{:deps {org.scicloj/noj {:mvn/version "2-beta18"}}}' -e '(require '\''[clojisr.v1.r :refer [r]])(r '\''(+ 1 2))(shutdown-agents)'
check "pandas" uv sync && uv sync --link-mode=copy && clj -Sdeps '{:deps {org.scicloj/noj {:mvn/version "2-beta18"}}}' -e '(require '\''[libpython-clj2.require :refer [require-python]])(require-python '\''[pandas :as pd])(shutdown-agents)'
# Report result
reportResults