Skip to content

Fix: validate_input_col for partial functions#95067

Closed
BeckerFelix wants to merge 2 commits intopytorch:masterfrom
BeckerFelix:fix_str_of_partial_fn
Closed

Fix: validate_input_col for partial functions#95067
BeckerFelix wants to merge 2 commits intopytorch:masterfrom
BeckerFelix:fix_str_of_partial_fn

Conversation

@BeckerFelix
Copy link
Contributor

@BeckerFelix BeckerFelix commented Feb 17, 2023

Fixes #95066

Proposed change:

do not call str() on a Callable to determine its name

Reasoning:

Please see #95066 for reasoning and examples

Effect:

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 17, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/95067

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit d4b3ed9:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 17, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: BeckerFelix / name: Felix Becker (cefc6d72686fb66fa1bab9005f541a10297f21ad)

@pytorch-bot pytorch-bot bot added the release notes: dataloader release notes category label Feb 17, 2023
@bdhirsh bdhirsh assigned ejguan and unassigned ejguan Feb 22, 2023
@bdhirsh bdhirsh requested a review from ejguan February 22, 2023 22:29
@bdhirsh bdhirsh added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 22, 2023
Copy link
Contributor

@NivekT NivekT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for spotting this issue and fixing it. I don't think this should cause any issue for lambda function right?

cc: @ejguan I will cherry-pick this into the release.

@BeckerFelix
Copy link
Contributor Author

LGTM! Thanks for spotting this issue and fixing it. I don't think this should cause any issue for lambda function right?

cc: @ejguan I will cherry-pick this into the release.

thanks for the review.
__name__ is valid on lambda functions, so we should be good.

@BeckerFelix
Copy link
Contributor Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 23, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR is too stale; the last push date was more than 3 days ago. Please rebase and try again. You can rebase by leaving the following comment on this PR:
@pytorchbot rebase

Details for Dev Infra team Raised by workflow job

@BeckerFelix
Copy link
Contributor Author

@pytorchbot rebase

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 23, 2023

You don't have permissions to rebase this PR since you are a first time contributor. If you think this is a mistake, please contact PyTorch Dev Infra.

@BeckerFelix
Copy link
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 2 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

Copy link
Contributor

@ejguan ejguan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pls add tests to test/test_datapipe.py?
You can inject them into test_map_tuple_list_with_col_iterdatapipe and test_map_dict_with_col_iterdatapipe

@BeckerFelix
Copy link
Contributor Author

test_map_tuple_list_with_col_iterdatapipe

Happy to enhance the tests. Can you be more specific of what exactly you would like to see tested, please? In both test_map_tuple_list_with_col_iterdatapipe and test_map_dict_with_col_iterdatapipe map functions, partials, and lambdas get mapped over a datapipe.
I could provide a test which creates a partial with a large input argument and maps this over the datapipe. Similar to the code snippet I provided in #95066. wdyt?

@ejguan
Copy link
Contributor

ejguan commented Mar 3, 2023

I could provide a test which creates a partial with a large input argument and maps this over the datapipe. Similar to the code snippet I provided in #95066. wdyt?

Sounds good to me.

@BeckerFelix
Copy link
Contributor Author

let me know what you think about d4b3ed9, please

@ejguan
Copy link
Contributor

ejguan commented Mar 3, 2023

@pytorchbot rebase

@ejguan ejguan added the topic: improvements topic category label Mar 3, 2023
@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Tried to rebase and push PR #95067, but it was already up to date

@BeckerFelix BeckerFelix requested a review from ejguan March 3, 2023 19:21
@ejguan
Copy link
Contributor

ejguan commented Mar 3, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 5, 2023
Fixes #95066

#### Proposed change:
do not call `str()` on a `Callable` to determine its name

#### Reasoning:
Please see pytorch/pytorch#95066 for reasoning and examples

#### Effect:
* The code example given in pytorch/pytorch#95066 now executes instantly.
* If invalid input is provided, the stacktrace now prints nicely as
  ```
  ValueError: The function foo takes 1 parameters, but 2 are required.
  ```

Pull Request resolved: pytorch/pytorch#95067
Approved by: https://github.com/NivekT, https://github.com/ejguan
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 5, 2023
Fixes #95066

#### Proposed change:
do not call `str()` on a `Callable` to determine its name

#### Reasoning:
Please see pytorch/pytorch#95066 for reasoning and examples

#### Effect:
* The code example given in pytorch/pytorch#95066 now executes instantly.
* If invalid input is provided, the stacktrace now prints nicely as
  ```
  ValueError: The function foo takes 1 parameters, but 2 are required.
  ```

Pull Request resolved: pytorch/pytorch#95067
Approved by: https://github.com/NivekT, https://github.com/ejguan
if isinstance(fn, functools.partial):
fn_name = fn.func.__name__
else:
fn_name = fn.__name__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes lots of problem as not all of callable objects have __name__
I am going to do a forward fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple example would be a nn.Module

pytorchmergebot pushed a commit that referenced this pull request Mar 8, 2023
Forward fix the problem introduced in #95067

Not all `Callable` objects have `__name__` implemented. Using `repr` as the backup solution to get function name or reference.
Pull Request resolved: #96213
Approved by: https://github.com/NivekT
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
Forward fix the problem introduced in pytorch/pytorch#95067

Not all `Callable` objects have `__name__` implemented. Using `repr` as the backup solution to get function name or reference.
Pull Request resolved: pytorch/pytorch#96213
Approved by: https://github.com/NivekT
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
Forward fix the problem introduced in pytorch/pytorch#95067

Not all `Callable` objects have `__name__` implemented. Using `repr` as the backup solution to get function name or reference.
Pull Request resolved: pytorch/pytorch#96213
Approved by: https://github.com/NivekT
ydwu4 added a commit to ydwu4/pytorch that referenced this pull request Mar 13, 2023
Fixes pytorch#95066

#### Proposed change:
do not call `str()` on a `Callable` to determine its name

#### Reasoning:
Please see pytorch#95066 for reasoning and examples

#### Effect:
* The code example given in pytorch#95066 now executes instantly.
* If invalid input is provided, the stacktrace now prints nicely as
  ```
  ValueError: The function foo takes 1 parameters, but 2 are required.
  ```

Pull Request resolved: pytorch#95067
Approved by: https://github.com/NivekT, https://github.com/ejguan
ydwu4 added a commit to ydwu4/pytorch that referenced this pull request Mar 13, 2023
Forward fix the problem introduced in pytorch#95067

Not all `Callable` objects have `__name__` implemented. Using `repr` as the backup solution to get function name or reference.
Pull Request resolved: pytorch#96213
Approved by: https://github.com/NivekT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: dataloader release notes category topic: improvements topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate_input_col is impractical for partial functions (with large arguments)

6 participants