con-duct


Namecon-duct JSON
Version 0.8.0 PyPI version JSON
download
home_pagehttps://github.com/con/duct/
SummaryRuns a not-so-simple command and collects resource usage metrics
upload_time2024-10-24 18:41:14
maintainerNone
docs_urlNone
authorAustin Macdonald
requires_python>=3.9
licenseMIT
keywords command-line cpu memory metrics output-capture provenance time usage
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # duct

[![codecov](https://codecov.io/gh/con/duct/graph/badge.svg?token=JrPazw0Vn4)](https://codecov.io/gh/con/duct)
[![PyPI version](https://badge.fury.io/py/con-duct.svg)](https://badge.fury.io/py/con-duct)

## Installation

    pip install con-duct

## Quickstart

Try it out!

    duct --sample-interval 0.5 --report-interval 1 test/data/test_script.py --duration 3 --memory-size=1000

`duct` is most useful when the report-interval is less than the duration of the script.

## Summary:

A process wrapper script that monitors the execution of a command.

<!-- BEGIN HELP -->
```shell
>duct --help

usage: duct [-h] [--version] [-p OUTPUT_PREFIX]
            [--summary-format SUMMARY_FORMAT] [--colors] [--clobber]
            [-l {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}] [-q]
            [--sample-interval SAMPLE_INTERVAL]
            [--report-interval REPORT_INTERVAL] [-c {all,none,stdout,stderr}]
            [-o {all,none,stdout,stderr}]
            [-t {all,system-summary,processes-samples}]
            command [command_args ...] ...

duct is a lightweight wrapper that collects execution data for an arbitrary
command.  Execution data includes execution time, system information, and
resource usage statistics of the command and all its child processes. It is
intended to simplify the problem of recording the resources necessary to
execute a command, particularly in an HPC environment.

Resource usage is determined by polling (at a sample-interval).
During execution, duct produces a JSON lines (see https://jsonlines.org) file
with one data point recorded for each report (at a report-interval).

environment variables:
  Many duct options can be configured by environment variables (which are
  overridden by command line options).

  DUCT_LOG_LEVEL: see --log-level
  DUCT_OUTPUT_PREFIX: see --output-prefix
  DUCT_SUMMARY_FORMAT: see --summary-format
  DUCT_SAMPLE_INTERVAL: see --sample-interval
  DUCT_REPORT_INTERVAL: see --report-interval
  DUCT_CAPTURE_OUTPUTS: see --capture-outputs

positional arguments:
  command [command_args ...]
                        The command to execute, along with its arguments.
  command_args          Arguments for the command.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -p OUTPUT_PREFIX, --output-prefix OUTPUT_PREFIX
                        File string format to be used as a prefix for the
                        files -- the captured stdout and stderr and the
                        resource usage logs. The understood variables are
                        {datetime}, {datetime_filesafe}, and {pid}. Leading
                        directories will be created if they do not exist. You
                        can also provide value via DUCT_OUTPUT_PREFIX env
                        variable. (default:
                        .duct/logs/{datetime_filesafe}-{pid}_)
  --summary-format SUMMARY_FORMAT
                        Output template to use when printing the summary
                        following execution. Accepts custom conversion flags:
                        !S: Converts filesizes to human readable units, green
                        if measured, red if None. !E: Colors exit code, green
                        if falsey, red if truthy, and red if None. !X: Colors
                        green if truthy, red if falsey. !N: Colors green if
                        not None, red if None (default: Summary: Exit Code:
                        {exit_code!E} Command: {command} Log files location:
                        {logs_prefix} Wall Clock Time: {wall_clock_time:.3f}
                        sec Memory Peak Usage (RSS): {peak_rss!S} Memory
                        Average Usage (RSS): {average_rss!S} Virtual Memory
                        Peak Usage (VSZ): {peak_vsz!S} Virtual Memory Average
                        Usage (VSZ): {average_vsz!S} Memory Peak Percentage:
                        {peak_pmem!N}% Memory Average Percentage:
                        {average_pmem!N}% CPU Peak Usage: {peak_pcpu!N}%
                        Average CPU Usage: {average_pcpu!N}% )
  --colors              Use colors in duct output. (default: False)
  --clobber             Replace log files if they already exist. (default:
                        False)
  -l {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}, --log_level {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Level of log output to stderr, use NONE to entirely
                        disable. (default: INFO)
  -q, --quiet           [deprecated, use log level NONE] Disable duct logging
                        output (to stderr) (default: False)
  --sample-interval SAMPLE_INTERVAL, --s-i SAMPLE_INTERVAL
                        Interval in seconds between status checks of the
                        running process. Sample interval must be less than or
                        equal to report interval, and it achieves the best
                        results when sample is significantly less than the
                        runtime of the process. (default: 1.0)
  --report-interval REPORT_INTERVAL, --r-i REPORT_INTERVAL
                        Interval in seconds at which to report aggregated
                        data. (default: 60.0)
  -c {all,none,stdout,stderr}, --capture-outputs {all,none,stdout,stderr}
                        Record stdout, stderr, all, or none to log files. You
                        can also provide value via DUCT_CAPTURE_OUTPUTS env
                        variable. (default: all)
  -o {all,none,stdout,stderr}, --outputs {all,none,stdout,stderr}
                        Print stdout, stderr, all, or none to stdout/stderr
                        respectively. (default: all)
  -t {all,system-summary,processes-samples}, --record-types {all,system-summary,processes-samples}
                        Record system-summary, processes-samples, or all
                        (default: all)

```
<!-- END HELP -->

# con-duct suite

In addition to `duct`, this project also includes a set of optional helpers under the `con-duct` command.
These helpers may use 3rd party python libraries.

## Installation

    pip install con-duct[all]

## Extras Helptext

<!-- BEGIN EXTRAS HELP -->
```shell
>con-duct --help

usage: con-duct <command> [options]

A command-line tool for managing various tasks.

positional arguments:
  {pp,plot}   Available subcommands
    pp        Pretty print a JSON log
    plot      Plot resource usage for an execution.

options:
  -h, --help  show this help message and exit

```
<!-- END EXTRAS HELP -->

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/con/duct/",
    "name": "con-duct",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "command-line, cpu, memory, metrics, output-capture, provenance, time, usage",
    "author": "Austin Macdonald",
    "author_email": "austin@dartmouth.edu",
    "download_url": "https://files.pythonhosted.org/packages/57/90/1fa2c07a35e61bf7f2ae1e328d5f4b7421f0d1bac2d3ed250f81932b27fe/con_duct-0.8.0.tar.gz",
    "platform": null,
    "description": "# duct\n\n[![codecov](https://codecov.io/gh/con/duct/graph/badge.svg?token=JrPazw0Vn4)](https://codecov.io/gh/con/duct)\n[![PyPI version](https://badge.fury.io/py/con-duct.svg)](https://badge.fury.io/py/con-duct)\n\n## Installation\n\n    pip install con-duct\n\n## Quickstart\n\nTry it out!\n\n    duct --sample-interval 0.5 --report-interval 1 test/data/test_script.py --duration 3 --memory-size=1000\n\n`duct` is most useful when the report-interval is less than the duration of the script.\n\n## Summary:\n\nA process wrapper script that monitors the execution of a command.\n\n<!-- BEGIN HELP -->\n```shell\n>duct --help\n\nusage: duct [-h] [--version] [-p OUTPUT_PREFIX]\n            [--summary-format SUMMARY_FORMAT] [--colors] [--clobber]\n            [-l {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}] [-q]\n            [--sample-interval SAMPLE_INTERVAL]\n            [--report-interval REPORT_INTERVAL] [-c {all,none,stdout,stderr}]\n            [-o {all,none,stdout,stderr}]\n            [-t {all,system-summary,processes-samples}]\n            command [command_args ...] ...\n\nduct is a lightweight wrapper that collects execution data for an arbitrary\ncommand.  Execution data includes execution time, system information, and\nresource usage statistics of the command and all its child processes. It is\nintended to simplify the problem of recording the resources necessary to\nexecute a command, particularly in an HPC environment.\n\nResource usage is determined by polling (at a sample-interval).\nDuring execution, duct produces a JSON lines (see https://jsonlines.org) file\nwith one data point recorded for each report (at a report-interval).\n\nenvironment variables:\n  Many duct options can be configured by environment variables (which are\n  overridden by command line options).\n\n  DUCT_LOG_LEVEL: see --log-level\n  DUCT_OUTPUT_PREFIX: see --output-prefix\n  DUCT_SUMMARY_FORMAT: see --summary-format\n  DUCT_SAMPLE_INTERVAL: see --sample-interval\n  DUCT_REPORT_INTERVAL: see --report-interval\n  DUCT_CAPTURE_OUTPUTS: see --capture-outputs\n\npositional arguments:\n  command [command_args ...]\n                        The command to execute, along with its arguments.\n  command_args          Arguments for the command.\n\noptions:\n  -h, --help            show this help message and exit\n  --version             show program's version number and exit\n  -p OUTPUT_PREFIX, --output-prefix OUTPUT_PREFIX\n                        File string format to be used as a prefix for the\n                        files -- the captured stdout and stderr and the\n                        resource usage logs. The understood variables are\n                        {datetime}, {datetime_filesafe}, and {pid}. Leading\n                        directories will be created if they do not exist. You\n                        can also provide value via DUCT_OUTPUT_PREFIX env\n                        variable. (default:\n                        .duct/logs/{datetime_filesafe}-{pid}_)\n  --summary-format SUMMARY_FORMAT\n                        Output template to use when printing the summary\n                        following execution. Accepts custom conversion flags:\n                        !S: Converts filesizes to human readable units, green\n                        if measured, red if None. !E: Colors exit code, green\n                        if falsey, red if truthy, and red if None. !X: Colors\n                        green if truthy, red if falsey. !N: Colors green if\n                        not None, red if None (default: Summary: Exit Code:\n                        {exit_code!E} Command: {command} Log files location:\n                        {logs_prefix} Wall Clock Time: {wall_clock_time:.3f}\n                        sec Memory Peak Usage (RSS): {peak_rss!S} Memory\n                        Average Usage (RSS): {average_rss!S} Virtual Memory\n                        Peak Usage (VSZ): {peak_vsz!S} Virtual Memory Average\n                        Usage (VSZ): {average_vsz!S} Memory Peak Percentage:\n                        {peak_pmem!N}% Memory Average Percentage:\n                        {average_pmem!N}% CPU Peak Usage: {peak_pcpu!N}%\n                        Average CPU Usage: {average_pcpu!N}% )\n  --colors              Use colors in duct output. (default: False)\n  --clobber             Replace log files if they already exist. (default:\n                        False)\n  -l {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}, --log_level {NONE,CRITICAL,ERROR,WARNING,INFO,DEBUG}\n                        Level of log output to stderr, use NONE to entirely\n                        disable. (default: INFO)\n  -q, --quiet           [deprecated, use log level NONE] Disable duct logging\n                        output (to stderr) (default: False)\n  --sample-interval SAMPLE_INTERVAL, --s-i SAMPLE_INTERVAL\n                        Interval in seconds between status checks of the\n                        running process. Sample interval must be less than or\n                        equal to report interval, and it achieves the best\n                        results when sample is significantly less than the\n                        runtime of the process. (default: 1.0)\n  --report-interval REPORT_INTERVAL, --r-i REPORT_INTERVAL\n                        Interval in seconds at which to report aggregated\n                        data. (default: 60.0)\n  -c {all,none,stdout,stderr}, --capture-outputs {all,none,stdout,stderr}\n                        Record stdout, stderr, all, or none to log files. You\n                        can also provide value via DUCT_CAPTURE_OUTPUTS env\n                        variable. (default: all)\n  -o {all,none,stdout,stderr}, --outputs {all,none,stdout,stderr}\n                        Print stdout, stderr, all, or none to stdout/stderr\n                        respectively. (default: all)\n  -t {all,system-summary,processes-samples}, --record-types {all,system-summary,processes-samples}\n                        Record system-summary, processes-samples, or all\n                        (default: all)\n\n```\n<!-- END HELP -->\n\n# con-duct suite\n\nIn addition to `duct`, this project also includes a set of optional helpers under the `con-duct` command.\nThese helpers may use 3rd party python libraries.\n\n## Installation\n\n    pip install con-duct[all]\n\n## Extras Helptext\n\n<!-- BEGIN EXTRAS HELP -->\n```shell\n>con-duct --help\n\nusage: con-duct <command> [options]\n\nA command-line tool for managing various tasks.\n\npositional arguments:\n  {pp,plot}   Available subcommands\n    pp        Pretty print a JSON log\n    plot      Plot resource usage for an execution.\n\noptions:\n  -h, --help  show this help message and exit\n\n```\n<!-- END EXTRAS HELP -->\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Runs a not-so-simple command and collects resource usage metrics",
    "version": "0.8.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/con/duct/issues",
        "Homepage": "https://github.com/con/duct/",
        "Source Code": "https://github.com/con/duct/"
    },
    "split_keywords": [
        "command-line",
        " cpu",
        " memory",
        " metrics",
        " output-capture",
        " provenance",
        " time",
        " usage"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74edbd41fb6786b7022faeb5ef08cd307704cf4b829ffd2e3bc3651560a3e51e",
                "md5": "ead2e4c69483256c5c508c1aae0ee185",
                "sha256": "98b8e75edf6c2b844b1694d49f3ad0671344e0847962441de752c9ee89933acd"
            },
            "downloads": -1,
            "filename": "con_duct-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ead2e4c69483256c5c508c1aae0ee185",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 18061,
            "upload_time": "2024-10-24T18:41:13",
            "upload_time_iso_8601": "2024-10-24T18:41:13.268123Z",
            "url": "https://files.pythonhosted.org/packages/74/ed/bd41fb6786b7022faeb5ef08cd307704cf4b829ffd2e3bc3651560a3e51e/con_duct-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57901fa2c07a35e61bf7f2ae1e328d5f4b7421f0d1bac2d3ed250f81932b27fe",
                "md5": "94f55f8869a78ae7bbeef3d51d883225",
                "sha256": "d7c1a5aeb0a6ee18803adef3ecdc61653529ab17846e8a14800be17a8bf50c68"
            },
            "downloads": -1,
            "filename": "con_duct-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "94f55f8869a78ae7bbeef3d51d883225",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 44119,
            "upload_time": "2024-10-24T18:41:14",
            "upload_time_iso_8601": "2024-10-24T18:41:14.797356Z",
            "url": "https://files.pythonhosted.org/packages/57/90/1fa2c07a35e61bf7f2ae1e328d5f4b7421f0d1bac2d3ed250f81932b27fe/con_duct-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-24 18:41:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "con",
    "github_project": "duct",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "con-duct"
}
        
Elapsed time: 0.36855s