Commit Graph
161 Commits
Author SHA1 Message Date
lechevaa cd3d5c2bbd Remove zero newton iterations assert for all_cases test 2025-10-09 13:03:53 +02:00
lechevaa 095b703005 Remove zero Newton iteration assert 2025-10-09 13:01:48 +02:00
Arne Morten Kvarving 1d757283dc don't use pytest and fix include paths 2025-10-08 15:21:26 +02:00
Arne Morten Kvarving 3c365a428a move hybrid newton test to an integration test directory
this is not a unit test for the python binaries
2025-10-08 14:41:58 +02:00
Arne Morten Kvarving 66b037d9a7 write output to cwd 2025-10-08 14:40:38 +02:00
Arne Morten Kvarving 7b0aeb1a4b (optionally) read path to flow binary from FLOW_BINARY environment variable 2025-10-08 14:40:12 +02:00
Arne Morten Kvarving 6a3c38721f fix import path for kerasify 2025-10-08 14:37:01 +02:00
lechevaa 372be6832c Remove tensorflow dependency of hybrid newton test 2025-10-08 13:45:22 +02:00
lechevaa 6a41fe4060 Remove "|" type for Python < 3.10 compatibility 2025-10-08 11:20:43 +02:00
lechevaa c26ca82c45 Fix hybrid newton python tests imports 2025-10-08 08:44:09 +02:00
David Landa-Marbán 2d327a6d32 Merge pull request #6424 from lechevaa/HybridNewton_flag
Hybrid newton flag
2025-10-06 09:51:37 +02:00
David Landa Marban 1fd280c68d Removing trailing spaces and adding eol at eof 2025-10-02 10:22:55 +02:00
lechevaa 5796d57604 Hybrid Newton Python tests and C++ refactoring 2025-09-29 10:59:55 +02:00
Arne Morten Kvarving 0afc5f352a Merge pull request #6482 from svenn-t/pysinglephase
Python one-phase (water) simulator
2025-09-23 15:24:02 +02:00
Arne Morten Kvarving 5efbb736aa Merge pull request #6492 from hakonhagland/docker_debugging
Improved python docker unit tests debugging
2025-09-23 13:24:12 +02:00
Svenn Tveit 8eaa56885d Use docstring template for OnePhaseSimulator documentation 2025-09-23 13:20:42 +02:00
Svenn Tveit 116e22e58c Safe creation of OnePhaseSimulator object in tests 2025-09-23 13:20:10 +02:00
Svenn Tveit 46559c532f Adressed review comments 2025-09-23 12:54:28 +02:00
Svenn Tveit fc3e1bb73f Tests for OnePhaseSimulator 2025-09-23 12:54:27 +02:00
Svenn Tveit 5153cd6fc0 Add OnePhaseSimulator to custom Python target 2025-09-23 12:52:46 +02:00
Svenn Tveit d0c08c4382 Python wrapper of single phase (water) simulator 2025-09-23 12:52:46 +02:00
Håkon Hægland bd402ee230 Fix auto-detection by not setting PYTHON_VERSIONS when not specified
The auto-detection wasn't working because the
CLI was always setting PYTHON_VERSIONS environment variable to all supported
versions when --python-versions was not provided.

Changes:
- click_helpers.py: Return None instead of all versions when option not provided
- helpers.py: Only set PYTHON_VERSIONS env var when explicitly specified
- main.py: Update type hints to allow None for python_versions parameter

Now the flow works correctly:
1. No --python-versions CLI option -> python_versions = None
2. None passed to Docker -> no PYTHON_VERSIONS env var set
3. Container auto-detects installed versions using pyenv
4. Tests run only on detected versions
2025-09-23 12:42:48 +02:00
Håkon Hægland 85344a3998 Auto-detect installed Python versions at runtime
When no --python-versions is specified at
runtime, auto-detect which Python versions are actually installed in the
container instead of defaulting to all versions from python_versions.json.

