Skip to content

Commit

Permalink
chores: update pyproject.toml and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
miili committed Mar 6, 2024
1 parent d3970fb commit b513d35
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repos:
- id: mixed-line-ending
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
rev: v0.3.0
hooks:
- id: ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
rev: v0.3.0
hooks:
- id: ruff-format
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ maintainers = [
{ name = "Marius Paul Isken", email = "mi@gfz-potsdam.de" },
{ name = "Sebastian Heimann", email = "heimann@uni-potsdam.de" },
]
keywords = ["earthquake", "detection", "locatiosation", "stacking-migration"]
keywords = [
"earthquake",
"detection",
"localization",
"stacking-migration",
"beamforming",
]

dependencies = [
"numpy>=1.17.3",
Expand Down Expand Up @@ -64,7 +70,11 @@ dev = [
"pytest-asyncio>=0.21",
]

docs = ["mkdocs-material>=9.4.8", "mkdocstrings[python]>=0.23", "qseek-extra"]
docs = [
"mkdocs-material>=9.4.8",
"mkdocstrings[python]>=0.23",
"qseek-insights",
]
completion = ["argcomplete>=3.2"]

[project.scripts]
Expand Down
7 changes: 4 additions & 3 deletions src/qseek/apps/qseek.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,10 @@ async def extract() -> None:
search = Search.load_rundir(args.rundir)
webserver = WebServer(search)

loop = asyncio.get_event_loop()
loop.create_task(webserver.start())
loop.run_forever()
async def start() -> None:
await webserver.start()

asyncio.run(start(), debug=loop_debug)

case "clear-cache":
logger.info("clearing cache directory %s", CACHE_DIR)
Expand Down
3 changes: 1 addition & 2 deletions src/qseek/corrections/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def get_subclasses(cls) -> tuple[type[TravelTimeCorrections], ...]:
return tuple(cls.__subclasses__())

@property
def n_stations(self) -> int:
...
def n_stations(self) -> int: ...

def get_delay(
self,
Expand Down
6 changes: 2 additions & 4 deletions src/qseek/images/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class ObservedArrival:
class ImageFunction(BaseModel):
image: Literal["base"] = "base"

async def process_traces(self, traces: list[Trace]) -> list[WaveformImage]:
...
async def process_traces(self, traces: list[Trace]) -> list[WaveformImage]: ...

@property
def name(self) -> str:
Expand All @@ -38,8 +37,7 @@ def blinding(self) -> timedelta:
"""Blinding duration for the image function. Added to padded waveforms."""
raise NotImplementedError("must be implemented by subclass")

def get_provided_phases(self) -> tuple[PhaseDescription, ...]:
...
def get_provided_phases(self) -> tuple[PhaseDescription, ...]: ...


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions src/qseek/images/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ImageFunctionsStats(Stats):
time_per_batch: timedelta = timedelta()
bytes_per_second: float = 0.0

_queue: asyncio.Queue[
Tuple[WaveformImages | WaveformBatch] | None
] | None = PrivateAttr(None)
_queue: asyncio.Queue[Tuple[WaveformImages | WaveformBatch] | None] | None = (
PrivateAttr(None)
)

def set_queue(
self,
Expand Down
7 changes: 4 additions & 3 deletions src/qseek/models/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ def load_rundir(cls, rundir: Path) -> EventCatalog:
logger.warning("cannot find %s", detection_file)
return catalog

with console.status(f"loading detections from {rundir}..."), open(
detection_file
) as f:
with (
console.status(f"loading detections from {rundir}..."),
open(detection_file) as f,
):
for idx, line in enumerate(f):
detection = EventDetection.model_validate_json(line)
detection.set_index(idx)
Expand Down
6 changes: 3 additions & 3 deletions src/qseek/models/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def _get_csv_dict(self) -> dict[str, Any]:
if self.observed:
csv_dict[f"{prefix}.model.time"] = self.observed.time
if self.traveltime_delay:
csv_dict[
f"{prefix}.traveltime_delay"
] = self.traveltime_delay.total_seconds()
csv_dict[f"{prefix}.traveltime_delay"] = (
self.traveltime_delay.total_seconds()
)
return csv_dict

def as_pyrocko_markers(self) -> list[marker.PhaseMarker]:
Expand Down
3 changes: 1 addition & 2 deletions src/qseek/models/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ def export_csv(self, filename: Path) -> None:
f"{sta.lat},{sta.lon},{sta.elevation},{sta.depth}\n"
)

def export_vtk(self, reference: Location | None = None) -> None:
...
def export_vtk(self, reference: Location | None = None) -> None: ...

def __hash__(self) -> int:
return hash(sta for sta in self)
3 changes: 1 addition & 2 deletions src/qseek/octree.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def get_node_coordinates(
raise ValueError(f"Unknown coordinate system: {system}")


class NodeSplitError(Exception):
...
class NodeSplitError(Exception): ...


@dataclass(slots=True)
Expand Down
6 changes: 3 additions & 3 deletions src/qseek/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ class Search(BaseModel):
_shift_range: timedelta = PrivateAttr(timedelta(seconds=0.0))
_window_padding: timedelta = PrivateAttr(timedelta(seconds=0.0))
_distance_range: tuple[float, float] = PrivateAttr((0.0, 0.0))
_travel_time_ranges: dict[
PhaseDescription, tuple[timedelta, timedelta]
] = PrivateAttr({})
_travel_time_ranges: dict[PhaseDescription, tuple[timedelta, timedelta]] = (
PrivateAttr({})
)
_last_detection_export: int = 0

_catalog: EventCatalog = PrivateAttr()
Expand Down
6 changes: 2 additions & 4 deletions src/qseek/tracers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ async def prepare(
octree: Octree,
stations: Stations,
rundir: Path | None = None,
):
...
): ...

def get_available_phases(self) -> tuple[str, ...]:
...
def get_available_phases(self) -> tuple[str, ...]: ...

def get_travel_time_location(
self,
Expand Down
7 changes: 4 additions & 3 deletions src/qseek/tracers/cake.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,10 @@ def _load_sptree(self) -> spit.SPTree:
if not self._file or not self._file.exists():
raise FileNotFoundError(f"file {self._file} not found")

with zipfile.ZipFile(
self._file, "r"
) as archive, TemporaryDirectory() as temp_dir:
with (
zipfile.ZipFile(self._file, "r") as archive,
TemporaryDirectory() as temp_dir,
):
archive.extract("model.sptree", path=temp_dir)
return spit.SPTree(filename=str(Path(temp_dir) / "model.sptree"))

Expand Down
3 changes: 1 addition & 2 deletions src/qseek/waveforms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def get_subclasses(cls) -> tuple[type[WaveformProvider], ...]:
def get_squirrel(self) -> Squirrel:
raise NotImplementedError

def prepare(self, stations: Stations) -> None:
...
def prepare(self, stations: Stations) -> None: ...

async def iter_batches(
self,
Expand Down
1 change: 0 additions & 1 deletion test/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import random

import numpy as np

from lassie.models import Location

KM = 1e3
Expand Down
1 change: 0 additions & 1 deletion test/test_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import Path

import pytest

from lassie.models.location import locations_to_csv
from lassie.search import Search

Expand Down

0 comments on commit b513d35

Please sign in to comment.