Skip to content

Commit 5a2e25f

Browse files
authored
Merge pull request #745 from BIM2SIM/development
update main
2 parents 20ff0eb + 679db76 commit 5a2e25f

File tree

12 files changed

+51
-198
lines changed

12 files changed

+51
-198
lines changed

.gitlab-ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,14 @@ build:main-energyplus:py3.11:
672672
- |
673673
plugin_test_dir=~/bim2sim-coding/bim2sim/plugins/${plugin}/test
674674
if [ -d "${plugin_test_dir}/unit" ] || [ -d "${plugin_test_dir}/integration" ]; then
675-
test_dirs=$(find ${plugin_test_dir} -maxdepth 1 -type d \( -name "unit" -o -name "integration" \) | tr '\n' ' ')
676-
coverage run --source=~/bim2sim-coding/bim2sim/plugins/${plugin} -m unittest discover -v ${test_dirs}
675+
if [ -d "${plugin_test_dir}/unit" ]; then
676+
echo "Running unit tests..."
677+
coverage run --source=~/bim2sim-coding/bim2sim/plugins/${plugin} -m unittest discover -v ${plugin_test_dir}/unit
678+
fi
679+
if [ -d "${plugin_test_dir}/integration" ]; then
680+
echo "Running integration tests..."
681+
coverage run --append --source=~/bim2sim-coding/bim2sim/plugins/${plugin} -m unittest discover -v ${plugin_test_dir}/integration
682+
fi
677683
else
678684
echo "No unit or integration test directories found."
679685
exit 1

