swarmauri_tool_containernewsession 0.7.5.dev1__tar.gz → 0.9.0.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: swarmauri_tool_containernewsession
3
- Version: 0.7.5.dev1
3
+ Version: 0.9.0.dev2
4
4
  Summary: Create a new Docker or Kubernetes session.
5
5
  License: Apache-2.0
6
6
  Author: Jacob Stewart
@@ -47,7 +47,8 @@ pip install swarmauri_tool_containernewsession
47
47
  ```python
48
48
  from swarmauri_tool_containernewsession import ContainerNewSessionTool
49
49
 
50
- result = ContainerNewSessionTool()(container_name="my-container", image="ubuntu:latest")
50
+ tool = ContainerNewSessionTool(container_name="my-container", image="ubuntu:latest")
51
+ result = tool()
51
52
  print(result["stdout"])
52
53
  ```
53
54
 
@@ -30,6 +30,7 @@ pip install swarmauri_tool_containernewsession
30
30
  ```python
31
31
  from swarmauri_tool_containernewsession import ContainerNewSessionTool
32
32
 
33
- result = ContainerNewSessionTool()(container_name="my-container", image="ubuntu:latest")
33
+ tool = ContainerNewSessionTool(container_name="my-container", image="ubuntu:latest")
34
+ result = tool()
34
35
  print(result["stdout"])
35
36
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_tool_containernewsession"
3
- version = "0.7.5.dev1"
3
+ version = "0.9.0.dev2"
4
4
  description = "Create a new Docker or Kubernetes session."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -17,32 +17,43 @@ class ContainerNewSessionTool(ToolBase):
17
17
 
18
18
  driver: Literal["docker", "kubernetes"] = "docker"
19
19
 
20
+ container_name: str | None = Field(
21
+ default=None, description="Name for the container or pod"
22
+ )
23
+ image: str | None = Field(default=None, description="Container image to launch")
24
+
20
25
  parameters: List[Parameter] = Field(
21
26
  default_factory=lambda: [
22
27
  Parameter(
23
28
  name="container_name",
24
29
  input_type="string",
25
30
  description="Name for the container or pod",
26
- required=True,
31
+ required=False,
27
32
  ),
28
33
  Parameter(
29
34
  name="image",
30
35
  input_type="string",
31
36
  description="Container image to launch",
32
- required=True,
37
+ required=False,
33
38
  ),
34
39
  ]
35
40
  )
36
41
 
37
- def __call__(self, container_name: str, image: str) -> dict:
42
+ def __call__(
43
+ self, container_name: str | None = None, image: str | None = None
44
+ ) -> dict:
45
+ name = container_name or self.container_name
46
+ img = image or self.image
47
+ if name is None or img is None:
48
+ raise ValueError("container_name and image must be provided")
38
49
  if self.driver == "docker":
39
50
  cmd = [
40
51
  "docker",
41
52
  "run",
42
53
  "-d",
43
54
  "--name",
44
- container_name,
45
- image,
55
+ name,
56
+ img,
46
57
  "sleep",
47
58
  "infinity",
48
59
  ]
@@ -50,9 +61,9 @@ class ContainerNewSessionTool(ToolBase):
50
61
  cmd = [
51
62
  "kubectl",
52
63
  "run",
53
- container_name,
64
+ name,
54
65
  "--image",
55
- image,
66
+ img,
56
67
  "-i",
57
68
  "--restart=Never",
58
69
  "--command",
@@ -63,4 +74,4 @@ class ContainerNewSessionTool(ToolBase):
63
74
  result = subprocess.run(cmd, capture_output=True, text=True)
64
75
  if result.returncode != 0:
65
76
  raise RuntimeError(result.stderr.strip())
66
- return {"session_name": container_name, "stdout": result.stdout.strip()}
77
+ return {"session_name": name, "stdout": result.stdout.strip()}