From e5507e12c9bdba167bf515020f97aaef01aa0a60 Mon Sep 17 00:00:00 2001 From: xuzhen Date: Sat, 6 Apr 2024 16:20:43 +0800 Subject: [PATCH] easyvolcap: update exception --- easyvolcap/dataloaders/__init__.py | 11 +++++++---- easyvolcap/dataloaders/datasets/__init__.py | 11 +++++++---- easyvolcap/models/__init__.py | 11 +++++++---- easyvolcap/models/cameras/__init__.py | 11 +++++++---- easyvolcap/models/networks/__init__.py | 11 +++++++---- easyvolcap/models/networks/embedders/__init__.py | 11 +++++++---- easyvolcap/models/renderers/__init__.py | 11 +++++++---- easyvolcap/models/samplers/__init__.py | 11 +++++++---- easyvolcap/models/supervisors/__init__.py | 11 +++++++---- easyvolcap/runners/__init__.py | 11 +++++++---- easyvolcap/runners/evaluators/__init__.py | 11 +++++++---- easyvolcap/runners/visualizers/__init__.py | 11 +++++++---- easyvolcap/runners/volumetric_video_runner.py | 5 ++++- 13 files changed, 88 insertions(+), 49 deletions(-) diff --git a/easyvolcap/dataloaders/__init__.py b/easyvolcap/dataloaders/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/dataloaders/__init__.py +++ b/easyvolcap/dataloaders/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/dataloaders/datasets/__init__.py b/easyvolcap/dataloaders/datasets/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/dataloaders/datasets/__init__.py +++ b/easyvolcap/dataloaders/datasets/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/__init__.py b/easyvolcap/models/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/__init__.py +++ b/easyvolcap/models/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/cameras/__init__.py b/easyvolcap/models/cameras/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/cameras/__init__.py +++ b/easyvolcap/models/cameras/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/networks/__init__.py b/easyvolcap/models/networks/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/networks/__init__.py +++ b/easyvolcap/models/networks/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/networks/embedders/__init__.py b/easyvolcap/models/networks/embedders/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/networks/embedders/__init__.py +++ b/easyvolcap/models/networks/embedders/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/renderers/__init__.py b/easyvolcap/models/renderers/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/renderers/__init__.py +++ b/easyvolcap/models/renderers/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/samplers/__init__.py b/easyvolcap/models/samplers/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/samplers/__init__.py +++ b/easyvolcap/models/samplers/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/models/supervisors/__init__.py b/easyvolcap/models/supervisors/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/models/supervisors/__init__.py +++ b/easyvolcap/models/supervisors/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/runners/__init__.py b/easyvolcap/runners/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/runners/__init__.py +++ b/easyvolcap/runners/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/runners/evaluators/__init__.py b/easyvolcap/runners/evaluators/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/runners/evaluators/__init__.py +++ b/easyvolcap/runners/evaluators/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/runners/visualizers/__init__.py b/easyvolcap/runners/visualizers/__init__.py index 498a2ae..db4819a 100644 --- a/easyvolcap/runners/visualizers/__init__.py +++ b/easyvolcap/runners/visualizers/__init__.py @@ -5,9 +5,12 @@ try: # from . import * # the actual imports exec(f'from . import {module}') - except ModuleNotFoundError as e: - from easyvolcap.utils.console_utils import * - log(yellow(f'Failed to import {red(module)}{red(".py")}, missing package: {red(e.name)}')) except Exception as e: + import sys from easyvolcap.utils.console_utils import * - stacktrace() # print a full stacktrace for the users convenience + + exception_type, exception_object, exception_traceback = sys.exc_info() + filename = exception_traceback.tb_frame.f_code.co_filename + line_number = exception_traceback.tb_lineno + + log(yellow(f'Failed to import {red(filename)}:{line_number}, {red(type(e))}: {red_slim(e)}}')) diff --git a/easyvolcap/runners/volumetric_video_runner.py b/easyvolcap/runners/volumetric_video_runner.py index 9834547..7d12f72 100644 --- a/easyvolcap/runners/volumetric_video_runner.py +++ b/easyvolcap/runners/volumetric_video_runner.py @@ -144,7 +144,10 @@ def __init__(self, self.test_using_inference_mode = test_using_inference_mode # Setting VRAM limit on Windows might make the framerate more stable - torch.cuda.set_per_process_memory_fraction(torch_vram_frac_limit) # set vram usage limit to current device + try: + torch.cuda.set_per_process_memory_fraction(torch_vram_frac_limit) # set vram usage limit to current device + except: + pass # HACK: GLOBAL VARIABLE, when dumping config, should ignore this one cfg.runner = self