11from typing import Dict , List , Optional
22from typing_extensions import Literal
33
4+ from clipped .compact .pydantic import model_validator , validation_after
5+ from clipped .config .schema import skip_partial
6+
47from polyaxon ._flow .io import V1IO
58from polyaxon ._flow .operations .base import BaseOp
69from polyaxon ._flow .params import ParamSpec , ops_params
7- from polyaxon ._flow .run import RunMixin , V1Runtime
10+ from polyaxon ._flow .run import RunMixin , V1RunKind , V1Runtime
811from polyaxon .exceptions import PolyaxonSchemaError
912
1013
@@ -21,6 +24,23 @@ class V1CompiledOperation(BaseOp, RunMixin):
2124 def get_run_kind (self ):
2225 return self .run .kind if self .run else None
2326
27+ @model_validator (** validation_after )
28+ @skip_partial
29+ def validate_sandbox_kind (cls , values ):
30+ plugins = cls .get_value_for_key ("plugins" , values )
31+ sandbox = cls .get_value_for_key ("sandbox" , plugins ) if plugins else None
32+ if sandbox is None or sandbox is False :
33+ return values
34+
35+ run = cls .get_value_for_key ("run" , values )
36+ if not run or run .kind != V1RunKind .SERVICE :
37+ got = run .kind if run else "unset"
38+ raise ValueError (
39+ "plugins.sandbox is only supported on kind: service in this version. "
40+ f"Got kind: { got } ."
41+ )
42+ return values
43+
2444 def validate_params (
2545 self ,
2646 params : Optional [Dict ] = None ,
0 commit comments