@@ -337,7 +337,6 @@ class SnapshotInfoMixin(ModelKindMixin):
337337 base_table_name_override : t .Optional [str ]
338338 dev_table_suffix : str
339339 table_naming_convention : TableNamingConvention
340- virtual_environment_mode : VirtualEnvironmentMode
341340
342341 @cached_property
343342 def identifier (self ) -> str :
@@ -383,6 +382,10 @@ def is_new_version(self) -> bool:
383382 def fully_qualified_table (self ) -> t .Optional [exp .Table ]:
384383 raise NotImplementedError
385384
385+ @property
386+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
387+ raise NotImplementedError
388+
386389 @property
387390 def is_forward_only (self ) -> bool :
388391 return self .change_category == SnapshotChangeCategory .FORWARD_ONLY
@@ -494,8 +497,10 @@ class SnapshotTableInfo(PydanticModel, SnapshotInfoMixin, frozen=True):
494497 custom_materialization : t .Optional [str ] = None
495498 dev_table_suffix : str
496499 model_gateway : t .Optional [str ] = None
497- table_naming_convention : TableNamingConvention = Field (default = TableNamingConvention .default )
498- virtual_environment_mode : VirtualEnvironmentMode = Field (default = VirtualEnvironmentMode .default )
500+ table_naming_convention : TableNamingConvention = TableNamingConvention .default
501+ virtual_environment_mode_ : VirtualEnvironmentMode = Field (
502+ default = VirtualEnvironmentMode .default , alias = "virtual_environment_mode"
503+ )
499504
500505 def __lt__ (self , other : SnapshotTableInfo ) -> bool :
501506 return self .name < other .name
@@ -527,6 +532,10 @@ def table_info(self) -> SnapshotTableInfo:
527532 """Helper method to return self."""
528533 return self
529534
535+ @property
536+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
537+ return self .virtual_environment_mode_
538+
530539 @property
531540 def data_version (self ) -> SnapshotDataVersion :
532541 return SnapshotDataVersion (
@@ -624,7 +633,6 @@ class Snapshot(PydanticModel, SnapshotInfoMixin):
624633 table_naming_convention_ : TableNamingConvention = Field (
625634 default = TableNamingConvention .default , alias = "table_naming_convention"
626635 )
627- virtual_environment_mode : VirtualEnvironmentMode = Field (default = VirtualEnvironmentMode .default )
628636
629637 @field_validator ("ttl" )
630638 @classmethod
@@ -677,7 +685,6 @@ def from_node(
677685 version : t .Optional [str ] = None ,
678686 cache : t .Optional [t .Dict [str , SnapshotFingerprint ]] = None ,
679687 table_naming_convention : TableNamingConvention = TableNamingConvention .default ,
680- virtual_environment_mode : VirtualEnvironmentMode = VirtualEnvironmentMode .default ,
681688 ) -> Snapshot :
682689 """Creates a new snapshot for a node.
683690
@@ -689,7 +696,6 @@ def from_node(
689696 version: The version that a snapshot is associated with. Usually set during the planning phase.
690697 cache: Cache of node name to fingerprints.
691698 table_naming_convention: Convention to follow when generating the physical table name
692- virtual_environment_mode: Mode for handling virtual environments
693699
694700 Returns:
695701 The newly created snapshot.
@@ -722,7 +728,6 @@ def from_node(
722728 ttl = ttl ,
723729 version = version ,
724730 table_naming_convention = table_naming_convention ,
725- virtual_environment_mode = virtual_environment_mode ,
726731 )
727732
728733 def __eq__ (self , other : t .Any ) -> bool :
@@ -1384,6 +1389,12 @@ def custom_materialization(self) -> t.Optional[str]:
13841389 return t .cast (CustomKind , self .model .kind ).materialization
13851390 return None
13861391
1392+ @property
1393+ def virtual_environment_mode (self ) -> VirtualEnvironmentMode :
1394+ return (
1395+ self .model .virtual_environment_mode if self .is_model else VirtualEnvironmentMode .default
1396+ )
1397+
13871398 def _ensure_categorized (self ) -> None :
13881399 if not self .change_category :
13891400 raise SQLMeshError (f"Snapshot { self .snapshot_id } has not been categorized yet." )
0 commit comments