Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync main into dev #97

Merged
merged 11 commits into from
Nov 6, 2024
53 changes: 35 additions & 18 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,58 @@ coverage:
status:
project:
default:
# basic
target: auto
threshold: 5
base: auto
threshold: 5%
paths:
- "src/"
- "tests/"
libsansmic:
target: auto
threshold: 5%
paths:
- "src/ext_modules/**/*.cpp"
- "src/ext_modules/**/*.c"
sansmic-py:
target: auto
threshold: 5%
paths:
- "src/python/**"
tests:
target: 100%
paths:
- "tests/**"
patch:
default:
target: auto
threshold: 5%
only_pulls: true
paths:
- "src/"
- "tests/"
# advanced settings
branches:
- main
- dev
if_ci_failed: error #success, failure, error, ignore
informational: false
only_pulls: false

comment:
layout: "header, diff, components" # show component info in the PR comment
layout: "condensed_header, condensed_diff, condensed_files, components" # show component info in the PR comment
require_changes: false
hide_project_coverage: false
behavior: new

component_management:
default_rules:
statuses:
- type: project
target: auto
branches:
- "!main"
- type: patch
individual_components:
- component_id: module_python
name: python code
name: python package
paths:
- src/python/**
- component_id: module_ext
name: C++ code
name: external modules
paths:
- src/ext_modules/**
- src/ext_modules/**/*.cpp
- src/ext_modules/**/*.c
- component_id: module_tests
name: tests
name: tests and examples
target: 100%
paths:
- tests/**
3 changes: 1 addition & 2 deletions .github/workflows/test-continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ jobs:

- name: Upload coverage reports to Codecov
if: success() || failure()
continue-on-error: true
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ inputs.os }}

- name: Test uninstall
if: success() || failure()
# Allow upload to codecov to fail but not fail all tests
run: python3 -m pip uninstall -y sansmic
87 changes: 49 additions & 38 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
- '!docs/conf.py'

workflow_dispatch:
inputs:
skip_coverage:
default: true
required: false
type: boolean

permissions:
contents: read

jobs:
test-all-versions-oses:
platforms:
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -60,52 +55,68 @@
run: |
python3 -m pip install --upgrade pip

- name: Action | Test editable build
run: python3 -m pip install -e .[formats,examples,tests]
- name: Action | Test installation
run: python3 -m pip install .[formats,examples,tests]

- name: Action | Test without coverage on Python 3.9 or if requested
if: ${{ (github.event == 'workflow_dispatch' && inputs.skip_coverage) || (matrix.os != 'ubuntu-latest' && matrix.version == '3.9') }}
- name: Action | Test package and examples
run: |
python3 -m pytest --nbmake --disable-warnings --no-header --color=auto examples/ tests/ >> $GITHUB_STEP_SUMMARY

- name: Action | Coverage and testing Linux - Python and C++ coverage
if: ${{ (github.event == 'pull_request' || ! inputs.skip_coverage ) && matrix.os == 'ubuntu-latest' && matrix.version != '3.9'}}
- name: Action | Test uninstall process
# Allow upload to codecov to fail but not fail all tests
run: python3 -m pip uninstall -y sansmic

coverage:
runs-on: ubuntu-latest
steps:
- name: Setup | Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.codecov.io:443
api.github.com:443
cli.codecov.io:443
codecov.io:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
storage.googleapis.com:443
uploader.codecov.io:443

- name: Setup | Check out the commit
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup | Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'

- name: Setup | Install dependencies
run: |
python3 -m pip install --upgrade pip
Dismissed Show dismissed Hide dismissed
python3 -m pip install -r requirements.txt
Dismissed Show dismissed Hide dismissed
python3 -m pip install gcovr==5.0
Dismissed Show dismissed Hide dismissed

- name: Setup | Install editable build
run: python3 -m pip install -e .[formats,examples,tests]

Dismissed Show dismissed Hide dismissed
- name: Action | Test package and examples and get coverage results
run: |
export CPPFLAGS="-coverage"
python3 -m pip install setuptools pybind11 gcovr
python3 setup.py build_ext --inplace --force
echo '### Run tests' >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
python3 -m pytest --nbmake --disable-warnings --cov=sansmic --cov=tests --no-header --color=auto examples/ tests/ | tee -a $GITHUB_STEP_SUMMARY
find src -type f -name '*.cpp' | xargs -I{} gcov -o build/temp*/src/ext_modules/libsansmic {}
gcovr --txt | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

- name: Action | Coverage and testing on MacOS - Python coverage only
if: ${{ (github.event == 'pull_request' || ! inputs.skip_coverage ) && matrix.os != 'windows-latest' && matrix.os != 'ubuntu-latest' }}
run: |
echo '### Run tests' >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
python3 -m pytest --nbmake --disable-warnings --cov=sansmic --cov=tests --no-header --color=auto examples/ tests/ | tee -a $GITHUB_STEP_SUMMARY
echo ' ' >> $GITHUB_STEP_SUMMARY
gcovr --txt -s -k | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

- name: Action | Coverage and testing on Windows - Python coverage only
if: ${{ (github.event == 'pull_request' || ! inputs.skip_coverage ) && matrix.os == 'windows-latest' }}
shell: powershell
run: |
echo '### Run tests' >> $Env:GITHUB_STEP_SUMMARY
echo '```bash' >> $Env:GITHUB_STEP_SUMMARY
python3 -m pytest --nbmake --disable-warnings --cov=sansmic --cov=tests --no-header --color=auto examples/ tests/ >> $Env:GITHUB_STEP_SUMMARY
echo '```' >> $Env:GITHUB_STEP_SUMMARY

