Skip to content

Commit

Permalink
output: generate FileOutput save_file_path property from output_dir a…
Browse files Browse the repository at this point in the history
…nd output_file_name
  • Loading branch information
eledhwen committed Jun 6, 2024
1 parent 444d63f commit 5f7e615
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion codecarbon/emissions_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _init_output_methods(self, api_key):
if self._save_to_file:
self._output_handlers.append(
FileOutput(
os.path.join(self._output_dir, self._output_file),
self._output_file,
self._output_dir,
self._on_csv_write,
)
Expand Down
5 changes: 3 additions & 2 deletions codecarbon/output_methods/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ class FileOutput(BaseOutput):
Saves experiment artifacts to a file
"""

def __init__(self, save_file_path: str, output_dir: str, on_csv_write: str = "append"):
def __init__(self, output_file_name: str, output_dir: str, on_csv_write: str = "append"):
if on_csv_write not in {"append", "update"}:
raise ValueError(
f"Unknown `on_csv_write` value: {on_csv_write}"
+ " (should be one of 'append' or 'update'"
)
self.output_file_name: str = output_file_name
self.output_dir: str = output_dir
self.on_csv_write: str = on_csv_write
self.save_file_path: str = save_file_path
self.save_file_path = os.path.join(self.output_dir, self.output_file_name)
logger.info(
f"Saving emissions data to file {os.path.abspath(self.save_file_path)}"
)
Expand Down

0 comments on commit 5f7e615

Please sign in to comment.