Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
429 changes: 429 additions & 0 deletions examples/workflow_management/folder/examples.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions flow360/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from flow360.component.project import Project
from flow360.component.simulation import migration, services
from flow360.component.simulation import units as u
from flow360.component.simulation.folder import Folder
from flow360.component.simulation.meshing_param.edge_params import (
AngleBasedRefinement,
AspectRatioBasedRefinement,
Expand Down Expand Up @@ -238,6 +239,7 @@
"DetachedEddySimulation",
"KOmegaSSTModelConstants",
"LinearSolver",
"Folder",
"ForcePerArea",
"Air",
"Sutherland",
Expand Down
17 changes: 17 additions & 0 deletions flow360/cloud/flow360_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,20 @@ def _validate_force_creation_config(self):
f"cannot be later than 'up_to' ({self.up_to})."
)
return self


class MoveToFolderRequestV2(Flow360RequestsV2):
"""Data model for moving folder using v2 endpoint"""

name: Optional[str] = pd_v2.Field(default=None, description="folder to move name")
tags: List[str] = pd_v2.Field(default=[], description="folder tags")
parent_folder_id: str = pd_v2.Field(alias="parentFolderId", default="ROOT.FLOW360")


class RenameAssetRequestV2(Flow360RequestsV2):
"""
Data model for renaming an asset (folder, project, surface mesh, volume mesh,
or case (other request fields, like folder to move to, already have implementations)
"""

name: str = pd_v2.Field(description="case to rename")
34 changes: 32 additions & 2 deletions flow360/component/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
import pydantic.v1 as pd_v1

from .. import error_messages
from ..cloud.flow360_requests import MoveCaseItem, MoveToFolderRequest
from ..cloud.flow360_requests import (
MoveCaseItem,
MoveToFolderRequest,
RenameAssetRequestV2,
)
from ..cloud.rest_api import RestApi
from ..cloud.s3_utils import CloudFileNotFoundError
from ..exceptions import Flow360RuntimeError, Flow360ValidationError, Flow360ValueError
Expand Down Expand Up @@ -178,7 +182,6 @@ class CaseMetaV2(AssetMetaBaseModelV2):
"""

id: str = pd.Field(alias="caseId")
case_mesh_id: str = pd.Field(alias="caseMeshId")
status: Flow360Status = pd.Field()

def to_case(self) -> Case:
Expand Down Expand Up @@ -542,6 +545,13 @@ def info(self) -> CaseMetaV2:
"""
return super().info

@property
def info_v2(self) -> CaseMetaV2:
"""
returns metadata v2 info for case
"""
return self._web_api_v2.info

@property
def project_id(self) -> Optional[str]:
"""Returns the project id of the case if case was run with V2 interface."""
Expand All @@ -551,6 +561,13 @@ def project_id(self) -> Optional[str]:
return self.info.project_id
raise ValueError("Case info is not of type CaseMeta or CaseMetaV2")

@property
def tags(self) -> List[str]:
"""
get case tags
"""
return self._web_api_v2.info.tags

@property
def volume_mesh(self) -> "VolumeMeshV2":
"""
Expand Down Expand Up @@ -668,6 +685,19 @@ def move_to_folder(self, folder: Folder):
)
return self

def rename(self, new_name: str):
"""
Rename the current case.

Parameters
----------
new_name : str
The new name for the case.
"""
RestApi(CaseInterfaceV2.endpoint).patch(
RenameAssetRequestV2(name=new_name).dict(), method=self.id
)

@classmethod
def _interface(cls):
return CaseInterface
Expand Down
14 changes: 9 additions & 5 deletions flow360/component/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import threading
from enum import Enum
from typing import Any, List, Literal, Union
from typing import Any, List, Literal, Optional, Union

import pydantic as pd

Expand All @@ -25,6 +25,7 @@
ResourceDraft,
)
from flow360.component.simulation.entity_info import GeometryEntityInfo
from flow360.component.simulation.folder import Folder
from flow360.component.simulation.primitives import Edge, GeometryBodyGroup, Surface
from flow360.component.simulation.unit_system import LengthType
from flow360.component.simulation.utils import model_attribute_unlock
Expand Down Expand Up @@ -91,12 +92,14 @@ def __init__(
solver_version: str = None,
length_unit: LengthUnitType = "m",
tags: List[str] = None,
folder: Optional[Folder] = None,
):
self._file_names = file_names
self.project_name = project_name
self.tags = tags if tags is not None else []
self.length_unit = length_unit
self.solver_version = solver_version
self.folder = folder
self._validate()
ResourceDraft.__init__(self)

Expand Down Expand Up @@ -186,9 +189,7 @@ def submit(self, description="", progress_callback=None, run_async=False) -> Geo
)
for file_path in self.file_names + mapbc_files
],
# pylint: disable=fixme
# TODO: remove hardcoding
parent_folder_id="ROOT.FLOW360",
parent_folder_id=self.folder.id if self.folder else "ROOT.FLOW360",
length_unit=self.length_unit,
description=description,
)
Expand Down Expand Up @@ -296,9 +297,12 @@ def from_file(
solver_version: str = None,
length_unit: LengthUnitType = "m",
tags: List[str] = None,
folder: Optional[Folder] = None,
) -> GeometryDraft:
# For type hint only but proper fix is to fully abstract the Draft class too.
return super().from_file(file_names, project_name, solver_version, length_unit, tags)
return super().from_file(
file_names, project_name, solver_version, length_unit, tags, folder=folder
)

def show_available_groupings(self, verbose_mode: bool = False):
"""Display all the possible groupings for faces and edges"""
Expand Down
4 changes: 4 additions & 0 deletions flow360/component/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class BaseInterface(BaseModel):

FolderInterface = BaseInterface(resource_type="Folder", s3_transfer_method=None, endpoint="folders")

FolderInterfaceV2 = BaseInterface(
resource_type="Folder", s3_transfer_method=None, endpoint="v2/folders"
)

ReportInterface = BaseInterface(
resource_type="Report",
s3_transfer_method=S3TransferType.REPORT,
Expand Down
Loading
Loading