Record calls of Python CLI commands into a Research Object Crate
Project description
rocrate-action-recorder
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 (links go to examples)
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rocrate_action_recorder-0.5.1.tar.gz.
File metadata
- Download URL: rocrate_action_recorder-0.5.1.tar.gz
- Upload date:
- Size: 88.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24ea66fca48219c94bd69819c720930ac0dcaca2cfc5e7d72200486d9975733c
|
|
| MD5 |
63ce4341649fa5a8536e21afca758cba
|
|
| BLAKE2b-256 |
6536484e0f6748016bbb821b8f1400ca4ff0450a1a4b5498f6ff5f22c010cae7
|
Provenance
The following attestation bundles were made for rocrate_action_recorder-0.5.1.tar.gz:
Publisher:
publish.yml on i-VRESSE/rocrate-action-recorder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocrate_action_recorder-0.5.1.tar.gz -
Subject digest:
24ea66fca48219c94bd69819c720930ac0dcaca2cfc5e7d72200486d9975733c - Sigstore transparency entry: 1246462193
- Sigstore integration time:
-
Permalink:
i-VRESSE/rocrate-action-recorder@984ad296c579225c4c33a0ca53e83cd2de90dda1 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/i-VRESSE
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@984ad296c579225c4c33a0ca53e83cd2de90dda1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rocrate_action_recorder-0.5.1-py3-none-any.whl.
File metadata
- Download URL: rocrate_action_recorder-0.5.1-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8aa1f18220690731d4b3abb34fdc35160bbd3784457993641ac4d50cc32309a
|
|
| MD5 |
938ac3a65d13e21f07073152df479736
|
|
| BLAKE2b-256 |
8b873db52bb30cbeeec6950a0b8b845fecbc3277ef1389cfa182feef3c038f37
|
Provenance
The following attestation bundles were made for rocrate_action_recorder-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on i-VRESSE/rocrate-action-recorder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocrate_action_recorder-0.5.1-py3-none-any.whl -
Subject digest:
d8aa1f18220690731d4b3abb34fdc35160bbd3784457993641ac4d50cc32309a - Sigstore transparency entry: 1246462235
- Sigstore integration time:
-
Permalink:
i-VRESSE/rocrate-action-recorder@984ad296c579225c4c33a0ca53e83cd2de90dda1 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/i-VRESSE
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@984ad296c579225c4c33a0ca53e83cd2de90dda1 -
Trigger Event:
release
-
Statement type: