Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add wrappers for ROOT rootcp CLI tool #3251

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 274 additions & 0 deletions phys/root/rootcp/environment.linux-64.pin.txt

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions phys/root/rootcp/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
channels:
- conda-forge
dependencies:
- ROOT =6.30.4
14 changes: 14 additions & 0 deletions phys/root/rootcp/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "rootcp"
description: Copy ROOT file/object(s) using the ROOT rootcp command line tool
url: https://github.com/root-project/root/blob/master/main/python/rootcp.py
authors:
- Jamie Gooding
input:
- ROOT file/object(s) target (to be copied) and destination.
output:
- >
single ROOT file containing copied target object(s).
params:
- extra: extra parameters to `rootcp` (see ROOT documentation, e.g. `-c` for compression levels)
- input_object_name: (optional) object in ROOT file to be copied.
- output_object_name: (optional) name of destination object to be copied to.
13 changes: 13 additions & 0 deletions phys/root/rootcp/test/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rule rootcp:
input:
"ntuple0.root",
log:
"logs/rootcp/rootcp.log",
params:
input_object_name="TestTree",
extra="--recreate",
threads: 1
output:
"ntuple0_copy.root",
wrapper:
"master/phys/root/rootcp"
Binary file added phys/root/rootcp/test/ntuple0.root
Binary file not shown.
22 changes: 22 additions & 0 deletions phys/root/rootcp/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
__author__ = "Jamie Gooding"
__copyright__ = "Copyright 2024, Jamie Gooding"
__email__ = "jamie.gooding@cern.ch"
__license__ = "MIT"


from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

object_in = snakemake.params.get("input_object_name", "")
if object_in:
object_in = f":{object_in}"

object_out = snakemake.params.get("output_object_name", "")
if object_out:
object_out = f":{object_out}"

shell(
"rootcp {extra} {snakemake.input}{object_in} {snakemake.output}{object_out} {log}"
)
8 changes: 8 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6852,6 +6852,14 @@ def test_root_filter_dict():
)


@skip_if_not_modified
def test_root_rootcp():
run(
"phys/root/rootcp",
["snakemake", "--cores", "2", "--use-conda", "-F"],
)


@skip_if_not_modified
def test_emu_abundance():
run(
Expand Down
Loading