-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ready for Review] fix bug where client can not access foreach stack (#…
…1766) * fix bug where client can not access foreach stack
- Loading branch information
Showing
5 changed files
with
32 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Keep this file minimum dependency as this will be imported by metaflow at bootup. | ||
def namedtuple_with_defaults(typename, field_descr, defaults=()): | ||
from typing import NamedTuple | ||
|
||
T = NamedTuple(typename, field_descr) | ||
T.__new__.__defaults__ = tuple(defaults) | ||
|
||
# Adding the following to ensure the named tuple can be (un)pickled correctly. | ||
import __main__ | ||
|
||
setattr(__main__, T.__name__, T) | ||
T.__module__ = "__main__" | ||
return T | ||
|
||
|
||
# Define the namedtuple with default here if they need to be accessible in client | ||
# (and w/o a real flow). | ||
foreach_frame_field_list = [ | ||
("step", str), | ||
("var", str), | ||
("num_splits", int), | ||
("index", int), | ||
("value", str), | ||
] | ||
ForeachFrame = namedtuple_with_defaults( | ||
"ForeachFrame", foreach_frame_field_list, (None,) * (len(foreach_frame_field_list)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters