Skip to content

Commit

Permalink
Remove unsupported @typing override
Browse files Browse the repository at this point in the history
Hot fix for Ubuntu. TODO: figure out why this was not caught by the CI/CD pipeline.
  • Loading branch information
aMarcireau committed Feb 12, 2025
1 parent e107eee commit 90be7e7
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 40 deletions.
6 changes: 3 additions & 3 deletions examples/camera_to_aedat4.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import faery

(
faery.events_stream_from_camera("Inivation") # Open an Inivation camera
.crop(10, 110, 10, 110) # Remove events outside the region (10, 10) to (110, 110)
.to_file("some.aedat4") # Save the events to a file
faery.events_stream_from_camera("Inivation") # Open an Inivation camera
.crop(10, 110, 10, 110) # Remove events outside the region (10, 10) to (110, 110)
.to_file("some.aedat4") # Save the events to a file
)
1 change: 1 addition & 0 deletions python/faery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def name_to_colormaps() -> dict[str, Colormap]:
)
}


from .event_camera_input import events_stream_from_camera


Expand Down
3 changes: 0 additions & 3 deletions python/faery/cli/colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (
["faery colormaps <output>"],
"render available colormaps",
)

@typing.override
def first_block_keywords(self) -> set[str]:
return {"colormaps"}

@typing.override
def run(self, arguments: list[str]):
parser = self.parser()
parser.add_argument("output", help="path of the output PNG file")
Expand Down
3 changes: 0 additions & 3 deletions python/faery/cli/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (["faery info <input>"], "prints information about a file")

@typing.override
def first_block_keywords(self) -> set[str]:
return {"info"}

@typing.override
def run(self, arguments: list[str]):
parser = self.parser()
parser.add_argument("path", help="path of the input file")
Expand Down
3 changes: 0 additions & 3 deletions python/faery/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (["faery init"], "initialize a Faery script")

@typing.override
def first_block_keywords(self) -> set[str]:
return {"init"}

