Skip to main content

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

Project description

scitex-resource

PyPI Python Tests Install Test Coverage Docs License: AGPL v3

System resource info, processor usage logging, and RAM limiting helpers, extracted from the SciTeX ecosystem as a standalone package.

Install

pip install scitex-resource

API

import scitex_resource as r

# Flat hub-friendly metrics (cpu/mem/disk/gpu/load) — cross-platform via psutil
metrics = r.get_metrics()

# Canonical machine identity — every scitex-* package consumes this so they
# all agree on "what host am I". Resolves env > project config > user config
# > short hostname. See ~/.scitex/resource/config.yaml below.
name = r.get_machine_name()
cfg = r.get_machine_config()        # {"canonical_name", "aliases", "role", "hpc": {...}}

# Rich human-readable snapshot (system info, GPU, network, disk partitions)
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)

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                    # don't surface login-node CPU as available
    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]

This is the ecosystem convention — see scitex-python _skills/general/01_arch_06_local-state-directories.md for the full .scitex/<pkg-short>/ layout (config tracked, runtime/ ignored).

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; defer to scitex.io only if a non-CSV path is requested (raises ImportError without scitex installed).
  • scitex.sh.sh → prefer scitex_sh if installed, fall back to plain subprocess.run (list-only).
  • scitex.session.start/close __main__ block → simplified to plain main().

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

License

AGPL-3.0-only (see 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

scitex_resource-0.3.2.tar.gz (37.6 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.3.2-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_resource-0.3.2.tar.gz
  • Upload date:
  • Size: 37.6 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.3.2.tar.gz
Algorithm Hash digest
SHA256 9997ab5a9a12c1d8e40c3beae409e0e342ec6cb55c31ddb9f1fc4becc66f076a
MD5 38e2b5b263ffd0017aa765119e435a3a
BLAKE2b-256 2d0ed2d42c72dc2e0decfd16db1aa0e033af00bef9c4f47df0680620a01d4f97

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_resource-0.3.2.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.3.2-py3-none-any.whl.

File metadata

  • Download URL: scitex_resource-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 38.5 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.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63903b87f137d5bb7b53f426bd86675945561edb5052ff84ac32cd0ff520e6de
MD5 6cb0d29a56fbc2da66c0f257d945af29
BLAKE2b-256 c26f4dbac71d88c42bbde39fdacc1a4a69cec4661b77e1fe2239f120d08beefe

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_resource-0.3.2-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