Skip to content

Commit 1cf590d

Browse files
committed
Merge branch 'QPR-11822' into 'master'
Resolve QPR-11822 Closes QPR-11822 See merge request qs/oreswig!44
2 parents 016643d + 54a7ff9 commit 1cf590d

61 files changed

Lines changed: 7954 additions & 11173 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
21
cmake_minimum_required(VERSION 3.8)
32

43
project(ORE-SWIG)
5-
6-
#add_subdirectory(QuantExt-SWIG/Python)
7-
#add_subdirectory(OREData-SWIG/Python)
4+
85
add_subdirectory(OREAnalytics-SWIG/Python)
9-
#add_subdirectory(OREAnalytics-SWIG/Java)
10-
#add_subdirectory(QuantExt-SWIG/Java)
11-
#add_subdirectory(OREData-SWIG/Java)
6+

Docker/Dockerfile-ORESWIG

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,10 @@ WORKDIR /swig/OREAnalytics-SWIG/Python/build.release
3535
RUN cmake -DORE=/swig ..
3636
RUN make -j ${num_cores}
3737
WORKDIR /
38-
RUN mkdir build
39-
RUN mv /swig/OREAnalytics-SWIG/Python/build.release/ORE.py build \
40-
&& mv /swig/OREAnalytics-SWIG/Python/build.release/_ORE.so build
41-
42-
ENV PYTHONPATH=/build
43-
44-
RUN cd swig/QuantLib-SWIG/Python/test \
45-
&& python3 -c "import sys, ORE; sys.modules['QuantLib']=ORE;import QuantLibTestSuite;QuantLibTestSuite.test()"
46-
RUN cd swig/QuantExt-SWIG/Python/test \
47-
&& python3 -c "import sys, ORE; sys.modules['QuantExt']=ORE;import QuantExtTestSuite;QuantExtTestSuite.test()"
48-
RUN cd swig/OREData-SWIG/Python/test \
49-
&& python3 -c "import sys, ORE; sys.modules['OREData']=ORE;import OREDataTestSuite;OREDataTestSuite.test()"
50-
RUN cd swig/OREAnalytics-SWIG/Python/test \
51-
&& python3 -c "import sys, ORE; sys.modules['OREAnalytics']=ORE;import OREAnalyticsTestSuite;OREAnalyticsTestSuite.test()"
52-
RUN rm -rf /swig \
53-
&& cd /usr/local/include \
54-
&& rm -rf boost \
55-
&& rm -rf orea \
56-
&& rm -rf ored \
57-
&& rm -rf ql \
58-
&& rm -rf qle
59-
60-
COPY oreswig/OREAnalytics-SWIG/Python/Examples ./Examples
38+
RUN mkdir oreswig
39+
RUN mv /swig/OREAnalytics-SWIG/Python/build.release/ORE.py oreswig \
40+
&& mv /swig/OREAnalytics-SWIG/Python/build.release/_ORE.so oreswig
41+
42+
ENV PYTHONPATH=/oreswig
43+
44+
WORKDIR /swig/OREAnalytics-SWIG/Python/Examples

Docker/Dockerfile-ORESWIG-App

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#syntax = nexus3.acadiasoft.net:4445/docker/dockerfile:experimental
2+
3+
ARG ore_version=latest
4+
ARG debian_tag=latest
5+
6+
FROM env_oreswig:${ore_version} as env_oreswig
7+
FROM env_ore:${ore_version} as env_ore
8+
FROM debian:${debian_tag}
9+
10+
RUN apt-get update \
11+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y dos2unix python3 python3-pip vim \
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN pip3 install matplotlib pandas nose nose_xunitmp datacompy
16+
17+
WORKDIR /
18+
RUN mkdir /oreswig
19+
RUN mkdir /oreswig/pythonlib
20+
21+
COPY --from=env_oreswig /oreswig/ORE.py /oreswig/pythonlib/ORE.py
22+
COPY --from=env_oreswig /oreswig/_ORE.so /oreswig/pythonlib/_ORE.so
23+
24+
COPY --from=env_ore /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
25+
26+
RUN true
27+
28+
COPY --from=env_ore /usr/local/lib /usr/local/lib
29+
30+
ENV PYTHONPATH=/oreswig/pythonlib
31+
ENV LD_LIBRARY_PATH=/usr/local/lib
32+
33+
RUN mkdir /oreswig/tests
34+
35+
COPY oreswig/QuantLib-SWIG/Python/test /oreswig/tests/QuantLibTestSuite
36+
# Delete the init.py otherwise nosetest will not pick up all the tests
37+
RUN rm oreswig/tests/QuantLibTestSuite/__init__.py
38+
COPY oreswig/OREAnalytics-SWIG/Python/test /oreswig/tests/ORETestSuite
39+
COPY oreswig/OREAnalytics-SWIG/Python/Examples /oreswig/example_scripts
40+
COPY ore/Examples /oreswig/Examples
41+
COPY ore/Tools /oreswig/Tools
42+
# Set env variable to run the ore examples with the python interface instead of the executable
43+
ENV ORE_EXAMPLES_USE_PYTHON=1
44+
45+
CMD bash