@typing.override
def run(self, arguments: list[str]):
parser = self.parser()
parser.add_argument(
Expand Down
3 changes: 0 additions & 3 deletions python/faery/cli/list_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,12 @@ def class_to_name_to_filter() -> dict[typing.Any, dict[str, Filter]]:


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (["faery list-filters"], "print available filters")

@typing.override
def first_block_keywords(self) -> set[str]:
return {"list-filters"}

@typing.override
def run(self, arguments: list[str]):
parser = self.parser()
parser.parse_args(args=arguments)
Expand Down
13 changes: 8 additions & 5 deletions python/faery/cli/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ def input_parser() -> argparse.ArgumentParser:
add_csv_properties(subparser)
# Inivation subparser
subparser = subparsers.add_parser("inivation")
subparser.add_argument("--buffer-size", type=int, default=1024, help="Array buffer size (default: %(default)s)")
subparser.add_argument(
"--buffer-size",
type=int,
default=1024,
help="Array buffer size (default: %(default)s)",
)
# UDP subparser
subparser = subparsers.add_parser("udp")
subparser.add_argument("address", type=list_filters.parse_udp)
Expand Down Expand Up @@ -282,7 +287,8 @@ def output_parser(
subparser.add_argument(
"--enforce-monotonic-timestamps",
action=argparse.BooleanOptionalAction,
help="Enforce non-monitonic timestamps. Defaults to True. Negate this with causion: some file formats do not support non-monotonic timestamps.")
help="Enforce non-monitonic timestamps. Defaults to True. Negate this with causion: some file formats do not support non-monotonic timestamps.",
)
subparser.set_defaults(enforce_monotonic_timestamps=True)
if stream_parent_class in {
faery.FiniteEventsStream,
Expand Down Expand Up @@ -612,7 +618,6 @@ def split_on_keywords(arguments: list[str]) -> typing.Iterator[list[str]]:


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (
[
Expand All @@ -624,11 +629,9 @@ def usage(self) -> tuple[list[str], str]:
"process data",
)

@typing.override
def first_block_keywords(self) -> set[str]:
return KEYWORDS

@typing.override
def run(self, arguments: list[str]):
stream_wrapper = StreamWrapper()
subcommands_arguments = list(split_on_keywords(arguments))
Expand Down
3 changes: 0 additions & 3 deletions python/faery/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@


class Command(command.Command):
@typing.override
def usage(self) -> tuple[list[str], str]:
return (["faery run"], "run a Faery script")

@typing.override
def first_block_keywords(self) -> set[str]:
return {"run"}

@typing.override
def run(self, arguments: list[str]):
parser = self.parser()
parser.add_argument(
Expand Down
16 changes: 11 additions & 5 deletions python/faery/event_camera_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

import faery.events_stream as events_stream


def has_event_camera_drivers():
return importlib.util.find_spec("event_camera_drivers") is not None


def has_inivation_camera_drivers():
if has_event_camera_drivers():
import event_camera_drivers as evd

return hasattr(evd, "InivationCamera")
return False

Expand All @@ -33,14 +35,17 @@ def __init__(self, buffer_size: int = 1024):
"""

super().__init__()

try:
import event_camera_drivers as evd

self.camera = evd.InivationCamera(buffer_size=buffer_size)
except ImportError as e:
logging.error("Inivation camera drivers not available, please install the event_camera_drivers library")
logging.error(
"Inivation camera drivers not available, please install the event_camera_drivers library"
)
raise e

def __iter__(self) -> typing.Iterator[np.ndarray]:
while self.camera.is_running():
v = next(self.camera)
Expand All @@ -50,11 +55,12 @@ def dimensions(self):
return self.camera.resolution()


def events_stream_from_camera(manufacturer: typing.Literal["Inivation", "Prophesee"], buffer_size: int = 1024):
def events_stream_from_camera(
manufacturer: typing.Literal["Inivation", "Prophesee"], buffer_size: int = 1024
):
if manufacturer == "Inivation":
return InivationCameraStream(buffer_size)
elif manufacturer == "Prophesee":
raise NotImplementedError("Prophesee camera drivers are not implemented yet")
else:
raise ValueError(f"Unknown camera manufacturer: {manufacturer}")

1 change: 1 addition & 0 deletions python/faery/events_stream_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class FiniteRegularEventsStreamState:
Total number of packets in the stream.
"""


class StateManager:
"""
Keeps track of the number of frames processed by the stream and calls `on_progress`.
Expand Down
12 changes: 9 additions & 3 deletions python/faery/file_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def events_to_file(
)
if file_type == "aedat":
assert path is not None
assert enforce_monotonic_timestamps, "AEDAT files do not support non-monotonic timestamps, since timestamps may overflow"
assert (
enforce_monotonic_timestamps
), "AEDAT files do not support non-monotonic timestamps, since timestamps may overflow"
with aedat.Encoder(
path=path if write_path is None else write_path,
description=[
Expand Down Expand Up @@ -174,7 +176,9 @@ def events_to_file(
t0 = 0
elif file_type == "dat":
assert path is not None
assert enforce_monotonic_timestamps, "DAT files do not support non-monotonic timestamps, since timestamps may overflow"
assert (
enforce_monotonic_timestamps
), "DAT files do not support non-monotonic timestamps, since timestamps may overflow"
with dat.Encoder(
path=path if write_path is None else write_path,
version="dat2" if version is None else version, # type: ignore
Expand Down Expand Up @@ -208,7 +212,9 @@ def events_to_file(
state_manager.end()
elif file_type == "es":
assert path is not None
assert enforce_monotonic_timestamps, "ES files do not support non-monotonic timestamps"
assert (
enforce_monotonic_timestamps
), "ES files do not support non-monotonic timestamps"
with event_stream.Encoder(
path=path if write_path is None else write_path,
event_type="dvs",
Expand Down
6 changes: 0 additions & 6 deletions python/faery/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,22 @@ def task_generator(
) -> Task:
class DecoratedTask(Task):

@typing.override
def suffix(self) -> str:
return suffix

@typing.override
def icon(self) -> str:
return icon

@typing.override
def name(self) -> str:
return function.__name__.replace("_", "-") if name is None else name

@typing.override
def code(self) -> str:
return textwrap.dedent(inspect.getsource(function))

@functools.cached_property
@typing.override
def hash(self) -> str:
return hash(function=function)

@typing.override
def __call__(
self,
input: pathlib.Path,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_low_level_decoder_encoder(file: assets.File):
separator=b","[0],
header=True,
dimensions=file.dimensions,
enforce_monotonic=True
enforce_monotonic=True,
) as encoder:
for events in decoder:
encoder.write(events)
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_low_level_decoder_encoder(file: assets.File):
version="evt2",
zero_t0=True,
dimensions=decoder.dimensions,
enforce_monotonic=True
enforce_monotonic=True,
) as encoder:
for packet in decoder:
encoder.write(packet)
Expand All @@ -167,7 +167,7 @@ def test_low_level_decoder_encoder(file: assets.File):
version="evt3",
zero_t0=True,
dimensions=decoder.dimensions,
enforce_monotonic=True
enforce_monotonic=True,
) as encoder:
for packet in decoder:
encoder.write(packet)
Expand Down

0 comments on commit 90be7e7

Please sign in to comment.