@@ -339,7 +339,6 @@ class SnapshotInfoMixin(ModelKindMixin):
339339 dev_table_suffix : str
340340 table_naming_convention : TableNamingConvention = Field (default = TableNamingConvention .default )
341341 forward_only : bool
342- virtual_environment_mode : VirtualEnvironmentMode
343342
344343 @cached_property
345344 def identifier (self ) -> str :
@@ -385,6 +384,10 @@ def is_new_version(self) -> bool:
385384 def fully_qualified_table (self ) -> t .Optional [exp .Table ]:
386385 raise NotImplementedError
387386
387+ @property
388+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
389+ raise NotImplementedError
390+
388391 @property
389392 def is_forward_only (self ) -> bool :
390393 return self .forward_only or self .change_category == SnapshotChangeCategory .FORWARD_ONLY
@@ -506,8 +509,10 @@ class SnapshotTableInfo(PydanticModel, SnapshotInfoMixin, frozen=True):
506509 dev_table_suffix : str
507510 model_gateway : t .Optional [str ] = None
508511 forward_only : bool = False
509- table_naming_convention : TableNamingConvention = Field (default = TableNamingConvention .default )
510- virtual_environment_mode : VirtualEnvironmentMode = Field (default = VirtualEnvironmentMode .default )
512+ table_naming_convention : TableNamingConvention = TableNamingConvention .default
513+ virtual_environment_mode_ : VirtualEnvironmentMode = Field (
514+ default = VirtualEnvironmentMode .default , alias = "virtual_environment_mode"
515+ )
511516
512517 def __lt__ (self , other : SnapshotTableInfo ) -> bool :
513518 return self .name < other .name
@@ -539,6 +544,10 @@ def table_info(self) -> SnapshotTableInfo:
539544 """Helper method to return self."""
540545 return self
541546
547+ @property
548+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
549+ return self .virtual_environment_mode_
550+
542551 @property
543552 def data_version (self ) -> SnapshotDataVersion :
544553 return SnapshotDataVersion (
@@ -637,7 +646,6 @@ class Snapshot(PydanticModel, SnapshotInfoMixin):
637646 default = TableNamingConvention .default , alias = "table_naming_convention"
638647 )
639648 forward_only : bool = False
640- virtual_environment_mode : VirtualEnvironmentMode = Field (default = VirtualEnvironmentMode .default )
641649
642650 @field_validator ("ttl" )
643651 @classmethod
@@ -690,7 +698,6 @@ def from_node(
690698 version : t .Optional [str ] = None ,
691699 cache : t .Optional [t .Dict [str , SnapshotFingerprint ]] = None ,
692700 table_naming_convention : TableNamingConvention = TableNamingConvention .default ,
693- virtual_environment_mode : VirtualEnvironmentMode = VirtualEnvironmentMode .default ,
694701 ) -> Snapshot :
695702 """Creates a new snapshot for a node.
696703
@@ -702,7 +709,6 @@ def from_node(
702709 version: The version that a snapshot is associated with. Usually set during the planning phase.
703710 cache: Cache of node name to fingerprints.
704711 table_naming_convention: Convention to follow when generating the physical table name
705- virtual_environment_mode: Mode for handling virtual environments
706712
707713 Returns:
708714 The newly created snapshot.
@@ -735,7 +741,6 @@ def from_node(
735741 ttl = ttl ,
736742 version = version ,
737743 table_naming_convention = table_naming_convention ,
738- virtual_environment_mode = virtual_environment_mode ,
739744 )
740745
741746 def __eq__ (self , other : t .Any ) -> bool :
@@ -1418,6 +1423,12 @@ def custom_materialization(self) -> t.Optional[str]:
14181423 return t .cast (CustomKind , self .model .kind ).materialization
14191424 return None
14201425
1426+ @property
1427+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
1428+ return (
1429+ self .model .virtual_environment_mode if self .is_model else VirtualEnvironmentMode .default
1430+ )
1431+
14211432 def _ensure_categorized (self ) -> None :
14221433 if not self .change_category :
14231434 raise SQLMeshError (f"Snapshot { self .snapshot_id } has not been categorized yet." )
0 commit comments