Skip to content

Commit 3e36271

Browse files
authored
Merge pull request #17 from WebODM/log
Log refactoring
2 parents 58b9235 + 9538322 commit 3e36271

60 files changed

Lines changed: 560 additions & 559 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ def vcpkg_export():
123123
exit(1)
124124

125125
pkgs = vcpkg_requirements()
126-
out = "vcpkg-export-%s" % odm_version().replace(".", "")
126+
out = "vcpkg-export-%s" % get_version().replace(".", "")
127127
run("vcpkg\\vcpkg export %s --output=%s --zip" % (" ".join(pkgs), out))
128128

129-
def odm_version():
129+
def get_version():
130130
with open("VERSION") as f:
131131
return f.read().split("\n")[0].strip()
132132

opendm/ai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_model(namespace, url, version, name = "model.onnx"):
4141
# Check if we need to download it
4242
model_file = os.path.join(versioned_dir, name)
4343
if not os.path.isfile(model_file):
44-
log.ODM_INFO("Downloading AI model from %s ..." % url)
44+
log.INFO("Downloading AI model from %s ..." % url)
4545

4646
last_update = 0
4747

@@ -51,23 +51,23 @@ def callback(progress):
5151
time_has_elapsed = time.time() - last_update >= 2
5252

5353
if time_has_elapsed or int(progress) == 100:
54-
log.ODM_INFO("Downloading: %s%%" % int(progress))
54+
log.INFO("Downloading: %s%%" % int(progress))
5555
last_update = time.time()
5656

5757
try:
5858
downloaded_file = download(url, versioned_dir, progress_callback=callback)
5959
except Exception as e:
60-
log.ODM_WARNING("Cannot download %s: %s" % (url, str(e)))
60+
log.WARNING("Cannot download %s: %s" % (url, str(e)))
6161
return None
6262

6363
if os.path.basename(downloaded_file).lower().endswith(".zip"):
64-
log.ODM_INFO("Extracting %s ..." % downloaded_file)
64+
log.INFO("Extracting %s ..." % downloaded_file)
6565
with zipfile.ZipFile(downloaded_file, 'r') as z:
6666
z.extractall(versioned_dir)
6767
os.remove(downloaded_file)
6868

6969
if not os.path.isfile(model_file):
70-
log.ODM_WARNING("Cannot find %s (is the URL to the AI model correct?)" % model_file)
70+
log.WARNING("Cannot find %s (is the URL to the AI model correct?)" % model_file)
7171
return None
7272
else:
7373
return model_file

opendm/align.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def compute_alignment_matrix(input_laz, align_file, stats_dir):
5656

5757
# Check if we need to reproject align file
5858
input_crs = get_point_cloud_crs(input_laz)
59-
log.ODM_INFO("Input CRS: %s" % input_crs)
59+
log.INFO("Input CRS: %s" % input_crs)
6060

6161
_, ext = os.path.splitext(align_file)
6262
repr_func = None
@@ -68,27 +68,27 @@ def compute_alignment_matrix(input_laz, align_file, stats_dir):
6868
align_crs = get_point_cloud_crs(align_file)
6969
repr_func = reproject_point_cloud
7070
else:
71-
log.ODM_WARNING("Unsupported alignment file: %s" % align_file)
71+
log.WARNING("Unsupported alignment file: %s" % align_file)
7272
return
7373

7474
to_delete = []
7575

7676
try:
77-
log.ODM_INFO("Align CRS: %s" % align_crs)
77+
log.INFO("Align CRS: %s" % align_crs)
7878
if input_crs != align_crs:
7979
# Reprojection needed
80-
log.ODM_INFO("Reprojecting %s to %s" % (align_file, input_crs))
80+
log.INFO("Reprojecting %s to %s" % (align_file, input_crs))
8181
align_file = repr_func(align_file, input_crs)
8282
to_delete.append(align_file)
8383

8484
conf = dataclasses.asdict(codem.CodemRunConfig(align_file, input_laz, OUTPUT_DIR=stats_dir))
8585
fnd_obj, aoi_obj = codem.preprocess(conf)
8686
fnd_obj.prep()
8787
aoi_obj.prep()
88-
log.ODM_INFO("Aligning reconstruction to %s" % align_file)
89-
log.ODM_INFO("Coarse registration...")
88+
log.INFO("Aligning reconstruction to %s" % align_file)
89+
log.INFO("Coarse registration...")
9090
dsm_reg = codem.coarse_registration(fnd_obj, aoi_obj, conf)
91-
log.ODM_INFO("Fine registration...")
91+
log.INFO("Fine registration...")
9292
icp_reg = codem.fine_registration(fnd_obj, aoi_obj, dsm_reg, conf)
9393

