Skip to content

Commit d827ac5

Browse files
Plot: Invert the future hash dictionary inside the function (#822)
* Plot: Invert the future hash dictionary inside the function * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cc2bf5f commit d827ac5

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

executorlib/standalone/plot.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ def add_element(arg, link_to, label=""):
8181
return node_lst, edge_lst
8282

8383

84-
def generate_task_hash_for_plotting(
85-
task_dict: dict, future_hash_inverse_dict: dict
86-
) -> bytes:
84+
def generate_task_hash_for_plotting(task_dict: dict, future_hash_dict: dict) -> bytes:
8785
"""
8886
Generate a hash for a task dictionary.
8987
9088
Args:
9189
task_dict (dict): Dictionary containing task information.
92-
future_hash_inverse_dict (dict): Dictionary mapping future hash to future object.
90+
future_hash_dict (dict): Dictionary mapping future hash to future object.
9391
9492
Returns:
9593
bytes: Hash generated for the task dictionary.
@@ -121,12 +119,13 @@ def convert_arg(arg, future_hash_inverse_dict):
121119
else:
122120
return arg
123121

122+
future_hash_inverted_dict = {v: k for k, v in future_hash_dict.items()}
124123
args_for_hash = [
125-
convert_arg(arg=arg, future_hash_inverse_dict=future_hash_inverse_dict)
124+
convert_arg(arg=arg, future_hash_inverse_dict=future_hash_inverted_dict)
126125
for arg in task_dict["args"]
127126
]
128127
kwargs_for_hash = {
129-
k: convert_arg(arg=v, future_hash_inverse_dict=future_hash_inverse_dict)
128+
k: convert_arg(arg=v, future_hash_inverse_dict=future_hash_inverted_dict)
130129
for k, v in task_dict["kwargs"].items()
131130
}
132131
return cloudpickle.dumps(

executorlib/task_scheduler/interactive/dependency.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ def submit( # type: ignore
146146
}
147147
task_hash = generate_task_hash_for_plotting(
148148
task_dict=task_dict,
149-
future_hash_inverse_dict={
150-
v: k for k, v in self._future_hash_dict.items()
151-
},
149+
future_hash_dict=self._future_hash_dict,
152150
)
153151
self._future_hash_dict[task_hash] = f
154152
self._task_hash_dict[task_hash] = task_dict

0 commit comments

Comments
 (0)