From b7a1a9cea7852d0363c67957ec9cf05668604bda Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Fri, 15 Dec 2023 22:47:41 +0800 Subject: [PATCH] add docstrings --- csst_common/__init__.py | 4 ++-- csst_common/file.py | 17 ++++++++++++++++- csst_common/pipeline.py | 29 +++++++++++++++++++++++++++++ csst_common/status.py | 19 ++++++++++++++++--- 4 files changed, 63 insertions(+), 6 deletions(-) diff --git a/csst_common/__init__.py b/csst_common/__init__.py index bd486b3..f0f48ca 100644 --- a/csst_common/__init__.py +++ b/csst_common/__init__.py @@ -10,11 +10,11 @@ Modified-History: 2023-12-15, Bo Zhang, add module header """ -from .ccds import CCDS from .decorator import parameterized_module_decorator -from .dfs import DFS from .file import File from .pipeline import Pipeline from .status import CsstResult, CsstStatus __version__ = "0.0.2" + +__all__ = ["Pipeline", "File", "CsstResult"] diff --git a/csst_common/file.py b/csst_common/file.py index 25136ba..5fa0e56 100644 --- a/csst_common/file.py +++ b/csst_common/file.py @@ -16,7 +16,22 @@ from typing import Optional class File: - def __init__(self, file_path: str = "/path/to/file.fits", new_dir=None): + """ + CSST MSC standard file path parser. + + It can be used for parse CSST MSC file paths and generate corresponding output file paths. + + Parameters + ---------- + file_path : str + File path. + new_dir : str + New directory. + """ + + def __init__( + self, file_path: str = "/path/to/file.fits", new_dir: Optional[str] = None + ): self.file_path = file_path # get dir name self.dirname = os.path.dirname(self.file_path) diff --git a/csst_common/pipeline.py b/csst_common/pipeline.py index 94a3e05..f6440f0 100644 --- a/csst_common/pipeline.py +++ b/csst_common/pipeline.py @@ -25,6 +25,35 @@ from .logger import get_logger class Pipeline: + """ + CSST pipeline configuration class. + + It should be used for every pipeline to initialize environment. + + Parameters + ---------- + dir_input : str + Input path. + dir_output : str + Output path. + dir_aux : str + Aux path. + dfs_root : str + DFS root path. + ccds_root : str + CCDS root path. + ccds_cache : str + CCDS cache path. + filter_warnings : bool + If `True`, filter warnings. + dfs : bool + If `True`, initialize DFS. + ccds : bool + If `True`, initialize CCDS. + **kwargs : Any + Additional keyword arguments. + """ + def __init__( self, dir_input: str = "/pipeline/input", diff --git a/csst_common/status.py b/csst_common/status.py index 0b0980c..9f8c6b7 100644 --- a/csst_common/status.py +++ b/csst_common/status.py @@ -15,10 +15,10 @@ from typing import Optional, Any class CsstStatus(IntEnum): """ - The CSST Status class. + The CSST standard status class. - This class provides a set of status which should be returned - from each CSST L1 functional module. + This class provides a set of status which should be returned from each CSST algorithm module. + 0, 1, 2 stands for PERFECT, WARNING, ERROR, respectively. Examples -------- @@ -36,6 +36,19 @@ class CsstStatus(IntEnum): class CsstResult: """ + CSST standard result class. + + This is designed for all algorithm modules. + + Parameters + ---------- + status : CsstStatus + The final status of the algorithm. + files : Optional[list[str]] + The files to which changes are made. + **output : Any + Additional results. + Examples -------- >>> CsstResult(CsstStatus.PERFECT, ["file1.fits", "file2.fits"]) -- GitLab