#14772 Python: Add WellPathCollection.import_well_log_files as object method and forward importWellLogFiles to it

RimWellPathCollection_importWellLogFiles imports LAS files given
explicitly and/or all LAS files in a folder. RicfImportWellLogFiles
forwards to it.

Project.import_well_paths() and Project.import_well_log_files() in
Python now call the object methods on the well path collection. Their
signatures and return values are unchanged, so no deprecation.
This commit is contained in:
Kristian Bendiksen committed 2026-09-22 14:19:23 +02:00
1 parent 06d6e2da65
commit b60ccf1f83
3 files changed
+72 -82

No files matched your search

+10 -14
View File
@@ -395,7 +395,7 @@ def import_well_paths(self, well_path_files=None, well_path_folder=""):
"""Import well paths into project
Arguments:
well_path_files(list): List of file paths to import
well_path_files(list): list of file paths to import
well_path_folder(str): A folder path containing files to import
Returns:
@@ -404,13 +404,11 @@ def import_well_paths(self, well_path_files=None, well_path_folder=""):
if well_path_files is None:
well_path_files = []
res = self._execute_command(
importWellPaths=Commands_pb2.ImportWellPathsRequest(
wellPathFolder=well_path_folder, wellPathFiles=well_path_files
)
names = self.well_path_collection().import_well_paths(
well_path_files=well_path_files, well_path_folder=well_path_folder
)
well_paths = []
for well_path_name in res.importWellPathsResult.wellPathNames:
for well_path_name in names.values:
well_paths.append(self.well_path_by_name(well_path_name))
return well_paths
@@ -444,21 +442,19 @@ def import_well_log_files(self, well_log_files=None, well_log_folder=""):
"""Import well log files into project
Arguments:
well_log_files(list): List of file paths to import
well_log_files(list): list of file paths to import
well_log_folder(str): A folder path containing files to import
Returns:
A list of well path names (strings) that had logs imported
A list of well path names (strings)
"""
if well_log_files is None:
well_log_files = []
res = self._execute_command(
importWellLogFiles=Commands_pb2.ImportWellLogFilesRequest(
wellLogFolder=well_log_folder, wellLogFiles=well_log_files
)
names = self.well_path_collection().import_well_log_files(
well_log_files=well_log_files, well_log_folder=well_log_folder
)
return res.importWellLogFilesResult.wellPathNames
return list(names.values)
@add_method(Project)
@@ -344,6 +344,33 @@ def test_import_well_log_files(rips_instance, initialize_test):
assert "RIPS_TEST" in well_path_names
def test_import_well_paths_and_logs_object_methods(rips_instance, initialize_test):
collection = rips_instance.project.well_path_collection()
# Import by folder: both .dev files in the test model folder
names = collection.import_well_paths(
well_path_folder=dataroot.PATH + "/TEST10K_FLT_LGR_NNC"
)
assert sorted(names.values) == ["Well Path A", "Well Path B"]
assert len(rips_instance.project.well_paths()) == 2
with pytest.raises(rips.RipsError):
collection.import_well_paths(well_path_files=["/does/not/exist.dev"])
with pytest.raises(rips.RipsError):
collection.import_well_paths()
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
las_path = os.path.join(tmpdirname, "rips_test.las")
with open(las_path, "w") as las_file:
las_file.write(_MINIMAL_LAS)
names = collection.import_well_log_files(well_log_files=[las_path])
assert list(names.values) == ["RIPS_TEST"]
with pytest.raises(rips.RipsError):
collection.import_well_log_files()
def test_exportSnapshots(rips_instance, initialize_test):
if not rips_instance.is_gui():
pytest.skip("Cannot run test without a GUI")