- name: Action | Upload coverage reports to Codecov
if: ${{ (github.event == 'pull_request' || ! inputs.skip_coverage) && success() || failure() }}
if: success() || failure()
continue-on-error: true
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.os }}

- name: Action | Test uninstall process
if: success() || failure()
# Allow upload to codecov to fail but not fail all tests
run: python3 -m pip uninstall -y sansmic
64 changes: 41 additions & 23 deletions docs/um/scenarios.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ be defined for **each** stage
* :confval:`injection-duration`
* :confval:`rest-duration`
* :confval:`brine-injection-sg`
* :confval:`brine-injection-depth`
* :confval:`brine-production-depth`
* :confval:`brine-injection-depth` xor :confval:`brine-injection-height`
* :confval:`brine-production-depth` xor :confval:`brine-production-height`
* :confval:`brine-injection-rate`


The keys which are required for at least the **first** stage are

* :confval:`set-cavern-sg`
* :confval:`brine-interface-depth`
* :confval:`brine-interface-depth` xor :confval:`brine-interface-height`


The keys which can be set using the ``[defaults]`` section
Expand Down Expand Up @@ -528,25 +528,37 @@ number of stages. A stage **requires** a title key.


.. confval:: brine-injection-depth
.. confval:: brine-injection-height

The *height* above the original :confval:`floor-depth` of the cavern
The *depth* (preferred) or *height* within the cavern
where the EOT for the injection string is located. If above the
production depth, it will be assigned to the outer casing,
otherwise it will apply to the inner casing.
This value is specified in :term:`foot` above :confval:`floor-depth`.
Changing depth values to handle measured depths below surface
is the second-highest priority update.

The :confval:`brine-injection-depth` is specified in :term:`foot`
below the :term:`ZDP` at the surface.

The :confval:`brine-injection-height` is specified in :term:`foot`
above the original :confval:`floor-depth`

Do not use both -depth and -height options.


.. confval:: brine-production-depth
.. confval:: brine-production-height

The *height* above the original :confval:`floor-depth` of the cavern
The *depth* (preferred) or *height* within the cavern
where the EOT for the injection string is located. If above the
injection depth, it will be assigned to the outer casing,
otherwise it will apply to the inner casing.
This value is specified in :term:`foot` above :confval:`floor-depth`.
Changing depth values to handle measured depths below surface
is the second-highest priority update.

The :confval:`brine-production-depth` is specified in :term:`foot`
below the :term:`ZDP` at the surface.

The :confval:`brine-production-height` is specified in :term:`foot`
above the original :confval:`floor-depth`

Do not use both -depth and -height options.


.. confval:: brine-injection-rate
Expand All @@ -558,18 +570,23 @@ number of stages. A stage **requires** a title key.


.. confval:: brine-interface-depth
.. confval:: brine-interface-height

The initial brine interface depth in *height* above the
:confval:`floor-depth`. This is only required for the first stage, and
The initial brine interface *depth* (preferred) or *height*
within the cavern. This is only required for the first stage, and
should not be set in subsequent stages unless you *want* to
manually reset the interface position. If so, you should also
set :confval:`set-initial-conditions` to true. If left blank or set
to 0, it will behave as if unset and use the value from the
previous stage.

Specified in :term:`foot` above :confval:`floor-depth`.
Changing depth values to handle measured depths below surface
is the second-highest priority update.
The :confval:`brine-interface-depth` is specified in :term:`foot`
below the :term:`ZDP` at the surface.

The :confval:`brine-interface-height` is specified in :term:`foot`
above the original :confval:`floor-depth`

Do not use both -depth and -height options.


.. confval:: set-cavern-sg
Expand All @@ -580,16 +597,17 @@ number of stages. A stage **requires** a title key.
for the first stage, it will be set to the maximum brine
specific gravity.

*Changed: v1.0.6*

The SANSMIC user guide from 2015 had an error, and stated that
subsequent stages did not use this value. In fact, this value
was still being set unless it was set to 1.0 or less. This
version of sansmic will give a warning when converting files
but behave *as was described in the user manual*. If you want
to replicate the old behavior, set :confval:`set-initial-conditions`
was still being set unless it was set to 1.0 or less.

sansmic will behave *as was described in the user manual*. To
replicate the old behavior, set :confval:`set-initial-conditions`
to true to force initialization of the cavern brine to the value
you specify in this key. You can also set this to 0.0 in an
old DAT file to force the proper behavior of continuing between
stages.
you specify in this key. (You can also set this to 0.0 in an
old DAT file to force this behavior in the FORTRAN version)


.. confval:: set-initial-conditions
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions examples/regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -28,7 +28,7 @@
"import matplotlib.pylab as plt\n",
"\n",
"model = sansmic.io.read_scenario(\"baseline.dat\")\n",
"tstF = sansmic.io.read_tst_file(\"baseline\")\n",
"tstF = sansmic.io.read_tst_file(\"baseline.tst.txt\")\n",
"resF = sansmic.io.read_json_results(\"baseline.json\")"
]
},
Expand Down Expand Up @@ -98,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -107,7 +107,7 @@
") as sim:\n",
" sim.run_sim()\n",
"resPy = sim.results\n",
"tstPy = sansmic.io.read_tst_file(\"regression\")"
"tstPy = sansmic.io.read_tst_file(\"regression.tst\")"
]
},
{
Expand Down
Loading