Skip to content

Commit

Permalink
Merge pull request #45 from LSSTDESC/issue/44/code_cleanup
Browse files Browse the repository at this point in the history
Issue/44/code cleanup
  • Loading branch information
eacharles authored Dec 2, 2024
2 parents a981fca + 873dbf9 commit c5cbc90
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 143 deletions.
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ disable = [
"abstract-method",
"invalid-name",
"too-many-statements",
"too-many-instance-attributes",
"missing-module-docstring",
"missing-class-docstring",
"missing-function-docstring",
Expand All @@ -73,7 +74,23 @@ disable = [
"use-dict-literal",
"broad-exception-caught",
]
generated-members = ["add", "multiply", "subtract", "divide", "sqrt", "floor", "atan2"]
max-line-length = 110
max-locals = 50
max-branches = 25
max-public-methods = 50
max-args = 7


[tool.mypy]
disallow_untyped_defs = true
disallow_incomplete_defs = true
ignore_missing_imports = true
local_partial_types = true
no_implicit_reexport = true
show_error_codes = true
strict_equality = true
warn_redundant_casts = true
warn_unreachable = true
warn_unused_ignores = true

1 change: 0 additions & 1 deletion src/rail/_pipelines/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from ._version import __version__

30 changes: 16 additions & 14 deletions src/rail/cli/pipe_commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

import click

from rail.core import __version__
Expand All @@ -15,15 +17,15 @@ def pipe_cli() -> None:

@pipe_cli.command(name="inspect")
@pipe_options.config_file()
def inspect(config_file):
def inspect(config_file: str) -> int:
"""Inspect a rail pipeline project config"""
return pipe_scripts.inspect(config_file)


@pipe_cli.command()
@pipe_options.config_file()
@pipe_options.flavor()
def build_pipelines(config_file, **kwargs):
def build_pipelines(config_file: str, **kwargs: Any) -> int:
"""Build the ceci pipeline configuraiton files"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
Expand All @@ -40,7 +42,7 @@ def build_pipelines(config_file, **kwargs):
@pipe_options.input_selection()
@pipe_options.selection()
@pipe_options.run_mode()
def reduce_roman_rubin(config_file, **kwargs):
def reduce_roman_rubin(config_file: str, **kwargs: Any) -> int:
"""Reduce the roman rubin simulations for PZ analysis"""
project = RailProject.load_config(config_file)
selections = project.get_selection_args(kwargs.pop('selection'))
Expand All @@ -58,15 +60,15 @@ def reduce_roman_rubin(config_file, **kwargs):
@pipe_options.selection()
@pipe_options.flavor()
@pipe_options.run_mode()
def truth_to_observed_pipeline(config_file, **kwargs):
def truth_to_observed_pipeline(config_file: str, **kwargs: Any) -> int:
"""Run the truth-to-observed analysis pipeline"""
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)
ok = 0
pipeline_name = "truth_to_observed"

pipeline_catalog_config = pipe_scripts.TruthToObservedPipelineCatalogConfiguration(
project, source_catalog_tag='reduced', sink_catalog_tag='degraded',
)
Expand All @@ -84,7 +86,7 @@ def truth_to_observed_pipeline(config_file, **kwargs):
@pipe_options.selection()
@pipe_options.flavor()
@pipe_options.run_mode()
def spectroscopic_selection_pipeline(config_file, **kwargs):
def spectroscopic_selection_pipeline(config_file: str, **kwargs: Any) -> int:
"""Run the spectroscopic selection analysis pipeline"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
Expand Down Expand Up @@ -116,7 +118,7 @@ def spectroscopic_selection_pipeline(config_file, **kwargs):
@pipe_options.selection()
@pipe_options.flavor()
@pipe_options.run_mode()
def blending_pipeline(config_file, **kwargs):
def blending_pipeline(config_file: str, **kwargs: Any) -> int:
"""Run the blending analysis pipeline"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
Expand Down Expand Up @@ -147,7 +149,7 @@ def blending_pipeline(config_file, **kwargs):
@pipe_options.selection()
@pipe_options.label()
@pipe_options.run_mode()
def subsample_data(config_file, **kwargs):
def subsample_data(config_file: str, **kwargs: Any) -> int:
"""Make a training data set by randomly selecting objects"""
project = RailProject.load_config(config_file)
flavors = project.get_flavor_args(kwargs.pop('flavor'))
Expand All @@ -164,7 +166,7 @@ def subsample_data(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def inform(config_file, **kwargs):
def inform(config_file: str, **kwargs: Any) -> int:
"""Run the inform pipeline"""
pipeline_name = "inform"
project = RailProject.load_config(config_file)
Expand All @@ -186,7 +188,7 @@ def inform(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def estimate_single(config_file, **kwargs):
def estimate_single(config_file: str, **kwargs: Any) -> int:
"""Run the estimation pipeline"""
pipeline_name = "estimate"
project = RailProject.load_config(config_file)
Expand All @@ -208,7 +210,7 @@ def estimate_single(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def evaluate_single(config_file, **kwargs):
def evaluate_single(config_file: str, **kwargs: Any) -> int:
"""Run the evaluation pipeline"""
pipeline_name = "evaluate"
project = RailProject.load_config(config_file)
Expand All @@ -230,7 +232,7 @@ def evaluate_single(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def pz_single(config_file, **kwargs):
def pz_single(config_file: str, **kwargs: Any) -> int:
"""Run the pz pipeline"""
pipeline_name = "pz"
project = RailProject.load_config(config_file)
Expand All @@ -252,7 +254,7 @@ def pz_single(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def tomography_single(config_file, **kwargs):
def tomography_single(config_file : str, **kwargs: Any) -> int:
"""Run the tomography pipeline"""
pipeline_name = "tomography"
project = RailProject.load_config(config_file)
Expand All @@ -274,7 +276,7 @@ def tomography_single(config_file, **kwargs):
@pipe_options.flavor()
@pipe_options.selection()
@pipe_options.run_mode()
def sompz_single(config_file, **kwargs):
def sompz_single(config_file: str, **kwargs: Any) -> int:
"""Run the sompz pipeline"""
pipeline_name = "sompz"
project = RailProject.load_config(config_file)
Expand Down
2 changes: 1 addition & 1 deletion src/rail/cli/pipe_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


__all__ = [
__all__: list[str] = [
"RunMode",
"config_path",
"flavor",
Expand Down
Loading

0 comments on commit c5cbc90

Please sign in to comment.