-
Notifications
You must be signed in to change notification settings - Fork 62
Support functionalities to enhance task traceability with metadata for dependency search. #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
79a2881
0cfe7ee
3eee422
ec3bf4f
22a69d0
08e3f59
9b19a1c
accbf1d
6719f4d
0bcc16c
5c41035
0b951ab
10795a2
32b4343
6f70a41
637f5da
b607926
a8059a1
27b1abd
5ac1c4d
f4479da
e71833b
46aabcf
7bde3b0
4c44cea
dd6a629
d884c79
f1418f8
6a1c4c2
0b06455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ | |||||||||
import os | ||||||||||
import sys | ||||||||||
from io import BytesIO | ||||||||||
from typing import Any, Iterable, Protocol, TypeVar, Union | ||||||||||
from typing import Any, Callable, Iterable, Protocol, TypeVar, Union | ||||||||||
|
||||||||||
import dill | ||||||||||
import luigi | ||||||||||
|
@@ -71,6 +71,19 @@ def flatten(targets: FlattenableItems[T]) -> list[T]: | |||||||||
return flat | ||||||||||
|
||||||||||
|
||||||||||
K = TypeVar('K') | ||||||||||
|
||||||||||
|
||||||||||
def map_flattenable_items(items: FlattenableItems[T], func: Callable[[T], K]) -> FlattenableItems[K]: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can use both Generics and isinstance at the same time, code would be below. def map_flattenable_items(items: FlattenableItems[T], func: Callable[[T], K]) -> FlattenableItems[K]:
if isinstance(items, dict):
return {k: map_flattenable_items(v, func) for k, v in items.items()}
if isinstance(str):
return items
if isinstance(items, Iterable[T]):
return [map_flattenable_items(i, func) for i in items]
return func(items) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.python.org/3.13/library/functions.html#map python original map define
Suggested change
|
||||||||||
if isinstance(items, dict): | ||||||||||
return {k: map_flattenable_items(v, func) for k, v in items.items()} | ||||||||||
if isinstance(items, str): | ||||||||||
return items # type: ignore | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case,
Suggested change
|
||||||||||
if isinstance(items, Iterable): | ||||||||||
return [map_flattenable_items(i, func) for i in items] | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, could you add testcase? |
||||||||||
return func(items) | ||||||||||
|
||||||||||
|
||||||||||
def load_dill_with_pandas_backward_compatibility(file: Union[FileLike, BytesIO]) -> Any: | ||||||||||
"""Load binary dumped by dill with pandas backward compatibility. | ||||||||||
pd.read_pickle can load binary dumped in backward pandas version, and also any objects dumped by pickle. | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this part is not needed?