Skip to main content

System resource info, processor usage logging, RAM limit — standalone module from the SciTeX ecosystem

Project description

scitex-resource

SciTeX

System resource info, processor usage logging, RAM limiting + machine-identity config.

Full Documentation · uv pip install scitex-resource[all]

PyPI Python Tests Install Test Coverage Docs License: AGPL v3


Installation

pip install scitex-resource

Architecture

src/scitex_resource/
├── __init__.py                # public API surface
├── _machine.py                # canonical machine name + config resolution
├── _log_processor_usages.py   # CPU / RAM CSV logger (continuous)
├── limit_ram.py               # cap process RSS via resource.RLIMIT_AS
├── _compat.py                 # vendored str / gen helpers (decoupling)
├── _utils/                    # psutil wrappers (metrics / specs)
└── _specs/                    # rich human-readable snapshot helpers

1 Interfaces

Python API
import scitex_resource as r

# Hub-friendly metrics (cross-platform via psutil)
metrics = r.get_metrics()

# Canonical machine identity
name = r.get_machine_name()
cfg = r.get_machine_config()        # {"canonical_name", "aliases", "role", "hpc": {...}}

# Rich snapshot
specs = r.get_specs()

# CPU/RAM samples + continuous CSV logging
usage = r.get_processor_usages()
r.log_processor_usages("/tmp/usage.csv", limit_min=30, interval_s=1)

# Cap process RAM
r.limit_ram(0.5)

Demo

flowchart LR
    env["$SCITEX_RESOURCE_MACHINE"] --> resolve["resolve canonical name"]
    proj["./.scitex/resource/config.yaml"] --> resolve
    home["~/.scitex/resource/config.yaml"] --> resolve
    host["socket.gethostname()"] --> resolve
    resolve --> name["get_machine_name() → 'mba'"]
    resolve --> cfg["get_machine_config()"]
    psutil["psutil"] --> metrics["get_metrics()"]
    metrics --> snapshot[("cpu / mem / disk / gpu / load")]
    psutil --> log["log_processor_usages('/tmp/usage.csv', limit_min=30)"]
    log --> csv[("usage.csv (continuous)")]

Quick Start

import scitex_resource as r

print(r.get_machine_name())          # canonical machine identity
metrics = r.get_metrics()            # cpu / mem / disk / gpu / load
specs = r.get_specs()                # rich human-readable snapshot

Machine identity config — ~/.scitex/resource/config.yaml

machine:
  canonical_name: mba                  # what every scitex-* package uses to refer to this host
  aliases:                              # optional; cross-package discovery / drift detection
    - Yusukes-MacBook-Air
    - Yusukes-MacBook-Air.local
  role: head                            # generic role tag (head, worker, hpc-login, ...)
  hpc:                                  # optional; HPC-only
    cluster: spartan
    login_only: true
    partitions: [physical, sapphire]

Resolution cascade (highest precedence first):

  1. $SCITEX_RESOURCE_MACHINE
  2. <project>/.scitex/resource/config.yaml machine.canonical_name
  3. ~/.scitex/resource/config.yaml machine.canonical_name
  4. socket.gethostname().split(".", 1)[0]

Status

Standalone fork of scitex.resource. Deps: pandas, psutil, PyYAML, matplotlib.

Decoupling notes:

  • scitex.str.readable_bytes / scitex.gen.fmt_size / scitex.str.printc → vendored as 3 small helpers in _compat.py.
  • scitex.io._load.load / scitex.io._save.save → use pandas.read_csv / to_csv directly for the CSV log files.
  • scitex.sh.sh → prefer scitex_sh if installed, fall back to plain subprocess.run (list-only).

The umbrella package's scitex.resource import path is preserved via a sys.modules-alias bridge.

Part of SciTeX

scitex-resource is part of SciTeX. Install via the umbrella with pip install scitex[resource] to use as scitex.resource (Python) or scitex resource ... (CLI).

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

License

AGPL-3.0-only (see LICENSE).


SciTeX

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

scitex_resource-0.4.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

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

scitex_resource-0.4.0-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

Details for the file scitex_resource-0.4.0.tar.gz.

File metadata

  • Download URL: scitex_resource-0.4.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_resource-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0c0d114ce09403f9ce6510b4a16bd66d1a8779c577bb6d1777c6f232e0db596a
MD5 97f371ab916ae3c427f2e0245664b7ca
BLAKE2b-256 5aecd760f1a2f89151cc11ee573ef49d609f081306f6ae8f3e2655603c7a3e9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_resource-0.4.0.tar.gz:

Publisher: publish-pypi.yml on ywatanabe1989/scitex-resource

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scitex_resource-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: scitex_resource-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_resource-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01f81654a41dd69dc4b48afb23484ed7a7fd0e052f2d946a4ff24e4819892cc1
MD5 32a0851afd950e576551e3a376dc4149
BLAKE2b-256 729ceb2f124386cca6b9b8882e1aa9b84b5a016f2b3bbe8eb5804cb8a71d5f0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_resource-0.4.0-py3-none-any.whl:

Publisher: publish-pypi.yml on ywatanabe1989/scitex-resource

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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