Skip to content

Commit

Permalink
Merge branch 'master' into fb-PWPA-2308-release-0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Rosenbach committed Dec 18, 2024
2 parents 63e17d3 + 68aa8df commit 18e8eb9
Show file tree
Hide file tree
Showing 27 changed files with 1,629 additions and 528 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keep GitHub Actions up to date with GitHub's Dependabot...
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: weekly
16 changes: 8 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ jobs:
if: startsWith(github.event.ref, 'refs/tags')

runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.x"
- name: Install build
run: |
python -m pip install --upgrade pip
Expand All @@ -27,11 +30,8 @@ jobs:
run: |
python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_token }}
uses: pypa/[email protected]
- name: GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand All @@ -37,7 +37,7 @@ jobs:
tox -e py
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
uses: codecov/codecov-action@v5.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
29 changes: 27 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,32 @@ Features
-----------

* Converter from Score input JSON to Alfacase
* Parser for the ALFAsim results
* Parser for the ALFAsim results and generate a JSON compatible with SCORE

How to use it
-------------
#. First, the user needs to create an instance of the converter::

from pathlib import Path
from alfasim_score.converter.alfacase.alfasim_score_converter import AlfasimScoreConverter
# path indicating where the SCORE input file is
score_input_filepath = Path("path/to/score_input.json")
# path indicating where the output file (converted from ALFAsim results) should be created
score_output_filepath = Path("path/to/score_output_result.json")
# then create a converter instance
converter = AlfasimScoreConverter(score_input_filepath, score_output_filepath)

#. To convert the SCORE input into an alfacase file, the user can do the following::

alfacase_filepath = Path("path/where/save/converted_score.alfacase")
converter.generate_alfasim_input_file(alfacase_filepath)

#. Run the ALFAsim with the generated file (and the pvt tables in the same folder)

#. Once the result file of ALFAsim is generated, one can call the converter for the output file::

alfasim_results_directory = Path("path/to/alfasim_results_folder")
converter.generate_score_output_file(alfasim_results_directory)


Development
Expand Down Expand Up @@ -91,7 +116,7 @@ Ex.: v1.0.5
1. Create a ``release-VERSION`` branch from ``upstream/master``.
2. Update ``CHANGELOG.rst``.
3. Push a branch with the changes.
4. Once all builds pass, push a ``VERSION`` tag to ``upstream``.
4. Once all builds pass, push a ``VERSION`` tag to ``upstream``. Ex: ``git tag v1.0.5; git push origin --tags``
5. Merge the PR.


Expand Down
1 change: 0 additions & 1 deletion src/alfasim_score/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from dataclasses import dataclass
from dataclasses import field
from enum import Enum
from pathlib import Path

from alfasim_score.constants import AIR_DENSITY_STANDARD
from alfasim_score.constants import WATER_DENSITY_STANDARD
Expand Down
26 changes: 10 additions & 16 deletions src/alfasim_score/conftest.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import pytest
from alfasim_sdk import PluginDescription
from barril.units import Array
from barril.units import Scalar
from enum import Enum
from pathlib import Path

from alfasim_score.common import Annuli
from alfasim_score.common import Annulus
from alfasim_score.common import AnnulusDepthTable
from alfasim_score.common import AnnulusModeType
from alfasim_score.common import FluidModelPvt
from alfasim_score.common import SolidMechanicalProperties
from alfasim_score.converter.alfacase.base_operation import BaseOperationBuilder
from alfasim_score.converter.alfacase.convert_alfacase import ScoreAlfacaseConverter
from alfasim_score.converter.alfacase.injection_operation import InjectionOperationBuilder
Expand All @@ -33,20 +23,24 @@ def alfacase_gas_lift(score_input_gas_lift: ScoreInputReader) -> ScoreAlfacaseCo


@pytest.fixture
def base_operation_gas_lift(shared_datadir: Path) -> BaseOperationBuilder:
return BaseOperationBuilder(shared_datadir / SCORE_GAS_LIFT_EXAMPLE_FILENAME)
def base_operation_gas_lift(score_input_gas_lift: ScoreInputReader) -> BaseOperationBuilder:
return BaseOperationBuilder(score_input_gas_lift)


@pytest.fixture
def production_operation_gas_lift(shared_datadir: Path) -> ProductionOperationBuilder:
return ProductionOperationBuilder(shared_datadir / SCORE_GAS_LIFT_EXAMPLE_FILENAME)
def production_operation_gas_lift(
score_input_gas_lift: ScoreInputReader,
) -> ProductionOperationBuilder:
return ProductionOperationBuilder(score_input_gas_lift)


@pytest.fixture
def production_operation_natural_flow(shared_datadir: Path) -> ProductionOperationBuilder:
return ProductionOperationBuilder(shared_datadir / SCORE_NATURAL_FLOW_EXAMPLE_FILENAME)
score_input_reader = ScoreInputReader(shared_datadir / SCORE_NATURAL_FLOW_EXAMPLE_FILENAME)
return ProductionOperationBuilder(score_input_reader)