Docker/DockerfileRunORE.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
2-
3-
docker-compose -f oreswig/Docker/docker-compose-oreswig.yml build || exit 1
2+
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose --env-file ore/Docker/.env -f oreswig/Docker/docker-compose-oreswig.yml build || exit 1
3+
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose --env-file ore/Docker/.env -f oreswig/Docker/docker-compose-oreswig-app.yml build || exit 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
3+
services:
4+
ore_plus_app:
5+
image: oreswig_app:${ORE_TAG}
6+
build:
7+
context: ../../
8+
dockerfile: oreswig/Docker/Dockerfile-ORESWIG-App
9+
args:
10+
- ore_version=${ORE_TAG}
11+
- debian_tag=${DEBIAN_TAG}

OREAnalytics-SWIG/Makefile.am

Lines changed: 0 additions & 12 deletions
This file was deleted.

OREAnalytics-SWIG/Python/Examples/ore.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
for name in analyticTypes:
4040
print("analytc:", name)
4141

42-
print("\npress <enter> ...")
43-
sys.stdin.readline()
44-
4542
#####################################
4643
# List all results, reports and cubes
4744

@@ -55,9 +52,6 @@
5552
for name in cubeNames:
5653
print("cube:", name)
5754

58-
print("\npress <enter> ...")
59-
sys.stdin.readline()
60-
6155
#######################
6256
# Access report details
6357

@@ -78,19 +72,13 @@
7872
for i in range(0, report.columns()):
7973
print("colum", i, "header", report.header(i), "type", report.columnType(i), columnTypes[report.columnType(i)])
8074

81-
print("\npress <enter> ...")
82-
sys.stdin.readline()
83-
8475
time = report.dataAsReal(2);
8576
epe = report.dataAsReal(3);
8677
ene = report.dataAsReal(4);
8778
print ("#Time", "EPE")
8879
for i in range(0, report.rows()):
8980
print("%5.2f %12.2f %12.2f" % (time[i], epe[i], ene[i]))
9081

91-
print("\npress <enter> ...")
92-
sys.stdin.readline()
93-
9482
#####################
9583
# Access cube details
9684

@@ -102,9 +90,6 @@
10290
print ("cube dates:", cube.numDates())
10391
print ("cube depth:", cube.depth())
10492

105-
print("\npress <enter> ...")
106-
sys.stdin.readline()
107-
10893
cubeIds = cube.ids()
10994
cubeDates = cube.dates()
11095

@@ -118,9 +103,6 @@
118103
###########################################################
119104
# Access one analytic e.g. to query the market or portfolio
120105

121-
print("\npress <enter> ...")
122-
sys.stdin.readline()
123-
124106
print("Inspect NPV analytic ...")
125107
analytic = ore.getAnalytic("NPV")
126108
market = analytic.getMarket()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
status=0
3+
return_code=0
4+
for file in *.py; do
5+
if [ -f "$file" ]; then
6+
echo RUN $file
7+
python3 "$file" || status=1
8+
return_code=$?
9+
if [ $return_code -gt $status ]; then
10+
status=$return_code
11+
fi
12+
fi
13+
done
14+
exit $status

OREAnalytics-SWIG/Python/Makefile.am

Lines changed: 0 additions & 38 deletions
This file was deleted.

OREAnalytics-SWIG/Python/README.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)