Skip to content

Update utils.py for py3.9+ compatibility#1

Merged
yuenherny merged 2 commits intomainfrom
update-py-func
Jul 29, 2022
Merged

Update utils.py for py3.9+ compatibility#1
yuenherny merged 2 commits intomainfrom
update-py-func

Conversation

@yuenherny
Copy link
Copy Markdown
Owner

Running the evaluation with Python 3.10.5 results in:
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them

Hence. replacing the legacy inspect.getargspec method with inspect.getfullargspec method, as per here:

# check that we give good parameters to the optimizer
    expected_args = inspect.getfullargspec(optim_fn.__init__)
    assert expected_args.args[:2] == ['self', 'params']
    if not all(k in expected_args.args[2:] for k in optim_params.keys()):
        raise Exception('Unexpected parameters: expected "%s", got "%s"' % (
            str(expected_args.args[2:]), str(optim_params.keys())))

This commit fixes this issue: facebookresearch#88. This fix was originated from this PR facebookresearch#87 which did not get merged after such a long time. Hence I forked this repo and implemented this fix myself.

Tested on Windows with Python 3.10.5.

@yuenherny yuenherny added the bug Something isn't working label Jul 29, 2022
@yuenherny yuenherny merged commit 2109c9e into main Jul 29, 2022
@yuenherny yuenherny deleted the update-py-func branch July 29, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant