Skip to content

Commit

Permalink
Merge pull request #2 from BAMresearch/v0.2_annika
Browse files Browse the repository at this point in the history
V0.2 annika
  • Loading branch information
YuXHe15 authored Jun 29, 2023
2 parents da67432 + e0b5fc7 commit 09da4f6
Show file tree
Hide file tree
Showing 23 changed files with 175 additions and 53 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/usecase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow will install the environment, run the usecase param_wall
name: tests

on:
push:
branches-ignore:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
CACHE_NUMBER: 1 # increase to reset cache manually

jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: checkout repo content
uses: actions/checkout@v2
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: amworkflow
use-mamba: true

- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- uses: actions/cache@v2
with:
path: "/usr/share/miniconda3/envs/amworkflow"
key: conda-${{ hashFiles('environment.yaml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache

- name: Update environment
run: mamba env update -n amworkflow -f environment.yaml
if: steps.cache.outputs.cache-hit != 'true'

- name: Install package
run: git clone https://github.com/tpaviot/pythonocc-utils.git && pip install ./pythonocc-utils

- name: Run param_wall
shell: bash -l {0} #new shell
run: |
python usecases/param_wall/param_wall.py
#name: Test
#
#on: [push]
#
#jobs:
# # Run tests
# test_model:
# name: Run tests
# runs-on: ${{ matrix.operating-system }}
# strategy:
# matrix:
# operating-system: [ubuntu-latest]
# steps:
# - uses: actions/checkout@v2
# - uses: conda-incubator/setup-miniconda@v2
# with:
# channels: conda-forge
# channel-priority: strict
# auto-update-conda: true
# environment-file: environment.yaml
#
# - name: Install package
# run: git clone https://github.com/tpaviot/pythonocc-utils.git && pip install ./pythonocc-utils
#
# - name: Run param_wall
# shell: bash -l {0} #new shell
# run: |
# python usecases/param_wall/param_wall.py
4 changes: 2 additions & 2 deletions amworkflow/src/constants/data_model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pydantic import BaseModel, ValidationError, NegativeInt, PositiveInt, conint, conlist, constr, PositiveFloat, validator
from typing import Optional
from polyfactory.factories.pydantic_factory import ModelFactory
from src.utils.parser import yaml_parser
from src.constants.enums import Directory as D
from amworkflow.src.utils.parser import yaml_parser
from amworkflow.src.constants.enums import Directory as D
class BatchParameter(BaseModel):
isbatch: bool

Expand Down
22 changes: 11 additions & 11 deletions amworkflow/src/core/workflow.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from OCC.Core.TopoDS import TopoDS_Shape
import yaml
from src.constants.enums import Directory as D
from src.constants.data_model import WallParam, DB_WallGeometryFile, DB_XdmfFile, DB_H5File
from src.utils.parser import yaml_parser
from amworkflow.src.constants.enums import Directory as D
from amworkflow.src.constants.data_model import WallParam, DB_WallGeometryFile, DB_XdmfFile, DB_H5File
from amworkflow.src.utils.parser import yaml_parser
import gmsh
from src.infrastructure.database.models.model import XdmfFile, H5File, FEResult, SliceFile, GCode
from src.infrastructure.database.cruds.crud import insert_data
from src.geometries.mesher import mesher, get_geom_pointer
from src.utils.writer import mesh_writer
from src.utils.permutator import simple_permutator
from src.utils.writer import namer, stl_writer, batch_num_creator
from tests.test import dimension_check
from amworkflow.src.infrastructure.database.models.model import XdmfFile, H5File, FEResult, SliceFile, GCode
from amworkflow.src.infrastructure.database.cruds.crud import insert_data
from amworkflow.src.geometries.mesher import mesher, get_geom_pointer
from amworkflow.src.utils.writer import mesh_writer
from amworkflow.src.utils.permutator import simple_permutator
from amworkflow.src.utils.writer import namer, stl_writer, batch_num_creator
from amworkflow.tests.test import dimension_check
import numpy as np
from src.utils.download import downloader
from amworkflow.src.utils.download import downloader
import copy

class BaseWorkflow(object):
Expand Down
4 changes: 2 additions & 2 deletions amworkflow/src/geometries/mesher.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import gmsh
import math as m
from OCC.Core.TopoDS import TopoDS_Shape
from src.geometries.operator import split
from src.geometries.operator import get_occ_bounding_box
from amworkflow.src.geometries.operator import split
from amworkflow.src.geometries.operator import get_occ_bounding_box
import logging

def get_geom_pointer(model: gmsh.model, shape: TopoDS_Shape) -> None:
Expand Down
2 changes: 1 addition & 1 deletion amworkflow/src/geometries/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from OCCUtils.Topology import Topo
from OCCUtils.Construct import make_face
from OCCUtils.Construct import vec_to_dir
from src.geometries.builder import geometry_builder
from amworkflow.src.geometries.builder import geometry_builder
from OCC.Core.BRepBndLib import brepbndlib_Add
from OCC.Core.Bnd import Bnd_Box

Expand Down
4 changes: 2 additions & 2 deletions amworkflow/src/geometries/simple_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Ax2, gp_Dir
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire, BRepBuilderAPI_MakeFace, BRepBuilderAPI_Sewing, BRepBuilderAPI_MakeSolid, BRepBuilderAPI_MakeShell, brepbuilderapi_Precision
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism, BRepPrimAPI_MakeCylinder
from src.geometries.operator import geom_copy, translate, reverse
from src.geometries.builder import geometry_builder
from amworkflow.src.geometries.operator import geom_copy, translate, reverse
from amworkflow.src.geometries.builder import geometry_builder

from OCC.Core.GC import GC_MakeArcOfCircle
import math as m
Expand Down
2 changes: 1 addition & 1 deletion amworkflow/src/infrastructure/database/Engine/engine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.infrastructure.database.models.model import engine, Base
from amworkflow.src.infrastructure.database.models.model import engine, Base
from sqlalchemy.orm import Session

Base.metadata.create_all(engine)
Expand Down
2 changes: 1 addition & 1 deletion amworkflow/src/infrastructure/database/cruds/crud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from uuid import uuid4
from src.infrastructure.database.Engine.engine import session
from amworkflow.src.infrastructure.database.Engine.engine import session
from sqlalchemy import insert
from sqlalchemy.sql.expression import select

Expand Down
4 changes: 2 additions & 2 deletions amworkflow/src/infrastructure/database/models/model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from sqlalchemy import create_engine
from src.constants.enums import Directory as D
from amworkflow.src.constants.enums import Directory as D
engine = create_engine("sqlite+pysqlite:////" + D.DATABASE_FILE_PATH.value + r'amworkflow.db', echo=True)

from typing import List
from typing import Optional
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from src.constants.enums import Timestamp as T
from amworkflow.src.constants.enums import Timestamp as T
from datetime import datetime
class Base(DeclarativeBase):
pass
Expand Down
2 changes: 1 addition & 1 deletion amworkflow/src/interface/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5.QtGui import QFont, QIcon
from OCC.Display.backend import load_backend
load_backend('qt-pyqt5')
from src.geometries.simple_geometry import create_box, create_prism
from amworkflow.src.geometries.simple_geometry import create_box, create_prism
from OCC.Display.qtDisplay import qtViewer3d
from OCC.Core.AIS import AIS_Shape, AIS_InteractiveObject

Expand Down
6 changes: 3 additions & 3 deletions amworkflow/src/utils/db_calib.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from src.infrastructure.database.cruds.crud import query_multi_data, delete_data
from src.infrastructure.database.models import model
from amworkflow.src.infrastructure.database.cruds.crud import query_multi_data, delete_data
from amworkflow.src.infrastructure.database.models import model
import inspect
from src.constants.enums import InputFormat, Directory
from amworkflow.src.constants.enums import InputFormat, Directory

def db_calib():
tables = [model.GeometryFile]
Expand Down
6 changes: 3 additions & 3 deletions amworkflow/src/utils/download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from src.infrastructure.database.cruds.crud import _query_data, query_multi_data
from src.infrastructure.database.models.model import GeometryFile, XdmfFile, H5File
from src.constants.enums import Directory as D
from amworkflow.src.infrastructure.database.cruds.crud import _query_data, query_multi_data
from amworkflow.src.infrastructure.database.models.model import GeometryFile, XdmfFile, H5File
from amworkflow.src.constants.enums import Directory as D
import shutil
import os

Expand Down
2 changes: 1 addition & 1 deletion amworkflow/src/utils/parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import yaml
import os
import logging
from src.constants.enums import Directory as D
from amworkflow.src.constants.enums import Directory as D
import numpy as np
import flatdict
import ruamel.yaml
Expand Down
6 changes: 3 additions & 3 deletions amworkflow/src/utils/sanity_check.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from src.constants.enums import Mapper as M
from src.constants.exceptions import DimensionViolationException
from amworkflow.src.constants.enums import Mapper as M
from amworkflow.src.constants.exceptions import DimensionViolationException
import numpy as np

def import_freecad_check():
import sys
from src.constants.enums import Directory
from amworkflow.src.constants.enums import Directory
freecad_path = Directory.SYS_PATH.value + Directory.FREECAD_PATH.value
sys.path.append(freecad_path)
try:
Expand Down
6 changes: 3 additions & 3 deletions amworkflow/src/utils/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import copy
from OCC.Core.StlAPI import StlAPI_Writer
from OCC.Extend.DataExchange import write_stl_file, write_step_file, read_stl_file
from tests.test import path_append_check
from amworkflow.tests.test import path_append_check
path_append_check()
from src.constants.enums import Directory
from src.constants.enums import Timestamp as T
from amworkflow.src.constants.enums import Directory
from amworkflow.src.constants.enums import Timestamp as T
from datetime import datetime
import numpy as np
import gmsh
Expand Down
2 changes: 1 addition & 1 deletion amworkflow/tests/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.constants.exceptions import DimensionViolationException
from amworkflow.src.constants.exceptions import DimensionViolationException


def dimension_check(dm_list: list):
Expand Down
6 changes: 3 additions & 3 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from doit.action import CmdAction
import amworkflow.src.core.create_geometry as cg
import amworkflow.src.constants.enums as e
from amworkflow.src.utils.db_calib import db_calib
import amworkflow.amworkflow.src.core.create_geometry as cg
import amworkflow.amworkflow.src.constants.enums as e
from amworkflow.amworkflow.src.utils.db_calib import db_calib
# Define actions here
def environment_init() -> bool:
import sys, os
Expand Down
7 changes: 4 additions & 3 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ dependencies:
- zipp=3.15.0=pyhd8ed1ab_0
- zlib=1.2.13=h166bdaf_4
- zstd=1.5.2=h3eb15da_6
- pydantic
- pyyaml
- pip:
- anyio==3.7.0
- argon2-cffi==21.3.0
Expand Down Expand Up @@ -371,7 +373,6 @@ dependencies:
- nest-asyncio==1.5.6
- notebook==6.5.4
- notebook-shim==0.2.3
- occutils==0.1.dev0
- overrides==7.3.1
- pandocfilters==1.5.0
- plotly==5.15.0
Expand All @@ -381,7 +382,6 @@ dependencies:
- pydantic==1.10.9
- pyrsistent==0.19.3
- python-json-logger==2.0.7
- pyyaml==6.0
- pyzmq==25.1.0
- rfc3339-validator==0.1.4
- rfc3986-validator==0.1.1
Expand All @@ -398,4 +398,5 @@ dependencies:
- webencodings==0.5.1
- websocket-client==1.6.1
- widgetsnbextension==3.6.4
prefix: /home/yhe/anaconda3/envs/amworkflow
- polyfactory
- -e .
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[project]
name = "amworkflow"
version = "0.2"
authors = [
{name = "Annika Robens-Radermacher", email = "[email protected]"},
]

description = "Automatic workflows for AM concrete appplications"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Science/Research",
]
license = {file = "LICENSE"}
keywords = ["AM concrete", "workflow", "CAD"]
dependencies = [
"fenics-dolfinx",
"gmsh",
]

[project.urls]
"Homepage" = "https://github.com/BAMresearch/amworkflow"
"Bug Tracker" = "https://github.com/BAMresearch/amworkflow/issues"

[build-system]
requires = ["setuptools", "wheel"]
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup

setup(
name='amworkflow',
version='',
packages=['amworkflow.src', 'amworkflow.tests'],
url='',
license='MIT',
author='Yuxiang He',
author_email='',
description=''
)
4 changes: 2 additions & 2 deletions usecases/param_wall/dodo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from param_wall import ParamWallWorkflow
from amworkflow.src.constants.data_model import WallGeometryParameter, DB_WallGeometryFile
from amworkflow.src.infrastructure.database.models.model import GeometryFile
from amworkflow.amworkflow.src.constants.data_model import WallGeometryParameter, DB_WallGeometryFile
from amworkflow.amworkflow.src.infrastructure.database.models.model import GeometryFile

def create_param_wall(yaml_dir: str,
filename: str,
Expand Down
15 changes: 8 additions & 7 deletions usecases/param_wall/param_wall.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import sys
import os
sys.path.append("/home/yhe/Documents/amworkflow/amworkflow")
import pathlib
#sys.path.append("/home/yhe/Documents/amworkflow/amworkflow")
from OCC.Core.TopoDS import TopoDS_Shape
from src.core.workflow import BaseWorkflow
from src.constants.data_model import WallParam, DB_WallGeometryFile
from src.infrastructure.database.models.model import GeometryFile
from src.geometries.simple_geometry import create_box
from amworkflow.src.core.workflow import BaseWorkflow
from amworkflow.src.constants.data_model import WallParam, DB_WallGeometryFile
from amworkflow.src.infrastructure.database.models.model import GeometryFile
from amworkflow.src.geometries.simple_geometry import create_box

class ParamWallWorkflow(BaseWorkflow):
def __init__(self, yaml_dir: str, filename: str, data_model: callable, geom_db_model: callable = None, geom_db_data_model: callable = None):
Expand Down Expand Up @@ -37,10 +38,10 @@ def geom_process(self, ind: int, param: list, name_type: str):
model.stl_hashname = hash_name
self.db_data_collection["geometry"].append(model.dict())

yaml_dir = r"//home/yhe/Documents/amworkflow/usecases/param_wall/"
yaml_dir = pathlib.Path(__file__).parent
yaml_filename = "test1.yaml"

p_wall = ParamWallWorkflow(yaml_dir=yaml_dir,
p_wall = ParamWallWorkflow(yaml_dir=str(yaml_dir),
filename=yaml_filename,
data_model= WallParam,
geom_db_model= GeometryFile,
Expand Down
2 changes: 1 addition & 1 deletion usecases/param_wall/test1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ geometry_parameter:
length:
length: 100
endpoint: 180
num: 1
num: 2
height:
length: 4.3
endpoint: 6.6
Expand Down

0 comments on commit 09da4f6

Please sign in to comment.