Skip to main content

Jeng

A simple WITSML client with utilities.

PyPI version Unit test

If you encounter any issues, please report them promptly here. Additionally, feel free to request any necessary features here.

Installation

pip install jeng

Getting started

  • Jeng should be compatible with Python 3.9 and higher.
  • Jeng should work with WITSML data schema v1.3.1.1 and v1.4.1.1.
  • Jeng should work the same for both TIME log type and DEPTH log type.
    • Log curve info list is not technically required for TIME log type. For DEPTH log type, the index log curve info is required. Thus, log curve info is set to required for generate.generate_log_query() to ensure the API stays consistent and not confusing.
  • Incompatible package version update:
    • 0.0.6 to 0.0.7: Change from jeng.client.WitsmlClient package to jeng.jeng.WitsmlClient
    • 1.0.0 to 1.0.1: Python 3.8 support was dropped due to EOL and to align with pandas.

Client

  1. To create and connect to WITSML Server:

    from jeng import jeng
    
    client = jeng.WitsmlClient()
    
    # return True if success, else False
    status = client.connect(
        url=CONNECTION_URL,
        username=CONNECTION_USERNAME,
        password=CONNECTION_PASSWORD,
    )
    
  2. To call wrapper API (make sure to connect to WTISML Server first):

    # send query to WMLS_AddToStore API
    with open(f"{QUERY_PATH}/query.xml", "r") as query:
        reply = client.add_to_store(
            wml_type_in="well",
            xml_in=query.read(),
        )
    
    # send query to WMLS_UpdateInStore API
    with open(f"{QUERY_PATH}/query.xml", "r") as query:
        reply = client.update_in_store(
            wml_type_in="well",
            xml_in=query.read(),
        )
    
    # send query to WMLS_GetFromStore API
    with open(f"{QUERY_PATH}/query.xml", "r") as query:
        reply = client.get_from_store(
            wml_type_in="well",
            xml_in=query.read(),
            return_element="all",
        )
    
    # send query to WMLS_DeleteFromStore API
    with open(f"{QUERY_PATH}/query.xml", "r") as query:
        reply = client.delete_from_store(
            wml_type_in="well",
            xml_in=query.read(),
        )
    
    # string is expected for xml_in and you can
    # pass string query to all the wrapper API
    client.add_to_store(
        wml_type_in="well",
        xml_in=query_xml_str,
    )
    
  3. To call other WITSML APIs than provided wrapper APIs (make sure to connect to WTISML Server first):

    # send WMLS_GetVersion directly from Jeng client service
    reply = client.service().WMLS_GetVersion()
    

Log Query Generator

from jeng import model, generate

# set log basic info
log_basic_info = model.LogBasicInfoModel(
    well_uid="WELL_001",
    well_name="WELL 001",
    wellbore_uid="WELLBORE_001",
    wellbore_name="WELLBORE 001",
    log_uid="LOG_001",
    log_name="LOG 001",
)

# set time log curve info
log_curve_info_list = [
    model.LogCurveInfoModel(
        uid="TIME",
        mnemonic="TIME",
        unit="s",
        curve_description="Time",
        type_log_data="date time",
        index_type="date time",
        is_index_curve=True,
    ),
    model.LogCurveInfoModel(
        uid="HKLA",
        mnemonic="HKLA",
        unit="klbf",
        curve_description="Average Hookload",
        type_log_data="double",
    ),
    ...
]

# set depth log curve info
log_curve_info_list = [
    model.LogCurveInfoModel(
        uid="DEPTH",
        mnemonic="DEPTH",
        unit="m",
        curve_description="Depth Index",
        type_log_data="double",
        index_type="measured depth",
        is_index_curve=True,
    ),
    model.LogCurveInfoModel(
        uid="HKLA",
        mnemonic="HKLA",
        unit="klbf",
        curve_description="Average Hookload",
        type_log_data="double",
    ),
    ...
]

...
# generate very basic query (log curve info list is optional)
query_xml = generate.generate_log_query(
    log_basic_info=log_basic_info,
)

# generate query (make sure to use mnemonic as column name)
query_xml = generate.generate_log_query(
    log_basic_info=log_basic_info,
    log_curve_info_list=log_curve_info_time_list,
    dataframe=dataframe,
)

# it's possible to generate WMLS_GetFromStore compatible
# query with specific time interval
query_xml = generate.generate_log_query(
    log_basic_info=log_basic_info,
    log_curve_info_list=log_curve_info_time_list,
    log_index=model.LogIndexModel(
        start="2020-06-30T17:44:00.000+08:00",
        end="2020-06-30T17:45:00.000+08:00",
    ),
)

# it's possible to generate WMLS_GetFromStore compatible
# query with specific non-time interval
query_xml = generate.generate_log_query(
    log_basic_info=log_basic_info,
    log_curve_info_list=log_curve_info_depth_list,
    log_index=model.LogIndexModel(
        start="2575.2",
        end="2575.5",
        type=model.LogIndexTypeEnum.NON_TIME,
    ),
)

Log Reply Parser

from jeng import parse

...

# parse WITSML XMLout reply data into dataframe
dataframe = parse.parse_log_into_dataframe(
    xml_out=reply["XMLout"],
)

# parse WITSML XMLout reply into model.LogCurveInfoModel
log_curve_info_list = parse.parse_log_into_curve_info(
    xml_out=reply["XMLout"],
)

Test

Make sure to have a WITSML server running for the test.

  1. Clone the project:

    git clone https://github.com/nazebzurati/jeng.git
    
  2. Prepare environment:

    # create environment and activate
    virtualenv env
    .\env\Scripts\activate       # on Windows
    source .\env\bin\activate    # on Mac and Linux
    
    # install development dependencies
    pip install -e .[dev]        # powershell and bash
    pip install -e .\[dev\]      # zsh
    
  3. Change the source code and test.

    # formatting
    isort . --skip env && black --line-length 120 .
    
    # run coverage and pytest
    coverage run -m pytest -v
    coverage run -m pytest -m integration -v    # test with WITSML server integration
    coverage run -m pytest -m unit -v           # test without WITSML server integration
    
    # run static code test
    coverage xml && sonar-scanner.bat -D"sonar.projectKey=<project-key>" -D"sonar.sources=." -D"sonar.host.url=<host-url>" -D"sonar.login=<project-token>"
    

Metadata

Release files for jeng 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jeng 1.0.1
File Size Uploaded
jeng-1.0.1.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for jeng 1.0.1
File Interpreter ABI Platform
jeng-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.4 MB

Release files / jeng-1.0.1.tar.gz

Download URL jeng-1.0.1.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
1eb8fd9c9cb0b9eae30f3b84685810c1599ff188fc90e8f7c67194e0fbbe04ab
BLAKE2b-256 checksum
How to use checksums
4305986695f4b518ba4e86a81046a4ff2d9432927d8c1f1d9bef1bfb32a46524
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / jeng-1.0.1-py3-none-any.whl

Download URL jeng-1.0.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72202e2082e5e524741cbb36daa3193f58bb97af47e2f57aca9600d70ece5aca
BLAKE2b-256 checksum
How to use checksums
b89b5fa3c5e7d152721a56dddcb5c7b863c1fee56810805e65e54febb2738f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

1 release file

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page