Skip to content

Commit

Permalink
Remove docker and stringcase from core dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Oct 30, 2024
1 parent a78fc60 commit dec6cbc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Renamed `Chat.input_fn` to `Chat.handle_input`.
- Renamed `Chat.output_fn` to `Chat.handle_output`.
- Renamed `EventListener.handler` to `EventListener.on_event`.
- **BREAKING**: Removed `stringcase` and `docker` from core dependencies. `ComputerTool` will now install this on the fly.
- Updated `EventListener.handler` return type to `Optional[BaseEvent | dict]`.
- `BaseTask.parent_outputs` type has changed from `dict[str, str | None]` to `dict[str, BaseArtifact]`.
- `Workflow.context["parent_outputs"]` type has changed from `dict[str, str | None]` to `dict[str, BaseArtifact]`.
Expand Down
2 changes: 2 additions & 0 deletions griptape/tools/computer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker
stringcase
12 changes: 9 additions & 3 deletions griptape/tools/computer/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from typing import TYPE_CHECKING, Optional

import docker
import stringcase
from attrs import Attribute, Factory, define, field
from docker.errors import NotFound
from docker.models.containers import Container
from schema import Literal, Schema

from griptape.artifacts import BaseArtifact, ErrorArtifact, TextArtifact
Expand Down Expand Up @@ -97,6 +94,8 @@ def execute_command(self, params: dict) -> BaseArtifact:
return self.execute_command_in_container(command)

def execute_command_in_container(self, command: str) -> BaseArtifact:
from docker.models.containers import Container

try:
binds = {self.local_workdir: {"bind": self.container_workdir, "mode": "rw"}} if self.local_workdir else None

Expand Down Expand Up @@ -160,12 +159,19 @@ def default_docker_client(self) -> Optional[DockerClient]:
return None

def image_name(self, tool: BaseTool) -> str:
import stringcase # pyright: ignore[reportMissingImports]

return f"{stringcase.snakecase(tool.name)}_image"

def container_name(self, tool: BaseTool) -> str:
import stringcase # pyright: ignore[reportMissingImports]

return f"{stringcase.snakecase(tool.name)}_container"

def remove_existing_container(self, name: str) -> None:
from docker.errors import NotFound
from docker.models.containers import Container

try:
existing_container = self.docker_client.containers.get(name)
if isinstance(existing_container, Container):
Expand Down
12 changes: 1 addition & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ schema = "^0.7.7"
pyyaml = "^6.0.1"
tenacity = "^8.5.0"
numpy = "^1.26.4"
stringcase = "^1.2.0"
docker = "^7.1.0"
requests = "^2.32.0"
filetype = "^1.2"

Expand Down

0 comments on commit dec6cbc

Please sign in to comment.