Skip to content

Commit

Permalink
utilities: output_graph_image: try to detect format from filename
Browse files Browse the repository at this point in the history
  • Loading branch information
kmantel committed Jun 25, 2024
1 parent 3000094 commit 3bd7a9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/graph_scheduler/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def output_graph_image(
directory.
format (str, optional): image format. Many common formats
supported. Pass None to display supported formats. Defaults
to png.
to png unless specified by **filename** extension.
Returns:
name of file containing written image
Expand All @@ -235,6 +235,10 @@ def output_graph_image(
"""
if filename is None:
filename = f'graph-scheduler-figure-{id(graph)}{os.path.extsep}{format}'
else:
filename_split = filename.split(os.path.extsep)
if len(filename_split) > 1:
format = filename_split[-1]

if not isinstance(graph, nx.Graph):
graph = dependency_dict_to_networkx_digraph(graph)
Expand Down

0 comments on commit 3bd7a9f

Please sign in to comment.