Skip to content

Commit

Permalink
V1.0 released
Browse files Browse the repository at this point in the history
  • Loading branch information
YuXHe15 committed Aug 7, 2023
1 parent 3e1ce23 commit 45327ab
Show file tree
Hide file tree
Showing 47 changed files with 422 additions and 7,289 deletions.
370 changes: 0 additions & 370 deletions amworkflow/src/core/_workflow.py

This file was deleted.

695 changes: 367 additions & 328 deletions amworkflow/src/core/workflow.py

Large diffs are not rendered by default.

37 changes: 36 additions & 1 deletion amworkflow/src/infrastructure/database/cruds/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sqlalchemy import insert
from sqlalchemy.sql.expression import select
import pandas as pd
from amworkflow.src.utils.visualizer import color_background

def insert_data(table: str,
data: dict,
Expand Down Expand Up @@ -65,6 +66,7 @@ def query_multi_data(table: str,
dd.pop("_sa_instance_state", None)
if target_column_name == None:
result = pd.DataFrame(result)
result.style.applymap(color_background)
# elif len(result) != 0:
# result = result[0]
return result
Expand Down Expand Up @@ -114,4 +116,37 @@ def delete_data(table: str,

def transcation_rollback():
from amworkflow.src.infrastructure.database.engine.engine import session
session.rollback()
session.rollback()

def query_join_tables(table: str, join_column: str, table1: str, join_column1:str, table2: str = None, join_column2:str = None, filter0: str = None, filter1: str = None, filter2: str = None, on_column_tb: str = None, on_column_tb1: str = None, on_column_tb2: str = None):
from amworkflow.src.infrastructure.database.engine.engine import session
table = db_list[table]
table1 = db_list[table1]
on_c0 = getattr(table, join_column)
on_c1 = getattr(table1, join_column1)
if on_column_tb is not None:
column0 = getattr(table, on_column_tb)
q = session.query(table).join(table1, on_c0 == on_c1)
c = []
if filter0 is not None:
c0 = filter0 == column0
c.append(c0)
if filter1 is not None:
column1 = getattr(table, on_column_tb1)
c1 = filter1 == column1
c.append(c1)
if table2 is not None:
table2= db_list[table2]
column2 = getattr(table, on_column_tb2)
q = q.join(table2)
if filter2 is not None:
c2 = filter2 == column2
c.append(c2)
if len(c) != 0:
q.filter(*c)
result = [i.__dict__ for i in q.all()]
for dd in result:
dd.pop("_sa_instance_state", None)

return pd.DataFrame(result)

10 changes: 5 additions & 5 deletions amworkflow/src/infrastructure/database/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GeometryFile(Base):
model_name: Mapped[str] = mapped_column(ForeignKey('ModelProfile.model_name', ondelete="CASCADE"))
linear_deflection: Mapped[float] = mapped_column(nullable=True)
angular_deflection: Mapped[float] = mapped_column(nullable=True)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now().replace(microsecond=0))
is_imported: Mapped[bool] = mapped_column(default=False)
task_id: Mapped[str] = mapped_column(ForeignKey("Task.task_id", ondelete="CASCADE"))
SliceFile = relationship("SliceFile", cascade="all, delete", back_populates="GeometryFile")
Expand Down Expand Up @@ -53,7 +53,7 @@ class MeshFile(Base):
mesh_size_factor: Mapped[float] = mapped_column(nullable=False)
layer_thickness: Mapped[float] = mapped_column(nullable=True)
layer_num: Mapped[int] = mapped_column(nullable=True)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now().replace(microsecond=0))
task_id: Mapped[str] = mapped_column(ForeignKey("Task.task_id", ondelete="CASCADE"))
geom_hashname = mapped_column(ForeignKey('GeometryFile.geom_hashname', ondelete="CASCADE"))
GeometryFile = relationship("GeometryFile", back_populates="MeshFile")
Expand Down Expand Up @@ -82,7 +82,7 @@ class FEResult(Base):
class ModelProfile(Base):
__tablename__ = "ModelProfile"
model_name: Mapped[str] = mapped_column(nullable=False, primary_key=True)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now().replace(microsecond=0))
GeometryFile = relationship("GeometryFile", cascade="all, delete", back_populates="ModelProfile")
imported_file_id: Mapped[str] = mapped_column(ForeignKey('ImportedFile.md5_id', ondelete="CASCADE"), nullable=True)
ImportedFile = relationship("ImportedFile", back_populates="ModelProfile")
Expand All @@ -92,7 +92,7 @@ class ModelProfile(Base):
class ModelParameter(Base):
__tablename__ = "ModelParameter"
param_name: Mapped[str] = mapped_column(nullable=False, primary_key=True)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now().replace(microsecond=0))
ParameterToProfile = relationship("ParameterToProfile", cascade="all, delete", back_populates="ModelParameter")