This resolves the issue where:
1. Building with --python-versions=3.12 installs only Python 3.12
2. Running without --python-versions would try to test all versions from JSON
3. Tests would fail for non-installed versions (3.8, 3.9, 3.10, 3.11, 3.13)

Now the runtime logic:
1. Uses `pyenv versions --bare` to detect installed versions
2. Maps full versions (3.12.9) to short versions (3.12)
3. Uses detected versions as default for testing
4. Falls back to JSON versions if detection fails

Example behavior:
- Build: --python-versions=3.12 (installs only 3.12.9)
- Runtime: auto-detects 3.12, tests only that version
- Explicit: --python-versions=3.11,3.12 still works as before
2025-09-23 11:46:27 +02:00
Håkon Hægland 412773785e Remove references to original behavior 2025-09-23 09:23:58 +02:00
Arne Morten Kvarving fafa4d8a19 Merge pull request #6418 from hakonhagland/docstring-template-refactor
Add support for Python docstring.json template format
2025-09-23 08:36:05 +02:00
Arne Morten Kvarving 7679d64ed1 Merge pull request #6488 from svenn-t/fix_pygaswater_tests
Fix Python gas-water simulator test failures
2025-09-23 08:31:49 +02:00
Håkon Hægland f355be1c65 Add debugging documentation for Docker wheel testing
Adds detailed documentation covering all debugging features implemented
in recent commits:

python/docker/test_wheels/scripts/README.md:
- New "Debugging" section with complete workflow examples
- Python version selection for faster builds (--python-versions)
- Focused test selection for isolation (--test-cases-common/simulators)
- Continue-on-error mode for comprehensive failure analysis
- Docker-specific debugging strategies
- Updated CLI option documentation

python/docker/README.md:
- Added debugging section reference with feature highlights
- Links to detailed debugging documentation
2025-09-23 08:31:34 +02:00
Håkon Hægland ac20e8ed87 Add --stop-on-error option for Docker wheel testing
Adds a new CLI option to control test execution behavior when failures occur:
- Without --stop-on-error (default): Continue running all tests even if some fail
- With --stop-on-error: Stop execution on first test failure (previous behavior)

This enables comprehensive debugging by running both opm-common and omp-simulators
tests in a single run, showing all failures at once rather than stopping at the first one.

Changes:
- Add --stop-on-error flag to run-docker-image command
- Pass STOP_ON_ERROR environment variable to Docker container
- Update entrypoint.py to handle continue-on-error behavior
- Modify test functions to check return codes and continue when appropriate
- Maintain backward compatibility with existing error handling
2025-09-23 08:13:53 +02:00
Håkon Hægland ddf2e3d338 Add Python version selection to Docker image builds
This enhancement allows specifying which Python versions to install during
Docker image builds, significantly reducing build times when only testing
specific Python versions during debugging.

Changes:
- Add --python-versions option to build-docker-image command
- Pass BUILD_PYTHON_VERSIONS build argument to Docker
- Update install_python_versions.py to respect BUILD_PYTHON_VERSIONS env var
- Validate requested versions against supported versions in python_versions.json
- Maintain backward compatibility (installs all versions if not specified)

Usage examples:
  # Build with only Python 3.12 (much faster for debugging)
  opm-wheels build-docker-image --docker-os="ubuntu-24.04" --python-versions="3.12"

  # Build with multiple specific versions
  omp-wheels build-docker-image --python-versions="3.11,3.12"

  # Build with all versions (original behavior)
  opm-wheels build-docker-image

Benefits:
- Reduces build time from ~7 minutes to ~2 minutes for single Python version
- Enables faster iteration during debugging of Docker-specific issues
- Particularly valuable when combined with --test-cases-* for focused testing
2025-09-23 07:06:24 +02:00
Håkon Hægland 0b8926c475 Add focused test selection for Docker wheel testing
This enhancement adds the ability to run specific test cases in the Docker
testing infrastructure, enabling more focused debugging and faster iteration
when investigating test failures.

