Skip to content

Commit

Permalink
Merge pull request #5 from daavid00/developing
Browse files Browse the repository at this point in the history
Updating to toml and documents
  • Loading branch information
daavid00 authored Aug 8, 2024
2 parents a6fbee9 + 9f8325d commit c80019d
Show file tree
Hide file tree
Showing 41 changed files with 584 additions and 188 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
sudo apt-get install mpi-default-bin
sudo apt-get install libopm-simulators-bin
- name: Install test dependecies
- name: Install dependecies
run: |
pip install --upgrade pip setuptools wheel
pip install -r dev-requirements.txt
Expand All @@ -47,9 +47,9 @@ jobs:
- name: Check code style and linting
run: |
black --check src/ tests/ setup.py
pylint src/ tests/ setup.py
mypy --ignore-missing-imports src/ tests/ setup.py
black --check src/ tests/
pylint src/ tests/
mypy --ignore-missing-imports src/ tests/
- name: Run the tests
run: |
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://github.com/cssr-tools/pycopm/actions/workflows/CI.yml/badge.svg)](https://github.com/cssr-tools/pycopm/actions/workflows/CI.yml)
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue.svg"></a>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.8%20to%203.12-blue.svg"></a>
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![DOI](https://zenodo.org/badge/815649176.svg)](https://zenodo.org/doi/10.5281/zenodo.12740838)
Expand All @@ -12,9 +12,9 @@ Creation of coarser models from given input decks.

## Installation
You will first need to install
* Flow (https://opm-project.org, Release 2024.04 or current master branches)
* OPM Flow (https://opm-project.org, Release 2024.04 or current master branches)

To install the _pycopm_ executable in an existing Python environment:
To install the _pycopm_ executable in an existing Python environment:

```bash
pip install git+https://github.com/cssr-tools/pycopm.git
Expand All @@ -34,15 +34,13 @@ python3 -m venv vpycopm
source vpycopm/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the pycopm package (in editable mode for contributions/modifications; otherwise, pip install .)
# Install the pycopm package
pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt
```

See the [_CI.yml_](https://github.com/OPM/pycopm/blob/main/.github/workflows/CI.yml) script for installation of OPM Flow (binary packages) and the pycopm package. If you are a Linux user (including the Windows subsystem for Linux), then you could try to build Flow from the master branches with mpi support, by running the script `./build_opm-flow_mpi.bash`, which in turn should build flow in the folder ./build/opm-simulators/bin/flow (you first need to install the [_OPM-Flow-prerequisites_](https://opm-project.org/?page_id=239)).

For macOS users, use at least a Python version of 3.10 (due to resdata), and run the `./build_opm-flow_macOS.bash` to build OPM Flow (the [_OPM-Flow-prerequisites_](https://opm-project.org/?page_id=239) can be installed via brew or macports).
See the [_installation_](https://cssr-tools.github.io/pycopm/installation.html) for further details on building OPM Flow from the master branches in Linux, Windows, and macOS, as well as the opm Python package.

## Running pycopm
You can run _pycopm_ as a single command line:
Expand All @@ -52,4 +50,10 @@ pycopm -i some_input -o some_output_folder
Run `pycopm --help` to see all possible command line argument options.

## Getting started
See the [_examples_](https://cssr-tools.github.io/pycopm/examples.html) in the [_documentation_](https://cssr-tools.github.io/pycopm/introduction.html).
See the [_examples_](https://cssr-tools.github.io/pycopm/examples.html) in the [_documentation_](https://cssr-tools.github.io/pycopm/introduction.html).

## About pycopm
The _pycopm_ package is being funded by the [_Center for Sustainable Subsurface Resources (CSSR)_](https://cssr.no)
[project no. 331841].
This is work in progress.
Contributions are more than welcome using the fork and pull request approach.
36 changes: 0 additions & 36 deletions build_opm-flow_macOS.bash

This file was deleted.

27 changes: 0 additions & 27 deletions build_opm-flow_mpi.bash

This file was deleted.

6 changes: 3 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
black
pylint
numpydoc
mypy
pylint
pytest-cov
sphinx
sphinx-rtd-theme
pytest
sphinx-rtd-theme
1 change: 1 addition & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Welcome to pycopm's documentation!
:maxdepth: 4

introduction
installation
configuration_file
examples
api
Expand Down
120 changes: 120 additions & 0 deletions docs/_sources/installation.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
============
Installation
============

Python package
--------------

To install the **pycopm** executable in an existing Python environment:

.. code-block:: bash
pip install git+https://github.com/cssr-tools/pycopm.git
If you are interested in modifying the source code, then you can clone the repository and
install the Python requirements in a virtual environment with the following commands:

.. code-block:: console
# Clone the repo
git clone https://github.com/cssr-tools/pycopm.git
# Get inside the folder
cd pycopm
# Create virtual environment
python3 -m venv vpycopm
# Activate virtual environment
source vpycopm/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the pycopm package
pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt
OPM Flow
--------
You also need to install:

* OPM Flow (https://opm-project.org, Release 2024.04 or current master branches)

.. tip::

See the `CI.yml <https://github.com/cssr-tools/pycopm/blob/main/.github/workflows/CI.yml>`_ script
for installation of OPM Flow (binary packages) and the pycopm package in Linux.

Source build in Linux/Windows
+++++++++++++++++++++++++++++
If you are a Linux user (including the Windows subsystem for Linux), then you could try to build Flow (after installing the `prerequisites <https://opm-project.org/?page_id=239>`_) from the master branches with mpi support by running
in the terminal the following lines (which in turn should build flow in the folder ./build/opm-simulators/bin/flow.):

.. code-block:: console
CURRENT_DIRECTORY="$PWD"
for repo in common grid models simulators
do
git clone https://github.com/OPM/opm-$repo.git
done
mkdir build
for repo in common grid models
do
mkdir build/opm-$repo
cd build/opm-$repo
cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
make -j5 opm$repo
cd ../..
done
mkdir build/opm-simulators
cd build/opm-simulators
cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators
make -j5 flow
cd ../..
.. tip::

You can create a .sh file (e.g., build_opm_mpi.sh), copy the previous lines, and run in the terminal **source build_opm_mpi.sh**

Source build in macOS
+++++++++++++++++++++
For macOS, there are no available binary packages, so OPM Flow needs to be built from source, in addition to the dune libraries
(see the `prerequisites <https://opm-project.org/?page_id=239>`_, which can be installed using macports or brew). This can be achieved by the following lines:

.. code-block:: console
CURRENT_DIRECTORY="$PWD"
for module in common geometry grid istl
do git clone https://gitlab.dune-project.org/core/dune-$module.git --branch v2.9.1
done
for module in common geometry grid istl
do ./dune-common/bin/dunecontrol --only=dune-$module cmake -DCMAKE_DISABLE_FIND_PACKAGE_MPI=1
./dune-common/bin/dunecontrol --only=dune-$module make -j5
done
for repo in common grid models simulators
do
git clone https://github.com/OPM/opm-$repo.git
done
mkdir build
for repo in common grid models
do
mkdir build/opm-$repo
cd build/opm-$repo
cmake -DUSE_MPI=0 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
make -j5 opm$repo
cd ../..
done
mkdir build/opm-simulators
cd build/opm-simulators
cmake -DUSE_MPI=0 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators
make -j5 flow
cd ../..
In addition, use at least a Python version of 3.10 (due to the resdata Python package).
14 changes: 0 additions & 14 deletions docs/_sources/introduction.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,3 @@ where
- \-y: Vector of y-coarsening (`` by default).
- \-z: Vector of z-coarsening (`` by default).
- \-e: Use `utf8` or `ISO-8859-1` encoding to read the deck (`ISO-8859-1` by default).

Installation
------------
See the `Github page <https://github.com/cssr-tools/pycopm>`_.

.. tip::
Check the `CI.yml <https://github.com/cssr-tools/pycopm/blob/main/.github/workflows/CI.yml>`_ file.

Getting started
---------------
See the :doc:`examples <./examples>`.

.. tip::
Check the `tests <https://github.com/cssr-tools/pycopm/blob/main/tests>`_.
7 changes: 4 additions & 3 deletions docs/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const Search = {

htmlToText: (htmlString, anchor) => {
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
for (const removalQuery of [".headerlinks", "script", "style"]) {
for (const removalQuery of [".headerlink", "script", "style"]) {
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
}
if (anchor) {
Expand Down Expand Up @@ -328,13 +328,14 @@ const Search = {
for (const [title, foundTitles] of Object.entries(allTitles)) {
if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
for (const [file, id] of foundTitles) {
let score = Math.round(100 * queryLower.length / title.length)
const score = Math.round(Scorer.title * queryLower.length / title.length);
const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
normalResults.push([
docNames[file],
titles[file] !== title ? `${titles[file]} > ${title}` : title,
id !== null ? "#" + id : "",
null,
score,
score + boost,
filenames[file],
]);
}
Expand Down
1 change: 1 addition & 0 deletions docs/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration_file.html">Configuration file</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">pycopm Python API</a></li>
Expand Down
1 change: 1 addition & 0 deletions docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration_file.html">Configuration file</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">pycopm Python API</a><ul>
Expand Down
5 changes: 3 additions & 2 deletions docs/configuration_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Introduction" href="introduction.html" />
<link rel="prev" title="Installation" href="installation.html" />
</head>

<body class="wy-body-for-nav">
Expand All @@ -48,6 +48,7 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Configuration file</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">pycopm Python API</a></li>
Expand Down Expand Up @@ -224,7 +225,7 @@ <h1>Configuration file<a class="headerlink" href="#configuration-file" title="Li
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="introduction.html" class="btn btn-neutral float-left" title="Introduction" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="installation.html" class="btn btn-neutral float-left" title="Installation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="examples.html" class="btn btn-neutral float-right" title="Examples" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>

Expand Down
1 change: 1 addition & 0 deletions docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration_file.html">Configuration file</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#via-configuration-files">Via configuration files</a><ul>
Expand Down
1 change: 1 addition & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration_file.html">Configuration file</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">pycopm Python API</a></li>
Expand Down
Loading

0 comments on commit c80019d

Please sign in to comment.