Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create VSCode Development Environment #900

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

GeoDerp
Copy link

@GeoDerp GeoDerp commented Mar 2, 2025

VSCode Dev Container - Development Environment

WIP, all commentary appreciated.


VS Code additions

  • control + shift + p -> Tasks: Run task -> Project Install

    • Build and install ramalama via pip
  • Run & Debug -> Run Benchmark

    • Runs benchmark on ollama://llama3.2:1b
  • Extensions automatically installed in Dev Container:

    • "ms-python.debugpy",
    • "ms-python.python",
    • "ms-python.black-formatter",
    • "ms-python.flake8"
  • Dev Container

    • Instance of Fedora with python pre-installed
    • .local/share/ramalama volume mounted to avoid re downloading model

Summary by Sourcery

Introduce a VSCode development environment with a devcontainer. This environment includes pre-installed extensions, configurations, and tasks for building, installing, and benchmarking the project. It also configures podman to run inside the container.

Build:

  • Add a Dockerfile to define the VSCode development container, including installing necessary dependencies like git, openssl, python3, and podman.
  • Configure podman to run inside the container.
  • Create a ramalama folder in the container.
  • Add tasks for project installation and benchmarking.
  • Add configurations for debugging and running benchmarks.
  • Add settings for formatting and linting.
  • Add extensions for Python development, debugging, formatting, and linting.

Copy link
Contributor

sourcery-ai bot commented Mar 2, 2025

Reviewer's Guide by Sourcery

This pull request introduces a VS Code development container for the project. It includes a Dockerfile to set up the environment, configurations for VS Code settings, extensions, debugging, and tasks. This aims to provide a consistent and reproducible development environment for contributors.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Configured a VS Code development container with necessary dependencies and settings.
  • Created a Dockerfile to define the container environment, including installing git, openssl, nano, python3, and podman.
  • Configured podman to run inside the container, including setting up user namespaces and necessary volumes.
  • Created a .devcontainer/devcontainer.json file to configure the VS Code development container.
  • Added .vscode/extensions.json to automatically install extensions in the dev container.
  • Added .vscode/launch.json to configure debug settings.
  • Added .vscode/settings.json to configure VS Code settings.
  • Added .vscode/tasks.json to configure VS Code tasks.
.devcontainer/Dockerfile
.devcontainer/devcontainer.json
.vscode/extensions.json
.vscode/launch.json
.vscode/settings.json
.vscode/tasks.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@GeoDerp
Copy link
Author

GeoDerp commented Mar 2, 2025

More then happy to close this pull request if deemed irrelevant.
Current issue is with: Error: no devices found in /dev/dri: invalid argument when running bin/ramalama benchmark ollama://llama3.2:1b

@GeoDerp GeoDerp force-pushed the feat(dev)--VSCode-Development-Environment branch from a9a6c02 to f12a639 Compare March 2, 2025 12:07
@ericcurtin
Copy link
Collaborator

@cgruver were you looking into something similar? PTAL

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One caveat on the extensions. Only users of Microsoft provided VSCode can use extensions from the Microsoft marketplace. Users of open-source builds of VSCode like VSCodium or Eclipse Che will technically be in violation of the MS Terms of Use if they pull extensions from the Marketplace. Open Source VSCode users will need to use Open-VSX.org which is hosted by the Eclipse foundation.

I know that most of these extensions exist there too, but I'm not sure all of them do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked Open-VSX.org, Seems like all the extensions exist but the ms-vscode-remote.remote-containers

@cgruver
Copy link
Collaborator

cgruver commented Mar 2, 2025

@cgruver were you looking into something similar? PTAL

Kind of similar. I am using an OpenShift Dev Spaces workspace for my development. However, it is using some Tech Preview features on OpenShift 4.18, so it's not generally useable by most. Once OCP ~4.19+ goes GA with kernel level user namespace support, I will probably create a PR to share my workspace.

For the curious, my workspace is here - https://github.com/cgruver/llama-cpp-intel-gpu-workspace

"--security-opt=unmask=ALL",
"--device=/dev/fuse",
"--systemd=false",
"--device=/dev/dri",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this fail if any of the referenced devices do not exist on a platform?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... Generally --device fails if the device doesn't actually exist, sometimes I wish we had a --device-if-exists option in podman

@GeoDerp
Copy link
Author

GeoDerp commented Mar 2, 2025

Thanks for all your reviews @ericcurtin @cgruver @rhatdan, I really appreciate it.
😁

I'll migrate those changes tonight. Also happy to close this PR if OCP is a better approach in the long run. ❤️

@cgruver
Copy link
Collaborator

cgruver commented Mar 2, 2025

Thanks for all your reviews @ericcurtin @cgruver @rhatdan, I really appreciate it. 😁

I'll migrate those changes tonight. Also happy to close this PR if OCP is a better approach in the long run. ❤️

Oh no, don't close the PR. This is a good addition. The OCP approach is an AND to this one. It's also more specialized.

Cheers.

@GeoDerp
Copy link
Author

GeoDerp commented Mar 3, 2025

Going to put some more thought into --device and running dev environment on VSCodium/Eclipse.

@GeoDerp GeoDerp force-pushed the feat(dev)--VSCode-Development-Environment branch from 00fd87d to 0fddd80 Compare March 3, 2025 05:54
@rhatdan
Copy link
Member

rhatdan commented Mar 4, 2025

Since I use emacs, I have no ability to review this. but I am fine with this going in.

@ericcurtin
Copy link
Collaborator

vim for life! I might change someday 😄

@rhatdan
Copy link
Member

rhatdan commented Mar 4, 2025

Ok we will rely on @GeoDerp being correct and wait for him to remove draft status and merge. then others who use vscode can make changes if necessary.

@rhatdan
Copy link
Member

rhatdan commented Mar 4, 2025

@n1hility Not sure if this is something you have experience with?

@GeoDerp
Copy link
Author

GeoDerp commented Mar 4, 2025

Ok we will rely on @GeoDerp being correct and wait for him to remove draft status and merge. then others who use vscode can make changes if necessary.

I'll wait until the weekend to do a thorough test, and think about some solutions for those two problems. 😁❤️

I'm currently thinking about adding open-ssh server to the devcontainer. Scripting an action to SSH in, if dev container extension doesn't exist (VSCodium / Eclipse).

Haven't got around to thinking about the, --device issue yet.

@GeoDerp
Copy link
Author

GeoDerp commented Mar 9, 2025

Still a work in progress. (not 100% sure that this PR adds enough to the project to merge).
Replaced the concept of VSCode DevContainers with a Bash script.

This Bash script builds and runs a container acting like a development environment. Then ssh's into the container via a installed IDE (VScode,VSCodium, Thiea)

The logs are still returning Error: no devices found in /dev/dri: invalid argument when running ramalama. I believe there is still a device permission issue to iron out. (podman in podman)

I also haven't tested VSCodium and Theia in-depth.

Posting commit in hopes of feedback and advice.

@GeoDerp
Copy link
Author

GeoDerp commented Mar 9, 2025

My thoughts are that the dev container environment is probably pretty useless, due to the project itself. (only requirements for the host is podman and python)

I am more than happy to rm the Development folder and leave the .vscode. therefore no containers Dev environment, but still get recommendations on extension to install. (And some helpful actions/tasks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants