Skip to content

Commit

Permalink
add timestamps to logging and default to info (#96)
Browse files Browse the repository at this point in the history
* add timestamps to logging and default to info

* formatting

* format

* fix imports

* format

* bump version to 0.2.14
  • Loading branch information
philippotto authored Jun 12, 2019
1 parent 4af2d9f commit 1c5b170
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name="wkcuber",
packages=find_packages(exclude=("tests",)),
version="0.2.13",
version="0.2.14",
install_requires=["scipy", "numpy", "pillow", "pyyaml", "wkw", "cluster_tools>=1.19"],
description="A cubing tool for webKnossos",
author="Norman Rzepka",
Expand Down
11 changes: 7 additions & 4 deletions wkcuber/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
from .downsampling import downsample_mags, downsample_mags_anisotropic, DEFAULT_EDGE_LEN
from .compress import compress_mag_inplace
from .metadata import write_webknossos_metadata
from .utils import add_verbose_flag, add_distribution_flags, add_anisotropic_flag
from .utils import (
add_verbose_flag,
add_distribution_flags,
add_anisotropic_flag,
setup_logging,
)
from .mag import Mag


Expand Down Expand Up @@ -44,9 +49,7 @@ def create_parser():

if __name__ == "__main__":
args = create_parser().parse_args()

if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)

scale = tuple(float(x) for x in args.scale.split(","))
bounding_box = cubing(
Expand Down
4 changes: 2 additions & 2 deletions wkcuber/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
add_distribution_flags,
get_executor_for_args,
wait_and_ensure_success,
setup_logging,
)
from .metadata import detect_resolutions
from typing import List
Expand Down Expand Up @@ -148,6 +149,5 @@ def compress_mags(

if __name__ == "__main__":
args = create_parser().parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)
compress_mags(args.source_path, args.layer_name, args.target_path, args.mag, args)
5 changes: 2 additions & 3 deletions wkcuber/convert_knossos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
add_distribution_flags,
get_executor_for_args,
wait_and_ensure_success,
setup_logging,
)
from .knossos import KnossosDataset, CUBE_EDGE_LEN

Expand Down Expand Up @@ -98,9 +99,7 @@ def convert_knossos(

if __name__ == "__main__":
args = create_parser().parse_args()

if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)

convert_knossos(
args.source_path,
Expand Down
5 changes: 2 additions & 3 deletions wkcuber/cubing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
add_distribution_flags,
get_executor_for_args,
wait_and_ensure_success,
setup_logging,
)
from .image_readers import image_reader

Expand Down Expand Up @@ -216,9 +217,7 @@ def cubing(source_path, target_path, layer_name, dtype, batch_size, args=None) -

if __name__ == "__main__":
args = create_parser().parse_args()

if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)

cubing(
args.source_path,
Expand Down
5 changes: 2 additions & 3 deletions wkcuber/downsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
get_executor_for_args,
wait_and_ensure_success,
add_anisotropic_flag,
setup_logging,
)

DEFAULT_EDGE_LEN = 256
Expand Down Expand Up @@ -530,9 +531,7 @@ def detect_larger_and_smaller_dimension(scale):

if __name__ == "__main__":
args = create_parser().parse_args()

if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)

from_mag = Mag(args.from_mag)
max_mag = Mag(args.max)
Expand Down
6 changes: 5 additions & 1 deletion wkcuber/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Optional
from .mag import Mag
from typing import List
from .utils import add_verbose_flag, setup_logging


def get_datasource_path(dataset_path):
Expand Down Expand Up @@ -41,6 +42,8 @@ def create_parser():
)
group.add_argument("--max_id", help="set max id of segmentation.", default=0)

add_verbose_flag(parser)

return parser


Expand Down Expand Up @@ -288,8 +291,9 @@ def detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box=None)


if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
args = create_parser().parse_args()
setup_logging(args)

if not args.refresh:
assert (
args.name is not None
Expand Down
5 changes: 2 additions & 3 deletions wkcuber/tile_cubing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
add_distribution_flags,
get_executor_for_args,
wait_and_ensure_success,
setup_logging,
)
from .cubing import create_parser, read_image_file
from .image_readers import image_reader
Expand Down Expand Up @@ -170,9 +171,7 @@ def tile_cubing(

if __name__ == "__main__":
args = create_parser().parse_args()

if args.verbose:
logging.basicConfig(level=logging.DEBUG)
setup_logging(args)

tile_cubing(
args.source_path,
Expand Down
8 changes: 8 additions & 0 deletions wkcuber/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ def add_anisotropic_flag(parser):
parser.set_defaults(anisotropic=False)


def setup_logging(args):

logging.basicConfig(
level=(logging.DEBUG if args.verbose else logging.INFO),
format="%(asctime)s %(levelname)s %(message)s",
)


def find_files(source_path, extensions):
# Find all files with a matching file extension
return (
Expand Down

0 comments on commit 1c5b170

Please sign in to comment.