Skip to content

Commit 8de6d7b

Browse files
committed
fixed bugs
1 parent c4022e0 commit 8de6d7b

File tree

6 files changed

+49
-31
lines changed

6 files changed

+49
-31
lines changed

scripts/build_features.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
if str(SRC_PATH) not in sys.path:
1616
sys.path.insert(0, str(SRC_PATH))
1717

18-
from patchseq_pipeline.config import load_config
19-
from patchseq_pipeline.data.preprocess import preprocess_pipeline
18+
# Local imports that require the repository `src/` on sys.path are imported inside
19+
# the CLI function to keep top-level imports tidy and satisfy linters.
2020

2121
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
2222

@@ -26,13 +26,17 @@
2626
@app.command()
2727
def run(
2828
config_path: Path = typer.Option(
29-
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML."
29+
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML." # noqa: B008
3030
),
3131
output_path: Optional[Path] = typer.Option(
32-
None, "--output", "-o", help="Override destination for processed AnnData."
32+
None, "--output", "-o", help="Override destination for processed AnnData." # noqa: B008
3333
),
3434
) -> None:
3535
"""Execute preprocessing using the configuration file."""
36+
# Import project package here to avoid module-level imports after code (E402)
37+
from patchseq_pipeline.config import load_config
38+
from patchseq_pipeline.data.preprocess import preprocess_pipeline
39+
3640
config = load_config(config_path)
3741
output = output_path or Path(config["paths"]["processed_dir"]) / "patchseq_processed.h5ad"
3842
preprocess_pipeline(

scripts/checksums.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
if str(SRC_PATH) not in sys.path:
1616
sys.path.insert(0, str(SRC_PATH))
1717

18-
from patchseq_pipeline.config import load_config
19-
from patchseq_pipeline.utils.checksums import digest_map
18+
# Project imports are performed inside the CLI handler to avoid module-level
19+
# imports after executable code (which triggers E402 in linters).
2020

2121
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
2222

@@ -36,21 +36,25 @@ def _collect_files(config: Dict) -> Dict[str, Path]:
3636
@app.command()
3737
def run(
3838
config_path: Path = typer.Option(
39-
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML."
39+
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML." # noqa: B008
4040
),
4141
output_file: Path = typer.Option(
42-
None,
42+
None, # noqa: B008
4343
"--output",
4444
"-o",
4545
help="Destination for checksum file (defaults to data/raw/checksums.sha256).",
4646
),
4747
verify: bool = typer.Option(
48-
False,
48+
False, # noqa: B008
4949
"--verify",
5050
help="Verify computed digests against values in config.download.checksums.",
5151
),
5252
) -> None:
5353
"""Compute SHA256 digests and optionally verify against expected values."""
54+
# Local project imports to satisfy linters (E402)
55+
from patchseq_pipeline.config import load_config
56+
from patchseq_pipeline.utils.checksums import digest_map
57+
5458
config = load_config(config_path)
5559
files = _collect_files(config)
5660
missing = [name for name, path in files.items() if not path.exists()]

scripts/download_data.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
if str(SRC_PATH) not in sys.path:
1515
sys.path.insert(0, str(SRC_PATH))
1616

17-
from patchseq_pipeline.config import load_config
18-
from patchseq_pipeline.data.download import (
19-
download_ephys_features,
20-
download_metadata,
21-
download_transcriptomics,
22-
)
17+
# Project imports are deferred into the CLI handler to avoid module-level
18+
# imports after executable code (E402 lint violations).
2319

2420
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
2521

@@ -29,21 +25,29 @@
2925
@app.command()
3026
def run(
3127
config_path: Path = typer.Option(
32-
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML."
28+
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML." # noqa: B008
3329
),
3430
manifest_path: Path = typer.Option(
35-
None,
31+
None, # noqa: B008
3632
"--manifest",
3733
"-m",
3834
help="Optional override for AllenSDK manifest path (defaults to config.paths.manifest).",
3935
),
4036
force: bool = typer.Option(
41-
False,
37+
False, # noqa: B008
4238
"--force",
4339
help="Re-download files even if they already exist.",
4440
),
4541
) -> None:
4642
"""Download the Patch-seq assets defined in the configuration file."""
43+
# Local project imports to satisfy linters (E402)
44+
from patchseq_pipeline.config import load_config
45+
from patchseq_pipeline.data.download import (
46+
download_ephys_features,
47+
download_metadata,
48+
download_transcriptomics,
49+
)
50+
4751
config = load_config(config_path)
4852
paths = config["paths"]
4953
manifest = manifest_path or Path(paths["manifest"])

scripts/generate_figures.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
if str(SRC_PATH) not in sys.path:
1515
sys.path.insert(0, str(SRC_PATH))
1616

17-
from patchseq_pipeline.analysis.feature_selection import summarize_feature_importance
18-
from patchseq_pipeline.config import load_config
19-
from patchseq_pipeline.viz.figures import generate_all_figures
17+
# Project imports deferred into the CLI handler to avoid E402.
2018

2119
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
2220

@@ -26,28 +24,33 @@
2624
@app.command()
2725
def run(
2826
config_path: Path = typer.Option(
29-
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML."
27+
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML." # noqa: B008
3028
),
3129
processed_path: Path = typer.Option(
32-
Path("data/processed/patchseq_processed.h5ad"),
30+
Path("data/processed/patchseq_processed.h5ad"), # noqa: B008
3331
"--processed",
3432
"-p",
3533
help="Processed AnnData file.",
3634
),
3735
models_dir: Path = typer.Option(
38-
Path("results/models"),
36+
Path("results/models"), # noqa: B008
3937
"--models-dir",
4038
"-m",
4139
help="Directory containing trained models.",
4240
),
4341
output_dir: Path = typer.Option(
44-
Path("results/figures"),
42+
Path("results/figures"), # noqa: B008
4543
"--output-dir",
4644
"-o",
4745
help="Destination directory for figures.",
4846
),
4947
) -> None:
5048
"""Generate all figures and save them to the configured output directory."""
49+
# Local imports to avoid module-level imports after top-level code
50+
from patchseq_pipeline.analysis.feature_selection import summarize_feature_importance
51+
from patchseq_pipeline.config import load_config
52+
from patchseq_pipeline.viz.figures import generate_all_figures
53+
5154
config = load_config(config_path)
5255
config["figures"]["output_dir"] = str(output_dir)
5356
summary_csv = summarize_feature_importance(models_dir, config, output_dir)

scripts/train_model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
if str(SRC_PATH) not in sys.path:
1616
sys.path.insert(0, str(SRC_PATH))
1717

18-
from patchseq_pipeline.config import ensure_output_dir, load_config
19-
from patchseq_pipeline.models.multimodal import train_elastic_net
18+
# Project imports deferred into the CLI handler to avoid E402.
2019

2120
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
2221

@@ -26,19 +25,23 @@
2625
@app.command()
2726
def run(
2827
config_path: Path = typer.Option(
29-
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML."
28+
Path("config/config.yaml"), "--config", "-c", help="Path to config YAML." # noqa: B008
3029
),
3130
input_path: Path = typer.Option(
32-
Path("data/processed/patchseq_processed.h5ad"),
31+
Path("data/processed/patchseq_processed.h5ad"), # noqa: B008
3332
"--input",
3433
"-i",
3534
help="Processed AnnData file.",
3635
),
3736
output_dir: Path = typer.Option(
38-
Path("results/models"), "--output-dir", "-o", help="Directory for trained models."
37+
Path("results/models"), "--output-dir", "-o", help="Directory for trained models." # noqa: B008
3938
),
4039
) -> None:
4140
"""Train ElasticNet models for each electrophysiology target."""
41+
# Local imports to avoid module-level imports after top-level code
42+
from patchseq_pipeline.config import ensure_output_dir, load_config
43+
from patchseq_pipeline.models.multimodal import train_elastic_net
44+
4245
config = load_config(config_path)
4346
ensure_output_dir(config)
4447
adata = anndata.read_h5ad(input_path)

src/patchseq_pipeline/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""PatchSeq-Epilepsy pipeline package."""
22

3-
from importlib.metadata import version, PackageNotFoundError
3+
from importlib.metadata import PackageNotFoundError, version
44

55
try:
66
__version__ = version("patchseq-epilepsy")

0 commit comments

Comments
 (0)