9494
app_reg = codem.registration.ApplyRegistration(

opendm/arghelpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def save_opts(opts_json, args):
3535
with open(opts_json, "w", encoding='utf-8') as f:
3636
f.write(json.dumps(args_to_dict(args)))
3737
except Exception as e:
38-
log.ODM_WARNING("Cannot save options to %s: %s" % (opts_json, str(e)))
38+
log.WARNING("Cannot save options to %s: %s" % (opts_json, str(e)))
3939

4040
def compare_args(opts_json, args, rerun_stages):
4141
if not os.path.isfile(opts_json):

opendm/bgfilter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class BgFilter():
1919
def __init__(self, model):
2020
self.model = model
2121

22-
log.ODM_INFO(' ?> Using provider %s' % provider)
22+
log.INFO(' ?> Using provider %s' % provider)
2323
self.load_model()
2424

2525

2626
def load_model(self):
27-
log.ODM_INFO(' -> Loading the model')
27+
log.INFO(' -> Loading the model')
2828

2929
self.session = ort.InferenceSession(self.model, providers=[provider])
3030

opendm/camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_opensfm_camera_models(cameras):
6464
for k in keys:
6565
if not k in valid_fields:
6666
camera.pop(k)
67-
log.ODM_WARNING("Invalid camera key ignored: %s" % k)
67+
log.WARNING("Invalid camera key ignored: %s" % k)
6868

6969
result[osfm_camera_id] = camera
7070
return result

opendm/cogeo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def convert_to_cogeo(src_path, blocksize=256, max_workers=1, compression="DEFLAT
1515
"""
1616

1717
if not os.path.isfile(src_path):
18-
log.ODM_WARNING("Cannot convert to cogeo: %s (file does not exist)" % src_path)
18+
log.WARNING("Cannot convert to cogeo: %s (file does not exist)" % src_path)
1919
return False
2020

21-
log.ODM_INFO("Optimizing %s as Cloud Optimized GeoTIFF" % src_path)
21+
log.INFO("Optimizing %s as Cloud Optimized GeoTIFF" % src_path)
2222

2323

2424
tmpfile = io.related_file_path(src_path, postfix='_cogeo')
@@ -47,15 +47,15 @@ def convert_to_cogeo(src_path, blocksize=256, max_workers=1, compression="DEFLAT
4747
"--config GDAL_NUM_THREADS {threads} "
4848
"\"{src_path}\" \"{tmpfile}\" ".format(**kwargs))
4949
except Exception as e:
50-
log.ODM_WARNING("Cannot create Cloud Optimized GeoTIFF: %s" % str(e))
50+
log.WARNING("Cannot create Cloud Optimized GeoTIFF: %s" % str(e))
5151

5252
if os.path.isfile(tmpfile):
5353
shutil.move(src_path, swapfile) # Move to swap location
5454

5555
try:
5656
shutil.move(tmpfile, src_path)
5757
except IOError as e:
58-
log.ODM_WARNING("Cannot move %s to %s: %s" % (tmpfile, src_path, str(e)))
58+
log.WARNING("Cannot move %s to %s: %s" % (tmpfile, src_path, str(e)))
5959
shutil.move(swapfile, src_path) # Attempt to restore
6060

6161
if os.path.isfile(swapfile):

opendm/concurrency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def stop_workers():
9292
if error is not None and single_thread_fallback:
9393
# Try to reprocess using a single thread
9494
# in case this was a memory error
95-
log.ODM_WARNING("Failed to run process in parallel, retrying with a single thread...")
95+
log.WARNING("Failed to run process in parallel, retrying with a single thread...")
9696
use_single_thread = True
9797
else:
9898
use_single_thread = True

opendm/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def config(argv=None, parser=None):
175175
yaml_defaults = {k.replace('-', '_'): v for k, v in yaml_defaults.items()}
176176
parser.set_defaults(**yaml_defaults)
177177
except Exception as e:
178-
log.ODM_WARNING(f"Could not load settings from {context.settings_path}: {e}")
178+
log.WARNING(f"Could not load settings from {context.settings_path}: {e}")
179179

180180
parser.add_argument('--project-path',
181181
metavar='<path>',
@@ -902,37 +902,37 @@ def config(argv=None, parser=None):
902902

903903
for p in unknown:
904904
if p in DEPRECATED:
905-
log.ODM_WARNING("%s is no longer a valid argument and will be ignored!" % p)
905+
log.WARNING("%s is no longer a valid argument and will be ignored!" % p)
906906

907907
# check that the project path setting has been set properly
908908
if not args.project_path:
909-
log.ODM_ERROR('You need to set the project path in the '
909+
log.ERROR('You need to set the project path in the '
910910
'settings.yaml file before you can run ODM, '
911911
'or use `--project-path <path>`. Run `python3 '
912912
'run.py --help` for more information. ')
913913
sys.exit(1)
914914

915915
if args.fast_orthophoto:
916-
log.ODM_INFO('Fast orthophoto is turned on, automatically setting --skip-3dmodel')
916+
log.INFO('Fast orthophoto is turned on, automatically setting --skip-3dmodel')
917917
args.skip_3dmodel = True
918918

919919
if args.dtm and not args.pc_classify:
920-
log.ODM_INFO("DTM is turned on, automatically turning on point cloud classification")
920+
log.INFO("DTM is turned on, automatically turning on point cloud classification")
921921
args.pc_classify = True
922922

923923
if args.skip_3dmodel and args.use_3dmesh:
924-
log.ODM_WARNING('--skip-3dmodel is set, but so is --use-3dmesh. --skip-3dmodel will be ignored.')
924+
log.WARNING('--skip-3dmodel is set, but so is --use-3dmesh. --skip-3dmodel will be ignored.')
925925
args.skip_3dmodel = False
926926

927927
if args.orthophoto_cutline and not args.crop:
928-
log.ODM_WARNING("--orthophoto-cutline is set, but --crop is not. --crop will be set to 0.01")
928+
log.WARNING("--orthophoto-cutline is set, but --crop is not. --crop will be set to 0.01")
929929
args.crop = 0.01
930930

931931
if args.sm_cluster:
932932
try:
933933
Node.from_url(args.sm_cluster).info()
934934
except exceptions.NodeConnectionError as e:
935-
log.ODM_ERROR("Cluster node seems to be offline: %s" % str(e))
935+
log.ERROR("Cluster node seems to be offline: %s" % str(e))
936936
sys.exit(1)
937937

938938
return args

opendm/cropper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def path(self, suffix):
2323
@staticmethod
2424
def crop(gpkg_path, geotiff_path, gdal_options, keep_original=True, warp_options=[]):
2525
if not os.path.exists(gpkg_path) or not os.path.exists(geotiff_path):
26-
log.ODM_WARNING("Either {} or {} does not exist, will skip cropping.".format(gpkg_path, geotiff_path))
26+
log.WARNING("Either {} or {} does not exist, will skip cropping.".format(gpkg_path, geotiff_path))
2727
return geotiff_path
2828

29-
log.ODM_INFO("Cropping %s" % geotiff_path)
29+
log.INFO("Cropping %s" % geotiff_path)
3030

3131
# Rename original file
3232
# path/to/odm_orthophoto.tif --> path/to/odm_orthophoto.original.tif
@@ -64,7 +64,7 @@ def crop(gpkg_path, geotiff_path, gdal_options, keep_original=True, warp_options
6464
os.remove(original_geotiff)
6565

6666
except Exception as e:
67-
log.ODM_WARNING('Something went wrong while cropping: {}'.format(e))
67+
log.WARNING('Something went wrong while cropping: {}'.format(e))
6868

6969
# Revert rename
7070
os.replace(original_geotiff, geotiff_path)
@@ -131,7 +131,7 @@ def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0, decimation
131131
@return filename to GeoJSON containing the polygon
132132
"""
133133
if not os.path.exists(pointcloud_path):
134-
log.ODM_WARNING('Point cloud does not exist, cannot generate bounds {}'.format(pointcloud_path))
134+
log.WARNING('Point cloud does not exist, cannot generate bounds {}'.format(pointcloud_path))
135135
return ''
136136

137137
# Do decimation prior to extracting boundary information
@@ -143,7 +143,7 @@ def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0, decimation
143143
"--filters.decimation.step={} ".format(pointcloud_path, decimated_pointcloud_path, decimation_step))
144144

145145
if not os.path.exists(decimated_pointcloud_path):
146-
log.ODM_WARNING('Could not decimate point cloud, thus cannot generate GPKG bounds {}'.format(decimated_pointcloud_path))
146+
log.WARNING('Could not decimate point cloud, thus cannot generate GPKG bounds {}'.format(decimated_pointcloud_path))
147147
return ''
148148

149149
# Use PDAL to dump boundary information
@@ -188,7 +188,7 @@ def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0, decimation
188188
if tmp.Area() > 0:
189189
convexhull = tmp
190190
else:
191-
log.ODM_WARNING("Very small crop area detected, we will not smooth it.")
191+
log.WARNING("Very small crop area detected, we will not smooth it.")
192192

193193
# Save to a new file
194194
bounds_geojson_path = self.path('bounds.geojson')
@@ -228,7 +228,7 @@ def create_bounds_gpkg(self, pointcloud_path, buffer_distance = 0, decimation_st
228228
@return filename to Geopackage containing the polygon
229229
"""
230230
if not os.path.exists(pointcloud_path):
231-
log.ODM_WARNING('Point cloud does not exist, cannot generate GPKG bounds {}'.format(pointcloud_path))
231+
log.WARNING('Point cloud does not exist, cannot generate GPKG bounds {}'.format(pointcloud_path))
232232
return ''
233233

234234

0 commit comments

Comments
 (0)