Skip to content

Commit

Permalink
Switch to warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-cooney committed Nov 5, 2023
1 parent 706ffe4 commit e0ebec6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
reportInvalidTypeVarUse=true
reportMatchNotExhaustive=true
reportMissingParameterType=true
reportMissingTypeArgument=true
reportMissingTypeArgument="warning"
reportOptionalCall=true
reportOptionalContextManager=true
reportOptionalIterable=true
Expand All @@ -115,7 +115,7 @@
reportTypedDictNotRequiredAccess=true
reportUnboundVariable=true
reportUnknownLambdaType=true
reportUnknownParameterType=true
reportUnknownParameterType="warning"
reportUnnecessaryCast=true
reportUnnecessaryComparison=true
reportUnnecessaryContains=true
Expand Down
4 changes: 2 additions & 2 deletions sparse_autoencoder/activation_store/base_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class ActivationStore(Dataset[ActivationStoreItem], ABC):
"""

@abstractmethod
def append(self, item: ActivationStoreItem) -> Future[None] | None:
def append(self, item: ActivationStoreItem) -> Future | None:
"""Add a Single Item to the Store."""
raise NotImplementedError

@abstractmethod
def extend(self, batch: ActivationStoreBatch) -> Future[None] | None:
def extend(self, batch: ActivationStoreBatch) -> Future | None:
"""Add a Batch to the Store."""
raise NotImplementedError

Expand Down
8 changes: 4 additions & 4 deletions sparse_autoencoder/activation_store/disk_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DiskActivationStore(ActivationStore):
_storage_path: Path
"""Path to the Directory where the Activation Vectors are Stored."""

_cache: ListProxy[ActivationStoreItem]
_cache: ListProxy
"""Cache for Activation Vectors.
Activation vectors are buffered in memory until the cache is full, at which point they are
Expand Down Expand Up @@ -132,7 +132,7 @@ def _write_to_disk(self, *, wait_for_max: bool = False) -> None:
filename = f"{self.__len__}.pt"
torch.save(stacked_activations, self._storage_path / filename)

def append(self, item: ActivationStoreItem) -> Future[None] | None:
def append(self, item: ActivationStoreItem) -> Future | None:
"""Add a Single Item to the Store.
Example:
Expand All @@ -158,7 +158,7 @@ def append(self, item: ActivationStoreItem) -> Future[None] | None:

return None # Keep mypy happy

def extend(self, batch: ActivationStoreBatch) -> Future[None] | None:
def extend(self, batch: ActivationStoreBatch) -> Future | None:
"""Add a Batch to the Store.
Example:
Expand Down Expand Up @@ -254,7 +254,7 @@ def __len__(self) -> int:
0
"""
# Calculate the length if not cached
if self._disk_n_activation_vectors.value is -1:
if self._disk_n_activation_vectors.value == -1:
cache_size: int = 0
for file in self._all_filenames:
cache_size += len(torch.load(file))
Expand Down
10 changes: 5 additions & 5 deletions sparse_autoencoder/activation_store/list_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ListActivationStore(ActivationStore):
torch.Size([2, 100])
"""

_data: list[ActivationStoreItem] | ListProxy[ActivationStoreItem]
_data: list[ActivationStoreItem] | ListProxy
"""Underlying List Data Store."""

_device: torch.device | None
Expand All @@ -78,13 +78,13 @@ class ListActivationStore(ActivationStore):
_pool: ProcessPoolExecutor | None = None
"""Multiprocessing Pool."""

_pool_exceptions: ListProxy[Exception] | list[Exception]
_pool_exceptions: ListProxy | list[Exception]
"""Pool Exceptions.
Used to keep track of exceptions.
"""

_pool_futures: list[Future[None]]
_pool_futures: list[Future]
"""Pool Futures.
Used to keep track of processes running in the pool.
Expand Down Expand Up @@ -205,7 +205,7 @@ def shuffle(self) -> None:
self.wait_for_writes_to_complete()
random.shuffle(self._data)

def append(self, item: ActivationStoreItem) -> Future[None] | None:
def append(self, item: ActivationStoreItem) -> Future | None:
"""Append a single item to the dataset.
Note **append is blocking**. For better performance use extend instead with batches.
Expand Down Expand Up @@ -239,7 +239,7 @@ def _extend(self, batch: ActivationStoreBatch) -> None:
except Exception as e: # noqa: BLE001
self._pool_exceptions.append(e)

def extend(self, batch: ActivationStoreBatch) -> Future[None] | None:
def extend(self, batch: ActivationStoreBatch) -> Future | None:
"""Extend the dataset with multiple items (non-blocking).
Example:
Expand Down

0 comments on commit e0ebec6

Please sign in to comment.