3030 validate_params_with_context ,
3131)
3232from flow360 .component .resource_base import Flow360Resource
33+ from flow360 .component .simulation .folder import Folder
3334from flow360 .component .simulation .simulation_params import SimulationParams
3435from flow360 .component .simulation .unit_system import LengthType
3536from flow360 .component .simulation .web .asset_base import AssetBase
@@ -635,6 +636,7 @@ def _create_project_from_files(
635636 length_unit : LengthUnitType = "m" ,
636637 tags : List [str ] = None ,
637638 run_async : bool = False ,
639+ folder : Optional [Folder ] = None ,
638640 ):
639641 """
640642 Initializes a project from a file.
@@ -653,6 +655,8 @@ def _create_project_from_files(
653655 Tags to assign to the project (default is None).
654656 run_async : bool, optional
655657 Whether to create the project asynchronously (default is False).
658+ folder : Optional[Folder], optional
659+ Parent folder for the project. If None, creates in root.
656660
657661 Returns
658662 -------
@@ -670,14 +674,16 @@ def _create_project_from_files(
670674 files ._check_files_existence ()
671675
672676 if isinstance (files , GeometryFiles ):
673- draft = Geometry .from_file (files .file_names , name , solver_version , length_unit , tags )
677+ draft = Geometry .from_file (
678+ files .file_names , name , solver_version , length_unit , tags , folder = folder
679+ )
674680 elif isinstance (files , SurfaceMeshFile ):
675681 draft = SurfaceMeshV2 .from_file (
676- files .file_names , name , solver_version , length_unit , tags
682+ files .file_names , name , solver_version , length_unit , tags , folder = folder
677683 )
678684 elif isinstance (files , VolumeMeshFile ):
679685 draft = VolumeMeshV2 .from_file (
680- files .file_names , name , solver_version , length_unit , tags
686+ files .file_names , name , solver_version , length_unit , tags , folder = folder
681687 )
682688 else :
683689 raise Flow360FileError (
@@ -718,7 +724,11 @@ def _create_project_from_files(
718724 return project
719725
720726 @classmethod
721- @pd .validate_call
727+ @pd .validate_call (
728+ config = {
729+ "arbitrary_types_allowed" : True
730+ } # Folder (v2: component/simulation/folder.py) does not have validate() defined
731+ )
722732 def from_geometry (
723733 cls ,
724734 files : Union [str , list [str ]],
@@ -728,6 +738,7 @@ def from_geometry(
728738 length_unit : LengthUnitType = "m" ,
729739 tags : List [str ] = None ,
730740 run_async : bool = False ,
741+ folder : Optional [Folder ] = None ,
731742 ):
732743 """
733744 Initializes a project from local geometry files.
@@ -746,6 +757,8 @@ def from_geometry(
746757 Tags to assign to the project (default is None).
747758 run_async : bool, optional
748759 Whether to create project asynchronously (default is False).
760+ folder : Optional[Folder], optional
761+ Parent folder for the project. If None, creates in root.
749762
750763 Returns
751764 -------
@@ -781,10 +794,11 @@ def from_geometry(
781794 length_unit = length_unit ,
782795 tags = tags ,
783796 run_async = run_async ,
797+ folder = folder ,
784798 )
785799
786800 @classmethod
787- @pd .validate_call
801+ @pd .validate_call ( config = { "arbitrary_types_allowed" : True })
788802 def from_surface_mesh (
789803 cls ,
790804 file : str ,
@@ -794,6 +808,7 @@ def from_surface_mesh(
794808 length_unit : LengthUnitType = "m" ,
795809 tags : List [str ] = None ,
796810 run_async : bool = False ,
811+ folder : Optional [Folder ] = None ,
797812 ):
798813 """
799814 Initializes a project from a local surface mesh file.
@@ -813,6 +828,8 @@ def from_surface_mesh(
813828 Tags to assign to the project (default is None).
814829 run_async : bool, optional
815830 Whether to create project asynchronously (default is False).
831+ folder : Optional[Folder], optional
832+ Parent folder for the project. If None, creates in root.
816833
817834 Returns
818835 -------
@@ -849,10 +866,11 @@ def from_surface_mesh(
849866 length_unit = length_unit ,
850867 tags = tags ,
851868 run_async = run_async ,
869+ folder = folder ,
852870 )
853871
854872 @classmethod
855- @pd .validate_call
873+ @pd .validate_call ( config = { "arbitrary_types_allowed" : True })
856874 def from_volume_mesh (
857875 cls ,
858876 file : str ,
@@ -862,6 +880,7 @@ def from_volume_mesh(
862880 length_unit : LengthUnitType = "m" ,
863881 tags : List [str ] = None ,
864882 run_async : bool = False ,
883+ folder : Optional [Folder ] = None ,
865884 ):
866885 """
867886 Initializes a project from a local volume mesh file.
@@ -881,6 +900,8 @@ def from_volume_mesh(
881900 Tags to assign to the project (default is None).
882901 run_async : bool, optional
883902 Whether to create project asynchronously (default is False).
903+ folder : Optional[Folder], optional
904+ Parent folder for the project. If None, creates in root.
884905
885906 Returns
886907 -------
@@ -917,6 +938,7 @@ def from_volume_mesh(
917938 length_unit = length_unit ,
918939 tags = tags ,
919940 run_async = run_async ,
941+ folder = folder ,
920942 )
921943
922944 @classmethod
0 commit comments