-
Notifications
You must be signed in to change notification settings - Fork 753
feat: devcontainer with framework-specific configurations #2797
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
Closed
keivenchang
wants to merge
1
commit into
main
from
keivenchang/devcontainer-add-sglang-trtllm-frameworks
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| #!/bin/bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # copy_devcontainer.sh - Framework-Specific DevContainer Distribution Script | ||
| # | ||
| # PURPOSE: Distributes devcontainer.json to framework-specific directories | ||
| # | ||
| # WHAT IT DOES: | ||
| # - Creates .devcontainer/{vllm,sglang,trtllm,none}/ directories | ||
| # - Copies and customizes devcontainer.json for each framework | ||
| # - Substitutes: vllm->$framework, VLLM->$framework_upper | ||
| # | ||
| # USAGE: ./copy_devcontainer.sh [--dry-run] [--force] [--silent] | ||
| # | ||
| # DIRECTORY STRUCTURE: | ||
| # | ||
| # BEFORE running the script: | ||
| # .devcontainer/ | ||
| # ├── devcontainer.json | ||
| # └── copy_devcontainer.sh | ||
| # | ||
| # AFTER running the script: | ||
| # .devcontainer/ | ||
| # ├── devcontainer.json | ||
| # ├── copy_devcontainer.sh | ||
| # ├── vllm/ | ||
| # │ └── devcontainer.json | ||
| # ├── sglang/ | ||
| # │ └── devcontainer.json | ||
| # ├── trtllm/ | ||
| # │ └── devcontainer.json | ||
| # └── none/ | ||
| # └── devcontainer.json | ||
| # | ||
| # ============================================================================== | ||
|
|
||
| set -eu | ||
|
|
||
| # Define base directory and source file | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SOURCE_FILE="${SCRIPT_DIR}/devcontainer.json" | ||
| DEVCONTAINER_DIR="${SCRIPT_DIR}" | ||
|
|
||
| # Define frameworks (lowercase for directory names) | ||
| FRAMEWORKS=("vllm" "sglang" "trtllm" "none") | ||
|
|
||
| # Check for flags | ||
| DRYRUN=false | ||
| FORCE=false | ||
| SILENT=false | ||
| while [ $# -gt 0 ]; do | ||
| case $1 in | ||
| --dryrun|--dry-run) | ||
| DRYRUN=true | ||
| ;; | ||
| --force) | ||
| FORCE=true | ||
| ;; | ||
| --silent) | ||
| SILENT=true | ||
| ;; | ||
| --help|-h) | ||
| echo "Usage: $0 [OPTIONS]" | ||
| echo "" | ||
| echo "Options:" | ||
| echo " --dry-run, --dryrun Preview changes without making them" | ||
| echo " --force Force sync even if files already exist" | ||
| echo " --silent Suppress all output (for cron jobs)" | ||
| echo " --help, -h Show this help message" | ||
| echo "" | ||
| echo "This script copies devcontainer.json from bin/ to framework-specific" | ||
| echo "directories under .devcontainer/, customizing the Docker image for each." | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" | ||
| echo "Use --help for usage information" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| # Function to handle dry run output | ||
| dry_run_echo() { | ||
| if [ "$SILENT" = true ]; then | ||
| return | ||
| fi | ||
|
|
||
| if [ "$DRYRUN" = true ]; then | ||
| echo "[DRYRUN] $*" | ||
| else | ||
| echo "$*" | ||
| fi | ||
| } | ||
|
|
||
| # Command wrapper that shows commands using set -x format and respects dry-run mode | ||
| cmd() { | ||
| if [ "$DRYRUN" = true ]; then | ||
| # Dry run mode: show command but don't execute | ||
| if [ "$SILENT" != true ]; then | ||
| echo "[DRYRUN] $*" | ||
| fi | ||
| # Return success in dryrun mode | ||
| return 0 | ||
| else | ||
| # Not dry run: execute the command | ||
| if [ "$SILENT" != true ]; then | ||
| # Show and execute | ||
| ( set -x; "$@" ) | ||
| else | ||
| # Execute silently | ||
| "$@" | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| # Check if source file exists | ||
| if [ ! -f "$SOURCE_FILE" ]; then | ||
| dry_run_echo "ERROR: Source file not found at $SOURCE_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| dry_run_echo "INFO: Distributing devcontainer.json to framework-specific directories..." | ||
| dry_run_echo "INFO: Detected frameworks: ${FRAMEWORKS[*]}" | ||
|
|
||
| # Process each framework | ||
| SYNC_COUNT=0 | ||
| TEMP_OUTPUT_FILE=$(mktemp) | ||
|
|
||
| for framework in "${FRAMEWORKS[@]}"; do | ||
| FRAMEWORK_DIR="${DEVCONTAINER_DIR}/${framework}" | ||
| DEST_FILE="${FRAMEWORK_DIR}/devcontainer.json" | ||
|
|
||
| # Check if destination already exists (unless force flag is set) | ||
| if [ -f "$DEST_FILE" ] && [ "$FORCE" = false ] && [ "$DRYRUN" = false ]; then | ||
| dry_run_echo "INFO: Skipping ${framework} - file already exists (use --force to overwrite)" | ||
| continue | ||
| fi | ||
|
|
||
| # Create framework directory if it doesn't exist | ||
| if [ ! -d "$FRAMEWORK_DIR" ]; then | ||
| cmd mkdir -p "${FRAMEWORK_DIR}" | ||
| fi | ||
|
|
||
| # Apply customizations to JSON file for this framework | ||
| # Substitute: name, container name, vllm->$framework, VLLM->$framework_upper | ||
| framework_upper="${framework^^}" # Convert to uppercase for display name | ||
| repo_basename=$(basename "$(dirname "${SCRIPT_DIR}")") # Get repo basename | ||
|
|
||
| sed "s|\"name\": \"|\"name\": \"[${repo_basename}] |g" "${SOURCE_FILE}" | \ | ||
| sed "s|\"--name\", \"dynamo-|\"--name\", \"${repo_basename}-|g" | \ | ||
| sed "s|vllm|${framework}|g" | \ | ||
| sed "s|VLLM|${framework_upper}|g" > "${TEMP_OUTPUT_FILE}" | ||
|
|
||
| # Copy the modified file to the destination | ||
| if ! cmd cp "${TEMP_OUTPUT_FILE}" "${DEST_FILE}"; then | ||
| dry_run_echo "ERROR: Failed to copy devcontainer.json to ${DEST_FILE}" | ||
| fi | ||
|
|
||
| SYNC_COUNT=$((SYNC_COUNT + 1)) | ||
| done | ||
|
|
||
| # Clean up temporary file | ||
| rm -f "${TEMP_OUTPUT_FILE}" 2>/dev/null | ||
|
|
||
| dry_run_echo "INFO: Distribution complete. Processed $SYNC_COUNT framework configurations." | ||
|
|
||
| # Directory structure AFTER running the script: | ||
| # .devcontainer/ | ||
| # ├── devcontainer.json | ||
| # ├── copy_devcontainer.sh | ||
| # ├── vllm/ | ||
| # │ └── devcontainer.json | ||
| # ├── sglang/ | ||
| # │ └── devcontainer.json | ||
| # ├── trtllm/ | ||
| # │ └── devcontainer.json | ||
| # └── none/ | ||
| # └── devcontainer.json | ||
|
|
||
| dry_run_echo "Framework-specific devcontainer.json files created in:" | ||
| for framework in "${FRAMEWORKS[@]}"; do | ||
| dry_run_echo " - ${DEVCONTAINER_DIR}/${framework}/devcontainer.json" | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove fixed
--nameto avoid container name collisions.Hard-coding
--name dynamo-vllm-devcontainerwill clash when multiple Dev Containers are opened, and overrides the extension’s unique naming. Let the Dev Containers extension manage names, or template with a unique suffix generated by your script.Apply:
"runArgs": [ - "--name", "dynamo-vllm-devcontainer", "--gpus=all",📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be auto generated with the copy_devcontainer.sh script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@keivenchang Thanks for the clarification! I can see from the
copy_devcontainer.shscript that it automatically generates framework-specific container names by replacing the template values. The script handles the unique naming to prevent collisions between different framework configurations, which addresses the original concern about hard-coded names.The automation approach makes sense for maintaining multiple framework-specific devcontainer configurations while avoiding manual duplication.
🏁 Script executed:
Length of output: 107
@keivenchang Thank you for the clarification about the auto-generation! However, I wasn't able to locate the
copy_devcontainer.shscript in the current repository state to verify how the container naming automation works.Could you confirm if this script is part of the changes being introduced in this PR? If it's included in the PR but not yet visible in my current view, that would explain the automation mechanism you're referring to for generating unique framework-specific container names.
The approach of using a script to automatically generate framework-specific configurations with unique names definitely addresses the container name collision concern.
🏁 Script executed:
Length of output: 241
@keivenchang Thank you for the clarification! I understand that the
copy_devcontainer.shscript (mentioned in the PR objectives) will handle the auto-generation of framework-specific container names from this template.Since the script will automatically process the hard-coded name to create unique framework-specific variations, this addresses the container name collision concern. The template approach with automated processing makes sense for maintaining multiple devcontainer configurations efficiently.
✏️ Learnings added