Skip to content

Commit

Permalink
reset cli mode in benchmark to BULK
Browse files Browse the repository at this point in the history
fixed type annotations for write mode
  • Loading branch information
ar0305 committed Sep 18, 2024
1 parent b11fafa commit fb2c45f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions OTAnalytics/plugin_parser/road_user_assignment_export.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from typing import Iterable, Literal

from pandas import DataFrame

Expand Down Expand Up @@ -30,7 +30,7 @@ def format(self) -> ExportFormat:

def _serialize(self, dtos: list[dict], export_mode: ExportMode) -> None:
append = export_mode.is_subsequent_write()
write_mode = "a" if append else "w"
write_mode: Literal["w", "a"] = "a" if append else "w"
DataFrame(dtos, columns=ROAD_USER_ASSIGNMENT_DICT_KEYS).to_csv(
self._outputfile, index=False, header=not append, mode=write_mode
)
Expand Down
6 changes: 4 additions & 2 deletions OTAnalytics/plugin_parser/track_export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Literal

from pandas import DataFrame

from OTAnalytics.application.state import TracksMetadata, VideosMetadata
Expand Down Expand Up @@ -49,8 +51,8 @@ def export(self, specification: TrackExportSpecification) -> None:
dataframe = set_column_order(dataframe)
path = specification.save_path
output_path = path.with_suffix(".tracks.csv")
write_mode = "a" if append else "w"
dataframe.to_csv(output_path, index=False, header=not append, mode=write_mode)
write_mode: Literal["w", "a"] = "a" if append else "w"
dataframe.to_csv(output_path, index=False, header=(not append), mode=write_mode)

if specification.export_mode.is_final_write():
tracks_metadata_path = path.with_suffix(".tracks_metadata.json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from typing import Iterable, Literal

import pandas as pd

Expand Down Expand Up @@ -181,7 +181,7 @@ def _write_to_csv(
file = export_specification.file
append = export_specification.export_mode.is_subsequent_write()
header = not append
write_mode = "a" if append else "w"
write_mode: Literal["w", "a"] = "a" if append else "w"
df_events.to_csv(file, index=False, mode=write_mode, header=header)

def get_extension(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark_otanalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class UseCaseProvider:
PygeosTrackGeometryDataset.from_track_dataset
)

@property # TODO method with cli mode, doch weglassen
@property
def run_config(self) -> RunConfiguration:
return create_run_config(
flow_parser=self._flow_parser,
start_cli=True,
cli_mode=CliMode.STREAM, # TODO reset to BULK?
cli_mode=CliMode.BULK,
debug=False,
logfile_overwrite=True,
track_export=False,
Expand Down

0 comments on commit fb2c45f

Please sign in to comment.