@pytest.fixture
def injection_operation(shared_datadir: Path) -> InjectionOperationBuilder:
return InjectionOperationBuilder(shared_datadir / SCORE_INJECTION_EXAMPLE_FILENAME)
score_input_reader = ScoreInputReader(shared_datadir / SCORE_INJECTION_EXAMPLE_FILENAME)
return InjectionOperationBuilder(score_input_reader)
4 changes: 3 additions & 1 deletion src/alfasim_score/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from alfasim_score.units import PRESSURE_UNIT
from alfasim_score.units import ROUGHNESS_UNIT
from alfasim_score.units import STD_VOLUMETRIC_FLOW_RATE_UNIT
from alfasim_score.units import TIME_UNIT

WELLBORE_NAME = "WELLBORE"
WELLBORE_TOP_NODE_NAME = "WELLBORE_TOP_NODE"
Expand Down Expand Up @@ -64,3 +63,6 @@
# set default value for annulus for the plugin APB
# there is no such option in the SCORE input so use this default value
HAS_FLUID_RETURN = True

# total number of walls in the output
TOTAL_WALLS = 6
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from pytest_regressions.file_regression import FileRegressionFixture

from alfasim_score.converter.alfacase.converter_main import convert_score_to_alfacase
from alfasim_score.converter.alfacase.alfasim_score_converter import AlfasimScoreConverter


@pytest.mark.parametrize(
Expand All @@ -12,8 +12,11 @@ def test_create_alfacase_file(
shared_datadir: Path, datadir: Path, file_regression: FileRegressionFixture, score_filename: str
) -> None:
score_input = shared_datadir / f"{score_filename}.json"
alfacase_output = datadir / f"{score_filename}.alfacase"
convert_score_to_alfacase(score_input, alfacase_output)
converted_alfacase_filepath = datadir / f"{score_filename}.alfacase"
converter = AlfasimScoreConverter(score_input, Path("score_output/dummy.json"))
converter.generate_alfasim_input_file(converted_alfacase_filepath)
file_regression.check(
alfacase_output.read_text(encoding="utf-8"), encoding="utf-8", extension=".alfacase"
converted_alfacase_filepath.read_text(encoding="utf-8"),
encoding="utf-8",
extension=".alfacase",
)
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,22 @@ outputs:
- mixture temperature
- pressure
- environment temperature
- annulus_a_temperature
- annulus_b_temperature
- annulus_c_temperature
- annulus_d_temperature
- annulus_e_temperature
- annulus_a_pressure
- annulus_b_pressure
- annulus_c_pressure
- annulus_d_pressure
- annulus_e_pressure
- wall_0_temperature
- wall_1_temperature
- wall_2_temperature
- wall_3_temperature
- wall_4_temperature
- wall_5_temperature
location: main
element_name: WELLBORE
profile_frequency:
Expand Down
27 changes: 12 additions & 15 deletions src/alfasim_score/converter/alfacase/_tests/test_output_results.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import json
import pandas as pd
import pytest
from barril.units import Scalar
from pathlib import Path
from pytest_regressions.file_regression import FileRegressionFixture

from alfasim_score.common import AnnulusLabel
from alfasim_score.converter.alfacase.score_output_generator import ScoreOutputGenerator
from alfasim_score.converter.alfacase.alfasim_score_converter import AlfasimScoreConverter


def test_generate_output_file_results(
shared_datadir: Path, datadir: Path, file_regression: FileRegressionFixture
) -> None:
alfasim_results_directory = shared_datadir / "case.data"
well_start_position = Scalar(2072, "m")
active_annuli = [AnnulusLabel.A, AnnulusLabel.B, AnnulusLabel.C]
output_generator = ScoreOutputGenerator(
alfasim_results_directory, well_start_position, active_annuli
)
output_generator.element_name = "7-SRR-2-RJS (2022-07-28_15-01-27)"
output_filepath = datadir / "output_score.json"
output_generator.generate_output_file(datadir / "output_score.json")
output_content = output_filepath.read_text(encoding="utf-8")
alfasim_results_path = shared_datadir / "case.data"
# dummy input file just to have the reader for this test
score_input_file = shared_datadir / "score_input_natural_flow.json"
output_file = datadir / "output_score.json"
converter = AlfasimScoreConverter(score_input_file, output_file)
# change the element name to match this test result well name
converter.output_builder.element_name = "7-SRR-2-RJS (2022-07-28_15-01-27)"
# TODO: remember to get these annuli inside the output class
converter.output_builder.active_annuli = [AnnulusLabel.A, AnnulusLabel.B, AnnulusLabel.C]
converter.generate_score_output_file(alfasim_results_path)
output_content = converter.output_builder.score_output_filepath.read_text(encoding="utf-8")
file_regression.check(output_content, extension=".json", encoding="utf-8")
Loading

0 comments on commit 18e8eb9

Please sign in to comment.