Commit a72501b4 authored by Greg Harris's avatar Greg Harris
Browse files

Merge branch 'main' into 47-soft-mapping-for-osdu-welllog-to-las-file

# Conflicts:
#	src/wbdutil/common/configuration.py
#	src/wbdutil/service/property_mapping.py
#	src/wbdutil/service/well_service.py
parents c0f051bc bffd7c45
......@@ -5,8 +5,8 @@ from unittest.mock import Mock
from . import TARGET_MODULE_NAME
# Test target module import
Configuration = importlib.import_module(f"{TARGET_MODULE_NAME}.configuration").Configuration
IFileLoader = importlib.import_module(f"{TARGET_MODULE_NAME}.file_loader").IFileLoader
Configuration = importlib.import_module(f"{TARGET_MODULE_NAME}.common.configuration").Configuration
IFileLoader = importlib.import_module(f"{TARGET_MODULE_NAME}.common.file_loader").IFileLoader
class TestConfiguration:
......
......@@ -4,7 +4,7 @@ import importlib
from . import TARGET_MODULE_NAME
# Test target module import
environment_var_helper = importlib.import_module(f"{TARGET_MODULE_NAME}.environment_var_helper")
environment_var_helper = importlib.import_module(f"{TARGET_MODULE_NAME}.wrapper.environment_var_helper")
EnvironmentVarHelper = environment_var_helper.EnvironmentVarHelper
MissingArgumentError = environment_var_helper.MissingArgumentError
......
......@@ -4,7 +4,7 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
# Test target module import
file_loader = import_module(f"{TARGET_MODULE_NAME}.file_loader")
file_loader = import_module(f"{TARGET_MODULE_NAME}.common.file_loader")
LasParser = file_loader.LasParser
FileValidationError = file_loader.FileValidationError
LocalFileLoader = file_loader.LocalFileLoader
......
......@@ -6,7 +6,7 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
# Test target module import
JsonToFile = import_module(f"{TARGET_MODULE_NAME}.json_writer").JsonToFile
JsonToFile = import_module(f"{TARGET_MODULE_NAME}.wrapper.json_writer").JsonToFile
class TestJsonToFile(unittest.TestCase):
......
......@@ -5,8 +5,8 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
# Test target module import
Record = import_module(f"{TARGET_MODULE_NAME}.record_mapper").Record
osdu_client = import_module(f"{TARGET_MODULE_NAME}.osdu_client")
Record = import_module(f"{TARGET_MODULE_NAME}.service.record_mapper").Record
osdu_client = import_module(f"{TARGET_MODULE_NAME}.wrapper.osdu_client")
DataLoaderWebResponseError = osdu_client.DataLoaderWebResponseError
OsduClient = osdu_client.OsduClient
......
......@@ -5,16 +5,16 @@ from . import TARGET_MODULE_NAME
# Test target module import
property_mapping = import_module(f"{TARGET_MODULE_NAME}.property_mapping")
property_mapping = import_module(f"{TARGET_MODULE_NAME}.service.property_mapping")
PropertyMapper = property_mapping.PropertyMapper
IPropertyMappingLoader = property_mapping.IPropertyMappingLoader
IDictionaryLoader = import_module(f"{TARGET_MODULE_NAME}.file_loader").IDictionaryLoader
WdutilValidationException = import_module(f"{TARGET_MODULE_NAME}.exceptions").WbdutilValidationException
WbdutilAttributeError = import_module(f"{TARGET_MODULE_NAME}.exceptions").WbdutilAttributeError
Configuration = import_module(f"{TARGET_MODULE_NAME}.configuration").Configuration
IFileLoader = import_module(f"{TARGET_MODULE_NAME}.file_loader").IFileLoader
IDictionaryLoader = import_module(f"{TARGET_MODULE_NAME}.common.file_loader").IDictionaryLoader
WdutilValidationException = import_module(f"{TARGET_MODULE_NAME}.common.exceptions").WbdutilValidationException
WbdutilAttributeError = import_module(f"{TARGET_MODULE_NAME}.common.exceptions").WbdutilAttributeError
Configuration = import_module(f"{TARGET_MODULE_NAME}.common.configuration").Configuration
IFileLoader = import_module(f"{TARGET_MODULE_NAME}.common.file_loader").IFileLoader
class TestPropertyMapper:
......@@ -23,7 +23,7 @@ class TestPropertyMapper:
mapping = {
"xyz": "abc",
"uvw": "ef"
}
}
target = self._construct_property_mapper(mapping)
......@@ -45,7 +45,7 @@ class TestPropertyMapper:
"dest1": "level1a.level2.level3",
"dest2": "level1b.level2",
"dest3": "level1a"
}
}
target = self._construct_property_mapper(mapping)
......@@ -74,7 +74,7 @@ class TestPropertyMapper:
"dest1": "level1a.level2.level4",
"dest2": "level1b.level2",
"dest3": "level1a"
}
}
target = self._construct_property_mapper(mapping)
......@@ -102,7 +102,7 @@ class TestPropertyMapper:
mapping = {
"level1.level2.a": "a",
"level1.b": "b"
}
}
target = self._construct_property_mapper(mapping)
......@@ -122,7 +122,7 @@ class TestPropertyMapper:
# Arrange
mapping = {
"dest": "src[1]",
}
}
target = self._construct_property_mapper(mapping)
......@@ -158,7 +158,7 @@ class TestPropertyMapper:
# Arrange
mapping = {
"dest": "src[0][1].nest[1].value",
}
}
target = self._construct_property_mapper(mapping)
......@@ -176,7 +176,7 @@ class TestPropertyMapper:
# Arrange
mapping = {
"dest": "src[a]",
}
}
target = self._construct_property_mapper(mapping)
......
......@@ -6,18 +6,18 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
# Test target module import
record_mapper = import_module(f"{TARGET_MODULE_NAME}.record_mapper")
record_mapper = import_module(f"{TARGET_MODULE_NAME}.service.record_mapper")
Record = record_mapper.Record
LasToRecordMapper = record_mapper.LasToRecordMapper
WellLogRecord = record_mapper.WellLogRecord
MappingUtilities = record_mapper.MappingUtilities
MapWellLogToLas = record_mapper.MapWellLogToLas
file_loader = import_module(f"{TARGET_MODULE_NAME}.file_loader")
file_loader = import_module(f"{TARGET_MODULE_NAME}.common.file_loader")
LasParser = file_loader.LasParser
LocalFileLoader = file_loader.LocalFileLoader
Configuration = import_module(f"{TARGET_MODULE_NAME}.configuration").Configuration
Configuration = import_module(f"{TARGET_MODULE_NAME}.common.configuration").Configuration
@pytest.fixture
......@@ -53,7 +53,7 @@ def config_incomplete():
@pytest.fixture
def record_mapper(las):
return LasToRecordMapper(las, Configuration(LocalFileLoader(), "test/test-config-files/config_example.json"))
return LasToRecordMapper(las, Configuration(LocalFileLoader(), "test/test-config-files/config_example.json"))
@pytest.fixture
......@@ -80,7 +80,7 @@ class TestLasToRecordMapper:
def test_record_mapper_raises_FileNotFoundError_when_config_file_not_found(self, las):
with pytest.raises(FileNotFoundError):
LasToRecordMapper(las, Configuration(LocalFileLoader(), "a/non/existent/file/path/config.json"))
LasToRecordMapper(las, Configuration(LocalFileLoader(), "a/non/existent/file/path/config.json"))
def test_wellbore_mapping_returns_Record_object_containing_formatted_config_variables(self, record_mapper):
# Arrange
......
......@@ -3,9 +3,9 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
ReflectionHelper = import_module(f"{TARGET_MODULE_NAME}.reflection_utilities").ReflectionHelper
WbdutilAttributeError = import_module(f"{TARGET_MODULE_NAME}.exceptions").WbdutilAttributeError
WbdutilValueError = import_module(f"{TARGET_MODULE_NAME}.exceptions").WbdutilValueError
ReflectionHelper = import_module(f"{TARGET_MODULE_NAME}.common.reflection_utilities").ReflectionHelper
WbdutilAttributeError = import_module(f"{TARGET_MODULE_NAME}.common.exceptions").WbdutilAttributeError
WbdutilValueError = import_module(f"{TARGET_MODULE_NAME}.common.exceptions").WbdutilValueError
class TestReflectionHelper:
......
......@@ -6,16 +6,16 @@ from importlib import import_module
from . import TARGET_MODULE_NAME
# Test target module import
well_service = import_module(f"{TARGET_MODULE_NAME}.well_service")
well_service = import_module(f"{TARGET_MODULE_NAME}.service.well_service")
WellBoreService = well_service.WellBoreService
WellLogService = well_service.WellLogService
DataLoaderConflictError = well_service.DataLoaderConflictError
osdu_client = import_module(f"{TARGET_MODULE_NAME}.osdu_client")
osdu_client = import_module(f"{TARGET_MODULE_NAME}.wrapper.osdu_client")
DataLoaderWebResponseError = osdu_client.DataLoaderWebResponseError
OsduClient = osdu_client.OsduClient
record_mapper = import_module(f"{TARGET_MODULE_NAME}.record_mapper")
record_mapper = import_module(f"{TARGET_MODULE_NAME}.service.record_mapper")
LasToRecordMapper = record_mapper.LasToRecordMapper
Record = record_mapper.Record
WellLogRecord = record_mapper.WellLogRecord
......
from typing import List
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..osdu_client import OsduClient
from ..configuration import Configuration
from ..file_loader import LocalFileLoader
from ..well_service import WellLogService
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..wrapper.osdu_client import OsduClient
from ..common.configuration import Configuration
from ..common.file_loader import LocalFileLoader
from ..service.well_service import WellLogService
logger = get_logger(__name__)
......
......@@ -2,12 +2,12 @@ import json
from pathlib import Path
from ntpath import basename
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..file_loader import LasParser, LocalFileLoader, FileUtilities
from ..record_mapper import LasToRecordMapper
from ..osdu_client import OsduClient
from ..configuration import Configuration
from ..well_service import WellBoreService, WellLogService, DataLoaderConflictError
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..common.file_loader import LasParser, LocalFileLoader, FileUtilities
from ..service.record_mapper import LasToRecordMapper
from ..wrapper.osdu_client import OsduClient
from ..common.configuration import Configuration
from ..service.well_service import WellBoreService, WellLogService, DataLoaderConflictError
logger = get_logger(__name__)
......
import json
from typing import List
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..osdu_client import OsduClient
from ..configuration import Configuration
from ..file_loader import LocalFileLoader
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..wrapper.osdu_client import OsduClient
from ..common.configuration import Configuration
from ..common.file_loader import LocalFileLoader
logger = get_logger(__name__)
......
from pathlib import Path
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..file_loader import LasParser, LocalFileLoader, FileUtilities
from ..record_mapper import LasToRecordMapper
from ..configuration import Configuration
from ..json_writer import JsonToFile
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..common.file_loader import LasParser, LocalFileLoader, FileUtilities
from ..service.record_mapper import LasToRecordMapper
from ..common.configuration import Configuration
from ..wrapper.json_writer import JsonToFile
logger = get_logger(__name__)
......@@ -26,7 +26,7 @@ def printlas(input_path):
def convert(input_path: str, wellbore_id: str, config_path: str = None):
"""
Convert a LAS file to Wellbore and Well Log and write to JSON files.
Convert a LAS file to Wellbore and Well Log and write to JSON files.
:param str input_path: Path and filename of a LAS file or folder containing LAS files
:param str wellbore_id: The wellbore id
:param str config_path: Path to the configuration file
......
import json
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..osdu_client import OsduClient
from ..configuration import Configuration
from ..file_loader import LocalFileLoader
from ..well_service import WellBoreService, WellLogService
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..wrapper.osdu_client import OsduClient
from ..common.configuration import Configuration
from ..common.file_loader import LocalFileLoader
from ..service.well_service import WellBoreService, WellLogService
logger = get_logger(__name__)
......
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..configuration import Configuration
from ..file_loader import LocalFileLoader
from ..osdu_client import DataLoaderWebResponseError, OsduClient
from ..well_service import WellLogService
from ..wrapper.environment_var_helper import EnvironmentVarHelper
from ..common.configuration import Configuration
from ..common.file_loader import LocalFileLoader
from ..wrapper.osdu_client import DataLoaderWebResponseError, OsduClient
from ..service.well_service import WellLogService
logger = get_logger(__name__)
......
......@@ -62,12 +62,12 @@ class Configuration:
rtype: Dict[str, Any]
"""
return self._config.get("welllog_mapping")
@property
def las_file_mapping(self) -> Union[Dict[str, Any], None]:
"""
Gets the las_file_mapping.
return: the las_file_mapping
rtype: Dict[str, Any]
"""
return self._config.get("las_file_mapping")
@property
def las_file_mapping(self) -> Union[Dict[str, Any], None]:
"""
Gets the las_file_mapping.
return: the las_file_mapping
rtype: Dict[str, Any]
"""
return self._config.get("las_file_mapping")
from typing import List
class WbdutilException(Exception):
"""
Base class for exceptions raised within Wdutil
"""
def __init__(self, *args):
"""
Create a new instance of a WdutilException
:param *args object: The Exception arguments
"""
super().__init__(args)
class WbdutilValidationException(Exception):
"""
General validation exception raised within Wdutil
"""
def __init__(self, error_messages: List[str], *args):
"""
Create a new instance of a WdutilValidationException
:param error_messages List[str]: The validation errors
:param *args object: The Exception arguments
"""
self._error_messages = error_messages
super().__init__(args)
@property
def error_messages(self) -> List[str]:
"""
Gets the list of validation errors
return: the validation errors
rtype: List[str]
"""
return self._error_messages
class WbdutilAttributeError(WbdutilException):
"""
Common exception class for attribute errors raised in the Wbdutil
"""
def __init__(self, message: str, inner_exception: Exception, *args):
"""
Create a new instance of a ExtendedPropertiesAttributeError
:param str message: The exception message
:param inner_exception Exception: The inner exception
:param args object: The Exception arguments
"""
self.message = message
self.inner_exception = inner_exception
super().__init__(args)
class WbdutilValueError(Exception):
def __init__(self, *args):
"""
Create a new instance of a WbdutilValueError
:param *args object: The Exception arguments
"""
super().__init__(args)
from typing import List
class WbdutilException(Exception):
"""
Base class for exceptions raised within Wdutil
"""
def __init__(self, *args):
"""
Create a new instance of a WdutilException
:param *args object: The Exception arguments
"""
super().__init__(args)
class WbdutilValidationException(Exception):
"""
General validation exception raised within Wdutil
"""
def __init__(self, error_messages: List[str], *args):
"""
Create a new instance of a WdutilValidationException
:param error_messages List[str]: The validation errors
:param *args object: The Exception arguments
"""
self._error_messages = error_messages
super().__init__(args)
@property
def error_messages(self) -> List[str]:
"""
Gets the list of validation errors
return: the validation errors
rtype: List[str]
"""
return self._error_messages
class WbdutilAttributeError(WbdutilException):
"""
Common exception class for attribute errors raised in the Wbdutil
"""
def __init__(self, message: str, inner_exception: Exception, *args):
"""
Create a new instance of a ExtendedPropertiesAttributeError
:param str message: The exception message
:param inner_exception Exception: The inner exception
:param args object: The Exception arguments
"""
self.message = message
self.inner_exception = inner_exception
super().__init__(args)
class WbdutilValueError(Exception):
def __init__(self, *args):
"""
Create a new instance of a WbdutilValueError
:param *args object: The Exception arguments
"""
super().__init__(args)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment