Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag committed Aug 30, 2023
1 parent 523b8ef commit e5e69ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pip install waretomo
waretomo -h
```

Every time you run waretomo, a log will be appended to an `waretomo.log` file in the output directory.

# Walkthrough

Here's a short summary of how I recommend using this script:
Expand Down
20 changes: 13 additions & 7 deletions src/waretomo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def cli(
Assumes the default Warp directory structure with generated imod stacks.
"""
import sys
from datetime import datetime
from inspect import cleandoc
from pathlib import Path

Expand Down Expand Up @@ -294,10 +296,8 @@ def cli(
f'{nl}{" " * 12}- {k}: {v}' for k, v in topaz_kwargs.items()
)

print(
Panel(
cleandoc(
f"""
summary = cleandoc(
f"""
[bold]Warp directory[/bold]: {warp_dir}
[bold]Mdoc directory[/bold]: {mdoc_dir}
[bold]Tilt series - NOT READY[/bold]: {not_ready_log}
Expand All @@ -307,10 +307,16 @@ def cli(
[bold]Run options[/bold]: {opts_log}
[bold]AreTomo options[/bold]: {aretomo_opts_log}
[bold]Topaz options[/bold]: {topaz_log}
"""
)
)
"""
)
print(Panel(summary))

if not dry_run:
with open(output_dir / "waretomo.log", "a") as f:
print("=" * 80, file=f)
print(datetime.now().strftime("%d/%m/%Y %H:%M:%S"), file=f)
print(f'Command: {" ".join(sys.argv)}', file=f)
print(summary, "\n", file=f)

if steps["fix"]:
from ._fix import fix_batch
Expand Down

0 comments on commit e5e69ef

Please sign in to comment.