From 8f66b302b7144d5f5ab0e0961974512f9370009b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Fri, 10 Jan 2020 17:42:03 +0100 Subject: [PATCH] Port from sunbeam to opm.io --- .libecl_version | 2 +- .travis.yml | 72 ++++++++++++++-------------------- requirements-dev.txt | 1 + requirements.txt | 2 +- src/subscript/sunsch/sunsch.py | 9 +++-- tests/test_eclcompress.py | 17 ++++---- 6 files changed, 49 insertions(+), 54 deletions(-) diff --git a/.libecl_version b/.libecl_version index 19d260155..ed74f50f3 100644 --- a/.libecl_version +++ b/.libecl_version @@ -1 +1 @@ -export LIBECL_VERSION=2.4.1 +export LIBECL_VERSION=2.7.0 diff --git a/.travis.yml b/.travis.yml index d08cc2b13..f137952c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 @@ -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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 1ba335949..b5a781661 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ pandas scipy +ecl2df>=0.5.0 pyyaml>=5.1 setuptools >=28 setuptools_scm diff --git a/requirements.txt b/requirements.txt index a0a1fb645..62ae7bc86 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/src/subscript/sunsch/sunsch.py b/src/subscript/sunsch/sunsch.py index 616fa1314..b542ea43d 100644 --- a/src/subscript/sunsch/sunsch.py +++ b/src/subscript/sunsch/sunsch.py @@ -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): @@ -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 @@ -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 diff --git a/tests/test_eclcompress.py b/tests/test_eclcompress.py index c236c00bf..092b1cbe1 100644 --- a/tests/test_eclcompress.py +++ b/tests/test_eclcompress.py @@ -3,7 +3,7 @@ import sys import os -import sunbeam.deck +import opm.io from subscript.eclcompress import eclcompress as eclc @@ -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(): @@ -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)