EnergyPlus.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ USER root
1717
RUN apt-get update && apt-get install -y ca-certificates curl libx11-6 libexpat1 \
1818
&& rm -rf /var/lib/apt/lists/*
1919

20-
RUN curl -SLO $ENERGYPLUS_DOWNLOAD_URL
20+
RUN curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL || \
21+
(sleep 30 && curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL)
2122

2223
RUN chmod +x $ENERGYPLUS_DOWNLOAD_FILENAME
2324

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ The focus of the currently released tool is on BPS and HVAC but we already provi
1515

1616
## Installation and Usage
1717
You can find detailed documentation and description how to install and to use in our [documentation](https://bim2sim.github.io/bim2sim//development/docs/overview.html). We recommend reading at least:
18-
* [Big Picture](https://bim2sim.github.io/bim2sim//development/docs/overview.html)
19-
* [Installation](https://bim2sim.github.io/bim2sim//development/docs/installation.html)
20-
* [First Steps](https://bim2sim.github.io/bim2sim//development/docs/first-steps.html)
21-
22-
For questions like why we don't use pip and if we support docker we refer to the linked documentation.
23-
18+
* [Big Picture](https://bim2sim.github.io/bim2sim//development/docs/big-picture.html) to understand the concepts of bim2sim
19+
* [PluginTemplate - How to install?](https://bim2sim.github.io/bim2sim//development/docs/user-guide/PluginTemplate.html#how-to-install) to understand how to install the Base of the framework.
2420

2521
## Related Publications
2622
* [Final Report of BIM2SIM project](https://www.tib.eu/en/search/id/TIBKAT:1819319997)

bim2sim/__init__.py

Lines changed: 6 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,17 @@
11
"""bim2sim library"""
2-
3-
import os
4-
import re
5-
import sys
6-
7-
import tempfile
8-
from os.path import expanduser
2+
from importlib.metadata import version
93

104
from bim2sim.kernel.decision.console import ConsoleDecisionHandler
115
from bim2sim.kernel.decision.decisionhandler import DecisionHandler
126
from bim2sim.project import Project
137

14-
VERSION = '0.1-dev'
8+
9+
try:
10+
__version__ = version("bim2sim")
11+
except Exception:
12+
__version__ = "unknown"
1513

1614

1715
def run_project(project: Project, handler: DecisionHandler):
1816
"""Run project using decision handler."""
1917
return handler.handle(project.run(), project.loaded_decisions)
20-
21-
22-
def _debug_run_hvac():
23-
"""Create example project and copy ifc if necessary"""
24-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), "..\\.."))
25-
rel_example = 'ExampleFiles/KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc'
26-
path_ifc = os.path.normpath(os.path.join(path_base, rel_example))
27-
path_example = _get_debug_project_path('hvac')
28-
29-
if Project.is_project_folder(path_example):
30-
project = Project(path_example)
31-
else:
32-
project = Project.create(path_example, path_ifc, 'hkesim', )
33-
34-
# setup_defualt(project.config['Frontend']['use'])
35-
run_project(project, ConsoleDecisionHandler())
36-
37-
38-
def _get_debug_project_path(aux):
39-
path_file = "debug_dir.user"
40-
try:
41-
f = open(path_file)
42-
path_example = f.read()
43-
f.close()
44-
except IOError:
45-
path_example = str(input("Specify debug root path (Leave blank for '" + expanduser('~')
46-
+ "'). This value will be remembered in '" + path_file + "': "))
47-
if len(path_example) == 0:
48-
path_example = expanduser('~')
49-
f = open(path_file, 'a')
50-
f.write(path_example)
51-
f.close()
52-
53-
if not path_example.endswith("/"):
54-
path_example += "/"
55-
56-
max_number = 0
57-
for item in os.listdir(path_example):
58-
m = re.search('testproject_%s([0-9]+)' % aux, item)
59-
if m:
60-
max_number = max(int(m.group(1)), max_number)
61-
62-
return path_example + "testproject_%s" % aux + str(max_number + 1)
63-
64-
65-
def _debug_run_bps():
66-
"""Create example project and copy ifc if necessary"""
67-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
68-
69-
# rel_example = 'ExampleFiles/AC20-FZK-Haus.ifc'
70-
# rel_example = 'ExampleFiles/KM_DPM_Vereinshaus_Gruppe62_Architektur_spaces.ifc'
71-
rel_example = 'ExampleFiles/AC20-Institute-Var-2.ifc'
72-
path_ifc = os.path.normpath(os.path.join(path_base, rel_example))
73-
path_example = _get_debug_project_path('bps')
74-
75-
if Project.is_project_folder(path_example):
76-
project = Project(path_example)
77-
else:
78-
project = Project.create(path_example, path_ifc, 'teaser', )
79-
80-
run_project(project, ConsoleDecisionHandler())
81-
82-
83-
def _debug_run_bps_ep():
84-
"""Create example project and copy ifc if necessary"""
85-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
86-
87-
rel_example = 'ExampleFiles/AC20-FZK-Haus.ifc'
88-
# rel_example = 'ResultFiles/AC20-FZK-Haus_with_SB44.ifc' # aktuell
89-
# rel_example = 'ResultFiles/Proposal_1_Storey_SpaceBoundaries_with_SB.ifc'
90-
# rel_example = 'ResultFiles/2020-10-15-KHH-Test_with_SB.ifc'
91-
# rel_example = 'ExampleFiles/AC20-Institute-Var-2.ifc'
92-
# rel_example = 'ExampleFiles/DigitalHub_Architektur2_2020_Achse_tragend_V2.ifc' # ok
93-
rel_example = 'ResultFiles/FM_ARC_DigitalHub_with_SB89.ifc'
94-
# ok
95-
# rel_example = 'ExampleFiles/AC-20-Smiley-West-10-Bldg.ifc'
96-
path_ifc = os.path.normpath(os.path.join(path_base, rel_example))
97-
98-
path_example = _get_debug_project_path('bps_ep')
99-
100-
if Project.is_project_folder(path_example):
101-
project = Project(path_example)
102-
else:
103-
project = Project.create(path_example, path_ifc, 'energyplus', )
104-
105-
run_project(project, ConsoleDecisionHandler())
106-
107-
108-
def _test_run_bps_ep(rel_path, temp_project=False):
109-
"""Create example project and copy ifc if necessary. Added for EnergyPlus integration tests"""
110-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
111-
112-
path_ifc = os.path.normpath(os.path.join(path_base, rel_path))
113-
114-
if not temp_project:
115-
path_example = _get_debug_project_path('bps_ep')
116-
else:
117-
path_example = tempfile.mkdtemp()
118-
119-
old_stderr = sys.stderr
120-
working_dir = os.getcwd()
121-
success = False
122-
if Project.is_project_folder(path_example):
123-
project = Project(path_example)
124-
else:
125-
project = Project.create(path_example, path_ifc, 'energyplus', )
126-
127-
try:
128-
print("Project directory: " + path_example)
129-
os.chdir(path_example)
130-
if Project.is_project_folder(path_example):
131-
project = Project(path_example)
132-
else:
133-
project = Project.create(path_example, path_ifc, 'energyplus', )
134-
135-
#HACK: We have to remember stderr because eppy resets it currently.
136-
success = run_project(project, ConsoleDecisionHandler())
137-
finally:
138-
os.chdir(working_dir)
139-
sys.stderr = old_stderr
140-
return success
141-
142-
143-
def _debug_run_hvac_aixlib():
144-
"""Create example project and copy ifc if necessary"""
145-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), "..\\.."))
146-
rel_example = 'ExampleFiles/KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc'
147-
path_ifc = os.path.normpath(os.path.join(path_base, rel_example))
148-
path_example = _get_debug_project_path('aix')
149-
150-
if Project.is_project_folder(path_example):
151-
project = Project(path_example)
152-
else:
153-
project = Project.create(path_example, path_ifc, 'aixlib', )
154-
155-
project.run()
156-

bim2sim/__main__.py

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@
1717
-i <source> --ifc <source> Path to ifc file
1818
-o --open Open config file
1919
"""
20-
21-
import os
22-
import sys
20+
from importlib.metadata import version
2321

2422
import docopt
2523

26-
from bim2sim import VERSION, run_project
24+
from bim2sim import run_project
2725
from bim2sim.project import Project, FolderStructure
2826
from bim2sim.kernel.decision.console import ConsoleDecisionHandler
2927

3028

29+
def get_version():
30+
"""Get package version"""
31+
try:
32+
return version("bim2sim")
33+
except Exception:
34+
return "unknown"
35+
36+
3137
def commandline_interface():
3238
"""user interface"""
3339

34-
args = docopt.docopt(__doc__, version=VERSION)
40+
args = docopt.docopt(__doc__, version=get_version())
3541

3642
# arguments
3743
project = args.get('project')
@@ -58,27 +64,4 @@ def commandline_interface():
5864
exit()
5965

6066

61-
def debug_params():
62-
"""Set debug console arguments"""
63-
64-
print("No parameters passed. Using debug parameters.")
65-
path_base = os.path.abspath(os.path.join(os.path.dirname(__file__), "..\\.."))
66-
rel_example = 'ExampleFiles/KM_DPM_Vereinshaus_Gruppe62_Heizung_with_pumps.ifc'
67-
path_ifc = os.path.normcase(os.path.join(path_base, rel_example))
68-
69-
#sys.argv.append('project')
70-
#sys.argv.append('create')
71-
#sys.argv.append(r'C:\temp\bim2sim\testproject')
72-
#sys.argv.extend(['-s', 'hkesim', '-i', path_ifc, '-o'])
73-
74-
sys.argv.append('project')
75-
sys.argv.append('load')
76-
sys.argv.append(r'C:\temp\bim2sim\testproject')
77-
78-
print("Debug parameters:\n%s"%("\n".join(sys.argv[1:])))
79-
80-
81-
if len(sys.argv) <= 1:
82-
debug_params()
83-
8467
commandline_interface()

bim2sim/kernel/decision/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- functions save() and load() to save to file system
88
"""
99

10+
from importlib.metadata import version
1011
import enum
1112
import hashlib
1213
import json
@@ -17,8 +18,6 @@
1718
import pint
1819

1920
from bim2sim.elements.mapping.units import ureg
20-
# todo remove version? what is this used for?
21-
__VERSION__ = '0.1'
2221
logger = logging.getLogger(__name__)
2322

2423

@@ -542,7 +541,7 @@ def save(bunch: DecisionBunch, path):
542541

543542
decisions = bunch.to_serializable()
544543
data = {
545-
'version': __VERSION__,
544+
'version': version("bim2sim"),
546545
'checksum_ifc': None,
547546
'decisions': decisions,
548547
}
@@ -561,11 +560,12 @@ def load(path) -> Dict[str, Any]:
561560
logger.info(f"Unable to load decisions. "
562561
f"No Existing decisions found at {ex.filename}")
563562
return {}
564-
version = data.get('version', '0')
565-
if version != __VERSION__:
563+
cur_version = data.get('version', '0')
564+
if cur_version != version("bim2sim"):
566565
try:
567-
data = convert(version, __VERSION__, data)
568-
logger.info("Converted stored decisions from version '%s' to '%s'", version, __VERSION__)
566+
data = convert(cur_version, version("bim2sim"), data)
567+
logger.info("Converted stored decisions from version '%s' to '%s'",
568+
cur_version, version("bim2sim"))
569569
except:
570570
logger.error("Decision conversion from %s to %s failed")
571571
return {}

bim2sim/plugins/PluginAixLib/test/regression/__init__.py

Whitespace-only changes.

bim2sim/plugins/PluginComfort/PluginComfort.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ USER root
2424
RUN apt-get update && apt-get install -y ca-certificates curl libx11-6 libexpat1 \
2525
&& rm -rf /var/lib/apt/lists/*
2626

27-
RUN curl -SLO $ENERGYPLUS_DOWNLOAD_URL
27+
RUN curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL || \
28+
(sleep 30 && curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL)
2829

2930
RUN chmod +x $ENERGYPLUS_DOWNLOAD_FILENAME
3031

bim2sim/plugins/PluginEnergyPlus/PluginEnergyPlus.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ USER root
2424
RUN apt-get update && apt-get install -y ca-certificates curl libx11-6 libexpat1 \
2525
&& rm -rf /var/lib/apt/lists/*
2626

27-
RUN curl -SLO $ENERGYPLUS_DOWNLOAD_URL
27+
RUN curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL || \
28+
(sleep 30 && curl -SLO --retry 5 --retry-delay 15 --retry-max-time 900 --connect-timeout 60 --max-time 3600 $ENERGYPLUS_DOWNLOAD_URL)
2829

2930
RUN chmod +x $ENERGYPLUS_DOWNLOAD_FILENAME
3031

docs/source/user-guide/PluginTemplate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ version of [mamba](https://github.com/mamba-org/mamba)) is used.
3535

3636
We will guide you through the process now.
3737
```shell
38-
# create fresh python environment with conda (python 3.9 to 3.11 are supported currently)
38+
# create fresh python environment with conda (python 3.10 to 3.11 are supported currently)
3939
micromamba create -n bim2sim python=3.11 -c conda-forge
4040
# activate your environment
4141
micromamba activate bim2sim

0 commit comments

Comments
 (0)