Skip to main content

No project description provided

Project description

natscale

A high-performance Python framework for HPC task distribution, load balancing, and monitoring powered by NATS.

Install NATS

deploy a NATS service

go install github.com/nats-io/nats-server/v2@latest

export PATH=$PATH:$(go env GOPATH)/bin

# -js 表示开启 JetStream 持久化功能
# -m 8222 (可选) 开启 HTTP 监控面板,方便在浏览器看状态
nats-server -js

create a NATS stream

nats stream add NATSCALE --subjects "hpc.tasks.>" --storage=file --ack --retention=work --discard new   --max-msgs 100000 --replicas 1

useful commands

check the stream info

watch -n 10 nats stream info NATSCALE

view the stream graph

nats stream graph

Usage

Manually send an ACK signal to confirm that the task has been successfully received and processed.

import time
import natscale as ns

cfg = ns.Config(
    nats_server="nats://127.0.0.1:4222",
    subject="netscale.tasks.*",
    timeout=3,
    retry = 4,
    auto_ack=False,
)

# manually do ack
with ns.Iterator(cfg) as tasks:
    for data, done in tasks:
        print(f"{data.id} --> {data}")
        time.sleep(1)
        done()

Auto send an ACK signal to confirm that the task has been successfully received and processed.

import time
import natscale as ns
from natscale.task.iter import NatsIterator as Iterator

cfg = ns.Config(
    nats_server="nats://127.0.0.1:4222",
    subject="netscale.tasks.*",
    timeout=3,
    retry = 4,
    auto_ack=True,
)

with Iterator(cfg) as tasks:
    for data in tasks:
        print(f"{data.id} --> {data}")
        time.sleep(1)

template-pdm-base

This project is generated by pdm template of https://github.com/POFK/template-pdm-base by command:

pdm init https://github.com/POFK/template-pdm-base <project_name>

also a non-interactive command is:

pdm init --name <project_name> --dist -n  https://github.com/POFK/template-pdm-base

first run after initialization

pdm install
detect-secrets scan > .secrets.baseline

git add .
pre-commit run -a

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

natscale-0.1.2.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

natscale-0.1.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file natscale-0.1.2.tar.gz.

File metadata

  • Download URL: natscale-0.1.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.2 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for natscale-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e16981a058bd6e300eb8fc6b4fb5e8f79d43946f18ce9ce3ff937282f79490da
MD5 a6df9255da19cad83f1038269ccbbdaf
BLAKE2b-256 6d019b13dc5e1bc0e4607b29c8fc8069db3af3323248eba07fd028ef4598f9e1

See more details on using hashes here.

File details

Details for the file natscale-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: natscale-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.2 CPython/3.14.2 Linux/6.11.0-1018-azure

File hashes

Hashes for natscale-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2666c7993a4e6e6d3c689b0d1c91b404e4cbb8208be8406456734035564484ff
MD5 dfbbbc24f00c9fb2f15bb2a3d6e07f04
BLAKE2b-256 f22af4a259105b1dba5752450558d59c40253fbc33e6955093a176cc47abceb9

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