Skip to content

Commit

Permalink
feat(optimizer): issue warning if results of different DP version loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed Jan 4, 2024
1 parent 0d73804 commit 1bf150f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions discopop_library/discopop_optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from discopop_library.discopop_optimizer.suggestions.optimizers.main import optimize_suggestions
from discopop_library.discopop_optimizer.utilities.simple_utilities import data_at
from discopop_library.discopop_optimizer.utilities.visualization.update_graph import show_update_graph
from discopop_library.global_data.version.utils import get_version
from discopop_library.result_classes.DetectionResult import DetectionResult
from discopop_library.discopop_optimizer.classes.system.System import System
from discopop_library.discopop_optimizer.Microbench.ExtrapInterpolatedMicrobench import (
Expand Down Expand Up @@ -105,6 +106,13 @@ def run(arguments: OptimizerArguments):
with open(os.path.join(explorer_dir, "detection_result_dump.json")) as f:
detection_result_dump_str = f.read()
detection_result: DetectionResult = jsonpickle.decode(detection_result_dump_str)
if detection_result.version != get_version():
warnings.warn(
"Restored DetectionResult was created using different DiscoPoP version: "
+ detection_result.version
+ "; current: "
+ get_version()
)
if arguments.verbose:
print("Done")

Expand Down
1 change: 1 addition & 0 deletions discopop_library/result_classes/DetectionResult.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from discopop_explorer.pattern_detectors.reduction_detector import ReductionInfo
from discopop_library.global_data.version.utils import get_version


class DetectionResult(object):
version: str
pet: PEGraphX
Expand Down

0 comments on commit 1bf150f

Please sign in to comment.