Skip to main content

Client and Worker module for Tin Arm Engineering LTC service

Project description

ltc_client

TeamCity build status

Node creation tool for TAE workers

Creating and Monitoring Jobs with ltc_client This guide provides a minimal, working example of how to create one or more jobs and monitor their progress asynchronously using ltc_client.

  1. Setup First, ensure you have the necessary libraries installed and import them. You will also need to configure the API connections, preferably using environment variables.

You can configure credentials using environment variables or a local YAML file.

Using Environment Variables

  • API Credentials: API_ROOT_URL, API_KEY, ORG_ID

Using a YAML Configuration File

Alternatively, create a file named configurations.yaml:

api:
  root_url: https://api.ltc.tinarmengineering.com
  api_key: XXXXXXXXXXXXX # Your API key from your account page
  org_id: XXXXXXXXXXXXX  # Your organization ID from your account page

stomp:
  host: queue.ltc.tinarmengineering.com
  port: 15671
  user: XXXXXXXX
  password: XXXXXXXXXX

You can then load it in your Python script (you may need to pip install pyyaml):

import yaml

with open("configurations.yaml", "r") as f:
    config = yaml.safe_load(f)
# example usage
api = ltc_client.Api(**config['api'])
  1. Create a machine For detils of each section see the example files.
m = ltc_client.Machine(
    stator=stator_parameters,
    rotor=rotor_parameters,
    winding=winding_parameters,
    materials=materials,
)

we also need to get the netlist.

netlist #we will give an example later
  1. Create multiple jobs
jobs = []
for idx in range(3):
    job = ltc_client.Job(machine=m, simulation=sim_param,  
        mesh_reuse_series=mesh_reuse_series,
        title=f"Job_{idx}",
        netlist=net)
    job.type = "electromagnetic_spmarc_fscwseg"
    jobs.append(job)
  1. Make a stomp connection
 def make_connection(stomp_conf):
    ws_echo = create_connection(
        f"{stomp_conf["protocol"]}://{stomp_conf["host"]}:{stomp_conf["port"]}/ws"
    )
    connection = webstompy.StompConnection(connector=ws_echo)
    connection.connect(login=stomp_conf["user"], passcode=stomp_conf["password"])
    
    return connection
connection = make_connection(config["stomp"])

Development with Poetry https://python-poetry.org/docs/basic-usage/

Before starting development:

sudo apt install pipx
pipx install poetry
pipx ensurepath

# restart terminal

poetry config virtualenvs.in-project true
poetry install --with test,dev

Before committing:

Check the formatting is compient with Black: poetry run black .

Run the tests: poetry run pytest

Get the coverage report: poetry run coverage report Hopefully it should not have gone down lower than this:

Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
ltc_client/__init__.py       7      0   100%
ltc_client/api.py          161     93    42%   38, 48-56, 72, 97-99, 104-106, 112, 118, 123-124, 128, 144, 149-156, 167, 171-173, 180, 191-200, 203-204, 211-212, 218, 223, 226-227, 236, 248-251, 259, 267-274, 278-280, 287-290, 298-301, 309-312, 319-328, 331-335, 340-342, 350-406
ltc_client/helpers.py      119     70    41%   48-57, 86, 89-105, 110-118, 121, 125-144, 147-175, 178, 193-195, 200-203, 207, 211, 214-228, 253-269
ltc_client/worker.py       179    116    35%   48, 85, 87, 97-98, 101, 142-197, 200-220, 223-236, 239, 242-250, 256-313, 317-365, 372-378, 382-393
------------------------------------------------------
TOTAL                      466    279    40%

To push a release with a tag, make your commits locally, don't push yet, then:

git tag 0.2.50
git push --atomic origin main 0.2.50

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

ltc_client-0.2.52.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

ltc_client-0.2.52-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file ltc_client-0.2.52.tar.gz.

File metadata

  • Download URL: ltc_client-0.2.52.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.12 Linux/5.15.0-161-generic

File hashes

Hashes for ltc_client-0.2.52.tar.gz
Algorithm Hash digest
SHA256 9bcb07e5d2d0591f5c2ed926135c2d8ca628c13d10d845ab281f30d8939cf514
MD5 d48b1370969b57775b2a35a3c8a499aa
BLAKE2b-256 638a516a3000ab08fae08342d1b23b747be27f4900c4bb81740be0ed9f5489bb

See more details on using hashes here.

File details

Details for the file ltc_client-0.2.52-py3-none-any.whl.

File metadata

  • Download URL: ltc_client-0.2.52-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.12 Linux/5.15.0-161-generic

File hashes

Hashes for ltc_client-0.2.52-py3-none-any.whl
Algorithm Hash digest
SHA256 95211e21cac856bf07f7569c85b8a8c64e6daab35e5d18ccb0f87b921dfe3643
MD5 02c5c76a67657b3c250915a7401a8691
BLAKE2b-256 c2c271cad9e4f58bbc4c3e546c68b06cc48afe41cc634dd5adfa8b844210d53a

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