Skip to content
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

positional and kwargs corner case fix in for _build_args_kwargs #2714

Closed
wants to merge 1 commit into from

Conversation

aliafzal
Copy link
Contributor

@aliafzal aliafzal commented Jan 30, 2025

Summary:

Context:

Setting None in positional args is colliding with the kwargs in situations when kwargs contains the argument name accepted by the method.

Eg :

def input_dist(ctx, id_feature_list):
    ...

// If _build_args_kwargs returns:
args = [None]
kwargs = {'id_feature_list': KJT}

input_dist(ctx, *args, **kwargs)
// extends to
input_dist(ctx, None, id_feature_list=KJT)

which results in "TypeError: got multiple values for argument 'id_feature_list'" because id_feature_list is provided both positionally (None) and via kwargs.

Differential Revision: D68892351

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 30, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68892351

aliafzal added a commit to aliafzal/torchrec that referenced this pull request Jan 31, 2025
…rch#2714)

Summary:

## Context:
Setting None in positional args is colliding with the kwargs in situations when kwargs contains the argument name accepted by the method.

Eg :
```
def input_dist(ctx, id_feature_list):
    ...

// If _build_args_kwargs returns:
args = [None]
kwargs = {'id_feature_list': KJT}

input_dist(ctx, *args, **kwargs)
// extends to
input_dist(ctx, None, id_feature_list=KJT)
```

which results in "TypeError: got multiple values for argument 'id_feature_list'" because id_feature_list is provided both positionally (None) and via kwargs.

## Fix:
Ensure _build_args_kwargs does not append None to args when an argument is already correctly assigned in kwargs.

Differential Revision: D68892351
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68892351

aliafzal added a commit to aliafzal/torchrec that referenced this pull request Feb 4, 2025
…rch#2714)

Summary:

## Context:
Setting None in positional args is colliding with the kwargs in situations when kwargs contains the argument name accepted by the method.

Eg :
```
def input_dist(ctx, id_feature_list):
    ...

// If _build_args_kwargs returns:
args = [None]
kwargs = {'id_feature_list': KJT}

input_dist(ctx, *args, **kwargs)
// extends to
input_dist(ctx, None, id_feature_list=KJT)
```

which results in "TypeError: got multiple values for argument 'id_feature_list'" because id_feature_list is provided both positionally (None) and via kwargs.

Reviewed By: sarckk

Differential Revision: D68892351
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68892351

…rch#2714)

Summary:

## Context:
Setting None in positional args is colliding with the kwargs in situations when kwargs contains the argument name accepted by the method.

Eg :
```
def input_dist(ctx, id_feature_list):
    ...

// If _build_args_kwargs returns:
args = [None]
kwargs = {'id_feature_list': KJT}

input_dist(ctx, *args, **kwargs)
// extends to
input_dist(ctx, None, id_feature_list=KJT)
```

which results in "TypeError: got multiple values for argument 'id_feature_list'" because id_feature_list is provided both positionally (None) and via kwargs.

Reviewed By: sarckk

Differential Revision: D68892351
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68892351

@aliafzal aliafzal changed the title []test positional and kwargs corner case fix in for _build_args_kwargs Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants