Skip to content

Commit

Permalink
Fixed Lance directory path bug in SpectrumDataset (#42)
Browse files Browse the repository at this point in the history
* fix lance path bugs

* Update linting and formating, and make lint fix

* Add target-version and fix formating arg

---------

Co-authored-by: William Fondrie <[email protected]>
  • Loading branch information
Alfred-N and wfondrie authored Dec 6, 2023
1 parent 2079903 commit bd2861f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 48 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ jobs:
python -m pip install --upgrade pip
pip install ruff
- name: Run black
uses: psf/black@stable

- name: Lint with Ruff
run: |
ruff check . --format=github
ruff check . --output-format=github
- name: Check for debugging print statements
- name: Check formatting with Ruff
run: |
if grep -rq "print(" depthcharge; then
echo "Found the following print statements:"
grep -r "print(" deptchcharge
exit 1
fi
ruff format --check .
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: detect-private-key
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.269
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
args: ['--show-fixes']
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.10
types_or: [ python, pyi, jupyter ]
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
7 changes: 3 additions & 4 deletions depthcharge/data/spectrum_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def __init__(
path = Path(self._tmpdir.name) / f"{uuid.uuid4()}.lance"

self._path = Path(path)
if self._path.suffix != "lance":
self._path = path.with_suffix(".lance")
if self._path.suffix != ".lance":
self._path = self._path.with_suffix(".lance")

# Now parse spectra.
if spectra is not None:
Expand Down Expand Up @@ -461,8 +461,7 @@ def _get_records(
except (pa.ArrowInvalid, TypeError):
spectra = arrow.spectra_to_stream(spectra, **kwargs)

for batch in spectra:
yield batch
yield from spectra


def _tensorize(obj: Any) -> Any: # noqa: ANN401
Expand Down
31 changes: 5 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ find = {namespaces = false}
[tool.setuptools_scm]

[tool.ruff]
line-length = 79
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "W", "C", "I", "D", "UP", "N", "ANN", "T20"]

# ANN101 Missing type annotation for `self` in method
Expand All @@ -71,34 +75,9 @@ select = ["E", "F", "W", "C", "I", "D", "UP", "N", "ANN", "T20"]
# ANN102 Missing type annotation for `cls` in classmethod
# D401 First line of docstring should be in imperative mood
ignore = ["D213", "ANN101", "D203", "D100", "ANN102", "D401"]
fix = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"*tests/*.py" = ["ANN", "N806"]
"__init__.py" = ["F401", "D104"]
"depthcharge/encoders/sinusoidal.py" = ["N803"]
"depthcharge/feedforward.py" = ["N803"]

[tool.black]
line-length = 79
target-version = ['py310']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''

0 comments on commit bd2861f

Please sign in to comment.