Skip to content

Commit

Permalink
Issue #394 Suppress deprecation warning emanating from python-kaleido…
Browse files Browse the repository at this point in the history
…/plotly
  • Loading branch information
bikegeek committed Nov 1, 2023
1 parent 745d716 commit f1eb04f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion metplotpy/plots/base_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import logging
import warnings
import numpy as np
import yaml
from typing import Union
Expand Down Expand Up @@ -343,6 +344,9 @@ def save_to_file(self):

image_name = self.get_config_value('plot_filename')

# Suppress deprecation warnings from third-party packages that are not in our control.
warnings.filterwarnings("ignore", category=DeprecationWarning)

# Create the directory for the output plot if it doesn't already exist
dirname = os.path.dirname(os.path.abspath(image_name))
if not os.path.exists(dirname):
Expand All @@ -354,9 +358,12 @@ def save_to_file(self):
self.logger.error(f"FileNotFoundError: Cannot save to file"
f" {image_name}")
# print("Can't save to file " + image_name)
except ResourceWarning:
self.logger.warning(f"ResourceWarning: in _kaleido"
f" {image_name}")

except ValueError as ex:
self.logger.error(f"ValueError: Could not save output file.")
# print(ex)
else:
self.logger.error(f"The figure {dirname} cannot be saved.")
print("Oops! The figure was not created. Can't save.")
Expand Down

0 comments on commit f1eb04f

Please sign in to comment.