From f922e017877a26bc4688a7c8ae9a1e32bc0b0c13 Mon Sep 17 00:00:00 2001 From: John Rofrano Date: Tue, 18 Feb 2025 19:11:50 +0000 Subject: [PATCH 1/3] Added devcontainer env with Python, Java, C, and Rust Signed-off-by: John Rofrano --- .devcontainer/Dockerfile | 59 +++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..0f402ee --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,59 @@ +# Image for a Python 3 development environment +FROM python:3.11-bookworm + +# Turn off interactive prompts +ENV DEBIAN_FRONTEND=noninteractive + +# Add any Python tools that are needed beyond Python 3.11 +RUN apt-get update && \ + apt-get install -y sudo build-essential lsb-release software-properties-common ca-certificates \ + python3.11-dev python3.11-venv libxmlsec1-dev gnupg gcc vim make git zip tree curl wget jq + +# Add LLVM for C support with symlinks +RUN wget https://apt.llvm.org/llvm.sh && \ + chmod +x llvm.sh && \ + ./llvm.sh 18 && \ + apt-get install -y llvm-18 llvm-18-dev clang-18 libclang-18-dev && \ + ln -s /usr/bin/clang-18 /usr/bin/clang && \ + ln -s /usr/bin/llvm-config-18 /usr/bin/llvm-config + +# Install Ollama +# RUN curl -fsSL https://ollama.com/install.sh | sh + +# Create a user for development +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user with passwordless sudo privileges +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \ + && usermod -aG sudo $USERNAME \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +# Set up the Python development environment +WORKDIR /python-sdk +RUN python3 -m pip install --upgrade pip wheel && \ + pip3 install poetry==1.8.5 + +# Enable color terminal for docker exec bash +ENV TERM=xterm-256color + +# Become a regular user +USER $USERNAME + +# Add Java dependencies with SDKMan as a regular user +ARG HOME="/home/$USERNAME" +RUN curl -s "https://get.sdkman.io" | bash +# this SHELL command is needed to allow using source +SHELL ["/bin/bash", "-c"] +RUN source "$HOME/.sdkman/bin/sdkman-init.sh" && \ + sdk install java 11.0.25-sem && \ + sdk use java 11.0.25-sem && \ + sdk install maven + +# Add Rust support +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh && \ + sh /tmp/rustup.sh -y && \ + rm /tmp/rustup.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..22cce0a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,71 @@ +{ + "name": "CLDK Python SDK", + "dockerFile": "Dockerfile", + "context": "..", + "remoteUser": "vscode", + "workspaceFolder": "/python-sdk", + "workspaceMount": "source=${localWorkspaceFolder},target=/python-sdk,type=bind,consistency=delegated", + // "mounts": [ + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ollama,target=/home/vscode/.ollama,type=bind,consistency=cached" + // ], + "runArgs": ["-h", "codellm-devkit", "--name", "python-sdk"], + "customizations": { + "vscode": { + "settings": { + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true + }, + "git.mergeEditor": true, + "autoDocstring.docstringFormat": "google", + "markdown-preview-github-styles.colorTheme": "light", + "makefile.extensionOutputFolder": "/tmp", + "python.terminal.activateEnvironment": true, + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": [ + "tests" + ], + "cSpell.words": [ + "pydantic", + "pyarrow", + "cldk", + "Codeanalyzer", + "treesitter" + ], + "files.exclude": { + "**/.git": true, + "**/.DS_Store": true, + "**/*.pyc": true, + "**/__pycache__": true, + "**/.pytest_cache": true + } + }, + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-toolsai.jupyter", + "ms-python.debugpy", + "ms-python.pylint", + "ms-python.flake8", + "ms-python.black-formatter", + "zeshuaro.vscode-python-poetry", + "njpwerner.autodocstring", + "wholroyd.jinja", + "yzhang.markdown-all-in-one", + "hnw.vscode-auto-open-markdown-preview", + "davidanson.vscode-markdownlint", + "bierner.markdown-preview-github-styles", + "tamasfe.even-better-toml", + "donjayamanne.githistory", + "GitHub.vscode-pull-request-github", + "hbenl.vscode-test-explorer", + "LittleFoxTeam.vscode-python-test-adapter", + "redhat.vscode-yaml", + "ms-azuretools.vscode-docker", + "streetsidesoftware.code-spell-checker" + ] + } + }, + "postCreateCommand": "sudo poetry config virtualenvs.create false && sudo poetry install; echo '---'; python3 --version; echo '---'; java -version; echo '---'; mvn --version; echo '--'; clang --version; echo '---';" +} From 126ca1f3bd9d7c8671659d217b0aac4a99d1a244 Mon Sep 17 00:00:00 2001 From: John Rofrano Date: Tue, 18 Feb 2025 19:12:07 +0000 Subject: [PATCH 2/3] Lock file was out of date Signed-off-by: John Rofrano --- poetry.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index 11734b2..34d3e00 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "annotated-types" @@ -1639,13 +1639,13 @@ min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-imp [[package]] name = "mkdocs-autorefs" -version = "1.3.0" +version = "1.3.1" description = "Automatically link across pages in MkDocs." optional = false python-versions = ">=3.9" files = [ - {file = "mkdocs_autorefs-1.3.0-py3-none-any.whl", hash = "sha256:d180f9778a04e78b7134e31418f238bba56f56d6a8af97873946ff661befffb3"}, - {file = "mkdocs_autorefs-1.3.0.tar.gz", hash = "sha256:6867764c099ace9025d6ac24fd07b85a98335fbd30107ef01053697c8f46db61"}, + {file = "mkdocs_autorefs-1.3.1-py3-none-any.whl", hash = "sha256:18c504ae4d3ee7f344369bb26cb31d4105569ee252aab7d75ec2734c2c8b0474"}, + {file = "mkdocs_autorefs-1.3.1.tar.gz", hash = "sha256:a6d30cbcccae336d622a66c2418a3c92a8196b69782774529ad441abb23c0902"}, ] [package.dependencies] @@ -1693,13 +1693,13 @@ dev = ["click", "codecov", "mkdocs-gen-files", "mkdocs-git-authors-plugin", "mkd [[package]] name = "mkdocs-material" -version = "9.6.2" +version = "9.6.4" description = "Documentation that simply works" optional = false python-versions = ">=3.8" files = [ - {file = "mkdocs_material-9.6.2-py3-none-any.whl", hash = "sha256:71d90dbd63b393ad11a4d90151dfe3dcbfcd802c0f29ce80bebd9bbac6abc753"}, - {file = "mkdocs_material-9.6.2.tar.gz", hash = "sha256:a3de1c5d4c745f10afa78b1a02f917b9dce0808fb206adc0f5bb48b58c1ca21f"}, + {file = "mkdocs_material-9.6.4-py3-none-any.whl", hash = "sha256:414e8376551def6d644b8e6f77226022868532a792eb2c9accf52199009f568f"}, + {file = "mkdocs_material-9.6.4.tar.gz", hash = "sha256:4d1d35e1c1d3e15294cb7fa5d02e0abaee70d408f75027dc7be6e30fb32e6867"}, ] [package.dependencies] @@ -1760,13 +1760,13 @@ python-legacy = ["mkdocstrings-python-legacy (>=0.2.1)"] [[package]] name = "mkdocstrings-python" -version = "1.14.5" +version = "1.16.0" description = "A Python handler for mkdocstrings." optional = false python-versions = ">=3.9" files = [ - {file = "mkdocstrings_python-1.14.5-py3-none-any.whl", hash = "sha256:ac394f273ae298aeaa6be4506768f05e61bd7c8119437ea98553354b1185c469"}, - {file = "mkdocstrings_python-1.14.5.tar.gz", hash = "sha256:8582eeac8cce952f395d76ec636fc814757cba7d8458aa75ba0529a3aa10d98c"}, + {file = "mkdocstrings_python-1.16.0-py3-none-any.whl", hash = "sha256:80ecbcca67fe29eb5a853ab7be0457231f6eefb5d079bcdf7dbae16962fc3f51"}, + {file = "mkdocstrings_python-1.16.0.tar.gz", hash = "sha256:546d53c7d559941abc726b2f78a41c0183480a95ba0a87ccc63b9b08740126f9"}, ] [package.dependencies] @@ -3526,19 +3526,19 @@ tests = ["tree-sitter-html (>=0.23.2)", "tree-sitter-javascript (>=0.23.1)", "tr [[package]] name = "tree-sitter-c" -version = "0.23.4" +version = "0.23.5" description = "C grammar for tree-sitter" optional = false python-versions = ">=3.9" files = [ - {file = "tree_sitter_c-0.23.4-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:2c92c0571b36b6da06f8882f34151dc11e67a493e9101cc0026a16da27709c05"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:98c285a23bf4fb6fb34140d6ea0f0d25d0a93e0d93692f9dffe3db6d1fe08534"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e42a3519825ca59c91b2b7aec08dd3c89e02690c7b315d54a1e1743f9be3f15"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c15c7588c3d95872328019073a8d5eaf7c2691b4d4ef0393a0168399b2ad2356"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:013403e74765d74e523f380f9df8f3d99e9fe94132a3fc0c8b29cba538a7b2bf"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-win_amd64.whl", hash = "sha256:a4d7bdeaca8f1da72352a945853f56aa5d34e7bc22569ec5bda5d7c1a04e5b0f"}, - {file = "tree_sitter_c-0.23.4-cp39-abi3-win_arm64.whl", hash = "sha256:edd36e12cc79b8b5bbc81fc336ff7d2577d0fe16afd18163c9aff7ae3ff69e15"}, - {file = "tree_sitter_c-0.23.4.tar.gz", hash = "sha256:9215c7888dd019038f162ea5646178f6e129cd2b49fc506d14becf5e426121d7"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:d0c696d318223efd8ccd9e72ce2ea7339ea30b3e7d1b575a5b2bebae19c56595"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:28c09b648064bc7c64c1bda268044cd9541c766d5e2265bc2fb648b7948840f5"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:367bda67bf3ffbab9ac6df2292e665b5f68103440756c9b2fa4ed3ee2e1e8075"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cd3463b1cf987a5b661f15bab1366c1e667f9d2c0e76cc53c81c12e2a6c71c5e"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:98b98e666ac2396dadd31638defc5d2880eff7df156a287cd2a4e6e55d513cc7"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-win_amd64.whl", hash = "sha256:54cd9c9a85d16112b7fc090db64257736b5ade3d1d6b8ac77736c8cba741c1c6"}, + {file = "tree_sitter_c-0.23.5-cp39-abi3-win_arm64.whl", hash = "sha256:29451cee460e2e1595c500a4049c81a0a5696e86734ecff78bc5cd744c9e0c6c"}, + {file = "tree_sitter_c-0.23.5.tar.gz", hash = "sha256:10e78174b9038a5590070de91a7d51e08049c9d46e0ab6cb8e216add9d03cabe"}, ] [package.extras] @@ -3803,4 +3803,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.11" -content-hash = "ddbcdf1f545f2d6462a62f8f08d26ae9722a38f57e8e7ede858c151282c5fb94" +content-hash = "93e6cc13cfb8a19566b4e9e5ce1c6384e886befc77cb12e5c677f3319acc92a8" From 964be403e6dd59f8f73fc95fc6e91d39faf200bc Mon Sep 17 00:00:00 2001 From: John Rofrano Date: Wed, 19 Feb 2025 19:15:30 +0000 Subject: [PATCH 3/3] Added dev container instructions Signed-off-by: John Rofrano --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 3d4d411..9134180 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,18 @@ Before we begin, make sure you have the following prerequisites installed: * Python 3.11 or later * Ollama v0.3.4 or later +If you are using [Visual Studio Code](https://code.visualstudio.com) with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension along with [Docker Desktop](https://www.docker.com/products/docker-desktop) or [Rancher Desktop](https://w3.ibm.com/w3publisher/docker-desktop/rancher-desktop), this project contains a Dev Container environment for you to develop in. + +Use the following commands: + +```bash +git clone https://github.com/codellm-devkit/python-sdk.git +cd python-dsk +code . +``` + +When Visual Studio Code starts, select the option to **Reopen in Container** and a development environment with Python, Java, C, and Rust will be available to you. See [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers) for more detailed instructions. + ### Step 1: Set up an Ollama server If don't already have ollama, please download and install it from here: [Ollama](https://ollama.com/download).