IO
conatus.io.file.FileWriter
¶
FileWriter(
base_folder: Path | str | None = None,
*,
run_folder: Path | str | None = None,
debug_folder: Path | str | None = None,
log_folder: Path | str | None = None,
out_folder: Path | str | None = None,
run_id: str | None = None
)
Bases: BaseModel
File writer class.
This class is used to write data to files.
It is used to write data to files in the following folders:
debug: Debug information.log: Log information.out: Output information.
| ATTRIBUTE | DESCRIPTION |
|---|---|
base_folder |
The base folder to log run outputs to.
TYPE:
|
run_folder |
The folder to write the outputs of a specific run to.
TYPE:
|
log_folder |
The folder to write logs to.
TYPE:
|
out_folder |
The folder to write outputs to.
TYPE:
|
debug_folder |
The folder to write debug information to.
TYPE:
|
run_id |
The ID of the run. Defaults to a Unix UTC timestamp.
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
base_folder
|
The base folder to log run outputs to. Defaults to the current working directory / "runs". |
run_folder
|
The folder to write the outputs of a specific run to. Defaults to {base_folder} / {Unix UTC timestamp}. |
debug_folder
|
The folder to write debug information to. Defaults to {base_folder} / "debug". |
log_folder
|
The folder to write logs to. Defaults to {run_folder} / "log". |
out_folder
|
The folder to write outputs to. Defaults to {run_folder} / "out". |
run_id
|
The ID of the run. Defaults to a Unix UTC timestamp.
TYPE:
|
Source code in conatus/io/file.py
write
¶
write(
data: str | bytes | BytesIO | StringIO,
file_name: str,
output_type: OutputType = LOG,
*,
append: bool = False
) -> None
Write data to a file.
We only accept str, bytes, BytesIO, and StringIO objects.
We will create the folder if it does not exist, even if we need to create parents.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data to write. |
file_name
|
The name of the file to write to.
TYPE:
|
output_type
|
The type of output. Defaults to
TYPE:
|
append
|
Whether to append to the file. Defaults to
TYPE:
|