Skip to content

Commit 8524b2a

Browse files
committed
Update rips module, proto files, and Python examples
1 parent 1416a20 commit 8524b2a

19 files changed

+121
-122
lines changed

docs/rips/PythonExamples/case_and_grid_operations/case_grid_group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID")
1313

1414
for case_path in case_paths:
15-
assert os.path.exists(
16-
case_path
17-
), "You need to set valid case paths for this script to work"
15+
assert os.path.exists(case_path), (
16+
"You need to set valid case paths for this script to work"
17+
)
1818

1919
case_group = resinsight.project.create_grid_case_group(case_paths=case_paths)
2020

docs/rips/PythonExamples/case_and_grid_operations/case_grid_group_generated_results.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID")
1414

1515
for case_path in case_paths:
16-
assert os.path.exists(
17-
case_path
18-
), "You need to set valid case paths for this script to work"
16+
assert os.path.exists(case_path), (
17+
"You need to set valid case paths for this script to work"
18+
)
1919

2020
case_group = resinsight.project.create_grid_case_group(case_paths=case_paths)
2121

docs/rips/PythonExamples/case_and_grid_operations/result_aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@
6767

6868
try:
6969
alias_result = roff_case.grid_property("STATIC_NATIVE", "PERMX", 0)
70-
except:
70+
except Exception:
7171
print("Result PERMX no longer exists!")

docs/rips/PythonExamples/wells_and_fractures/modeled_well_path_lateral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
# Check that lateral is a lateral
6161
parentWell = lateral.parent_branch()
6262

63-
if parentWell != None:
63+
if parentWell is not None:
6464
print("Parent is " + parentWell.name)
6565

66-
if parentWell.parent_branch() == None:
66+
if parentWell.parent_branch() is None:
6767
print("Parent is top level well.")

docs/rips/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "generated"))
55

6-
from .resinsight_classes import *
6+
from .resinsight_classes import * # noqa: F403
77

88
from .case import Case as Case, EclipseCase as EclipseCase, GeoMechCase as GeoMechCase
99
from .grid import Grid as Grid
@@ -17,15 +17,15 @@
1717
)
1818
from .well_log_plot import WellLogPlot as WellLogPlot
1919
from .well_path import WellPath as WellPath
20-
from . import well_path_collection
20+
from . import well_path_collection as well_path_collection # noqa: F401
2121
from .simulation_well import SimulationWell as SimulationWell
2222
from .exception import RipsError as RipsError
2323
from .surface import RegularSurface as RegularSurface
2424

2525
from typing import List
2626

2727
__all__: List[str] = []
28-
for key in class_dict():
28+
for key in class_dict(): # noqa: F405
2929
__all__.append(key)
3030

3131
# Add classes not in resinsight_classes

docs/rips/contour_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def export_to_text(
3737

3838

3939
@add_method(GeoMechContourMap)
40-
def export_to_text(
40+
def export_to_text( # noqa: F811
4141
self: GeoMechContourMap,
4242
export_file_name: str = "",
4343
export_local_coordinates: bool = False,

docs/rips/instance.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import signal
1515
import sys
1616
import json
17+
import subprocess
1718

1819
import grpc
1920

@@ -164,7 +165,7 @@ def launch(
164165
with tempfile.TemporaryDirectory() as tmp_dir_path:
165166
port_number_file = tmp_dir_path + "/portnumber.txt"
166167
parameters: List[str] = [
167-
"ResInsight",
168+
resinsight_executable,
168169
"--server",
169170
str(requested_port),
170171
"--portnumberfile",
@@ -178,7 +179,8 @@ def launch(
178179
for i in range(0, len(parameters)):
179180
parameters[i] = str(parameters[i])
180181

181-
pid = os.spawnv(os.P_NOWAIT, resinsight_executable, parameters)
182+
process = subprocess.Popen(parameters)
183+
pid = process.pid
182184
if pid:
183185
port = Instance.__read_port_number_from_file(
184186
port_number_file, init_timeout

docs/rips/resinsight_classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .generated.generated_classes import *
1+
from .generated.generated_classes import * # noqa: F403

docs/rips/tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import pytest
22
import sys
33
import os
4+
import multiprocessing
5+
6+
# Use spawn instead of fork to avoid deadlocks with gRPC threads
7+
multiprocessing.set_start_method("spawn", force=True)
48

59
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
6-
import rips
10+
import rips # noqa: E402
711

812
_rips_instance = None
913

docs/rips/tests/test_completion_export.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33

44
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
5-
import rips
65

76
import dataroot
87

@@ -69,9 +68,9 @@ def compare_with_reference(
6968
Raises:
7069
AssertionError: If files don't match or don't exist
7170
"""
72-
assert os.path.exists(
73-
export_file_path
74-
), f"Export {file_description} does not exist: {export_file_path}"
71+
assert os.path.exists(export_file_path), (
72+
f"Export {file_description} does not exist: {export_file_path}"
73+
)
7574

7675
with open(export_file_path, "r") as f:
7776
content = f.read()

0 commit comments

Comments
 (0)