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

moved cli to src/rail/cli/rail_pipe #51

Merged
merged 1 commit into from
Dec 6, 2024
Merged
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
moved cli to src/rail/cli/rail_pipe
  • Loading branch information
eacharles committed Dec 4, 2024
commit e48a304d75f9973c406ccd750e19f595c97f72c4
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ dev = [
]

[project.scripts]
rail_pipe = "rail.cli.pipe_commands:pipe_cli"
rail_pipe = "rail.cli.rail_pipe.pipe_commands:pipe_cli"

[build-system]
requires = [
Empty file.
5 changes: 5 additions & 0 deletions src/rail/cli/rail_pipe/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file must exist with these contents
from .pipe_commands import pipe_cli

if __name__ == "__main__":
pipe_cli()
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
from rail.core import __version__

from rail.utils.project import RailProject
from rail.cli import pipe_options, pipe_scripts
from rail.cli.reduce_roman_rubin_data import reduce_roman_rubin_data
from rail.cli.rail_pipe import pipe_options, pipe_scripts
from rail.cli.rail_pipe.reduce_roman_rubin_data import reduce_roman_rubin_data


@click.group()
@@ -37,41 +37,46 @@ def build_command(config_file: str, **kwargs: Any) -> int:
return ok


@pipe_cli.command(name="reduce")
@pipe_cli.command(name="subsample")
@pipe_options.config_file()
@pipe_options.input_tag()
@pipe_options.input_selection()
@pipe_options.selection()
@pipe_options.flavor()
@pipe_options.label()
@pipe_options.run_mode()
def reduce_command(config_file: str, **kwargs: Any) -> int:
"""Reduce the roman rubin simulations for PZ analysis"""
def subsample_command(config_file: str, **kwargs: Any) -> int:
"""Make a training or test data set by randomly selecting objects"""
"""Make a training data set by randomly selecting objects"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
selections = project.get_selection_args(kwargs.pop('selection'))
input_selections = kwargs.pop('input_selection')
iter_kwargs = project.generate_kwargs_iterable(selection=selections, input_selection=input_selections)
input_tag = kwargs.pop('input_tag', 'truth')
iter_kwargs = project.generate_kwargs_iterable(flavor=flavors, selection=selections)
ok = 0
for kw in iter_kwargs:
ok |= reduce_roman_rubin_data(project, input_tag, **kw, **kwargs)
ok |= pipe_scripts.subsample_data(project, **kw, **kwargs)
return ok


@pipe_cli.command(name="subsample")
@pipe_cli.group(name="reduce")
def reduce_group() -> None:
"""Reduce input data for PZ analysis"""


@reduce_group.command(name="roman_rubin")
@pipe_options.config_file()
@pipe_options.input_tag()
@pipe_options.input_selection()
@pipe_options.selection()
@pipe_options.flavor()
@pipe_options.label()
@pipe_options.run_mode()
def subsample_command(config_file: str, **kwargs: Any) -> int:
"""Make a training or test data set by randomly selecting objects"""
"""Make a training data set by randomly selecting objects"""
def reduce_roman_rubin(config_file: str, **kwargs: Any) -> int:
"""Reduce the roman rubin simulations for PZ analysis"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
selections = project.get_selection_args(kwargs.pop('selection'))
iter_kwargs = project.generate_kwargs_iterable(flavor=flavors, selection=selections)
input_selections = kwargs.pop('input_selection')
iter_kwargs = project.generate_kwargs_iterable(selection=selections, input_selection=input_selections)
input_tag = kwargs.pop('input_tag', 'truth')
ok = 0
for kw in iter_kwargs:
ok |= pipe_scripts.subsample_data(project, **kw, **kwargs)
ok |= reduce_roman_rubin_data(project, input_tag, **kw, **kwargs)
return ok


Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

import click

from rail.cli.options import (
from rail.cli.rail.options import (
EnumChoice,
PartialOption,
PartialArgument,
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
from rail.utils import catalog_utils
from rail.core.stage import RailPipeline
from rail.utils.project import RailProject
from rail.cli.pipe_options import RunMode
from rail.cli.rail_pipe.pipe_options import RunMode


def handle_command(
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
import pyarrow.parquet as pq
from pyarrow import acero

from rail.cli.pipe_options import RunMode
from rail.cli.rail_pipe.pipe_options import RunMode
from rail.utils.project import RailProject


Loading