Skip to main content

rocrate-action-recorder

PyPI DOI Research Software Directory Badge github repo badge github license badge CI readthedocs

Python package to record calls of Python CLI commands into a Research Object Crate (RO-Crate). Useful to track which commands were executed, which files were used as input or output, and which software was used to execute the command.

Supports RO-Crate 1.1 specification. Specifically the Process Run Crate profile.

Provides adapters for CLIs based on:

Install

pip install rocrate-action-recorder

For Click support, install the optional extra:

pip install "rocrate-action-recorder[click]"

For Cyclopts support, install the optional extra:

pip install "rocrate-action-recorder[cyclopts]"

Usage

Example of recording a CLI command (example-cli input.txt output.txt) implemented with argparse.

import argparse
from pathlib import Path
import sys

from rocrate_action_recorder import recorded_argparse

parser = argparse.ArgumentParser(prog="example-cli", description="Example CLI")
parser.add_argument("--version", action="version", version="%(prog)s 1.2.3")
parser.add_argument("--no-record", action="store_false", help="Disable RO-Crate recording.")
parser.add_argument("input", type=Path, help="Input file")
parser.add_argument("output", type=Path, help="Output file")


@recorded_argparse(
    parser=parser,
    input_files=["input"],
    output_files=["output"],
    dataset_license="CC-BY-4.0",
    enabled_argument="no_record",
)
def handler(args: argparse.Namespace):
    # For demonstration, just upper case input to output, replace with real logic
    args.output.write_text(args.input.read_text().upper())


# Prepare input
Path("input.txt").write_text("hello")
# Simulate command-line arguments
sys.argv.extend(["input.txt", "output.txt"])

args = parser.parse_args()
handler(args)

After execution, a ro-crate-metadata.json file (like this one) will be generated in the current working directory, describing the execution of the CLI command.

You can also call the low-level record function directly.

See documentation for more details.

Contributions

See AGENTS.md for commands and hints for contributions.

Citation

See CITATION.cff for citation information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rocrate_action_recorder-0.6.0.tar.gz (90.9 kB view details)

Uploaded Source

Built Distribution

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

rocrate_action_recorder-0.6.0-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file rocrate_action_recorder-0.6.0.tar.gz.

File metadata

  • Download URL: rocrate_action_recorder-0.6.0.tar.gz
  • Upload date:
  • Size: 90.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for rocrate_action_recorder-0.6.0.tar.gz
Algorithm Hash digest
SHA256 1bfbc4d7e65a23742c6e2cfb4755a270b1835b152bb42fd7d66cc850b4cd950a
MD5 2f0e7a32108fe34a6634842a149314f5
BLAKE2b-256 1daa22dea8fb6e15ce40ff341296e77d146c8bf6eb1db8bea92fd53f72d05f7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocrate_action_recorder-0.6.0.tar.gz:

Publisher: publish.yml on i-VRESSE/rocrate-action-recorder

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

File details

Details for the file rocrate_action_recorder-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rocrate_action_recorder-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0adf11446630ee3d984aa6cd7d8213844660f091e23a00dbe69e42e560a76235
MD5 e82e6792e5451c97bf859234db2c2ec5
BLAKE2b-256 d1db4caebddf53fa8a1f4a79202495521ed6e3c3303a92681a174ee6e00441b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocrate_action_recorder-0.6.0-py3-none-any.whl:

Publisher: publish.yml on i-VRESSE/rocrate-action-recorder

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

Release history Release notifications | RSS feed

0.7.1

2 files

0.7.0

2 files

This release

0.6.0 This release

2 files

0.5.3

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page