Changes:
- Add --test-cases-common and --test-cases-simulators CLI options to opm-wheels
- Pass test selection as environment variables to Docker container
- Update entrypoint.py to support selective test execution:
  * Run only opm-common tests when --test-cases-common is specified
  * Run only opm-simulators tests when --test-cases-simulators is specified
  * Maintain backward compatibility (run all tests if no selection specified)
- Support both host-tests-dir and cloned repo testing modes

Usage examples:
  # Run only esmry tests from opm-common
  opm-wheels run-docker-image --test-cases-common=esmry

  # Run only basic tests from opm-simulators
  opm-wheels run-docker-image --test-cases-simulators=basic

  # Run specific tests from both suites
  opm-wheels run-docker-image --test-cases-common=esmry --test-cases-simulators=mpi

This enables efficient debugging of Docker-specific test failures by isolating
problematic test cases without running the full test suite.
2025-09-23 06:48:20 +02:00
Håkon Hægland c195df978d Refactor: Use factory fixtures for simulator creation in tests
Move simulator instantiation to factory functions that automatically
disable async ECL output. This prevents future contributors from
forgetting the --enable-async-ecl-output=false flag.

- Add create_black_oil_simulator/create_gas_water_simulator to pytest_common
- Define ENABLE_ASYNC_ECL_OUTPUT_FLAG constant
- Update all tests to use factory functions
- No functional changes, pure refactoring
2025-09-23 05:09:20 +02:00
Håkon Hægland 831354a0db Fix race condition in Python tests by disabling async ECL output
Add --enable-async-ecl-output=false to all Python simulator tests to prevent
race condition between async file writing tasklets and pushd context manager.

Problem:
- Tests use pushd() to change directory before running simulations
- Simulator dispatches async tasklets to write ECL output files
- pushd context exits before async writes complete
- Tasklets write files in wrong directory (build/python/ instead of test_data/)
- Causes confusing error messages and misplaced output files

Solution:
- Disable async ECL output during tests for deterministic behavior
- Files now created in correct locations within test_data/ directories
- Eliminates "Can not open EclFile" errors in logs
- Makes test execution predictable and synchronous
2025-09-22 20:46:10 +02:00
Svenn Tveit b79d16c3e8 Fix failures in docker tests 2025-09-19 14:18:22 +02:00
David Landa Marban d3101a9c80 BIOFILM effects for gas-water systems 2025-09-18 11:15:48 +02:00
Håkon Hægland 2f6bf952e1 Use new docstring format for python modules 2025-09-17 15:35:17 +02:00
Arne Morten Kvarving 26660b6640 python packaging: update to use python_simulator_modules target 2025-09-17 14:53:52 +02:00
Håkon Hægland 7552aec2c0 Update CMakeLists.txt to pass simulator type to docstring generator
- Add 'BlackOil' as 5th parameter to generate_docstring_hpp.py
- Prepares for template-based docstring generation
- Will work with updated opm-common generate_docstring_hpp.py script
2025-09-17 14:47:04 +02:00
Håkon Hægland 6fe5742145 Convert docstrings to template format with simulator configurations
- Create unified template structure with 'simulators', 'constructors', and 'common_methods' sections
- Add support for both BlackOil and GasWater simulators
- Use {{name}} and {{class}} placeholders for template expansion
- Eliminates need for duplicate JSON files
2025-09-17 14:47:02 +02:00
Håkon Hægland 3c6313b619 Custom target to build all simulator modules
Create a convenience target to build all Python simulator modules.
2025-09-17 10:06:50 +02:00
Svenn Tveit 753fcc2ec4 Cleaned up formatting 2025-09-17 10:06:50 +02:00
Svenn Tveit a69e10485b Clarify ordering and clean up doc in rest of the tests 2025-09-17 10:06:50 +02:00
Håkon Hægland b5e7ccc0b1 Clarify why test case ordering is necessary
and delete comment in code about static variables that can no longer be
reproduced.
2025-09-17 10:06:49 +02:00
Svenn Tveit 67a701ef4f Tests for PyGasWaterSimulator 2025-09-17 10:06:49 +02:00
Svenn Tveit 32dd09c78f Add Python gas-water simulator and refactor to template base class
Extend the Python blackoil simulator to support two-phase gas-water
simulations by extracting common functionality into a template base
class and implementing proper module separation.

