Commit 14d14604 authored by Chad Leong's avatar Chad Leong
Browse files

Merge branch '43-rename-fileload-to-parse' into 'main'

Resolve "Rename 'fileload' command to 'parse' to remove ambiguity"

Closes #43

See merge request !36
parents 7e0fa7e8 b2d80d17
Pipeline #96766 passed with stages
in 4 minutes and 43 seconds
......@@ -3,4 +3,5 @@ env/
__pycache__/
.vs/
.vscode/
lasloader.egg-info/
\ No newline at end of file
wbdutil.egg-info/
build/
\ No newline at end of file
......@@ -39,9 +39,9 @@ Help for any group or command can be obtained by using the `-h` option.
There are several groups:
* `download`: Download a welllog and curve data to a las format file.
* `fileload`: Dry run of the ingest command, instead of uploading data to the OSDU instance it creates json files for the wellbore and welllog.
* `ingest`: Upload a wellbore, welllog and/or bulk data to an OSDU instance
* `list`: List the data held in OSDU for a given wellbore or welllog id.
* `parse`: Dry run of the ingest command, instead of uploading data to the OSDU instance it creates json files for the wellbore and welllog.
* `search`: Search for a wellbore given a well name.
* `update`: Update the existing bulk data for a given welllog
......
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
logger = get_logger(__name__)
def printlas(input_path):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser = LasParser(LocalFileLoader())
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
print(las_data.header)
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.
: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
"""
config_path = EnvironmentVarHelper.get_config_path(config_path)
las_parser = LasParser(LocalFileLoader())
config = Configuration(LocalFileLoader(), config_path)
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
mapper = LasToRecordMapper(las_data, config)
wellbore_record = mapper.map_to_wellbore_record()
welllog_record = mapper.map_to_well_log_record(wellbore_id)
path = Path(file_path)
writer = JsonToFile()
writer.write(vars(wellbore_record), path.with_suffix('.wellbore.json'))
logger.warning(f"Wellbore record file created: {path.with_suffix('.wellbore.json')}")
writer.write(vars(welllog_record), path.with_suffix('.welllog.json'))
logger.warning(f"Well log record file created: {path.with_suffix('.welllog.json')}")
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
logger = get_logger(__name__)
def printlas(input_path):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser = LasParser(LocalFileLoader())
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
print(las_data.header)
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.
: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
"""
config_path = EnvironmentVarHelper.get_config_path(config_path)
las_parser = LasParser(LocalFileLoader())
config = Configuration(LocalFileLoader(), config_path)
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
mapper = LasToRecordMapper(las_data, config)
wellbore_record = mapper.map_to_wellbore_record()
welllog_record = mapper.map_to_well_log_record(wellbore_id)
path = Path(file_path)
writer = JsonToFile()
writer.write(vars(wellbore_record), path.with_suffix('.wellbore.json'))
logger.warning(f"Wellbore record file created: {path.with_suffix('.wellbore.json')}")
writer.write(vars(welllog_record), path.with_suffix('.welllog.json'))
logger.warning(f"Well log record file created: {path.with_suffix('.welllog.json')}")
......@@ -34,7 +34,7 @@ class DdmsCommandLoader(CLICommandsLoader):
def load_command_table(self, args):
"""Load all commands"""
with CommandGroup(self, 'fileload', MODULE_NAME + '.commands.file_load#{}') as group:
with CommandGroup(self, 'parse', MODULE_NAME + '.commands.parse#{}') as group:
group.command('convert', 'convert')
group.command('print', 'printlas')
......@@ -66,11 +66,11 @@ class DdmsCommandLoader(CLICommandsLoader):
help='''The path and filename of the configuration file.
Defaults to \'CONFIGPATH\' environment variable if not set.''')
# 'fileload'
with ArgumentsContext(self, 'fileload') as arg_context:
# 'parse'
with ArgumentsContext(self, 'parse') as arg_context:
self._register_input_path_argument(arg_context)
with ArgumentsContext(self, 'fileload convert') as arg_context:
with ArgumentsContext(self, 'parse convert') as arg_context:
self._register_wellbore_id_flag(arg_context)
# 'ingest'
......
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