Skip to content

Commit 6867ba9

Browse files
committed
Add sandbox plugin
* Add missing tmux plugin docstring
1 parent af2215b commit 6867ba9

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

cli/polyaxon/_flow/plugins/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class V1Plugins(BaseSchemaModel):
2121
docker: bool, optional, default: False
2222
shm: bool, optional, default: True
2323
tmux: bool, optional, default: False
24+
sandbox: bool, optional, default: False
2425
mount_artifacts_store: bool, optional, default: True
2526
collect_artifacts: bool, optional, default: True
2627
collect_logs: bool, optional, default: True
@@ -39,6 +40,7 @@ class V1Plugins(BaseSchemaModel):
3940
>>> docker:
4041
>>> shm:
4142
>>> tmux:
43+
>>> sandbox:
4244
>>> mountArtifactsStore:
4345
>>> collectArtifacts:
4446
>>> collectLogs:
@@ -59,6 +61,7 @@ class V1Plugins(BaseSchemaModel):
5961
>>> docker=True,
6062
>>> shm=True,
6163
>>> tmux=True,
64+
>>> sandbox=True,
6265
>>> mount_artifacts_store=True,
6366
>>> collect_artifacts=False,
6467
>>> collect_logs=False,
@@ -133,6 +136,36 @@ class V1Plugins(BaseSchemaModel):
133136
>>> shm: false
134137
```
135138
139+
### tmux
140+
141+
<blockquote class="light">This plugin is disabled by default.</blockquote>
142+
143+
This plugin ships a statically-linked `tmux` into the user container so
144+
that the in-cluster shell session opened by `polyaxon ops shell` can attach
145+
to a persistent terminal. Without it, `shell` falls back to `/bin/bash` and
146+
the session ends as soon as the websocket disconnects.
147+
148+
To enable this plugin:
149+
150+
```yaml
151+
>>> plugins:
152+
>>> tmux: true
153+
```
154+
155+
### sandbox
156+
157+
<blockquote class="light">This plugin is disabled by default.</blockquote>
158+
159+
This plugin enables the sandbox daemon for programmatic exec, filesystem,
160+
and PTY access from SDKs, agents, and UIs.
161+
162+
To enable this plugin:
163+
164+
```yaml
165+
>>> plugins:
166+
>>> sandbox: true
167+
```
168+
136169
### mountArtifactsStore
137170
138171
<blockquote class="light">This plugin is disabled by default.</blockquote>
@@ -270,6 +303,7 @@ class V1Plugins(BaseSchemaModel):
270303
docker: Optional[BoolOrRef] = None
271304
shm: Optional[BoolOrRef] = None
272305
tmux: Optional[BoolOrRef] = None
306+
sandbox: Optional[BoolOrRef] = None
273307
mount_artifacts_store: Optional[BoolOrRef] = Field(
274308
alias="mountArtifactsStore", default=None
275309
)
@@ -306,6 +340,7 @@ def get_or_create(
306340
config.set_auto_resume()
307341
config.set_external_host()
308342
config.set_tmux()
343+
config.set_sandbox()
309344
return config
310345

311346
@staticmethod
@@ -375,3 +410,7 @@ def set_external_host(self, default: bool = False):
375410
def set_tmux(self, default: bool = False):
376411
if self.tmux is None:
377412
self.tmux = default
413+
414+
def set_sandbox(self, default: bool = False):
415+
if self.sandbox is None:
416+
self.sandbox = default

cli/tests/test_polyflow/test_plugins/test_plugins.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from clipped.utils.assertions import assert_equal_dict
44

5-
from polyaxon._flow import V1CompiledOperation, V1Plugins, V1RunKind
5+
from polyaxon.schemas import V1CompiledOperation, V1Plugins, V1RunKind
66
from polyaxon._polyaxonfile.specs import kinds
77
from polyaxon._utils.test_utils import BaseTestCase
88

@@ -46,6 +46,11 @@ def test_plugins_config(self):
4646
config = V1Plugins.from_dict(config_dict)
4747
assert_equal_dict(config_dict, config.to_dict())
4848

49+
# Add sandbox bool
50+
config_dict["sandbox"] = True
51+
config = V1Plugins.from_dict(config_dict)
52+
assert_equal_dict(config_dict, config.to_dict())
53+
4954
# Add notifications
5055
config_dict["notifications"] = [
5156
{"connections": ["test1"], "trigger": "succeeded"},
@@ -66,6 +71,17 @@ def test_plugins_tmux_config(self):
6671
assert_equal_dict(config_dict, config.to_dict())
6772
assert config.tmux is False
6873

74+
def test_plugins_sandbox_config(self):
75+
config_dict = {"sandbox": True}
76+
config = V1Plugins.from_dict(config_dict)
77+
assert_equal_dict(config_dict, config.to_dict())
78+
assert config.sandbox is True
79+
80+
config_dict = {"sandbox": False}
81+
config = V1Plugins.from_dict(config_dict)
82+
assert_equal_dict(config_dict, config.to_dict())
83+
assert config.sandbox is False
84+
6985
def test_get_from_spec(self):
7086
compiled_operation = V1CompiledOperation.read(
7187
{
@@ -79,6 +95,7 @@ def test_get_from_spec(self):
7995
"collectArtifacts": False,
8096
"syncStatuses": False,
8197
"externalHost": True,
98+
"sandbox": True,
8299
},
83100
"run": {"kind": V1RunKind.JOB, "container": {"image": "test"}},
84101
}
@@ -94,6 +111,7 @@ def test_get_from_spec(self):
94111
assert plugins.sync_statuses is False
95112
assert plugins.external_host is True
96113
assert plugins.tmux is False
114+
assert plugins.sandbox is True
97115

98116
def test_read_keys_from_env(self):
99117
spec = V1Plugins(
@@ -106,6 +124,7 @@ def test_read_keys_from_env(self):
106124
sync_statuses=True,
107125
external_host=True,
108126
tmux=True,
127+
sandbox=True,
109128
)
110129
spec = V1Plugins.get_or_create(spec)
111130
assert spec.auth is True
@@ -117,6 +136,7 @@ def test_read_keys_from_env(self):
117136
assert spec.sync_statuses is True
118137
assert spec.external_host is True
119138
assert spec.tmux is True
139+
assert spec.sandbox is True
120140

121141
def test_get_from_empty_env(self):
122142
spec = V1Plugins()
@@ -130,6 +150,7 @@ def test_get_from_empty_env(self):
130150
assert spec.sync_statuses is True
131151
assert spec.external_host is False
132152
assert spec.tmux is False
153+
assert spec.sandbox is False
133154

134155
spec = V1Plugins()
135156
spec = V1Plugins.get_or_create(spec)
@@ -142,3 +163,4 @@ def test_get_from_empty_env(self):
142163
assert spec.sync_statuses is True
143164
assert spec.external_host is False
144165
assert spec.tmux is False
166+
assert spec.sandbox is False

0 commit comments

Comments
 (0)