class ParameterToProfile(Base):
Expand All @@ -101,7 +101,7 @@ class ParameterToProfile(Base):
param_name: Mapped[str] = mapped_column(ForeignKey('ModelParameter.param_name', ondelete="CASCADE"),nullable=False,primary_key=True)
model_name: Mapped[str] = mapped_column(ForeignKey('ModelProfile.model_name', ondelete="CASCADE"), primary_key=True)
param_status: Mapped[bool] = mapped_column(nullable=False, default=True)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now)
created_date: Mapped[datetime] = mapped_column(nullable=False, default=datetime.now().replace(microsecond=0))
# model_parameter = relationship("ModelParameter", foreign_keys=[param_name])
# profile_name = relationship("ModelProfile", foreign_keys=[model_name])
ModelParameter = relationship("ModelParameter", back_populates="ParameterToProfile")
Expand Down
6 changes: 5 additions & 1 deletion amworkflow/src/interface/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def amworkflow(mode: str = "production"):
args.db_opt_dir = utw.mk_dir(os.path.dirname(caller_fullpath), "output")
args.db_file_dir = utw.mk_dir(dbdir, "files")
cfg.DB_DIR = dbdir
from amworkflow.src.core._workflow import BaseWorkflow
from amworkflow.src.core.workflow import BaseWorkflow
flow = BaseWorkflow(args = args)
def inner_decorator(func):
def wrapped(*args, **kwargs):
Expand Down Expand Up @@ -73,6 +73,10 @@ def insert_data(table: str, data: dict, isbatch: bool = False) -> None:
def have_data_in_db(table: str, column_name, dataset: list, filter_by: str = None, search_column: str = None, filter_by2: str = None, search_column2: str = None) -> bool | list:
return utr.having_data(table=table, column_name=column_name,dataset=dataset, filter=filter_by, search_column=search_column, filter2=filter_by2, search_column2=search_column2)

@staticmethod
def query_join_data(table: str, join_column: str, table1: str, join_column1:str, table2: str = None, join_column2:str = None, filter0: str = None, filter1: str = None, filter2: str = None, on_column_tb: str = None, on_column_tb1: str = None, on_column_tb2: str = None):
return cr.query_join_tables(table=table, join_column=join_column, table1=table1, join_column1=join_column1, table2=table2, filter0=filter0, filter1=filter1, filter2=filter2, on_column_tb=on_column_tb, on_column_tb1=on_column_tb1, on_column_tb2=on_column_tb2)

class geom(object):
@staticmethod
def geometry_builder(*args) -> topods_Compound:
Expand Down
1 change: 0 additions & 1 deletion amworkflow/src/utils/sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def path_valid_check(path: str, format: list = None) -> bool:
if os.path.isdir(dir_path) == False:
raise AssertionError("wrong path provided")
if format != None:

fmt = filename.rsplit(".",1)[1]
# if dir_path is not a directory

Expand Down
8 changes: 7 additions & 1 deletion amworkflow/src/utils/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ def mesh_visualizer():
gmsh.is_initialized()
except:
raise GmshUseBeforeInitializedException()
gmsh.fltk.run()
gmsh.fltk.run()

def color_background(value):
if value:
return 'background-color: green'
# else:
# return 'background-color: blue'
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "amworkflow"
version = "0.4"
version = "1.0"
authors = [
{name = "Annika Robens-Radermacher", email = "[email protected]"},
{name = "Yuxiang He", email = "[email protected]"}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
path_to_am = os.getcwd()
setup(
name='amworkflow',
version='0.4',
version='1.0',
packages=['amworkflow.src', 'amworkflow.tests'],
install_requires=[f"OCCUtils-0.1.dev0 @ file://localhost/{path_to_am}/amworkflow/dependencies/OCCUtils-0.1.dev0-py3-none-any.whl"],
package_data={
Expand Down
Binary file removed usecases/param_prism/db/amworkflow.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed usecases/param_prism/db/imports/terrain.stl
Binary file not shown.
Binary file removed usecases/test_am4/db/amworkflow.db
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 45327ab

Please sign in to comment.