in src/loading_manifest/osdu_laslog_manifest.py [0:0]
def create_laslog_manifest_from_path(
input_path, output_path,
preload_file_path, file_source,
osdu_authorid, schema_ns_name, schema_ns_value,
acl, legal, uom_persistable_reference,
schema_version, dict_schemas):
# check supported schema version
if schema_version not in SUPPORTED_SCHEMA_VERSIONS:
logging.error("Schema version %s is not in the supported list: %s", schema_version,
SUPPORTED_SCHEMA_VERSIONS)
logging.info("Generated 0 laslog load manifests.")
return
# list laslog filenames
files = os.listdir(input_path)
files_laslog = fnmatch.filter(files, "*.las")
valid_files = []
logging.info("Checking {} files".format(len(files_laslog)))
for file_laslog in sorted(files_laslog):
file_laslog = file_laslog.strip()
# minimum check: file and size
if cm.is_nonzero_file(input_path, file_laslog):
valid_files.append(file_laslog)
processed_files = []
logging.info("Processing {} files".format(len(valid_files)))
for valid_file in valid_files:
full_valid_file_path = os.path.join(input_path, valid_file)
# retrieve wellbore id/curves
try:
log_data = read_data_from_log_file(full_valid_file_path)
except Exception:
logging.exception("Unable to read laslog file: {}".format(full_valid_file_path))
continue
uniq_id = log_data.get('log_uniqid', None)
wellbore_id = uniq_id
# wellbore_name = log_data.get('well_name', None)
log_curves = log_data.get('log_curves', None)
if log_curves is None or len(log_curves) <= 0:
logging.warning("LogCurves not found for: " + full_valid_file_path)
laslog_file = valid_file
output_file = os.path.join(output_path,
"load_log_" + schema_version + "_"
+ laslog_file.replace(".", "_") + ".json")
try:
with open(output_file, "w") as f:
json.dump(
obj=create_laslog_manifest(
laslog_name=laslog_file,
preload_file_path=preload_file_path,
file_source=file_source,
wellbore_id=wellbore_id,
log_data=log_data,
osdu_authorid=osdu_authorid,
schema_ns_name=schema_ns_name,
schema_ns_value=schema_ns_value,
acl=acl,
legal=legal,
uom_persistable_reference=uom_persistable_reference,
schema_version=schema_version,
dict_schemas=dict_schemas
),
fp=f,
indent=4
)
processed_files.append(laslog_file)
except Exception:
logging.exception("Unable to process laslog file: {}".format(laslog_file))
os.remove(output_file)
logging.info("Generated {} laslog load manifests.".format(len(processed_files)))