Skip to main content

A client for submitting calculation tasks and polling results

Project description

DMRG Task Client

A Python client for submitting calculation tasks to a server and polling results.

Installation

pip install Qumulate

Usage Example

from entropec_quantumoperator_test import DMRGClient

# Initialize client with server URL
client = DMRGClient(api_base="http://192.168.124.22:12805")

def main():
    # 初始化客户端
    client = DMRGClient(
        api_base="http://192.168.124.22:12805",  # 服务地址
        timeout=1000,  # 超时时间(秒)
        retry_interval=5  # 结果轮询间隔(秒)
    )

    # 任务参数
    task_id = "test_task_001"  # 使用唯一实例ID
    program = " vmps1FM"  # 选择调用的程序
    # program = "measureSC"  # 选择调用的程序
    params = {
        "CaseParams": {
            "Geometry": "OBC",
            "Lx": 3,
            "Ly": 4,
            "t": 1.0,
            "t2": -0.2,
            "J": 3.0,
            "J2": 1.0,
            "phi": 0.1,
            "mu": 0,
            "NumHole": 2,
            "Sweeps": 5,
            "Dmin": 10,
            "Dmax": 10,
            "CutOff": 1e-9,
            "LanczErr": 1e-9,
            "MaxLanczIter": 70,
            "Threads": 2,
            "noise": [0.1, 0.01],
            "Perturbation": 0.0,
            "BondSingletPairPerturbation": 0.0,
            "wavelength": 4
        }
    }


    try:
        # 提交任务
        print("提交测试任务...")
        response = client.submit_job(task_id, program, params)
        print(f"提交响应: {response}")

        # 获取结果(限制重试次数,避免无限等待)
        print("获取测试结果...")
        result = client.fetch_result(task_id, max_retries=5)
        print(f"测试结果: {result}")  # 打印部分结果

    except Exception as e:
        print(f"测试失败: {str(e)}")


if __name__ == "__main__":
    main()

API Reference

DMRGClient

__init__(api_base, timeout=10, retry_interval=5)

Initialize a new DMRG client.

  • api_base: Base URL of the DMRG server
  • timeout: Request timeout in seconds (default: 10)
  • retry_interval: Interval between result polling attempts (default: 5)

submit_job(task_id, program, params)

Submit a DMRG calculation task.

  • task_id: Unique identifier for the task
  • program: The program to execute (e.g., "vmps1FM" or "measureSC")
  • params: Dictionary containing calculation parameters
  • Returns: Server response JSON

fetch_result(task_id, max_retries=None)

Poll for calculation results.

  • task_id: Task identifier to fetch results for
  • max_retries: Maximum number of retries (None for infinite)
  • Returns: Calculation result text

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qumulate-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qumulate-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file qumulate-0.1.0.tar.gz.

File metadata

  • Download URL: qumulate-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for qumulate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd53083182bc95a7af11ef12978395b0c100eb25b6bc858c7c42a3e0867c12c0
MD5 dbd1a57a7088e8652b6891f33009973a
BLAKE2b-256 6df74e1a59639d66602e508dba411dc37998aa57aee6b36988b25b1cbf149cf1

See more details on using hashes here.

File details

Details for the file qumulate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qumulate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for qumulate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b2f78193c19aa5bad04e541db6c86f2c1009342eac1e430c1b8345e6b06dc31
MD5 0b92a73428729ba1d6d32abc60816df7
BLAKE2b-256 26d604e495233e875920a3ad4ed0bcd6ec2eeb60e1092998dd9a42c127b9d426

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page