- Extract PyBaseSimulator<TypeTag> template base class containing all
  common simulator functionality (20+ methods including advance, run,
  step, property access, and MPI handling)
- Add PyGasWaterSimulator for two-phase gas-water simulations using
  FlowGasWaterProblem TypeTag with oil phase disabled
- Split Python modules to avoid ODR violations:
  - BlackOil.so for PyBlackOilSimulator (FlowProblemTPFA)
  - GasWater.so for PyGasWaterSimulator (FlowGasWaterProblem)
- Implement proper template instantiation control with explicit
  instantiations per module

- Eliminate ~400 lines of code duplication between simulators
- Clean inheritance hierarchy: derived classes contain only constructors
- Type-safe specialization through OPM's TypeTag property system
- Separate docstring generation for each simulator type
- Independent build targets with shared infrastructure

- Update CMakeLists.txt to support multiple pybind11 modules
- Add docstrings_gw_simulators.json for gas-water simulator documentation
- Remove centralized Pybind11Exporter.cpp in favor of distributed exports
- Implement proper build dependencies and custom targets

This establishes a scalable foundation for extending OPM's Python
bindings to support additional simulator types (thermal, polymer,
solvent) while maintaining type safety and avoiding symbol conflicts.

Files changed: 21 files, 915 insertions, 428 deletions
2025-09-17 10:06:44 +02:00
Arne Morten Kvarving b44692349e python packaging: enable LTO 2025-09-15 09:53:25 +02:00
Håkon Hægland 53270c95b6 docker: clean pip usage and drop pytest-runner
- Export PIP_ROOT_USER_ACTION=ignore to silence root-user warning in manylinux.
- Remove pytest-runner from build-time pip installs; no longer needed after
  removing setup_requires.
2025-09-12 17:57:33 +02:00
Håkon Hægland ac490531f1 python/docker: finalize pyproject build-system and SPDX license
- Bump setuptools floor to >=61 in pyproject.toml with rationale comments.
- Declare build-backend explicitly; keep classic scikit-build.
- Switch setup.py license to SPDX expression (GPL-3.0-or-later) and remove
  deprecated license classifier, keeping only non-license classifiers.
2025-09-12 16:06:51 +02:00
Håkon Hægland 31716f2cef docker/python: switch to PEP 517 builds via python -m build
- Replace direct setup.py invocations with: python -m build --sdist --wheel
- Add comments explaining motivation (setuptools deprecations, build isolation)
  and why we drop explicit --plat-name/--python-tag (auditwheel/env handles).
- Ensure the build frontend is present per-interpreter by installing 'build'.

Also add build-backend to pyproject.toml with notes and TODO for full modernization.
2025-09-12 16:00:57 +02:00
Håkon Hægland ce3ee6fc98 python: remove deprecated setup.py args (setuptools warnings)
- Drop legacy setup_requires and test_suite to stop
  setuptools _DeprecatedInstaller / fetch_build_eggs and
  unknown distribution option warnings.
- Add inline comment explaining rationale and PEP 517 context.
2025-09-12 15:42:24 +02:00
Håkon Hægland d5664a5f1c python/docker(test_wheels): prefer hyphenated OS names; accept colon input
- Default --docker-os to ubuntu-22.04
- Normalize input (: -> -) for paths/tags
- Fallback to legacy directories pre-rename
- Update docs with Windows compatibility note
2025-09-12 13:08:40 +02:00