Skip to content

Commit

Permalink
Port from sunbeam to opm.io
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Mar 2, 2020
1 parent f88544a commit 8f66b30
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .libecl_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export LIBECL_VERSION=2.4.1
export LIBECL_VERSION=2.7.0
72 changes: 30 additions & 42 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
language: python

dist: trusty
dist: bionic

compiler:
- gcc

addons:
apt:
packages:
- libboost-all-dev
- libboost-python-dev
- liblapack-dev

sudo: required

matrix:
include:
- python: '2.7'
- python: '3.5'
- python: '3.6'
# - python: '3.7' # Missing working compile setup for sunbeam
- python: '3.7'
- python: '3.8'

before_install:
- python --version
- export CXX="g++-4.9" CC="gcc-4.9"
- export INSTALL_DIR=`pwd`/../install
- export PATH=$PATH:$INSTALL_DIR/bin
- export PYTHONPATH=$INSTALL_DIR/lib/python$TRAVIS_PYTHON_VERSION/dist-packages:$PYTHONPATH
- export PYTHONPATH=$INSTALL_DIR/lib/python$TRAVIS_PYTHON_VERSION/site-packages:$INSTALL_DIR/lib/python$TRAVIS_PYTHON_VERSION/dist-packages:$PYTHONPATH
- export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$INSTALL_DIR/lib64:$LD_LIBRARY_PATH
- export LIBECL_VERSION="2.6.0"
- echo $INSTALL_DIR
Expand All @@ -26,27 +34,14 @@ before_install:
- export MPLBACKEND="Agg"


addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
- libboost1.55-all-dev
- liblapack-dev

sudo: required

install:
- python -m pip install --upgrade pip
- python -m pip install --upgrade -r requirements.txt
- python -m pip install --upgrade -r requirements-dev.txt

# We compile and install libecl, because we need the C utilities as well as
# the Python API. Only the Python API follows from the pip-installable libecl.
before_script:
# For now we have to make install libecl.
# Remove when it's possible to pip install
- source .libecl_version
- git clone https://github.com/equinor/libecl
- pushd libecl
Expand All @@ -55,39 +50,32 @@ before_script:
- pip install -r requirements.txt
- mkdir build
- pushd build
- cmake .. -DENABLE_PYTHON=ON
- cmake .. -DBUILD_TESTS=OFF
-DENABLE_PYTHON=ON
-DBUILD_APPLICATIONS=ON
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
-DCMAKE_PREFIX_PATH=$INSTALL_DIR
-DINSTALL_ERT_LEGACY=ON
-DCMAKE_C_FLAGS='-Werror=all'
-DCMAKE_CXX_FLAGS='-Werror -Wno-unused-result'
- make
- make install
- popd;popd
- rm -rf libecl
- make -j 4 install
- python -c "import ecl; print(ecl.__file__)"

# We also need sunbeam, which requires opm-common:
- popd
- rm -rf python/tests # Avoid running these tests.
- popd
- git clone --recursive https://github.com/OPM/opm-common.git
- git clone --recursive https://github.com/equinor/sunbeam.git
- mkdir opm-common/build
- pushd opm-common/build
- git checkout release/sunbeam/2019.02
- pushd opm-common
# Build against specific (i.e. tested) opm-common version
# Latest release (2019.10) does not support all Python bindings
- git checkout 31e6f31
- mkdir build
- pushd build
- cmake .. -DCMAKE_PREFIX_PATH=$INSTALL_DIR
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
-DOPM_ENABLE_PYTHON=ON
-DOPM_INSTALL_PYTHON=ON
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=ON
- make -j 4 install
- popd
- mkdir sunbeam/build
- pushd sunbeam/build
- cmake .. -DCMAKE_PREFIX_PATH=$INSTALL_DIR
-DUSE_RPATH=ON
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
-DPYTHON_EXECUTABLE=`which python`
- make -j 4 install
- popd
- popd; popd

script:
- python setup.py test
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pandas
scipy
ecl2df>=0.5.0
pyyaml>=5.1
setuptools >=28
setuptools_scm
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pyyaml>=5.1
pyscal>=0.1.5
matplotlib
numpy
ecl2df<0.5.0
ecl2df>=0.5.0
configsuite
six>=1.12.0
xtgeo
9 changes: 6 additions & 3 deletions src/subscript/sunsch/sunsch.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# -*- coding: utf-8 -*-
"""
Tool for generating Eclipse Schedule files
This script was originally based on a library named sunbeam,
hence the name. Later, this library has been merged into opm-common
"""

import datetime
import tempfile
import argparse
import yaml
from sunbeam.tools import TimeVector
from opm.tools import TimeVector


def datetime_from_date(date):
Expand All @@ -16,7 +19,7 @@ def datetime_from_date(date):


def process_sch_config(sunschconf, quiet=True):
"""Process a Schedule configuration into a sunbeam TimeVector
"""Process a Schedule configuration into a opm.tools TimeVector
:param sunschconf : configuration for the schedule merges and inserts
:type sunschconf: dict
Expand Down Expand Up @@ -218,7 +221,7 @@ def get_parser():
produced given certain input files.
Output will not be generated unless the produced data is valid in
Eclipse, checking provided by sunbeam/opm-parser.""",
Eclipse, checking provided by OPM.""",
epilog="""YAML-file components:
init - filename for the initial file. If omitted, defaults to an
Expand Down
17 changes: 10 additions & 7 deletions tests/test_eclcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import os

import sunbeam.deck
import opm.io

from subscript.eclcompress import eclcompress as eclc

Expand Down Expand Up @@ -66,11 +66,12 @@ def test_eclcompress():
compressed = eclc.compress_multiple_keywordsets(kwsets, cleaned)
compressedstr = "\n".join(compressed)

# Feed the compressed string into sunbeam. Sunbeam hopefully chokes on whatever
# Feed the compressed string into opm.io. OPM hopefully chokes on whatever
# Eclipse would choke on (and hopefully not on more..)
recovery = [("PARSE_MISSING_DIMS_KEYWORD", sunbeam.action.ignore)]

assert sunbeam.deck.parse_string(compressedstr, recovery=recovery)
parsecontext = opm.io.ParseContext(
[("PARSE_MISSING_DIMS_KEYWORD", opm.io.action.ignore)]
)
assert opm.io.Parser().parse_string(compressedstr, parsecontext)


def test_main():
Expand Down Expand Up @@ -98,5 +99,7 @@ def test_main():
assert compressedbytes < origbytes

compressedstr = "\n".join(compressedlines)
recovery = [("PARSE_MISSING_DIMS_KEYWORD", sunbeam.action.ignore)]
assert sunbeam.deck.parse_string(compressedstr, recovery=recovery)
parsecontext = opm.io.ParseContext(
[("PARSE_MISSING_DIMS_KEYWORD", opm.io.action.ignore)]
)
assert opm.io.Parser().parse_string(compressedstr, parsecontext)

0 comments on commit 8f66b30

Please sign in to comment.