-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Dockerfile and docker-compose.yml #17
base: develop
Are you sure you want to change the base?
Add Dockerfile and docker-compose.yml #17
Conversation
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe changes involve updating a Dockerfile for a containerized application that now builds upon an NVIDIA PyTorch image, setting up the environment, and installing dependencies. A new Python module Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
@coderabbitai review |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- docker-compose.yml
Files selected for processing (3)
- Dockerfile (1 hunks)
- app/dummy_modal.py (1 hunks)
- app/grounded_cutouts.py (3 hunks)
Files skipped from review due to trivial changes (1)
- Dockerfile
Additional comments: 2
app/grounded_cutouts.py (2)
219-226: The new root endpoint
/
is correctly implemented and follows FastAPI conventions. It's a simple endpoint that returns a "Hello world!" message, which can be useful for health checks or verifying that the service is up and running.325-329: The
create_all_cutouts
function has been updated to useSAM_CHECKPOINT_PATH_LOW
instead ofSAM_CHECKPOINT_PATH
. This change should be verified to ensure that it aligns with the intended use case, as it may affect the performance and accuracy of the model being used.
@CodiumAI-Agent /review |
PR Analysis
PR Feedback
How to useInstructions
|
@CodiumAI-Agent /add docs |
How to use PR-Agent
|
@CodiumAI-Agent /improve |
PR Code Suggestions💡 Suggestion: The decorator functions in the Stub class are identical. Consider refactoring them into a single function. File: app/dummy_modal.py (2-19) Example code:Existing code: class Stub:
def __init__(self, *args, **kwargs):
pass
def cls(self, *args, **kwargs):
def decorator(cls):
return cls
return decorator
def local_entrypoint(self, *args, **kwargs):
def decorator(func):
return func
return decorator
def function(self, *args, **kwargs):
def decorator(func):
return func
return decorator Improved code: class Stub:
def __init__(self, *args, **kwargs):
pass
def decorator(self, *args, **kwargs):
def decorator(func):
return func
return decorator
cls = decorator
local_entrypoint = decorator
function = decorator 💡 Suggestion: Consider using multi-stage builds to reduce the size of the final Docker image. File: Dockerfile (1-26) Example code:Existing code: # Use an official NVIDIA PyTorch runtime as a parent image
FROM nvcr.io/nvidia/pytorch:22.12-py3
# Add the current directory contents into the container
ADD /app .
# Install any needed packages
RUN apt-get update && \
apt-get install -y git wget libgl1-mesa-glx libglib2.0-0 && \
echo $CUDA_HOME && \
git clone https://github.com/IDEA-Research/GroundingDINO.git && \
pip install -q -e GroundingDINO/ && \
pip install uvicorn && \
mkdir -p app/weights && \
mkdir -p app/data && \
pip uninstall -y supervision && \
pip uninstall -y opencv-python && \
pip install opencv-python==4.8.0.74 && \
pip install -q supervision==0.6.0 && \
wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth -P app/weights/ && \
wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg -P app/images/ Improved code: # Use an official NVIDIA PyTorch runtime as a parent image
FROM nvcr.io/nvidia/pytorch:22.12-py3 as builder
# Add the current directory contents into the container
ADD /app .
# Install any needed packages
RUN apt-get update && \
apt-get install -y git wget libgl1-mesa-glx libglib2.0-0 && \
echo $CUDA_HOME && \
git clone https://github.com/IDEA-Research/GroundingDINO.git && \
pip install -q -e GroundingDINO/ && \
pip install uvicorn && \
mkdir -p app/weights && \
mkdir -p app/data && \
pip uninstall -y supervision && \
pip uninstall -y opencv-python && \
pip install opencv-python==4.8.0.74 && \
pip install -q supervision==0.6.0 && \
wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth -P app/weights/ && \
wget -q https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth -P app/weights/ && \
wget -q https://media.roboflow.com/notebooks/examples/dog.jpeg -P app/images/
FROM nvcr.io/nvidia/pytorch:22.12-py3
COPY --from=builder /app /app 💡 Suggestion: Consider using COPY instead of ADD for better transparency and to avoid unexpected behavior. File: Dockerfile (7-8) Example code:Existing code: # Add the current directory contents into the container
ADD /app . Improved code: # Copy the current directory contents into the container
COPY ./app /app 💡 Suggestion: Consider using environment variables for sensitive data instead of hardcoding them in the docker-compose file. File: docker-compose.yml (12-16) Example code:Existing code: environment:
- AWS_ACCESS_KEY_ID=your_access_key
- AWS_SECRET_ACCESS_KEY=your_secret_key
- AWS_REGION=your_region
- CUTOUT_BUCKET=your_bucket Improved code: environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION}
- CUTOUT_BUCKET=${CUTOUT_BUCKET} |
@CodiumAI-Agent /add_docs |
@@ -0,0 +1,50 @@ | |||
# dummy_modal.py | |||
class Stub: |
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.
Suggestion: Proposed documentation
class Stub: | |
class Stub: | |
""" | |
This is a stub class that provides dummy implementations for various methods. | |
""" |
return func | ||
return decorator | ||
|
||
class Secret: |
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.
Suggestion: Proposed documentation
class Secret: | |
class Secret: | |
""" | |
This is a Secret class that provides a static method 'from_name'. | |
""" |
def from_name(*args, **kwargs): | ||
pass | ||
|
||
class Mount: |
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.
Suggestion: Proposed documentation
class Mount: | |
class Mount: | |
""" | |
This is a Mount class that provides a static method 'from_local_python_packages'. | |
""" |
def from_local_python_packages(*args, **kwargs): | ||
pass | ||
|
||
class Image: |
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.
Suggestion: Proposed documentation
class Image: | |
class Image: | |
""" | |
This is an Image class that provides static and instance methods for handling images. | |
""" |
def run_commands(self, *args, **kwargs): | ||
return self | ||
|
||
def asgi_app(*args, **kwargs): |
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.
Suggestion: Proposed documentation
def asgi_app(*args, **kwargs): | |
def asgi_app(*args, **kwargs): | |
""" | |
This is a decorator function 'asgi_app' that returns the function it decorates. | |
""" |
return func | ||
return decorator | ||
|
||
def method(*args, **kwargs): |
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.
Suggestion: Proposed documentation
def method(*args, **kwargs): | |
def method(*args, **kwargs): | |
""" | |
This is a decorator function 'method' that returns the function it decorates. | |
""" |
@CodiumAI-Agent /describe |
@CodiumAI-Agent /update_changelog |
@CodiumAI-Agent /generate_labels |
Dockerizing the app to be able to run on a local system instead of just on modal
Summary by CodeRabbit
New Features
dummy_modal.py
module to handle various application functionalities./
that returns a greeting message.Bug Fixes
sam_checkpoint_path
parameter to use the correct path increate_all_cutouts
function.Documentation
dummy_modal.py
module for clarity.Refactor